Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: chrome/browser/devtools/device/devtools_android_bridge.h

Issue 612913002: DevTools: Split RemotePage and RemotePageTarget (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@values
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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();
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 device_manager_->SetDeviceProviders(device_providers); 207 device_manager_->SetDeviceProviders(device_providers);
188 } 208 }
189 209
190 void set_task_scheduler_for_test( 210 void set_task_scheduler_for_test(
191 base::Callback<void(const base::Closure&)> scheduler) { 211 base::Callback<void(const base::Closure&)> scheduler) {
192 task_scheduler_ = scheduler; 212 task_scheduler_ = scheduler;
193 } 213 }
194 214
195 bool HasDevToolsWindow(const std::string& agent_id); 215 bool HasDevToolsWindow(const std::string& agent_id);
196 216
197 std::vector<RemotePage*> CreatePages(scoped_refptr<RemoteBrowser> browser); 217 DevToolsTargetImpl* CreatePageTarget(scoped_refptr<RemotePage> browser);
dgozman 2014/09/30 09:23:48 browser->page
dgozman 2014/09/30 09:23:48 We should comment that caller gets ownership of th
vkuzkokov 2014/10/01 09:05:17 Done.
198 218
199 typedef base::Callback<void(RemotePage*)> RemotePageCallback; 219 typedef base::Callback<void(scoped_refptr<RemotePage>)> RemotePageCallback;
200 void Open(scoped_refptr<RemoteBrowser> browser, 220 void Open(scoped_refptr<RemoteBrowser> browser,
201 const std::string& url, 221 const std::string& url,
202 const RemotePageCallback& callback); 222 const RemotePageCallback& callback);
203 223
204 scoped_refptr<content::DevToolsAgentHost> GetBrowserAgentHost( 224 scoped_refptr<content::DevToolsAgentHost> GetBrowserAgentHost(
205 scoped_refptr<RemoteBrowser> browser); 225 scoped_refptr<RemoteBrowser> browser);
206 226
207 private: 227 private:
208 friend struct content::BrowserThread::DeleteOnThread< 228 friend struct content::BrowserThread::DeleteOnThread<
209 content::BrowserThread::UI>; 229 content::BrowserThread::UI>;
(...skipping 19 matching lines...) Expand all
229 249
230 void StartDeviceCountPolling(); 250 void StartDeviceCountPolling();
231 void StopDeviceCountPolling(); 251 void StopDeviceCountPolling();
232 void RequestDeviceCount(const base::Callback<void(int)>& callback); 252 void RequestDeviceCount(const base::Callback<void(int)>& callback);
233 void ReceivedDeviceCount(int count); 253 void ReceivedDeviceCount(int count);
234 254
235 static void ScheduleTaskDefault(const base::Closure& task); 255 static void ScheduleTaskDefault(const base::Closure& task);
236 256
237 void CreateDeviceProviders(); 257 void CreateDeviceProviders();
238 258
239 void SendJsonRequest(scoped_refptr<RemoteBrowser> browser, 259 void SendJsonRequest(const BrowserId& browser_id,
240 const std::string& url, 260 const std::string& url,
241 const JsonRequestCallback& callback); 261 const JsonRequestCallback& callback);
242 262
243 void SendProtocolCommand(scoped_refptr<RemoteBrowser> browser, 263 void SendProtocolCommand(const BrowserId& browser_id,
244 const std::string& debug_url, 264 const std::string& debug_url,
245 const std::string& method, 265 const std::string& method,
246 base::DictionaryValue* params, 266 base::DictionaryValue* params,
247 const base::Closure callback); 267 const base::Closure callback);
248 268
249 AndroidDeviceManager::AndroidWebSocket* CreateWebSocket( 269 AndroidDeviceManager::AndroidWebSocket* CreateWebSocket(
250 scoped_refptr<RemoteBrowser> browser, 270 const BrowserId& browser_id,
251 const std::string& url, 271 const std::string& url,
252 AndroidDeviceManager::AndroidWebSocket::Delegate* delegate); 272 AndroidDeviceManager::AndroidWebSocket::Delegate* delegate);
253 273
254 void PageCreatedOnUIThread(scoped_refptr<RemoteBrowser> browser, 274 void PageCreatedOnUIThread(scoped_refptr<RemoteBrowser> browser,
255 const RemotePageCallback& callback, 275 const RemotePageCallback& callback,
256 const std::string& url, 276 const std::string& url,
257 int result, 277 int result,
258 const std::string& response); 278 const std::string& response);
259 279
260 void NavigatePageOnUIThread(scoped_refptr<RemoteBrowser> browser, 280 void NavigatePageOnUIThread(scoped_refptr<RemoteBrowser> browser,
(...skipping 29 matching lines...) Expand all
290 310
291 typedef std::vector<PortForwardingListener*> PortForwardingListeners; 311 typedef std::vector<PortForwardingListener*> PortForwardingListeners;
292 PortForwardingListeners port_forwarding_listeners_; 312 PortForwardingListeners port_forwarding_listeners_;
293 scoped_ptr<PortForwardingController> port_forwarding_controller_; 313 scoped_ptr<PortForwardingController> port_forwarding_controller_;
294 314
295 PrefChangeRegistrar pref_change_registrar_; 315 PrefChangeRegistrar pref_change_registrar_;
296 DISALLOW_COPY_AND_ASSIGN(DevToolsAndroidBridge); 316 DISALLOW_COPY_AND_ASSIGN(DevToolsAndroidBridge);
297 }; 317 };
298 318
299 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_DEVTOOLS_ANDROID_BRIDGE_H_ 319 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_DEVTOOLS_ANDROID_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698