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_DEVTOOLS_DEVTOOLS_HTTP_HANDLER_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_HTTP_HANDLER_IMPL_H_ |
6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_HTTP_HANDLER_IMPL_H_ | 6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_HTTP_HANDLER_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
16 #include "content/public/browser/devtools_agent_host.h" | 16 #include "content/public/browser/devtools_agent_host.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/http/http_status_code.h" | 19 #include "net/http/http_status_code.h" |
20 #include "net/server/http_server.h" | 20 #include "net/server/http_server.h" |
21 | 21 |
22 namespace base { | 22 namespace base { |
23 class DictionaryValue; | 23 class DictionaryValue; |
24 class ListValue; | 24 class ListValue; |
25 class Thread; | 25 class Thread; |
26 class Value; | 26 class Value; |
27 } | 27 } |
28 | 28 |
29 namespace net { | 29 namespace net { |
30 class ServerSocketFactory; | 30 class StreamListenSocketFactory; |
31 class URLRequestContextGetter; | 31 class URLRequestContextGetter; |
32 } | 32 } |
33 | 33 |
34 namespace content { | 34 namespace content { |
35 | 35 |
36 class DevToolsBrowserTarget; | 36 class DevToolsBrowserTarget; |
37 | 37 |
38 class DevToolsHttpHandlerImpl | 38 class DevToolsHttpHandlerImpl |
39 : public DevToolsHttpHandler, | 39 : public DevToolsHttpHandler, |
40 public base::RefCountedThreadSafe<DevToolsHttpHandlerImpl>, | 40 public base::RefCountedThreadSafe<DevToolsHttpHandlerImpl>, |
41 public net::HttpServer::Delegate { | 41 public net::HttpServer::Delegate { |
42 private: | 42 private: |
43 friend class base::RefCountedThreadSafe<DevToolsHttpHandlerImpl>; | 43 friend class base::RefCountedThreadSafe<DevToolsHttpHandlerImpl>; |
44 friend class DevToolsHttpHandler; | 44 friend class DevToolsHttpHandler; |
45 | 45 |
46 DevToolsHttpHandlerImpl(scoped_ptr<ServerSocketFactory> server_socket_factory, | 46 // Takes ownership over |socket_factory|. |
| 47 DevToolsHttpHandlerImpl(const net::StreamListenSocketFactory* socket_factory, |
47 const std::string& frontend_url, | 48 const std::string& frontend_url, |
48 DevToolsHttpHandlerDelegate* delegate, | 49 DevToolsHttpHandlerDelegate* delegate, |
49 const base::FilePath& active_port_output_directory); | 50 const base::FilePath& active_port_output_directory); |
50 virtual ~DevToolsHttpHandlerImpl(); | 51 virtual ~DevToolsHttpHandlerImpl(); |
51 void Start(); | 52 void Start(); |
52 | 53 |
53 // DevToolsHttpHandler implementation. | 54 // DevToolsHttpHandler implementation. |
54 virtual void Stop() OVERRIDE; | 55 virtual void Stop() OVERRIDE; |
55 virtual GURL GetFrontendURL() OVERRIDE; | 56 virtual GURL GetFrontendURL() OVERRIDE; |
56 | 57 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 std::string GetFrontendURLInternal(const std::string target_id, | 110 std::string GetFrontendURLInternal(const std::string target_id, |
110 const std::string& host); | 111 const std::string& host); |
111 | 112 |
112 base::DictionaryValue* SerializeTarget(const DevToolsTarget& target, | 113 base::DictionaryValue* SerializeTarget(const DevToolsTarget& target, |
113 const std::string& host); | 114 const std::string& host); |
114 | 115 |
115 // The thread used by the devtools handler to run server socket. | 116 // The thread used by the devtools handler to run server socket. |
116 scoped_ptr<base::Thread> thread_; | 117 scoped_ptr<base::Thread> thread_; |
117 | 118 |
118 std::string frontend_url_; | 119 std::string frontend_url_; |
119 const scoped_ptr<ServerSocketFactory> server_socket_factory_; | 120 scoped_ptr<const net::StreamListenSocketFactory> socket_factory_; |
120 scoped_ptr<net::HttpServer> server_; | 121 scoped_refptr<net::HttpServer> server_; |
121 typedef std::map<int, DevToolsAgentHostClient*> ConnectionToClientMap; | 122 typedef std::map<int, DevToolsAgentHostClient*> ConnectionToClientMap; |
122 ConnectionToClientMap connection_to_client_ui_; | 123 ConnectionToClientMap connection_to_client_ui_; |
123 const scoped_ptr<DevToolsHttpHandlerDelegate> delegate_; | 124 scoped_ptr<DevToolsHttpHandlerDelegate> delegate_; |
124 const base::FilePath active_port_output_directory_; | 125 base::FilePath active_port_output_directory_; |
125 typedef std::map<std::string, DevToolsTarget*> TargetMap; | 126 typedef std::map<std::string, DevToolsTarget*> TargetMap; |
126 TargetMap target_map_; | 127 TargetMap target_map_; |
127 typedef std::map<int, scoped_refptr<DevToolsBrowserTarget> > BrowserTargets; | 128 typedef std::map<int, scoped_refptr<DevToolsBrowserTarget> > BrowserTargets; |
128 BrowserTargets browser_targets_; | 129 BrowserTargets browser_targets_; |
129 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpHandlerImpl); | 130 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpHandlerImpl); |
130 }; | 131 }; |
131 | 132 |
132 } // namespace content | 133 } // namespace content |
133 | 134 |
134 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_HTTP_HANDLER_IMPL_H_ | 135 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_HTTP_HANDLER_IMPL_H_ |
OLD | NEW |