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

Side by Side Diff: chrome/browser/devtools/devtools_adb_bridge.h

Issue 12559008: DevTools: add backend for discovering connected ADB devices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Same with Fetch for fetching discovery pages. Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_ADB_BRIDGE_H_
6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_ADB_BRIDGE_H_
7
8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "net/url_request/url_request.h"
13
14 namespace base {
15 class Thread;
16 }
17
18 class DevToolsAdbBridge
19 : public base::RefCountedThreadSafe<DevToolsAdbBridge>,
20 public net::URLRequest::Delegate {
21 public:
22 typedef base::Callback<void(const std::string& error,
23 const std::string& data)> Callback;
24
25 static DevToolsAdbBridge* Start(Profile* profile);
26 void Query(const std::string query, const Callback& callback);
27 void Fetch(const std::string url, const Callback& callback);
28 void Stop();
29
30 private:
31 friend class base::RefCountedThreadSafe<DevToolsAdbBridge>;
32 struct RequestInfo;
33
34 explicit DevToolsAdbBridge(Profile* profile);
35 virtual ~DevToolsAdbBridge();
36
37 void StartHandlerOnFileThread();
38 void StopHandlerOnFileThread();
39
40 void ResetHandlerAndReleaseOnUIThread();
41 void ResetHandlerOnUIThread();
42
43 void InitOnHandlerThread();
44 void QueryOnHandlerThread(const std::string query, const Callback& callback);
45 void FetchOnHandlerThread(const std::string query, const Callback& callback);
46 void QueryResponseOnHandlerThread(const Callback& callback,
47 const std::string& error,
48 const std::string& response);
49 void TeardownOnHandlerThread();
50
51 void RespondOnUIThread(const Callback& callback,
52 const std::string& error,
53 const std::string& response);
54
55 // net::URLRequest::Delegate implementation.
56 virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE;
57 virtual void OnReadCompleted(net::URLRequest* request,
58 int bytes_read) OVERRIDE;
59
60 // The thread used by the devtools to run client socket.
61 scoped_ptr<base::Thread> thread_;
62
63 std::map<net::URLRequest*, RequestInfo> request_info_;
64 Profile* profile_;
65
66 DISALLOW_COPY_AND_ASSIGN(DevToolsAdbBridge);
67 };
68
69 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_ADB_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698