blob: 473774e08ccf3f807436d0c465e5e94bb65ed42c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_DEVTOOLS_BRIDGE_ABSTRACT_DATA_CHANNEL_H_
#define COMPONENTS_DEVTOOLS_BRIDGE_ABSTRACT_DATA_CHANNEL_H_
#include <string>
#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
namespace devtools_bridge {
/**
* WebRTC DataChannel adapter for DevTools bridge. Not thread safe.
*/
class AbstractDataChannel {
public:
AbstractDataChannel() {}
virtual ~AbstractDataChannel() {}
/**
* Called on WebRTC signaling thread.
*/
class Observer {
public:
Observer() {}
virtual ~Observer() {}
virtual void OnOpen() = 0;
virtual void OnClose() = 0;
virtual void OnMessage(const void* data, size_t length) = 0;
private:
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;
virtual void SendBinaryMessage(void* data, size_t length) = 0;
virtual void SendTextMessage(void* data, size_t length) = 0;
virtual void Close() = 0;
virtual scoped_refptr<Proxy> proxy() = 0;
private:
DISALLOW_COPY_AND_ASSIGN(AbstractDataChannel);
};
} // namespace devtools_bridge
#endif // COMPONENTS_DEVTOOLS_BRIDGE_ABSTRACT_DATA_CHANNEL_H_
|