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

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

Issue 18137007: DevTools: add about:flag for ADB-less remote debugging. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For landing Created 7 years, 5 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/android_usb_device.cc ('k') | chrome/browser/devtools/devtools_adb_bridge.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/devtools/devtools_adb_bridge.h
diff --git a/chrome/browser/devtools/devtools_adb_bridge.h b/chrome/browser/devtools/devtools_adb_bridge.h
index 4f12770e8e3fc62967114046cf57f1ad2258b6c7..775bbec5f5bbe3f62b81e5aebd78d26b3931542e 100644
--- a/chrome/browser/devtools/devtools_adb_bridge.h
+++ b/chrome/browser/devtools/devtools_adb_bridge.h
@@ -11,15 +11,26 @@
#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
-#include "base/memory/weak_ptr.h"
+#include "components/browser_context_keyed_service/browser_context_keyed_service.h"
+#include "components/browser_context_keyed_service/browser_context_keyed_service_factory.h"
#include "net/socket/tcp_client_socket.h"
+template<typename T> struct DefaultSingletonTraits;
+
namespace base {
class MessageLoop;
class DictionaryValue;
class Thread;
}
+namespace content {
+class BrowserContext;
+}
+
+namespace crypto {
+class RSAPrivateKey;
+}
+
class Profile;
// The format used for constructing DevTools server socket names.
@@ -28,11 +39,43 @@ extern const char kDevToolsChannelNameFormat[];
typedef base::Callback<void(int, const std::string&)> CommandCallback;
typedef base::Callback<void(int result, net::StreamSocket*)> SocketCallback;
-class DevToolsAdbBridge {
+class DevToolsAdbBridge :
+ public base::RefCountedThreadSafe<DevToolsAdbBridge> {
public:
typedef base::Callback<void(int result,
const std::string& response)> Callback;
+ class Wrapper : public BrowserContextKeyedService {
+ public:
+ Wrapper(Profile* profile);
+ virtual ~Wrapper();
+
+ DevToolsAdbBridge* Get();
+ private:
+ scoped_refptr<DevToolsAdbBridge> bridge_;
+ };
+
+ class Factory : public BrowserContextKeyedServiceFactory {
+ public:
+ // Returns singleton instance of DevToolsAdbBridge.
+ static Factory* GetInstance();
+
+ // Returns DevToolsAdbBridge associated with |profile|.
+ static DevToolsAdbBridge* GetForProfile(Profile* profile);
+
+ private:
+ friend struct DefaultSingletonTraits<Factory>;
+ friend class DevToolsAdbBridge;
+
+ Factory();
+ virtual ~Factory();
+
+ // BrowserContextKeyedServiceFactory overrides:
+ virtual BrowserContextKeyedService* BuildServiceInstanceFor(
+ content::BrowserContext* context) const OVERRIDE;
+ DISALLOW_COPY_AND_ASSIGN(Factory);
+ };
+
class RemotePage : public base::RefCounted<RemotePage> {
public:
RemotePage(const std::string& serial,
@@ -113,9 +156,12 @@ class DevToolsAdbBridge {
DISALLOW_COPY_AND_ASSIGN(AndroidDevice);
};
+ typedef std::vector<scoped_refptr<AndroidDevice> > AndroidDevices;
+ typedef base::Callback<void(const AndroidDevices&)> AndroidDevicesCallback;
+
explicit DevToolsAdbBridge(Profile* profile);
- ~DevToolsAdbBridge();
+ void EnumerateDevices(const AndroidDevicesCallback& callback);
void Query(const std::string query, const Callback& callback);
void Pages(const PagesCallback& callback);
void Attach(const std::string& serial,
@@ -124,9 +170,12 @@ class DevToolsAdbBridge {
const std::string& frontend_url);
private:
+ friend class base::RefCountedThreadSafe<DevToolsAdbBridge>;
friend class AdbAttachCommand;
friend class AgentHostDelegate;
+ virtual ~DevToolsAdbBridge();
+
class RefCountedAdbThread : public base::RefCounted<RefCountedAdbThread> {
public:
static scoped_refptr<RefCountedAdbThread> GetInstance();
@@ -142,10 +191,14 @@ class DevToolsAdbBridge {
base::Thread* thread_;
};
+ void ReceivedDevices(const AndroidDevicesCallback& callback,
+ int result,
+ const std::string& response);
+
Profile* profile_;
scoped_refptr<RefCountedAdbThread> adb_thread_;
- base::WeakPtrFactory<DevToolsAdbBridge> weak_factory_;
bool has_message_loop_;
+ scoped_ptr<crypto::RSAPrivateKey> rsa_key_;
DISALLOW_COPY_AND_ASSIGN(DevToolsAdbBridge);
};
« no previous file with comments | « chrome/browser/devtools/adb/android_usb_device.cc ('k') | chrome/browser/devtools/devtools_adb_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698