[refactor] More post-NSS WebCrypto cleanups (utility functions).
[chromium-blink-merge.git] / content / browser / devtools / protocol / tethering_handler.h
blob21f1a9a27a6050371d5b606f7f5a1a7f7e389162
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 CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TETHERING_HANDLER_H_
6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TETHERING_HANDLER_H_
8 #include "base/memory/weak_ptr.h"
9 #include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h"
11 namespace net {
12 class ServerSocket;
15 namespace content {
16 namespace devtools {
17 namespace tethering {
19 // This class implements reversed tethering handler.
20 class TetheringHandler {
21 public:
22 using Response = DevToolsProtocolClient::Response;
23 using CreateServerSocketCallback =
24 base::Callback<scoped_ptr<net::ServerSocket>(std::string*)>;
26 TetheringHandler(const CreateServerSocketCallback& socket_callback,
27 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
28 ~TetheringHandler();
30 void SetClient(scoped_ptr<Client> client);
32 Response Bind(DevToolsCommandId command_id, int port);
33 Response Unbind(DevToolsCommandId command_id, int port);
35 private:
36 class TetheringImpl;
38 void Accepted(uint16 port, const std::string& name);
39 bool Activate();
41 void SendBindSuccess(DevToolsCommandId command_id);
42 void SendUnbindSuccess(DevToolsCommandId command_id);
43 void SendInternalError(DevToolsCommandId command_id,
44 const std::string& message);
46 scoped_ptr<Client> client_;
47 CreateServerSocketCallback socket_callback_;
48 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
49 bool is_active_;
50 base::WeakPtrFactory<TetheringHandler> weak_factory_;
52 static TetheringImpl* impl_;
54 DISALLOW_COPY_AND_ASSIGN(TetheringHandler);
57 } // namespace tethering
58 } // namespace devtools
59 } // namespace content
61 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TETHERING_HANDLER_H_