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

Unified Diff: chrome/browser/devtools/android_device.h

Issue 26568004: Introduced AndroidDeviceProvider to simplify testing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed unused constants, thus fixed compile errors. Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/devtools/adb_web_socket.cc ('k') | chrome/browser/devtools/android_device.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/devtools/android_device.h
diff --git a/chrome/browser/devtools/android_device.h b/chrome/browser/devtools/android_device.h
new file mode 100644
index 0000000000000000000000000000000000000000..8631da4802a47e0bcfe0391f72b6346d34baf8ad
--- /dev/null
+++ b/chrome/browser/devtools/android_device.h
@@ -0,0 +1,94 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_DEVTOOLS_ANDROID_DEVICE_H_
+#define CHROME_BROWSER_DEVTOOLS_ANDROID_DEVICE_H_
+
+#include <vector>
+
+#include "base/memory/ref_counted.h"
+#include "chrome/browser/devtools/adb/android_usb_device.h"
+#include "chrome/browser/devtools/refcounted_adb_thread.h"
+#include "chrome/browser/profiles/profile.h"
+#include "content/public/browser/browser_thread.h"
+#include "crypto/rsa_private_key.h"
+#include "net/socket/stream_socket.h"
+
+class AndroidDevice : public base::RefCounted<AndroidDevice> {
+ public:
+ typedef base::Callback<void(int, const std::string&)> CommandCallback;
+ typedef base::Callback<void(int result, net::StreamSocket*)> SocketCallback;
+
+ AndroidDevice(const std::string& serial, bool is_connected);
+
+ virtual void RunCommand(const std::string& command,
+ const CommandCallback& callback) = 0;
+ virtual void OpenSocket(const std::string& socket_name,
+ const SocketCallback& callback) = 0;
+ virtual void HttpQuery(const std::string& la_name,
+ const std::string& request,
+ const CommandCallback& callback);
+ void HttpUpgrade(const std::string& la_name,
+ const std::string& request,
+ const SocketCallback& callback);
+
+ std::string serial() { return serial_; }
+ bool is_connected() { return is_connected_; }
+
+ std::string model() { return model_; }
+ void set_model(const std::string& model) { model_ = model; }
+
+ protected:
+ friend class base::RefCounted<AndroidDevice>;
+ virtual ~AndroidDevice();
+
+ private:
+ void OnHttpSocketOpened(const std::string& request,
+ const CommandCallback& callback,
+ int result,
+ net::StreamSocket* socket);
+ void OnHttpSocketOpened2(const std::string& request,
+ const SocketCallback& callback,
+ int result,
+ net::StreamSocket* socket);
+
+ std::string serial_;
+ bool is_connected_;
+ std::string model_;
+
+ DISALLOW_COPY_AND_ASSIGN(AndroidDevice);
+};
+
+
+class AndroidDeviceProvider
+ : public base::RefCountedThreadSafe<
+ AndroidDeviceProvider,
+ content::BrowserThread::DeleteOnUIThread> {
+ public:
+ typedef std::vector<scoped_refptr<AndroidDevice> > AndroidDevices;
+ typedef base::Callback<void(const AndroidDevices&)> QueryDevicesCallback;
+
+ virtual void QueryDevices(const QueryDevicesCallback& callback) = 0;
+
+ static void CountDevices(bool discover_usb_devices,
+ const base::Callback<void(int)>& callback);
+
+ static scoped_refptr<AndroidDeviceProvider> GetAdbDeviceProvider();
+ static scoped_refptr<AndroidDeviceProvider>
+ GetUsbDeviceProvider(Profile* profile);
+
+ protected:
+ friend struct
+ content::BrowserThread::DeleteOnThread<content::BrowserThread::UI>;
+ friend class base::DeleteHelper<AndroidDeviceProvider>;
+
+ AndroidDeviceProvider();
+ virtual ~AndroidDeviceProvider();
+ static void RunCallbackOnUIThread(const QueryDevicesCallback& callback,
+ const AndroidDevices& result);
+
+ scoped_refptr<RefCountedAdbThread> adb_thread_;
+};
+
+#endif // CHROME_BROWSER_DEVTOOLS_ANDROID_DEVICE_H_
« no previous file with comments | « chrome/browser/devtools/adb_web_socket.cc ('k') | chrome/browser/devtools/android_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698