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