| 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; |
| 38 void SetRenderFrameHost(RenderFrameHostImpl* host) override; |
| 36 Response Disable() override; | 39 Response Disable() override; |
| 37 | 40 |
| 38 void Bind(int port, std::unique_ptr<BindCallback> callback) override; | 41 void Bind(int port, std::unique_ptr<BindCallback> callback) override; |
| 39 void Unbind(int port, std::unique_ptr<UnbindCallback> callback) override; | 42 void Unbind(int port, std::unique_ptr<UnbindCallback> callback) override; |
| 40 | 43 |
| 41 private: | 44 private: |
| 42 class TetheringImpl; | 45 class TetheringImpl; |
| 43 | 46 |
| 44 void Accepted(uint16_t port, const std::string& name); | 47 void Accepted(uint16_t port, const std::string& name); |
| 45 bool Activate(); | 48 bool Activate(); |
| 46 | 49 |
| 47 std::unique_ptr<Tethering::Frontend> frontend_; | 50 std::unique_ptr<Tethering::Frontend> frontend_; |
| 48 CreateServerSocketCallback socket_callback_; | 51 CreateServerSocketCallback socket_callback_; |
| 49 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 52 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 50 bool is_active_; | 53 bool is_active_; |
| 51 base::WeakPtrFactory<TetheringHandler> weak_factory_; | 54 base::WeakPtrFactory<TetheringHandler> weak_factory_; |
| 52 | 55 |
| 53 static TetheringImpl* impl_; | 56 static TetheringImpl* impl_; |
| 54 | 57 |
| 55 DISALLOW_COPY_AND_ASSIGN(TetheringHandler); | 58 DISALLOW_COPY_AND_ASSIGN(TetheringHandler); |
| 56 }; | 59 }; |
| 57 | 60 |
| 58 } // namespace protocol | 61 } // namespace protocol |
| 59 } // namespace content | 62 } // namespace content |
| 60 | 63 |
| 61 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TETHERING_HANDLER_H_ | 64 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TETHERING_HANDLER_H_ |
| OLD | NEW |