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

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

Issue 287643002: DevTools: Partially redesigned DevToolsAndroidBridge and AndroidDeviceManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed unused include Created 6 years, 7 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 6a0f781e8138db2e0c4df7204a4de1a33537ee0f..2e713d9094bc8ad4ceb9eae736b2b276270a5354 100644
--- a/chrome/browser/devtools/device/devtools_android_bridge.h
+++ b/chrome/browser/devtools/device/devtools_android_bridge.h
@@ -72,33 +72,6 @@ class DevToolsAndroidBridge
DISALLOW_COPY_AND_ASSIGN(Factory);
};
- class AndroidWebSocket : public base::RefCountedThreadSafe<AndroidWebSocket> {
- public:
- class Delegate {
- public:
- virtual void OnSocketOpened() = 0;
- virtual void OnFrameRead(const std::string& message) = 0;
- virtual void OnSocketClosed(bool closed_by_device) = 0;
-
- protected:
- virtual ~Delegate() {}
- };
-
- AndroidWebSocket() {}
-
- virtual void Connect() = 0;
- virtual void Disconnect() = 0;
- virtual void SendFrame(const std::string& message) = 0;
-
- protected:
- virtual ~AndroidWebSocket() {}
-
- private:
- friend class base::RefCountedThreadSafe<AndroidWebSocket>;
-
- DISALLOW_COPY_AND_ASSIGN(AndroidWebSocket);
- };
-
class RemotePage {
public:
virtual ~RemotePage() {}
@@ -107,15 +80,16 @@ class DevToolsAndroidBridge
};
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<DevToolsAndroidBridge> android_bridge,
- const std::string& serial,
- const AndroidDeviceManager::BrowserInfo& browser_info);
+ RemoteBrowser(scoped_refptr<Device> device,
+ const AndroidDeviceManager::BrowserInfo& browser_info);
- std::string serial() { return serial_; }
+ std::string serial() { return device_->serial(); }
std::string socket() { return socket_; }
std::string display_name() { return display_name_; }
@@ -133,9 +107,9 @@ class DevToolsAndroidBridge
std::vector<RemotePage*> CreatePages();
void SetPageDescriptors(const base::ListValue&);
- typedef base::Callback<void(int, const std::string&)> JsonRequestCallback;
void SendJsonRequest(const std::string& request,
const JsonRequestCallback& callback);
+
void SendProtocolCommand(const std::string& debug_url,
const std::string& method,
base::DictionaryValue* params,
@@ -171,8 +145,7 @@ class DevToolsAndroidBridge
int result,
const std::string& response);
- scoped_refptr<DevToolsAndroidBridge> android_bridge_;
- const std::string serial_;
+ scoped_refptr<Device> device_;
const std::string socket_;
std::string display_name_;
const AndroidDeviceManager::BrowserInfo::Type type_;
@@ -186,12 +159,10 @@ class DevToolsAndroidBridge
class RemoteDevice : public base::RefCounted<RemoteDevice> {
public:
- RemoteDevice(scoped_refptr<DevToolsAndroidBridge> android_bridge,
- const std::string& serial,
- const AndroidDeviceManager::DeviceInfo& device_info,
- bool connected);
+ RemoteDevice(scoped_refptr<Device> device,
+ const AndroidDeviceManager::DeviceInfo& device_info);
- std::string serial() { return serial_; }
+ std::string serial() { return device_->serial(); }
std::string model() { return model_; }
bool is_connected() { return connected_; }
RemoteBrowsers& browsers() { return browsers_; }
@@ -204,8 +175,7 @@ class DevToolsAndroidBridge
friend class base::RefCounted<RemoteDevice>;
virtual ~RemoteDevice();
- scoped_refptr<DevToolsAndroidBridge> android_bridge_;
- std::string serial_;
+ scoped_refptr<Device> device_;
std::string model_;
bool connected_;
RemoteBrowsers browsers_;
@@ -252,7 +222,7 @@ class DevToolsAndroidBridge
class HandlerThread : public base::RefCountedThreadSafe<HandlerThread> {
public:
static scoped_refptr<HandlerThread> GetInstance();
- base::MessageLoop* message_loop();
+ scoped_refptr<base::MessageLoopProxy> message_loop();
private:
friend class base::RefCountedThreadSafe<HandlerThread>;
@@ -266,7 +236,7 @@ class DevToolsAndroidBridge
virtual ~DevToolsAndroidBridge();
- base::MessageLoop* device_message_loop() {
+ scoped_refptr<base::MessageLoopProxy> device_message_loop() {
return handler_thread_->message_loop();
}
@@ -276,8 +246,7 @@ class DevToolsAndroidBridge
void CreatedDeviceManager(scoped_refptr<AndroidDeviceManager> device_manager);
void RequestDeviceList();
- void ReceivedDeviceList(RemoteDevices* devices);
-
+ void ReceivedDeviceList(scoped_ptr<RemoteDevices> devices);
void RequestDeviceCount();
void ReceivedDeviceCount(int count);
@@ -286,6 +255,7 @@ class DevToolsAndroidBridge
Profile* profile_;
scoped_refptr<HandlerThread> handler_thread_;
scoped_refptr<AndroidDeviceManager> device_manager_;
+ RemoteDevices devices_;
typedef std::vector<DeviceListListener*> DeviceListListeners;
DeviceListListeners device_list_listeners_;

Powered by Google App Engine
This is Rietveld 408576698