Evict resources from resource pool after timeout
[chromium-blink-merge.git] / components / devtools_service / devtools_http_server.h
blob6906db689ff86c94e1af615640dcd00fa2c34582
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"
15 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h"
17 namespace devtools_service {
19 class DevToolsService;
21 class DevToolsHttpServer : public mojo::HttpServerDelegate {
22 public:
23 // |service| must outlive this object.
24 DevToolsHttpServer(DevToolsService* service, uint16_t remote_debugging_port);
25 ~DevToolsHttpServer() override;
27 private:
28 class HttpConnectionDelegateImpl;
30 // mojo::HttpServerDelegate implementation.
31 void OnConnected(
32 mojo::HttpConnectionPtr connection,
33 mojo::InterfaceRequest<mojo::HttpConnectionDelegate> delegate) override;
35 // The following three methods are called by HttpConnectionDelegateImpl.
36 using OnReceivedRequestCallback =
37 mojo::HttpConnectionDelegate::OnReceivedRequestCallback;
38 void OnReceivedRequest(HttpConnectionDelegateImpl* connection,
39 mojo::HttpRequestPtr request,
40 const OnReceivedRequestCallback& callback);
41 using OnReceivedWebSocketRequestCallback =
42 mojo::HttpConnectionDelegate::OnReceivedWebSocketRequestCallback;
43 void OnReceivedWebSocketRequest(
44 HttpConnectionDelegateImpl* connection,
45 mojo::HttpRequestPtr request,
46 const OnReceivedWebSocketRequestCallback& callback);
47 void OnConnectionClosed(HttpConnectionDelegateImpl* connection);
49 mojo::HttpResponsePtr ProcessJsonRequest(mojo::HttpRequestPtr request);
51 // Not owned by this object.
52 DevToolsService* const service_;
54 const uint16_t remote_debugging_port_;
56 scoped_ptr<mojo::Binding<mojo::HttpServerDelegate>>
57 http_server_delegate_binding_;
59 // Owns the elements.
60 std::set<HttpConnectionDelegateImpl*> connections_;
62 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpServer);
65 } // namespace devtools_service
67 #endif // COMPONENTS_DEVTOOLS_SERVICE_DEVTOOLS_HTTP_SERVER_H_