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

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

Powered by Google App Engine
This is Rietveld 408576698