| 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_ANDROID_DEVICE_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVICE_ANDROID_DEVICE_MANAGER_H_ |
| 6 #define CHROME_BROWSER_DEVTOOLS_DEVICE_ANDROID_DEVICE_MANAGER_H_ | 6 #define CHROME_BROWSER_DEVTOOLS_DEVICE_ANDROID_DEVICE_MANAGER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/threading/non_thread_safe.h" | 11 #include "base/threading/non_thread_safe.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 #include "ui/gfx/size.h" |
| 14 | 15 |
| 15 namespace net { | 16 namespace net { |
| 16 class StreamSocket; | 17 class StreamSocket; |
| 17 } | 18 } |
| 18 | 19 |
| 19 class AndroidDeviceManager | 20 class AndroidDeviceManager |
| 20 : public base::RefCountedThreadSafe<AndroidDeviceManager>, | 21 : public base::RefCountedThreadSafe<AndroidDeviceManager>, |
| 21 public base::NonThreadSafe { | 22 public base::NonThreadSafe { |
| 22 public: | 23 public: |
| 23 typedef base::Callback<void(int, const std::string&)> CommandCallback; | 24 typedef base::Callback<void(int, const std::string&)> CommandCallback; |
| 24 typedef base::Callback<void(int result, net::StreamSocket*)> SocketCallback; | 25 typedef base::Callback<void(int result, net::StreamSocket*)> SocketCallback; |
| 25 | 26 |
| 27 struct BrowserInfo { |
| 28 BrowserInfo(); |
| 29 |
| 30 enum Type { |
| 31 kTypeChrome, |
| 32 kTypeWebView, |
| 33 kTypeOther |
| 34 }; |
| 35 |
| 36 std::string socket_name; |
| 37 std::string display_name; |
| 38 Type type; |
| 39 }; |
| 40 |
| 41 struct DeviceInfo { |
| 42 DeviceInfo(); |
| 43 ~DeviceInfo(); |
| 44 |
| 45 std::string model; |
| 46 gfx::Size screen_size; |
| 47 std::vector<BrowserInfo> browser_info; |
| 48 }; |
| 49 |
| 50 typedef base::Callback<void(const DeviceInfo&)> DeviceInfoCallback; |
| 51 |
| 26 class Device : public base::RefCounted<Device>, | 52 class Device : public base::RefCounted<Device>, |
| 27 public base::NonThreadSafe { | 53 public base::NonThreadSafe { |
| 28 protected: | 54 protected: |
| 29 friend class AndroidDeviceManager; | 55 friend class AndroidDeviceManager; |
| 30 | 56 |
| 31 typedef AndroidDeviceManager::CommandCallback CommandCallback; | 57 typedef AndroidDeviceManager::CommandCallback CommandCallback; |
| 32 typedef AndroidDeviceManager::SocketCallback SocketCallback; | 58 typedef AndroidDeviceManager::SocketCallback SocketCallback; |
| 59 typedef AndroidDeviceManager::DeviceInfoCallback DeviceInfoCallback; |
| 33 | 60 |
| 34 Device(const std::string& serial, bool is_connected); | 61 Device(const std::string& serial, bool is_connected); |
| 35 | 62 |
| 36 virtual void RunCommand(const std::string& command, | 63 virtual void QueryDeviceInfo(const DeviceInfoCallback& callback) = 0; |
| 37 const CommandCallback& callback) = 0; | 64 |
| 38 virtual void OpenSocket(const std::string& socket_name, | 65 virtual void OpenSocket(const std::string& socket_name, |
| 39 const SocketCallback& callback) = 0; | 66 const SocketCallback& callback) = 0; |
| 40 | 67 |
| 41 std::string serial() { return serial_; } | 68 std::string serial() { return serial_; } |
| 42 bool is_connected() { return is_connected_; } | 69 bool is_connected() { return is_connected_; } |
| 43 | 70 |
| 44 friend class base::RefCounted<Device>; | 71 friend class base::RefCounted<Device>; |
| 45 virtual ~Device(); | 72 virtual ~Device(); |
| 46 | 73 |
| 47 private: | 74 private: |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 typedef base::Callback<void (const std::vector<std::string>&)> | 107 typedef base::Callback<void (const std::vector<std::string>&)> |
| 81 QueryDevicesCallback; | 108 QueryDevicesCallback; |
| 82 | 109 |
| 83 void QueryDevices(const DeviceProviders& providers, | 110 void QueryDevices(const DeviceProviders& providers, |
| 84 const QueryDevicesCallback& callback); | 111 const QueryDevicesCallback& callback); |
| 85 | 112 |
| 86 void Stop(); | 113 void Stop(); |
| 87 | 114 |
| 88 bool IsConnected(const std::string& serial); | 115 bool IsConnected(const std::string& serial); |
| 89 | 116 |
| 90 void RunCommand(const std::string& serial, | 117 void QueryDeviceInfo(const std::string& serial, |
| 91 const std::string& command, | 118 const DeviceInfoCallback& callback); |
| 92 const CommandCallback& callback); | |
| 93 | 119 |
| 94 void OpenSocket(const std::string& serial, | 120 void OpenSocket(const std::string& serial, |
| 95 const std::string& socket_name, | 121 const std::string& socket_name, |
| 96 const SocketCallback& callback); | 122 const SocketCallback& callback); |
| 97 | 123 |
| 98 void HttpQuery(const std::string& serial, | 124 void HttpQuery(const std::string& serial, |
| 99 const std::string& socket_name, | 125 const std::string& socket_name, |
| 100 const std::string& request, | 126 const std::string& request, |
| 101 const CommandCallback& callback); | 127 const CommandCallback& callback); |
| 102 | 128 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 120 | 146 |
| 121 Device* FindDevice(const std::string& serial); | 147 Device* FindDevice(const std::string& serial); |
| 122 | 148 |
| 123 typedef std::map<std::string, scoped_refptr<Device> > DeviceMap; | 149 typedef std::map<std::string, scoped_refptr<Device> > DeviceMap; |
| 124 DeviceMap devices_; | 150 DeviceMap devices_; |
| 125 | 151 |
| 126 bool stopped_; | 152 bool stopped_; |
| 127 }; | 153 }; |
| 128 | 154 |
| 129 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_ANDROID_DEVICE_MANAGER_H_ | 155 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_ANDROID_DEVICE_MANAGER_H_ |
| OLD | NEW |