OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TETHERING_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TETHERING_HANDLER_H_ |
6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TETHERING_HANDLER_H_ | 6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TETHERING_HANDLER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 16 #include "content/browser/devtools/protocol/devtools_domain_handler.h" |
16 #include "content/browser/devtools/protocol/tethering.h" | 17 #include "content/browser/devtools/protocol/tethering.h" |
17 | 18 |
18 namespace net { | 19 namespace net { |
19 class ServerSocket; | 20 class ServerSocket; |
20 } | 21 } |
21 | 22 |
22 namespace content { | 23 namespace content { |
23 namespace protocol { | 24 namespace protocol { |
24 | 25 |
25 // This class implements reversed tethering handler. | 26 // This class implements reversed tethering handler. |
26 class TetheringHandler : public Tethering::Backend { | 27 class TetheringHandler : public DevToolsDomainHandler, |
| 28 public Tethering::Backend { |
27 public: | 29 public: |
28 using CreateServerSocketCallback = | 30 using CreateServerSocketCallback = |
29 base::Callback<std::unique_ptr<net::ServerSocket>(std::string*)>; | 31 base::Callback<std::unique_ptr<net::ServerSocket>(std::string*)>; |
30 | 32 |
31 TetheringHandler(const CreateServerSocketCallback& socket_callback, | 33 TetheringHandler(const CreateServerSocketCallback& socket_callback, |
32 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 34 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
33 ~TetheringHandler() override; | 35 ~TetheringHandler() override; |
34 | 36 |
35 void Wire(UberDispatcher*); | 37 void Wire(UberDispatcher* dispatcher) override; |
36 Response Disable() override; | |
37 | 38 |
38 void Bind(int port, std::unique_ptr<BindCallback> callback) override; | 39 void Bind(int port, std::unique_ptr<BindCallback> callback) override; |
39 void Unbind(int port, std::unique_ptr<UnbindCallback> callback) override; | 40 void Unbind(int port, std::unique_ptr<UnbindCallback> callback) override; |
40 | 41 |
41 private: | 42 private: |
42 class TetheringImpl; | 43 class TetheringImpl; |
43 | 44 |
44 void Accepted(uint16_t port, const std::string& name); | 45 void Accepted(uint16_t port, const std::string& name); |
45 bool Activate(); | 46 bool Activate(); |
46 | 47 |
47 std::unique_ptr<Tethering::Frontend> frontend_; | 48 std::unique_ptr<Tethering::Frontend> frontend_; |
48 CreateServerSocketCallback socket_callback_; | 49 CreateServerSocketCallback socket_callback_; |
49 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 50 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
50 bool is_active_; | 51 bool is_active_; |
51 base::WeakPtrFactory<TetheringHandler> weak_factory_; | 52 base::WeakPtrFactory<TetheringHandler> weak_factory_; |
52 | 53 |
53 static TetheringImpl* impl_; | 54 static TetheringImpl* impl_; |
54 | 55 |
55 DISALLOW_COPY_AND_ASSIGN(TetheringHandler); | 56 DISALLOW_COPY_AND_ASSIGN(TetheringHandler); |
56 }; | 57 }; |
57 | 58 |
58 } // namespace protocol | 59 } // namespace protocol |
59 } // namespace content | 60 } // namespace content |
60 | 61 |
61 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TETHERING_HANDLER_H_ | 62 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TETHERING_HANDLER_H_ |
OLD | NEW |