1 // Copyright 2015 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 COMPONENTS_DEVTOOLS_SERVICE_DEVTOOLS_HTTP_SERVER_H_
6 #define COMPONENTS_DEVTOOLS_SERVICE_DEVTOOLS_HTTP_SERVER_H_
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "mojo/services/network/public/interfaces/http_connection.mojom.h"
13 #include "mojo/services/network/public/interfaces/http_message.mojom.h"
14 #include "mojo/services/network/public/interfaces/http_server.mojom.h"
16 namespace devtools_service
{
18 class DevToolsService
;
20 class DevToolsHttpServer
: public mojo::HttpServerDelegate
{
22 // |service| must outlive this object.
23 DevToolsHttpServer(DevToolsService
* service
, uint16_t remote_debugging_port
);
24 ~DevToolsHttpServer() override
;
27 class HttpConnectionDelegateImpl
;
29 // mojo::HttpServerDelegate implementation.
31 mojo::HttpConnectionPtr connection
,
32 mojo::InterfaceRequest
<mojo::HttpConnectionDelegate
> delegate
) override
;
34 // The following three methods are called by HttpConnectionDelegateImpl.
35 using OnReceivedRequestCallback
=
36 mojo::HttpConnectionDelegate::OnReceivedRequestCallback
;
37 void OnReceivedRequest(HttpConnectionDelegateImpl
* connection
,
38 mojo::HttpRequestPtr request
,
39 const OnReceivedRequestCallback
& callback
);
40 using OnReceivedWebSocketRequestCallback
=
41 mojo::HttpConnectionDelegate::OnReceivedWebSocketRequestCallback
;
42 void OnReceivedWebSocketRequest(
43 HttpConnectionDelegateImpl
* connection
,
44 mojo::HttpRequestPtr request
,
45 const OnReceivedWebSocketRequestCallback
& callback
);
46 void OnConnectionClosed(HttpConnectionDelegateImpl
* connection
);
48 mojo::HttpResponsePtr
ProcessJsonRequest(mojo::HttpRequestPtr request
);
50 // Not owned by this object.
51 DevToolsService
* const service_
;
53 const uint16_t remote_debugging_port_
;
55 scoped_ptr
<mojo::Binding
<mojo::HttpServerDelegate
>>
56 http_server_delegate_binding_
;
59 std::set
<HttpConnectionDelegateImpl
*> connections_
;
61 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpServer
);
64 } // namespace devtools_service
66 #endif // COMPONENTS_DEVTOOLS_SERVICE_DEVTOOLS_HTTP_SERVER_H_