Add an exponential backoff to rechecking the app list doodle.
[chromium-blink-merge.git] / components / devtools_bridge / abstract_data_channel.h
blob473774e08ccf3f807436d0c465e5e94bb65ed42c
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/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
14 namespace devtools_bridge {
16 /**
17 * WebRTC DataChannel adapter for DevTools bridge. Not thread safe.
19 class AbstractDataChannel {
20 public:
21 AbstractDataChannel() {}
22 virtual ~AbstractDataChannel() {}
24 /**
25 * Called on WebRTC signaling thread.
27 class Observer {
28 public:
29 Observer() {}
30 virtual ~Observer() {}
32 virtual void OnOpen() = 0;
33 virtual void OnClose() = 0;
35 virtual void OnMessage(const void* data, size_t length) = 0;
37 private:
38 DISALLOW_COPY_AND_ASSIGN(Observer);
41 /**
42 * Proxy for accessing data channel from a different thread.
43 * May outlive data channel (methods will have no effect if DataChannel
44 * destroyed).
46 class Proxy : public base::RefCountedThreadSafe<Proxy> {
47 public:
48 virtual void SendBinaryMessage(const void* data, size_t length) = 0;
49 virtual void Close() = 0;
51 protected:
52 Proxy() {}
53 virtual ~Proxy() {}
55 private:
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;
71 private:
72 DISALLOW_COPY_AND_ASSIGN(AbstractDataChannel);
75 } // namespace devtools_bridge
77 #endif // COMPONENTS_DEVTOOLS_BRIDGE_ABSTRACT_DATA_CHANNEL_H_