OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CHROME_BROWSER_DEVTOOLS_DEVICE_DEVTOOLS_ANDROID_BRIDGE_H_ | 5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVICE_DEVTOOLS_ANDROID_BRIDGE_H_ |
6 #define CHROME_BROWSER_DEVTOOLS_DEVICE_DEVTOOLS_ANDROID_BRIDGE_H_ | 6 #define CHROME_BROWSER_DEVTOOLS_DEVICE_DEVTOOLS_ANDROID_BRIDGE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 | 64 |
65 Factory(); | 65 Factory(); |
66 virtual ~Factory(); | 66 virtual ~Factory(); |
67 | 67 |
68 // BrowserContextKeyedServiceFactory overrides: | 68 // BrowserContextKeyedServiceFactory overrides: |
69 virtual KeyedService* BuildServiceInstanceFor( | 69 virtual KeyedService* BuildServiceInstanceFor( |
70 content::BrowserContext* context) const override; | 70 content::BrowserContext* context) const override; |
71 DISALLOW_COPY_AND_ASSIGN(Factory); | 71 DISALLOW_COPY_AND_ASSIGN(Factory); |
72 }; | 72 }; |
73 | 73 |
74 class RemotePage { | 74 typedef std::pair<std::string, std::string> BrowserId; |
75 | |
76 class RemotePage : public base::RefCounted<RemotePage> { | |
75 public: | 77 public: |
76 virtual ~RemotePage() {} | 78 const std::string& serial() { return browser_id_.first; } |
77 virtual DevToolsTargetImpl* GetTarget() = 0; | 79 const std::string& socket() { return browser_id_.second; } |
78 virtual std::string GetFrontendURL() = 0; | 80 const std::string& frontend_url() { return frontend_url_; } |
81 const base::DictionaryValue& dict(); | |
dgozman
2014/10/15 14:53:12
I think we should move this to private.
vkuzkokov
2014/10/15 15:24:19
Removed.
| |
82 bool is_web_view() { return is_web_view_; } | |
83 | |
84 private: | |
85 friend class base::RefCounted<RemotePage>; | |
86 friend class DevToolsAndroidBridge; | |
87 | |
88 RemotePage(const BrowserId& browser_id, | |
89 const base::DictionaryValue& dict, | |
90 bool is_web_view); | |
91 | |
92 virtual ~RemotePage(); | |
93 | |
94 BrowserId browser_id_; | |
95 std::string frontend_url_; | |
96 bool is_web_view_; | |
97 scoped_ptr<base::DictionaryValue> dict_; | |
98 | |
99 DISALLOW_COPY_AND_ASSIGN(RemotePage); | |
79 }; | 100 }; |
80 | 101 |
102 typedef std::vector<scoped_refptr<RemotePage> > RemotePages; | |
81 typedef base::Callback<void(int, const std::string&)> JsonRequestCallback; | 103 typedef base::Callback<void(int, const std::string&)> JsonRequestCallback; |
82 | 104 |
83 class RemoteBrowser : public base::RefCounted<RemoteBrowser> { | 105 class RemoteBrowser : public base::RefCounted<RemoteBrowser> { |
84 public: | 106 public: |
85 const std::string& serial() { return serial_; } | 107 const std::string& serial() { return browser_id_.first; } |
86 const std::string& socket() { return socket_; } | 108 const std::string& socket() { return browser_id_.second; } |
87 const std::string& display_name() { return display_name_; } | 109 const std::string& display_name() { return display_name_; } |
88 const std::string& version() { return version_; } | 110 const std::string& version() { return version_; } |
111 const RemotePages& pages() { return pages_; } | |
89 | 112 |
90 bool IsChrome(); | 113 bool IsChrome(); |
91 bool IsWebView(); | 114 bool IsWebView(); |
92 | 115 |
93 typedef std::vector<int> ParsedVersion; | 116 typedef std::vector<int> ParsedVersion; |
94 ParsedVersion GetParsedVersion(); | 117 ParsedVersion GetParsedVersion(); |
95 | 118 |
96 const base::ListValue& page_descriptors(); | |
97 | |
98 private: | 119 private: |
99 friend class base::RefCounted<RemoteBrowser>; | 120 friend class base::RefCounted<RemoteBrowser>; |
100 friend class DevToolsAndroidBridge; | 121 friend class DevToolsAndroidBridge; |
101 | 122 |
102 RemoteBrowser(const std::string& serial, | 123 RemoteBrowser(const std::string& serial, |
103 const AndroidDeviceManager::BrowserInfo& browser_info); | 124 const AndroidDeviceManager::BrowserInfo& browser_info); |
104 | 125 |
105 virtual ~RemoteBrowser(); | 126 virtual ~RemoteBrowser(); |
106 | 127 |
107 std::string serial_; | 128 BrowserId browser_id_; |
108 const std::string socket_; | |
109 std::string display_name_; | 129 std::string display_name_; |
110 const AndroidDeviceManager::BrowserInfo::Type type_; | 130 AndroidDeviceManager::BrowserInfo::Type type_; |
111 std::string version_; | 131 std::string version_; |
112 scoped_ptr<base::ListValue> page_descriptors_; | 132 RemotePages pages_; |
113 | 133 |
114 DISALLOW_COPY_AND_ASSIGN(RemoteBrowser); | 134 DISALLOW_COPY_AND_ASSIGN(RemoteBrowser); |
115 }; | 135 }; |
116 | 136 |
117 typedef std::vector<scoped_refptr<RemoteBrowser> > RemoteBrowsers; | 137 typedef std::vector<scoped_refptr<RemoteBrowser> > RemoteBrowsers; |
118 | 138 |
119 class RemoteDevice : public base::RefCounted<RemoteDevice> { | 139 class RemoteDevice : public base::RefCounted<RemoteDevice> { |
120 public: | 140 public: |
121 std::string serial() { return serial_; } | 141 std::string serial() { return serial_; } |
122 std::string model() { return model_; } | 142 std::string model() { return model_; } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 device_manager_->SetDeviceProviders(device_providers); | 210 device_manager_->SetDeviceProviders(device_providers); |
191 } | 211 } |
192 | 212 |
193 void set_task_scheduler_for_test( | 213 void set_task_scheduler_for_test( |
194 base::Callback<void(const base::Closure&)> scheduler) { | 214 base::Callback<void(const base::Closure&)> scheduler) { |
195 task_scheduler_ = scheduler; | 215 task_scheduler_ = scheduler; |
196 } | 216 } |
197 | 217 |
198 bool HasDevToolsWindow(const std::string& agent_id); | 218 bool HasDevToolsWindow(const std::string& agent_id); |
199 | 219 |
200 std::vector<RemotePage*> CreatePages(scoped_refptr<RemoteBrowser> browser); | 220 // Creates new target instance owned by caller. |
221 DevToolsTargetImpl* CreatePageTarget(scoped_refptr<RemotePage> browser); | |
201 | 222 |
202 typedef base::Callback<void(RemotePage*)> RemotePageCallback; | 223 typedef base::Callback<void(scoped_refptr<RemotePage>)> RemotePageCallback; |
203 void OpenRemotePage(scoped_refptr<RemoteBrowser> browser, | 224 void OpenRemotePage(scoped_refptr<RemoteBrowser> browser, |
204 const std::string& url, | 225 const std::string& url, |
205 const RemotePageCallback& callback); | 226 const RemotePageCallback& callback); |
206 | 227 |
207 scoped_refptr<content::DevToolsAgentHost> GetBrowserAgentHost( | 228 scoped_refptr<content::DevToolsAgentHost> GetBrowserAgentHost( |
208 scoped_refptr<RemoteBrowser> browser); | 229 scoped_refptr<RemoteBrowser> browser); |
209 | 230 |
210 typedef std::pair<scoped_refptr<AndroidDeviceManager::Device>, | 231 typedef std::pair<scoped_refptr<AndroidDeviceManager::Device>, |
211 scoped_refptr<RemoteDevice>> CompleteDevice; | 232 scoped_refptr<RemoteDevice>> CompleteDevice; |
212 typedef std::vector<CompleteDevice> CompleteDevices; | 233 typedef std::vector<CompleteDevice> CompleteDevices; |
(...skipping 20 matching lines...) Expand all Loading... | |
233 | 254 |
234 void StartDeviceCountPolling(); | 255 void StartDeviceCountPolling(); |
235 void StopDeviceCountPolling(); | 256 void StopDeviceCountPolling(); |
236 void RequestDeviceCount(const base::Callback<void(int)>& callback); | 257 void RequestDeviceCount(const base::Callback<void(int)>& callback); |
237 void ReceivedDeviceCount(int count); | 258 void ReceivedDeviceCount(int count); |
238 | 259 |
239 static void ScheduleTaskDefault(const base::Closure& task); | 260 static void ScheduleTaskDefault(const base::Closure& task); |
240 | 261 |
241 void CreateDeviceProviders(); | 262 void CreateDeviceProviders(); |
242 | 263 |
243 void SendJsonRequest(scoped_refptr<RemoteBrowser> browser, | 264 void SendJsonRequest(const BrowserId& browser_id, |
244 const std::string& url, | 265 const std::string& url, |
245 const JsonRequestCallback& callback); | 266 const JsonRequestCallback& callback); |
246 | 267 |
247 void SendProtocolCommand(scoped_refptr<RemoteBrowser> browser, | 268 void SendProtocolCommand(const BrowserId& browser_id, |
248 const std::string& debug_url, | 269 const std::string& debug_url, |
249 const std::string& method, | 270 const std::string& method, |
250 base::DictionaryValue* params, | 271 base::DictionaryValue* params, |
251 const base::Closure callback); | 272 const base::Closure callback); |
252 | 273 |
253 AndroidDeviceManager::AndroidWebSocket* CreateWebSocket( | 274 AndroidDeviceManager::AndroidWebSocket* CreateWebSocket( |
254 scoped_refptr<RemoteBrowser> browser, | 275 const BrowserId& browser_id, |
255 const std::string& url, | 276 const std::string& url, |
256 AndroidDeviceManager::AndroidWebSocket::Delegate* delegate); | 277 AndroidDeviceManager::AndroidWebSocket::Delegate* delegate); |
257 | 278 |
258 void PageCreatedOnUIThread(scoped_refptr<RemoteBrowser> browser, | 279 void PageCreatedOnUIThread(scoped_refptr<RemoteBrowser> browser, |
259 const RemotePageCallback& callback, | 280 const RemotePageCallback& callback, |
260 const std::string& url, | 281 const std::string& url, |
261 int result, | 282 int result, |
262 const std::string& response); | 283 const std::string& response); |
263 | 284 |
264 void NavigatePageOnUIThread(scoped_refptr<RemoteBrowser> browser, | 285 void NavigatePageOnUIThread(scoped_refptr<RemoteBrowser> browser, |
(...skipping 28 matching lines...) Expand all Loading... | |
293 | 314 |
294 typedef std::vector<PortForwardingListener*> PortForwardingListeners; | 315 typedef std::vector<PortForwardingListener*> PortForwardingListeners; |
295 PortForwardingListeners port_forwarding_listeners_; | 316 PortForwardingListeners port_forwarding_listeners_; |
296 scoped_ptr<PortForwardingController> port_forwarding_controller_; | 317 scoped_ptr<PortForwardingController> port_forwarding_controller_; |
297 | 318 |
298 PrefChangeRegistrar pref_change_registrar_; | 319 PrefChangeRegistrar pref_change_registrar_; |
299 DISALLOW_COPY_AND_ASSIGN(DevToolsAndroidBridge); | 320 DISALLOW_COPY_AND_ASSIGN(DevToolsAndroidBridge); |
300 }; | 321 }; |
301 | 322 |
302 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_DEVTOOLS_ANDROID_BRIDGE_H_ | 323 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_DEVTOOLS_ANDROID_BRIDGE_H_ |
OLD | NEW |