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> |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 class DevToolsBrowserTarget; | 35 class DevToolsBrowserTarget; |
36 class DevToolsClientHost; | 36 class DevToolsClientHost; |
37 | 37 |
38 class DevToolsHttpHandlerImpl | 38 class DevToolsHttpHandlerImpl |
39 : public DevToolsHttpHandler, | 39 : public DevToolsHttpHandler, |
40 public NotificationObserver, | 40 public NotificationObserver, |
41 public base::RefCountedThreadSafe<DevToolsHttpHandlerImpl>, | 41 public base::RefCountedThreadSafe<DevToolsHttpHandlerImpl>, |
42 public net::HttpServer::Delegate { | 42 public net::HttpServer::Delegate { |
43 private: | 43 private: |
44 struct PageInfo; | |
45 typedef std::vector<PageInfo> PageList; | |
46 friend class base::RefCountedThreadSafe<DevToolsHttpHandlerImpl>; | 44 friend class base::RefCountedThreadSafe<DevToolsHttpHandlerImpl>; |
47 friend class DevToolsHttpHandler; | 45 friend class DevToolsHttpHandler; |
48 | 46 |
49 static bool SortPageListByTime(const PageInfo& info1, const PageInfo& info2); | |
50 | |
51 // Takes ownership over |socket_factory|. | 47 // Takes ownership over |socket_factory|. |
52 DevToolsHttpHandlerImpl(const net::StreamListenSocketFactory* socket_factory, | 48 DevToolsHttpHandlerImpl(const net::StreamListenSocketFactory* socket_factory, |
53 const std::string& frontend_url, | 49 const std::string& frontend_url, |
54 DevToolsHttpHandlerDelegate* delegate); | 50 DevToolsHttpHandlerDelegate* delegate); |
55 virtual ~DevToolsHttpHandlerImpl(); | 51 virtual ~DevToolsHttpHandlerImpl(); |
56 void Start(); | 52 void Start(); |
57 | 53 |
58 // DevToolsHttpHandler implementation. | 54 // DevToolsHttpHandler implementation. |
59 virtual void Stop() OVERRIDE; | 55 virtual void Stop() OVERRIDE; |
60 virtual void SetDevToolsAgentHostBinding( | 56 virtual void SetDevToolsAgentHostBinding( |
(...skipping 10 matching lines...) Expand all Loading... |
71 const net::HttpServerRequestInfo& info) OVERRIDE; | 67 const net::HttpServerRequestInfo& info) OVERRIDE; |
72 virtual void OnWebSocketRequest( | 68 virtual void OnWebSocketRequest( |
73 int connection_id, | 69 int connection_id, |
74 const net::HttpServerRequestInfo& info) OVERRIDE; | 70 const net::HttpServerRequestInfo& info) OVERRIDE; |
75 virtual void OnWebSocketMessage(int connection_id, | 71 virtual void OnWebSocketMessage(int connection_id, |
76 const std::string& data) OVERRIDE; | 72 const std::string& data) OVERRIDE; |
77 virtual void OnClose(int connection_id) OVERRIDE; | 73 virtual void OnClose(int connection_id) OVERRIDE; |
78 | 74 |
79 void OnJsonRequestUI(int connection_id, | 75 void OnJsonRequestUI(int connection_id, |
80 const net::HttpServerRequestInfo& info); | 76 const net::HttpServerRequestInfo& info); |
81 void OnThumbnailRequestUI(int connection_id, | 77 void OnThumbnailRequestUI(int connection_id, const GURL& page_url); |
82 const net::HttpServerRequestInfo& info); | |
83 void OnDiscoveryPageRequestUI(int connection_id); | 78 void OnDiscoveryPageRequestUI(int connection_id); |
84 | 79 |
85 void OnWebSocketRequestUI(int connection_id, | 80 void OnWebSocketRequestUI(int connection_id, |
86 const net::HttpServerRequestInfo& info); | 81 const net::HttpServerRequestInfo& info); |
87 void OnWebSocketMessageUI(int connection_id, const std::string& data); | 82 void OnWebSocketMessageUI(int connection_id, const std::string& data); |
88 void OnCloseUI(int connection_id); | 83 void OnCloseUI(int connection_id); |
89 | 84 |
90 void ResetHandlerThread(); | 85 void ResetHandlerThread(); |
91 void ResetHandlerThreadAndRelease(); | 86 void ResetHandlerThreadAndRelease(); |
92 | 87 |
(...skipping 10 matching lines...) Expand all Loading... |
103 const std::string& jsonp); | 98 const std::string& jsonp); |
104 void Send200(int connection_id, | 99 void Send200(int connection_id, |
105 const std::string& data, | 100 const std::string& data, |
106 const std::string& mime_type); | 101 const std::string& mime_type); |
107 void Send404(int connection_id); | 102 void Send404(int connection_id); |
108 void Send500(int connection_id, | 103 void Send500(int connection_id, |
109 const std::string& message); | 104 const std::string& message); |
110 void AcceptWebSocket(int connection_id, | 105 void AcceptWebSocket(int connection_id, |
111 const net::HttpServerRequestInfo& request); | 106 const net::HttpServerRequestInfo& request); |
112 | 107 |
113 PageList GeneratePageList(); | |
114 | |
115 // Returns the front end url without the host at the beginning. | 108 // Returns the front end url without the host at the beginning. |
116 std::string GetFrontendURLInternal(const std::string rvh_id, | 109 std::string GetFrontendURLInternal(const std::string rvh_id, |
117 const std::string& host); | 110 const std::string& host); |
118 | 111 |
119 PageInfo CreatePageInfo(RenderViewHost* rvh, | 112 base::DictionaryValue* SerializePageInfo(RenderViewHost* rvh, |
120 DevToolsHttpHandlerDelegate::TargetType type); | |
121 | |
122 base::DictionaryValue* SerializePageInfo(const PageInfo& page_info, | |
123 const std::string& host); | 113 const std::string& host); |
124 | 114 |
125 // The thread used by the devtools handler to run server socket. | 115 // The thread used by the devtools handler to run server socket. |
126 scoped_ptr<base::Thread> thread_; | 116 scoped_ptr<base::Thread> thread_; |
127 | 117 |
128 std::string overridden_frontend_url_; | 118 std::string overridden_frontend_url_; |
129 scoped_ptr<const net::StreamListenSocketFactory> socket_factory_; | 119 scoped_ptr<const net::StreamListenSocketFactory> socket_factory_; |
130 scoped_refptr<net::HttpServer> server_; | 120 scoped_refptr<net::HttpServer> server_; |
131 typedef std::map<int, DevToolsClientHost*> ConnectionToClientHostMap; | 121 typedef std::map<int, DevToolsClientHost*> ConnectionToClientHostMap; |
132 ConnectionToClientHostMap connection_to_client_host_ui_; | 122 ConnectionToClientHostMap connection_to_client_host_ui_; |
133 scoped_ptr<DevToolsHttpHandlerDelegate> delegate_; | 123 scoped_ptr<DevToolsHttpHandlerDelegate> delegate_; |
134 DevToolsAgentHostBinding* binding_; | 124 DevToolsAgentHostBinding* binding_; |
135 scoped_ptr<DevToolsAgentHostBinding> default_binding_; | 125 scoped_ptr<DevToolsAgentHostBinding> default_binding_; |
136 NotificationRegistrar registrar_; | 126 NotificationRegistrar registrar_; |
137 scoped_ptr<DevToolsBrowserTarget> browser_target_; | 127 scoped_ptr<DevToolsBrowserTarget> browser_target_; |
138 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpHandlerImpl); | 128 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpHandlerImpl); |
139 }; | 129 }; |
140 | 130 |
141 } // namespace content | 131 } // namespace content |
142 | 132 |
143 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_HTTP_HANDLER_IMPL_H_ | 133 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_HTTP_HANDLER_IMPL_H_ |
OLD | NEW |