summaryrefslogtreecommitdiffstats
path: root/components/devtools_bridge/abstract_data_channel.h
diff options
context:
space:
mode:
authorserya <serya@chromium.org>2014-11-18 22:34:17 -0800
committerCommit bot <commit-bot@chromium.org>2014-11-19 06:34:36 +0000
commit648090c58236cc635b853992b53b67d38eb3ca6a (patch)
tree085d6789cf221c085071661add961ab46f022a6e /components/devtools_bridge/abstract_data_channel.h
parent85fb6f102205ae33f4fde9d3afe66f626d5459b4 (diff)
downloadchromium_src-648090c58236cc635b853992b53b67d38eb3ca6a.zip
chromium_src-648090c58236cc635b853992b53b67d38eb3ca6a.tar.gz
chromium_src-648090c58236cc635b853992b53b67d38eb3ca6a.tar.bz2
Native tunnel implementation.
Native API lets using single IO thread (in contrast with Java LocalSocket which provides blocking API). Another benefit of using native implementation is sharing code with client side (see https://codereview.chromium.org/720133002/ - net::StreamSocket needed). Significant tests modifications needed because: 1. net::StreamSocket doesn't allow to close stream in each direction separately (in request/response scenario server calculates end of stream position from content). 2. SocketTunnelServer becomes dependent on native implementation of AbstractDataChannel. TBR=szym@chromium.org (for dependency on net) BUG=383418 Review URL: https://codereview.chromium.org/735003004 Cr-Commit-Position: refs/heads/master@{#304771}
Diffstat (limited to 'components/devtools_bridge/abstract_data_channel.h')
-rw-r--r--components/devtools_bridge/abstract_data_channel.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/components/devtools_bridge/abstract_data_channel.h b/components/devtools_bridge/abstract_data_channel.h
index 43acc45..473774e 100644
--- a/components/devtools_bridge/abstract_data_channel.h
+++ b/components/devtools_bridge/abstract_data_channel.h
@@ -8,6 +8,7 @@
#include <string>
#include "base/callback.h"
+#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
namespace devtools_bridge {
@@ -37,6 +38,26 @@ class AbstractDataChannel {
DISALLOW_COPY_AND_ASSIGN(Observer);
};
+ /**
+ * Proxy for accessing data channel from a different thread.
+ * May outlive data channel (methods will have no effect if DataChannel
+ * destroyed).
+ */
+ class Proxy : public base::RefCountedThreadSafe<Proxy> {
+ public:
+ virtual void SendBinaryMessage(const void* data, size_t length) = 0;
+ virtual void Close() = 0;
+
+ protected:
+ Proxy() {}
+ virtual ~Proxy() {}
+
+ private:
+ friend class base::RefCountedThreadSafe<Proxy>;
+
+ DISALLOW_COPY_AND_ASSIGN(Proxy);
+ };
+
virtual void RegisterObserver(scoped_ptr<Observer> observer) = 0;
virtual void UnregisterObserver() = 0;
@@ -45,6 +66,8 @@ class AbstractDataChannel {
virtual void Close() = 0;
+ virtual scoped_refptr<Proxy> proxy() = 0;
+
private:
DISALLOW_COPY_AND_ASSIGN(AbstractDataChannel);
};