Roll leveldb 3f7758:803d69 (v1.17 -> v1.18)
[chromium-blink-merge.git] / components / devtools_bridge / abstract_data_channel.h
blob43acc45d2f4f625cc831749419ba8f3606ad9801
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_
8 #include <string>
10 #include "base/callback.h"
11 #include "base/memory/scoped_ptr.h"
13 namespace devtools_bridge {
15 /**
16 * WebRTC DataChannel adapter for DevTools bridge. Not thread safe.
18 class AbstractDataChannel {
19 public:
20 AbstractDataChannel() {}
21 virtual ~AbstractDataChannel() {}
23 /**
24 * Called on WebRTC signaling thread.
26 class Observer {
27 public:
28 Observer() {}
29 virtual ~Observer() {}
31 virtual void OnOpen() = 0;
32 virtual void OnClose() = 0;
34 virtual void OnMessage(const void* data, size_t length) = 0;
36 private:
37 DISALLOW_COPY_AND_ASSIGN(Observer);
40 virtual void RegisterObserver(scoped_ptr<Observer> observer) = 0;
41 virtual void UnregisterObserver() = 0;
43 virtual void SendBinaryMessage(void* data, size_t length) = 0;
44 virtual void SendTextMessage(void* data, size_t length) = 0;
46 virtual void Close() = 0;
48 private:
49 DISALLOW_COPY_AND_ASSIGN(AbstractDataChannel);
52 } // namespace devtools_bridge
54 #endif // COMPONENTS_DEVTOOLS_BRIDGE_ABSTRACT_DATA_CHANNEL_H_