[RFC spice-gtk 1/5] spice-channel: new 'total-write-bytes' property

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

 



From: Victor Toso <me@xxxxxxxxxxxxxx>

Combined with "total-read-bytes" property that already exists, the
application can estimate the write and read rate of each SpiceChannel
as well as the whole SpiceSession.

Related: https://bugs.freedesktop.org/show_bug.cgi?id=96598
Related: https://bugs.freedesktop.org/show_bug.cgi?id=87324

Signed-off-by: Victor Toso <victortoso@xxxxxxxxxx>
---
 src/spice-channel-priv.h |  1 +
 src/spice-channel.c      | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/src/spice-channel-priv.h b/src/spice-channel-priv.h
index 50aca5c..76d1aae 100644
--- a/src/spice-channel-priv.h
+++ b/src/spice-channel-priv.h
@@ -139,6 +139,7 @@ struct _SpiceChannelPrivate {
     GArray                      *remote_common_caps;
 
     gsize                       total_read_bytes;
+    gsize                       total_write_bytes;
     uint64_t                    last_message_serial;
     GSList                      *flushing;
 
diff --git a/src/spice-channel.c b/src/spice-channel.c
index e42e560..b3fd521 100644
--- a/src/spice-channel.c
+++ b/src/spice-channel.c
@@ -95,6 +95,7 @@ enum {
     PROP_CHANNEL_ID,
     PROP_TOTAL_READ_BYTES,
     PROP_SOCKET,
+    PROP_TOTAL_WRITE_BYTES,
 };
 
 /* Signals */
@@ -228,6 +229,9 @@ static void spice_channel_get_property(GObject    *gobject,
     case PROP_SOCKET:
         g_value_set_object(value, c->sock);
         break;
+    case PROP_TOTAL_WRITE_BYTES:
+        g_value_set_ulong(value, c->total_write_bytes);
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
         break;
@@ -349,6 +353,24 @@ static void spice_channel_class_init(SpiceChannelClass *klass)
                              G_PARAM_READABLE |
                              G_PARAM_STATIC_STRINGS));
 
+
+    /**
+     * SpiceChannel:total-write-bytes
+     *
+     *
+     * Get the amount of bytes written through the wire.
+     *
+     * Since: 0.34
+     */
+    g_object_class_install_property
+        (gobject_class, PROP_TOTAL_WRITE_BYTES,
+         g_param_spec_ulong("total-write-bytes",
+                            "Total write bytes",
+                            "Amount of bytes written",
+                            0, G_MAXULONG, 0,
+                            G_PARAM_READABLE |
+                            G_PARAM_STATIC_STRINGS));
+
     /**
      * SpiceChannel::channel-event:
      * @channel: the channel that emitted the signal
@@ -852,6 +874,7 @@ static void spice_channel_flush_wire(SpiceChannel *channel,
             return;
         }
         offset += ret;
+        c->total_write_bytes += ret;
     }
 }
 
-- 
2.9.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]