OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_DEBUGGER_DEVTOOLS_HTTP_HANDLER_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_DEBUGGER_DEVTOOLS_HTTP_HANDLER_IMPL_H_ |
6 #define CONTENT_BROWSER_DEBUGGER_DEVTOOLS_HTTP_HANDLER_IMPL_H_ | 6 #define CONTENT_BROWSER_DEBUGGER_DEVTOOLS_HTTP_HANDLER_IMPL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
17 #include "content/public/browser/devtools_http_handler.h" | 17 #include "content/public/browser/devtools_http_handler.h" |
18 #include "content/public/browser/devtools_http_handler_delegate.h" | 18 #include "content/public/browser/devtools_http_handler_delegate.h" |
19 #include "net/server/http_server.h" | 19 #include "net/server/http_server.h" |
20 #include "net/url_request/url_request.h" | 20 #include "net/url_request/url_request.h" |
21 | 21 |
22 namespace net { | 22 namespace net { |
| 23 class StreamListenSocketFactory; |
23 class URLRequestContextGetter; | 24 class URLRequestContextGetter; |
24 } | 25 } |
25 | 26 |
26 namespace content { | 27 namespace content { |
27 | 28 |
28 class DevToolsClientHost; | 29 class DevToolsClientHost; |
29 class RenderViewHost; | 30 class RenderViewHost; |
30 | 31 |
31 class DevToolsHttpHandlerImpl | 32 class DevToolsHttpHandlerImpl |
32 : public DevToolsHttpHandler, | 33 : public DevToolsHttpHandler, |
33 public base::RefCountedThreadSafe<DevToolsHttpHandlerImpl>, | 34 public base::RefCountedThreadSafe<DevToolsHttpHandlerImpl>, |
34 public net::HttpServer::Delegate, | 35 public net::HttpServer::Delegate, |
35 public net::URLRequest::Delegate { | 36 public net::URLRequest::Delegate { |
36 private: | 37 private: |
37 struct PageInfo; | 38 struct PageInfo; |
38 typedef std::vector<PageInfo> PageList; | 39 typedef std::vector<PageInfo> PageList; |
39 friend class base::RefCountedThreadSafe<DevToolsHttpHandlerImpl>; | 40 friend class base::RefCountedThreadSafe<DevToolsHttpHandlerImpl>; |
40 friend class DevToolsHttpHandler; | 41 friend class DevToolsHttpHandler; |
41 | 42 |
42 static bool SortPageListByTime(const PageInfo& info1, const PageInfo& info2); | 43 static bool SortPageListByTime(const PageInfo& info1, const PageInfo& info2); |
43 | 44 |
44 DevToolsHttpHandlerImpl(const std::string& ip, | 45 // Takes ownership over |socket_factory|. |
45 int port, | 46 DevToolsHttpHandlerImpl(const net::StreamListenSocketFactory* socket_factory, |
46 const std::string& frontend_url, | 47 const std::string& frontend_url, |
47 net::URLRequestContextGetter* request_context_getter, | 48 net::URLRequestContextGetter* request_context_getter, |
48 DevToolsHttpHandlerDelegate* delegate); | 49 DevToolsHttpHandlerDelegate* delegate); |
49 virtual ~DevToolsHttpHandlerImpl(); | 50 virtual ~DevToolsHttpHandlerImpl(); |
50 void Start(); | 51 void Start(); |
51 | 52 |
52 // DevToolsHttpHandler implementation. | 53 // DevToolsHttpHandler implementation. |
53 virtual void Stop() OVERRIDE; | 54 virtual void Stop() OVERRIDE; |
54 virtual void SetRenderViewHostBinding( | 55 virtual void SetRenderViewHostBinding( |
55 RenderViewHostBinding* binding) OVERRIDE; | 56 RenderViewHostBinding* binding) OVERRIDE; |
(...skipping 30 matching lines...) Expand all Loading... |
86 | 87 |
87 void Send200(int connection_id, | 88 void Send200(int connection_id, |
88 const std::string& data, | 89 const std::string& data, |
89 const std::string& mime_type = "text/html"); | 90 const std::string& mime_type = "text/html"); |
90 void Send404(int connection_id); | 91 void Send404(int connection_id); |
91 void Send500(int connection_id, | 92 void Send500(int connection_id, |
92 const std::string& message); | 93 const std::string& message); |
93 void AcceptWebSocket(int connection_id, | 94 void AcceptWebSocket(int connection_id, |
94 const net::HttpServerRequestInfo& request); | 95 const net::HttpServerRequestInfo& request); |
95 | 96 |
96 std::string ip_; | |
97 int port_; | |
98 std::string overridden_frontend_url_; | 97 std::string overridden_frontend_url_; |
| 98 scoped_ptr<const net::StreamListenSocketFactory> socket_factory_; |
99 scoped_refptr<net::HttpServer> server_; | 99 scoped_refptr<net::HttpServer> server_; |
100 typedef std::map<net::URLRequest*, int> | 100 typedef std::map<net::URLRequest*, int> |
101 RequestToSocketMap; | 101 RequestToSocketMap; |
102 RequestToSocketMap request_to_connection_io_; | 102 RequestToSocketMap request_to_connection_io_; |
103 typedef std::map<int, std::set<net::URLRequest*> > | 103 typedef std::map<int, std::set<net::URLRequest*> > |
104 ConnectionToRequestsMap; | 104 ConnectionToRequestsMap; |
105 ConnectionToRequestsMap connection_to_requests_io_; | 105 ConnectionToRequestsMap connection_to_requests_io_; |
106 typedef std::map<net::URLRequest*, scoped_refptr<net::IOBuffer> > | 106 typedef std::map<net::URLRequest*, scoped_refptr<net::IOBuffer> > |
107 BuffersMap; | 107 BuffersMap; |
108 BuffersMap request_to_buffer_io_; | 108 BuffersMap request_to_buffer_io_; |
109 typedef std::map<int, content::DevToolsClientHost*> | 109 typedef std::map<int, content::DevToolsClientHost*> |
110 ConnectionToClientHostMap; | 110 ConnectionToClientHostMap; |
111 ConnectionToClientHostMap connection_to_client_host_ui_; | 111 ConnectionToClientHostMap connection_to_client_host_ui_; |
112 net::URLRequestContextGetter* request_context_getter_; | 112 net::URLRequestContextGetter* request_context_getter_; |
113 scoped_ptr<DevToolsHttpHandlerDelegate> delegate_; | 113 scoped_ptr<DevToolsHttpHandlerDelegate> delegate_; |
114 RenderViewHostBinding* binding_; | 114 RenderViewHostBinding* binding_; |
115 scoped_ptr<RenderViewHostBinding> default_binding_; | 115 scoped_ptr<RenderViewHostBinding> default_binding_; |
116 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpHandlerImpl); | 116 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpHandlerImpl); |
117 }; | 117 }; |
118 | 118 |
119 } // namespace content | 119 } // namespace content |
120 | 120 |
121 #endif // CONTENT_BROWSER_DEBUGGER_DEVTOOLS_HTTP_HANDLER_IMPL_H_ | 121 #endif // CONTENT_BROWSER_DEBUGGER_DEVTOOLS_HTTP_HANDLER_IMPL_H_ |
OLD | NEW |