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 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h" | 12 #include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h" |
13 | 13 |
14 namespace net { | 14 namespace net { |
15 class ServerSocket; | 15 class ServerSocket; |
16 } | 16 } |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 namespace devtools { | 19 namespace devtools { |
20 namespace tethering { | 20 namespace tethering { |
21 | 21 |
22 // This class implements reversed tethering handler. | 22 // This class implements reversed tethering handler. |
23 class TetheringHandler { | 23 class TetheringHandler { |
24 public: | 24 public: |
25 using Response = DevToolsProtocolClient::Response; | 25 using Response = DevToolsProtocolClient::Response; |
26 using CreateServerSocketCallback = | 26 using CreateServerSocketCallback = |
27 base::Callback<scoped_ptr<net::ServerSocket>(std::string*)>; | 27 base::Callback<std::unique_ptr<net::ServerSocket>(std::string*)>; |
28 | 28 |
29 TetheringHandler(const CreateServerSocketCallback& socket_callback, | 29 TetheringHandler(const CreateServerSocketCallback& socket_callback, |
30 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 30 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
31 ~TetheringHandler(); | 31 ~TetheringHandler(); |
32 | 32 |
33 void SetClient(scoped_ptr<Client> client); | 33 void SetClient(std::unique_ptr<Client> client); |
34 | 34 |
35 Response Bind(DevToolsCommandId command_id, int port); | 35 Response Bind(DevToolsCommandId command_id, int port); |
36 Response Unbind(DevToolsCommandId command_id, int port); | 36 Response Unbind(DevToolsCommandId command_id, int port); |
37 | 37 |
38 private: | 38 private: |
39 class TetheringImpl; | 39 class TetheringImpl; |
40 | 40 |
41 void Accepted(uint16_t port, const std::string& name); | 41 void Accepted(uint16_t port, const std::string& name); |
42 bool Activate(); | 42 bool Activate(); |
43 | 43 |
44 void SendBindSuccess(DevToolsCommandId command_id); | 44 void SendBindSuccess(DevToolsCommandId command_id); |
45 void SendUnbindSuccess(DevToolsCommandId command_id); | 45 void SendUnbindSuccess(DevToolsCommandId command_id); |
46 void SendInternalError(DevToolsCommandId command_id, | 46 void SendInternalError(DevToolsCommandId command_id, |
47 const std::string& message); | 47 const std::string& message); |
48 | 48 |
49 scoped_ptr<Client> client_; | 49 std::unique_ptr<Client> client_; |
50 CreateServerSocketCallback socket_callback_; | 50 CreateServerSocketCallback socket_callback_; |
51 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 51 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
52 bool is_active_; | 52 bool is_active_; |
53 base::WeakPtrFactory<TetheringHandler> weak_factory_; | 53 base::WeakPtrFactory<TetheringHandler> weak_factory_; |
54 | 54 |
55 static TetheringImpl* impl_; | 55 static TetheringImpl* impl_; |
56 | 56 |
57 DISALLOW_COPY_AND_ASSIGN(TetheringHandler); | 57 DISALLOW_COPY_AND_ASSIGN(TetheringHandler); |
58 }; | 58 }; |
59 | 59 |
60 } // namespace tethering | 60 } // namespace tethering |
61 } // namespace devtools | 61 } // namespace devtools |
62 } // namespace content | 62 } // namespace content |
63 | 63 |
64 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TETHERING_HANDLER_H_ | 64 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TETHERING_HANDLER_H_ |
OLD | NEW |