API for binary_dependencies, and import changes to call the new API.
[chromium-blink-merge.git] / components / devtools_service / devtools_http_server.h
bloba4f4eed1ff6eabeb1cf19971f763cd2b2ae45afd
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_
8 #include <set>
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 {
21 public:
22 // |service| must outlive this object.
23 DevToolsHttpServer(DevToolsService* service, uint16_t remote_debugging_port);
24 ~DevToolsHttpServer() override;
26 private:
27 class HttpConnectionDelegateImpl;
29 // mojo::HttpServerDelegate implementation.
30 void OnConnected(
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_;
58 // Owns the elements.
59 std::set<HttpConnectionDelegateImpl*> connections_;
61 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpServer);
64 } // namespace devtools_service
66 #endif // COMPONENTS_DEVTOOLS_SERVICE_DEVTOOLS_HTTP_SERVER_H_