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

Unified Diff: chrome/browser/devtools/device/devtools_android_bridge.h

Issue 596253003: DevTools: RemoteDevice and RemoteBrowser are now value types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pfc3
Patch Set: Fixed test Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/devtools/device/devtools_android_bridge.h
diff --git a/chrome/browser/devtools/device/devtools_android_bridge.h b/chrome/browser/devtools/device/devtools_android_bridge.h
index 2f283a1205f14e88f850655720b8f8729f2551d2..18193d2847bbc10eb303aebce065c7f59a7dab1a 100644
--- a/chrome/browser/devtools/device/devtools_android_bridge.h
+++ b/chrome/browser/devtools/device/devtools_android_bridge.h
@@ -41,9 +41,6 @@ class DevToolsAndroidBridge
DevToolsAndroidBridge,
content::BrowserThread::DeleteOnUIThread> {
public:
- typedef base::Callback<void(int result,
- const std::string& response)> Callback;
-
class Wrapper : public KeyedService {
public:
explicit Wrapper(content::BrowserContext* context);
@@ -81,73 +78,36 @@ class DevToolsAndroidBridge
virtual std::string GetFrontendURL() = 0;
};
- typedef base::Callback<void(RemotePage*)> RemotePageCallback;
typedef base::Callback<void(int, const std::string&)> JsonRequestCallback;
- typedef AndroidDeviceManager::Device Device;
- typedef AndroidDeviceManager::AndroidWebSocket AndroidWebSocket;
class RemoteBrowser : public base::RefCounted<RemoteBrowser> {
public:
- RemoteBrowser(scoped_refptr<Device> device,
+ RemoteBrowser(const std::string& serial,
dgozman 2014/09/25 14:23:17 Can we make constructor private?
vkuzkokov 2014/09/25 16:48:47 Done.
const AndroidDeviceManager::BrowserInfo& browser_info);
- std::string serial() { return device_->serial(); }
- std::string socket() { return socket_; }
+ const std::string& serial() { return serial_; }
+ const std::string& socket() { return socket_; }
- std::string display_name() { return display_name_; }
+ const std::string& display_name() { return display_name_; }
void set_display_name(const std::string& name) { display_name_ = name; }
- std::string version() { return version_; }
+ const std::string& version() { return version_; }
void set_version(const std::string& version) { version_ = version; }
- bool IsChrome() const;
- bool IsWebView() const;
+ bool IsChrome();
+ bool IsWebView();
typedef std::vector<int> ParsedVersion;
- ParsedVersion GetParsedVersion() const;
-
- std::vector<RemotePage*> CreatePages();
- void SetPageDescriptors(const base::ListValue&);
-
- void SendJsonRequest(const std::string& request,
- const JsonRequestCallback& callback);
-
- void SendProtocolCommand(const std::string& debug_url,
- const std::string& method,
- base::DictionaryValue* params,
- const base::Closure callback);
-
- void Open(const std::string& url,
- const RemotePageCallback& callback);
+ ParsedVersion GetParsedVersion();
- scoped_refptr<content::DevToolsAgentHost> GetAgentHost();
-
- AndroidWebSocket* CreateWebSocket(
- const std::string& url,
- DevToolsAndroidBridge::AndroidWebSocket::Delegate* delegate);
+ const base::ListValue& page_descriptors();
+ void set_page_descriptors(const base::ListValue&);
private:
friend class base::RefCounted<RemoteBrowser>;
virtual ~RemoteBrowser();
- void InnerOpen(const std::string& url,
- const JsonRequestCallback& callback);
-
- void PageCreatedOnUIThread(
- const JsonRequestCallback& callback,
- const std::string& url, int result, const std::string& response);
-
- void NavigatePageOnUIThread(const JsonRequestCallback& callback,
- int result,
- const std::string& response,
- const std::string& url);
-
- void RespondToOpenOnUIThread(
- const DevToolsAndroidBridge::RemotePageCallback& callback,
- int result,
- const std::string& response);
-
- scoped_refptr<Device> device_;
+ std::string serial_;
const std::string socket_;
std::string display_name_;
const AndroidDeviceManager::BrowserInfo::Type type_;
@@ -161,23 +121,20 @@ class DevToolsAndroidBridge
class RemoteDevice : public base::RefCounted<RemoteDevice> {
public:
- RemoteDevice(scoped_refptr<Device> device,
+ RemoteDevice(const std::string& serial,
dgozman 2014/09/25 14:23:17 ditto
vkuzkokov 2014/09/25 16:48:47 Done.
const AndroidDeviceManager::DeviceInfo& device_info);
- std::string serial() { return device_->serial(); }
+ std::string serial() { return serial_; }
std::string model() { return model_; }
bool is_connected() { return connected_; }
RemoteBrowsers& browsers() { return browsers_; }
gfx::Size screen_size() { return screen_size_; }
- void OpenSocket(const std::string& socket_name,
- const AndroidDeviceManager::SocketCallback& callback);
-
private:
friend class base::RefCounted<RemoteDevice>;
virtual ~RemoteDevice();
- scoped_refptr<Device> device_;
+ std::string serial_;
std::string model_;
bool connected_;
RemoteBrowsers browsers_;
@@ -238,19 +195,38 @@ class DevToolsAndroidBridge
static bool HasDevToolsWindow(const std::string& agent_id);
+ std::vector<RemotePage*> CreatePages(scoped_refptr<RemoteBrowser> browser);
dgozman 2014/09/25 14:23:17 Why this is not a part of RemoteBrowser?
vkuzkokov 2014/09/25 16:48:47 RemotePage requires reference to device which is n
+
+ typedef base::Callback<void(RemotePage*)> RemotePageCallback;
+ void Open(scoped_refptr<RemoteBrowser> browser,
+ const std::string& url,
+ const RemotePageCallback& callback);
+
+ scoped_refptr<content::DevToolsAgentHost> GetAgentHost(
dgozman 2014/09/25 14:23:17 GetBrowserAgentHost? Why this is not a part of Rem
vkuzkokov 2014/09/25 16:48:47 GetAgentHost requires reference to device which is
+ scoped_refptr<RemoteBrowser> browser);
+
private:
friend struct content::BrowserThread::DeleteOnThread<
content::BrowserThread::UI>;
friend class base::DeleteHelper<DevToolsAndroidBridge>;
+ friend class AgentHostDelegate;
dgozman 2014/09/25 14:23:17 Let's not make AgentHostDelegate and RemotePageTar
vkuzkokov 2014/09/25 16:48:47 Done.
+ friend class PortForwardingController;
+ friend class RemotePageTarget;
+
virtual ~DevToolsAndroidBridge();
void StartDeviceListPolling();
void StopDeviceListPolling();
bool NeedsDeviceListPolling();
- void RequestDeviceList(
- const base::Callback<void(const RemoteDevices&)>& callback);
- void ReceivedDeviceList(const RemoteDevices& devices);
+
+ typedef base::Callback<void(const AndroidDeviceManager::Devices&,
+ const RemoteDevices&)> DeviceListCallback;
+ void RequestDeviceList(const DeviceListCallback& callback);
+
+ void ReceivedDeviceList(const AndroidDeviceManager::Devices& devices,
+ const RemoteDevices& remote_devices);
+
void StartDeviceCountPolling();
void StopDeviceCountPolling();
void RequestDeviceCount(const base::Callback<void(int)>& callback);
@@ -260,13 +236,49 @@ class DevToolsAndroidBridge
void CreateDeviceProviders();
+ void SendJsonRequest(scoped_refptr<RemoteBrowser> browser,
+ const std::string& url,
+ const JsonRequestCallback& callback);
+
+ void SendProtocolCommand(scoped_refptr<RemoteBrowser> browser,
+ const std::string& debug_url,
+ const std::string& method,
+ base::DictionaryValue* params,
+ const base::Closure callback);
+
+ AndroidDeviceManager::AndroidWebSocket* CreateWebSocket(
+ scoped_refptr<RemoteBrowser> browser,
+ const std::string& url,
+ AndroidDeviceManager::AndroidWebSocket::Delegate* delegate);
+
+ void PageCreatedOnUIThread(scoped_refptr<RemoteBrowser> browser,
+ const RemotePageCallback& callback,
+ const std::string& url,
+ int result,
+ const std::string& response);
+
+ void NavigatePageOnUIThread(scoped_refptr<RemoteBrowser> browser,
+ const RemotePageCallback& callback,
+ int result,
+ const std::string& response,
+ const std::string& url);
+
+ void RespondToOpenOnUIThread(scoped_refptr<RemoteBrowser> browser,
+ const RemotePageCallback& callback,
+ int result,
+ const std::string& response);
+
Profile* profile_;
scoped_refptr<AndroidDeviceManager> device_manager_;
- RemoteDevices devices_;
+
+ typedef std::map<std::string, scoped_refptr<AndroidDeviceManager::Device>>
+ DeviceMap;
+ DeviceMap device_map_;
typedef std::vector<DeviceListListener*> DeviceListListeners;
DeviceListListeners device_list_listeners_;
- base::CancelableCallback<void(const RemoteDevices&)> device_list_callback_;
+ base::CancelableCallback<void(const AndroidDeviceManager::Devices&,
+ const RemoteDevices&)> device_list_callback_;
typedef std::vector<DeviceCountListener*> DeviceCountListeners;
DeviceCountListeners device_count_listeners_;

Powered by Google App Engine
This is Rietveld 408576698