[rygel] core: Centralize continuation handling



commit 864c4d3eb1291eba8a43de0c1ab9dc73c3c65ce8
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Fri May 14 17:15:19 2010 +0300

    core: Centralize continuation handling
    
    Move the continuation of run() method to base HTTPResponse class and
    handle as much of it as possible in there.

 src/rygel/rygel-http-response.vala     |    6 ++++++
 src/rygel/rygel-live-response.vala     |    4 ----
 src/rygel/rygel-seekable-response.vala |    6 ++++--
 3 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/src/rygel/rygel-http-response.vala b/src/rygel/rygel-http-response.vala
index 6b5477f..e57fca1 100644
--- a/src/rygel/rygel-http-response.vala
+++ b/src/rygel/rygel-http-response.vala
@@ -29,6 +29,8 @@ internal abstract class Rygel.HTTPResponse : GLib.Object, Rygel.StateMachine {
 
     public Cancellable cancellable { get; set; }
 
+    protected SourceFunc run_continue;
+
     public HTTPResponse (Soup.Server  server,
                          Soup.Message msg,
                          bool         partial,
@@ -65,6 +67,10 @@ internal abstract class Rygel.HTTPResponse : GLib.Object, Rygel.StateMachine {
     }
 
     public virtual void end (bool aborted, uint status) {
+        if (this.run_continue != null) {
+            this.run_continue ();
+        }
+
         if (status != Soup.KnownStatusCode.NONE) {
             this.msg.set_status (status);
         }
diff --git a/src/rygel/rygel-live-response.vala b/src/rygel/rygel-live-response.vala
index c6c24c6..377b05a 100644
--- a/src/rygel/rygel-live-response.vala
+++ b/src/rygel/rygel-live-response.vala
@@ -36,8 +36,6 @@ internal class Rygel.LiveResponse : Rygel.HTTPResponse {
 
     private HTTPSeek time_range;
 
-    private SourceFunc run_continue;
-
     private size_t buffered;
     private bool out_of_sync;
 
@@ -83,8 +81,6 @@ internal class Rygel.LiveResponse : Rygel.HTTPResponse {
         }
 
         base.end (aborted, status);
-
-        this.run_continue ();
     }
 
     private void prepare_pipeline (string name,
diff --git a/src/rygel/rygel-seekable-response.vala b/src/rygel/rygel-seekable-response.vala
index faf612d..e88e9b0 100644
--- a/src/rygel/rygel-seekable-response.vala
+++ b/src/rygel/rygel-seekable-response.vala
@@ -118,9 +118,11 @@ internal class Rygel.SeekableResponse : Rygel.HTTPResponse {
                                         this.bytes_to_read (),
                                         this.priority,
                                         this.cancellable);
-        SourceFunc cb = read_contents.callback;
+        this.run_continue = read_contents.callback;
         this.msg.wrote_chunk.connect ((msg) => {
-                cb ();
+            if (this.run_continue != null) {
+                this.run_continue ();
+            }
         });
 
         while (bytes_read > 0) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]