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> |
(...skipping 14 matching lines...) Expand all Loading... | |
25 class Value; | 25 class Value; |
26 } | 26 } |
27 | 27 |
28 namespace net { | 28 namespace net { |
29 class StreamListenSocketFactory; | 29 class StreamListenSocketFactory; |
30 class URLRequestContextGetter; | 30 class URLRequestContextGetter; |
31 } | 31 } |
32 | 32 |
33 namespace content { | 33 namespace content { |
34 | 34 |
35 class DevToolsBrowserTarget; | |
35 class DevToolsClientHost; | 36 class DevToolsClientHost; |
36 class RenderViewHost; | 37 class RenderViewHost; |
37 | 38 |
39 class DevToolsServerSender { | |
40 public: | |
41 DevToolsServerSender() {} | |
42 | |
43 virtual void SendJson(int connection_id, | |
pfeldman
2012/12/12 20:17:12
I think you should make handler return resulting m
bulach
2012/12/13 17:36:23
Done.
| |
44 net::HttpStatusCode status_code, | |
45 base::Value* value, | |
46 const std::string& message, | |
47 const std::string& jsonp) = 0; | |
48 virtual void Send200(int connection_id, | |
49 const std::string& data, | |
50 const std::string& mime_type) = 0; | |
51 virtual void Send404(int connection_id) = 0; | |
52 virtual void Send500(int connection_id, | |
53 const std::string& message) = 0; | |
54 | |
55 private: | |
56 DISALLOW_COPY_AND_ASSIGN(DevToolsServerSender); | |
57 }; | |
58 | |
38 class DevToolsHttpHandlerImpl | 59 class DevToolsHttpHandlerImpl |
39 : public DevToolsHttpHandler, | 60 : public DevToolsHttpHandler, |
40 public NotificationObserver, | 61 public NotificationObserver, |
41 public base::RefCountedThreadSafe<DevToolsHttpHandlerImpl>, | 62 public base::RefCountedThreadSafe<DevToolsHttpHandlerImpl>, |
42 public net::HttpServer::Delegate { | 63 public net::HttpServer::Delegate, |
64 public DevToolsServerSender { | |
43 private: | 65 private: |
44 struct PageInfo; | 66 struct PageInfo; |
45 typedef std::vector<PageInfo> PageList; | 67 typedef std::vector<PageInfo> PageList; |
46 friend class base::RefCountedThreadSafe<DevToolsHttpHandlerImpl>; | 68 friend class base::RefCountedThreadSafe<DevToolsHttpHandlerImpl>; |
47 friend class DevToolsHttpHandler; | 69 friend class DevToolsHttpHandler; |
48 | 70 |
49 static bool SortPageListByTime(const PageInfo& info1, const PageInfo& info2); | 71 static bool SortPageListByTime(const PageInfo& info1, const PageInfo& info2); |
50 | 72 |
51 // Takes ownership over |socket_factory|. | 73 // Takes ownership over |socket_factory|. |
52 DevToolsHttpHandlerImpl(const net::StreamListenSocketFactory* socket_factory, | 74 DevToolsHttpHandlerImpl(const net::StreamListenSocketFactory* socket_factory, |
(...skipping 19 matching lines...) Expand all Loading... | |
72 virtual void OnWebSocketRequest( | 94 virtual void OnWebSocketRequest( |
73 int connection_id, | 95 int connection_id, |
74 const net::HttpServerRequestInfo& info) OVERRIDE; | 96 const net::HttpServerRequestInfo& info) OVERRIDE; |
75 virtual void OnWebSocketMessage(int connection_id, | 97 virtual void OnWebSocketMessage(int connection_id, |
76 const std::string& data) OVERRIDE; | 98 const std::string& data) OVERRIDE; |
77 virtual void OnClose(int connection_id) OVERRIDE; | 99 virtual void OnClose(int connection_id) OVERRIDE; |
78 | 100 |
79 void OnJsonRequestUI(int connection_id, | 101 void OnJsonRequestUI(int connection_id, |
80 const net::HttpServerRequestInfo& info); | 102 const net::HttpServerRequestInfo& info); |
81 void OnThumbnailRequestUI(int connection_id, | 103 void OnThumbnailRequestUI(int connection_id, |
82 const net::HttpServerRequestInfo& info); | 104 const net::HttpServerRequestInfo& info); |
83 void OnDiscoveryPageRequestUI(int connection_id); | 105 void OnDiscoveryPageRequestUI(int connection_id); |
84 | 106 |
85 void OnWebSocketRequestUI(int connection_id, | 107 void OnWebSocketRequestUI(int connection_id, |
86 const net::HttpServerRequestInfo& info); | 108 const net::HttpServerRequestInfo& info); |
87 void OnWebSocketMessageUI(int connection_id, const std::string& data); | 109 void OnWebSocketMessageUI(int connection_id, const std::string& data); |
110 void OnTraceRequestUI(int connection_id, | |
pfeldman
2012/12/12 20:17:12
No need for this now.
bulach
2012/12/13 17:36:23
Done.
| |
111 const net::HttpServerRequestInfo& info); | |
88 void OnCloseUI(int connection_id); | 112 void OnCloseUI(int connection_id); |
89 | 113 |
90 void ResetHandlerThread(); | 114 void ResetHandlerThread(); |
91 void ResetHandlerThreadAndRelease(); | 115 void ResetHandlerThreadAndRelease(); |
92 | 116 |
93 void Init(); | 117 void Init(); |
94 void Teardown(); | 118 void Teardown(); |
95 | 119 |
96 void StartHandlerThread(); | 120 void StartHandlerThread(); |
97 void StopHandlerThread(); | 121 void StopHandlerThread(); |
98 | 122 |
99 void SendJson(int connection_id, | 123 virtual void SendJson(int connection_id, |
100 net::HttpStatusCode status_code, | 124 net::HttpStatusCode status_code, |
101 base::Value* value, | 125 base::Value* value, |
102 const std::string& message, | 126 const std::string& message, |
103 const std::string& jsonp); | 127 const std::string& jsonp) OVERRIDE; |
104 void Send200(int connection_id, | 128 virtual void Send200(int connection_id, |
105 const std::string& data, | 129 const std::string& data, |
106 const std::string& mime_type); | 130 const std::string& mime_type) OVERRIDE; |
107 void Send404(int connection_id); | 131 virtual void Send404(int connection_id) OVERRIDE; |
108 void Send500(int connection_id, | 132 virtual void Send500(int connection_id, |
109 const std::string& message); | 133 const std::string& message) OVERRIDE; |
110 void AcceptWebSocket(int connection_id, | 134 void AcceptWebSocket(int connection_id, |
111 const net::HttpServerRequestInfo& request); | 135 const net::HttpServerRequestInfo& request); |
112 | 136 |
113 PageList GeneratePageList(); | 137 PageList GeneratePageList(); |
114 | 138 |
115 // Returns the front end url without the host at the beginning. | 139 // Returns the front end url without the host at the beginning. |
116 std::string GetFrontendURLInternal(const std::string rvh_id, | 140 std::string GetFrontendURLInternal(const std::string rvh_id, |
117 const std::string& host); | 141 const std::string& host); |
118 | 142 |
119 PageInfo CreatePageInfo(RenderViewHost* rvh); | 143 PageInfo CreatePageInfo(RenderViewHost* rvh); |
120 | 144 |
121 base::DictionaryValue* SerializePageInfo(const PageInfo& page_info, | 145 base::DictionaryValue* SerializePageInfo(const PageInfo& page_info, |
122 const std::string& host); | 146 const std::string& host); |
123 | 147 |
124 // The thread used by the devtools handler to run server socket. | 148 // The thread used by the devtools handler to run server socket. |
125 scoped_ptr<base::Thread> thread_; | 149 scoped_ptr<base::Thread> thread_; |
126 | 150 |
127 std::string overridden_frontend_url_; | 151 std::string overridden_frontend_url_; |
128 scoped_ptr<const net::StreamListenSocketFactory> socket_factory_; | 152 scoped_ptr<const net::StreamListenSocketFactory> socket_factory_; |
129 scoped_refptr<net::HttpServer> server_; | 153 scoped_refptr<net::HttpServer> server_; |
130 typedef std::map<int, DevToolsClientHost*> ConnectionToClientHostMap; | 154 typedef std::map<int, DevToolsClientHost*> ConnectionToClientHostMap; |
131 ConnectionToClientHostMap connection_to_client_host_ui_; | 155 ConnectionToClientHostMap connection_to_client_host_ui_; |
132 scoped_ptr<DevToolsHttpHandlerDelegate> delegate_; | 156 scoped_ptr<DevToolsHttpHandlerDelegate> delegate_; |
133 RenderViewHostBinding* binding_; | 157 RenderViewHostBinding* binding_; |
134 scoped_ptr<RenderViewHostBinding> default_binding_; | 158 scoped_ptr<RenderViewHostBinding> default_binding_; |
135 NotificationRegistrar registrar_; | 159 NotificationRegistrar registrar_; |
160 scoped_ptr<DevToolsBrowserTarget> browser_target_; | |
136 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpHandlerImpl); | 161 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpHandlerImpl); |
137 }; | 162 }; |
138 | 163 |
139 } // namespace content | 164 } // namespace content |
140 | 165 |
141 #endif // CONTENT_BROWSER_DEBUGGER_DEVTOOLS_HTTP_HANDLER_IMPL_H_ | 166 #endif // CONTENT_BROWSER_DEBUGGER_DEVTOOLS_HTTP_HANDLER_IMPL_H_ |
OLD | NEW |