1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_DEVTOOLS_BRIDGE_ABSTRACT_DATA_CHANNEL_H_
6 #define COMPONENTS_DEVTOOLS_BRIDGE_ABSTRACT_DATA_CHANNEL_H_
10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
14 namespace devtools_bridge
{
17 * WebRTC DataChannel adapter for DevTools bridge. Not thread safe.
19 class AbstractDataChannel
{
21 AbstractDataChannel() {}
22 virtual ~AbstractDataChannel() {}
25 * Called on WebRTC signaling thread.
30 virtual ~Observer() {}
32 virtual void OnOpen() = 0;
33 virtual void OnClose() = 0;
35 virtual void OnMessage(const void* data
, size_t length
) = 0;
38 DISALLOW_COPY_AND_ASSIGN(Observer
);
42 * Proxy for accessing data channel from a different thread.
43 * May outlive data channel (methods will have no effect if DataChannel
46 class Proxy
: public base::RefCountedThreadSafe
<Proxy
> {
48 virtual void SendBinaryMessage(const void* data
, size_t length
) = 0;
49 virtual void Close() = 0;
56 friend class base::RefCountedThreadSafe
<Proxy
>;
58 DISALLOW_COPY_AND_ASSIGN(Proxy
);
61 virtual void RegisterObserver(scoped_ptr
<Observer
> observer
) = 0;
62 virtual void UnregisterObserver() = 0;
64 virtual void SendBinaryMessage(void* data
, size_t length
) = 0;
65 virtual void SendTextMessage(void* data
, size_t length
) = 0;
67 virtual void Close() = 0;
69 virtual scoped_refptr
<Proxy
> proxy() = 0;
72 DISALLOW_COPY_AND_ASSIGN(AbstractDataChannel
);
75 } // namespace devtools_bridge
77 #endif // COMPONENTS_DEVTOOLS_BRIDGE_ABSTRACT_DATA_CHANNEL_H_