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 | 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_http_handler.h" | 16 #include "content/public/browser/devtools_http_handler.h" |
17 #include "content/public/browser/devtools_http_handler_delegate.h" | 17 #include "content/public/browser/devtools_http_handler_delegate.h" |
| 18 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/public/browser/notification_registrar.h" |
18 #include "net/server/http_server.h" | 20 #include "net/server/http_server.h" |
19 | 21 |
20 namespace base { | 22 namespace base { |
21 class DictionaryValue; | 23 class DictionaryValue; |
22 class Thread; | 24 class Thread; |
23 class Value; | 25 class Value; |
24 } | 26 } |
25 | 27 |
26 namespace net { | 28 namespace net { |
27 class StreamListenSocketFactory; | 29 class StreamListenSocketFactory; |
28 class URLRequestContextGetter; | 30 class URLRequestContextGetter; |
29 } | 31 } |
30 | 32 |
31 namespace content { | 33 namespace content { |
32 | 34 |
33 class DevToolsClientHost; | 35 class DevToolsClientHost; |
34 class RenderViewHost; | 36 class RenderViewHost; |
35 | 37 |
36 class DevToolsHttpHandlerImpl | 38 class DevToolsHttpHandlerImpl |
37 : public DevToolsHttpHandler, | 39 : public DevToolsHttpHandler, |
| 40 public NotificationObserver, |
38 public base::RefCountedThreadSafe<DevToolsHttpHandlerImpl>, | 41 public base::RefCountedThreadSafe<DevToolsHttpHandlerImpl>, |
39 public net::HttpServer::Delegate { | 42 public net::HttpServer::Delegate { |
40 private: | 43 private: |
41 struct PageInfo; | 44 struct PageInfo; |
42 typedef std::vector<PageInfo> PageList; | 45 typedef std::vector<PageInfo> PageList; |
43 friend class base::RefCountedThreadSafe<DevToolsHttpHandlerImpl>; | 46 friend class base::RefCountedThreadSafe<DevToolsHttpHandlerImpl>; |
44 friend class DevToolsHttpHandler; | 47 friend class DevToolsHttpHandler; |
45 | 48 |
46 static bool SortPageListByTime(const PageInfo& info1, const PageInfo& info2); | 49 static bool SortPageListByTime(const PageInfo& info1, const PageInfo& info2); |
47 | 50 |
48 // Takes ownership over |socket_factory|. | 51 // Takes ownership over |socket_factory|. |
49 DevToolsHttpHandlerImpl(const net::StreamListenSocketFactory* socket_factory, | 52 DevToolsHttpHandlerImpl(const net::StreamListenSocketFactory* socket_factory, |
50 const std::string& frontend_url, | 53 const std::string& frontend_url, |
51 DevToolsHttpHandlerDelegate* delegate); | 54 DevToolsHttpHandlerDelegate* delegate); |
52 virtual ~DevToolsHttpHandlerImpl(); | 55 virtual ~DevToolsHttpHandlerImpl(); |
53 void Start(); | 56 void Start(); |
54 | 57 |
55 // DevToolsHttpHandler implementation. | 58 // DevToolsHttpHandler implementation. |
56 virtual void Stop() OVERRIDE; | 59 virtual void Stop() OVERRIDE; |
57 virtual void SetRenderViewHostBinding( | 60 virtual void SetRenderViewHostBinding( |
58 RenderViewHostBinding* binding) OVERRIDE; | 61 RenderViewHostBinding* binding) OVERRIDE; |
59 virtual GURL GetFrontendURL(RenderViewHost* render_view_host) OVERRIDE; | 62 virtual GURL GetFrontendURL(RenderViewHost* render_view_host) OVERRIDE; |
60 | 63 |
| 64 // NotificationObserver implementation. |
| 65 virtual void Observe(int type, |
| 66 const NotificationSource& source, |
| 67 const NotificationDetails& details) OVERRIDE; |
| 68 |
61 // net::HttpServer::Delegate implementation. | 69 // net::HttpServer::Delegate implementation. |
62 virtual void OnHttpRequest(int connection_id, | 70 virtual void OnHttpRequest(int connection_id, |
63 const net::HttpServerRequestInfo& info) OVERRIDE; | 71 const net::HttpServerRequestInfo& info) OVERRIDE; |
64 virtual void OnWebSocketRequest( | 72 virtual void OnWebSocketRequest( |
65 int connection_id, | 73 int connection_id, |
66 const net::HttpServerRequestInfo& info) OVERRIDE; | 74 const net::HttpServerRequestInfo& info) OVERRIDE; |
67 virtual void OnWebSocketMessage(int connection_id, | 75 virtual void OnWebSocketMessage(int connection_id, |
68 const std::string& data) OVERRIDE; | 76 const std::string& data) OVERRIDE; |
69 virtual void OnClose(int connection_id) OVERRIDE; | 77 virtual void OnClose(int connection_id) OVERRIDE; |
70 | 78 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 122 |
115 std::string overridden_frontend_url_; | 123 std::string overridden_frontend_url_; |
116 scoped_ptr<const net::StreamListenSocketFactory> socket_factory_; | 124 scoped_ptr<const net::StreamListenSocketFactory> socket_factory_; |
117 scoped_refptr<net::HttpServer> server_; | 125 scoped_refptr<net::HttpServer> server_; |
118 typedef std::map<int, content::DevToolsClientHost*> | 126 typedef std::map<int, content::DevToolsClientHost*> |
119 ConnectionToClientHostMap; | 127 ConnectionToClientHostMap; |
120 ConnectionToClientHostMap connection_to_client_host_ui_; | 128 ConnectionToClientHostMap connection_to_client_host_ui_; |
121 scoped_ptr<DevToolsHttpHandlerDelegate> delegate_; | 129 scoped_ptr<DevToolsHttpHandlerDelegate> delegate_; |
122 RenderViewHostBinding* binding_; | 130 RenderViewHostBinding* binding_; |
123 scoped_ptr<RenderViewHostBinding> default_binding_; | 131 scoped_ptr<RenderViewHostBinding> default_binding_; |
| 132 NotificationRegistrar registrar_; |
124 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpHandlerImpl); | 133 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpHandlerImpl); |
125 }; | 134 }; |
126 | 135 |
127 } // namespace content | 136 } // namespace content |
128 | 137 |
129 #endif // CONTENT_BROWSER_DEBUGGER_DEVTOOLS_HTTP_HANDLER_IMPL_H_ | 138 #endif // CONTENT_BROWSER_DEBUGGER_DEVTOOLS_HTTP_HANDLER_IMPL_H_ |
OLD | NEW |