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"
19 // This class implements reversed tethering handler.
20 class TetheringHandler
{
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
);
30 void SetClient(scoped_ptr
<Client
> client
);
32 Response
Bind(DevToolsCommandId command_id
, int port
);
33 Response
Unbind(DevToolsCommandId command_id
, int port
);
38 void Accepted(uint16 port
, const std::string
& name
);
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_
;
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_