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

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

Issue 22685003: Visualize status of port forwarding sockets in chrome:inspect Devices tab (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 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_TETHERING_ADB_FILTER_H_ 5 #ifndef CHROME_BROWSER_DEVTOOLS_TETHERING_ADB_FILTER_H_
6 #define CHROME_BROWSER_DEVTOOLS_TETHERING_ADB_FILTER_H_ 6 #define CHROME_BROWSER_DEVTOOLS_TETHERING_ADB_FILTER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/prefs/pref_change_registrar.h" 13 #include "base/prefs/pref_change_registrar.h"
14 #include "chrome/browser/devtools/adb_web_socket.h" 14 #include "chrome/browser/devtools/adb_web_socket.h"
15 #include "chrome/browser/devtools/devtools_adb_bridge.h" 15 #include "chrome/browser/devtools/devtools_adb_bridge.h"
16 16
17 class PrefService; 17 class PrefService;
18 18
19 namespace base { 19 namespace base {
20 class MessageLoop; 20 class MessageLoop;
21 } 21 }
22 22
23 class TetheringAdbFilter { 23 class TetheringAdbFilter {
24 public: 24 public:
25 typedef DevToolsAdbBridge::RemoteDevice::PortStatus PortStatus;
26 typedef DevToolsAdbBridge::RemoteDevice::PortStatusMap PortStatusMap;
27
25 TetheringAdbFilter(int adb_port, 28 TetheringAdbFilter(int adb_port,
26 const std::string& serial, 29 const std::string& serial,
27 base::MessageLoop* adb_message_loop, 30 base::MessageLoop* adb_message_loop,
28 PrefService* pref_service, 31 PrefService* pref_service,
29 scoped_refptr<AdbWebSocket> web_socket); 32 scoped_refptr<AdbWebSocket> web_socket);
30 ~TetheringAdbFilter(); 33 ~TetheringAdbFilter();
31 34
35 const PortStatusMap& port_status() { return port_status_; }
36
32 bool ProcessIncomingMessage(const std::string& message); 37 bool ProcessIncomingMessage(const std::string& message);
33 38
34 private: 39 private:
35 typedef std::map<int, std::string> ForwardingMap; 40 typedef std::map<int, std::string> ForwardingMap;
36 41
42 typedef base::Callback<void(PortStatus)> CommandCallback;
43 typedef std::map<int, CommandCallback> CommandCallbackMap;
44
37 void OnPrefsChange(); 45 void OnPrefsChange();
38 46
39 void ChangeForwardingMap(ForwardingMap map); 47 void ChangeForwardingMap(ForwardingMap map);
40 48
41 void SerializeChanges(const std::string& method, 49 void SerializeChanges(const std::string& method,
42 const ForwardingMap& old_map, 50 const ForwardingMap& old_map,
43 const ForwardingMap& new_map); 51 const ForwardingMap& new_map);
44 52
45 void SendCommand(const std::string& method, int port); 53 void SendCommand(const std::string& method, int port);
54 bool ProcessResponse(const std::string& json);
55
56 void ProcessBindResponseOnUIThread(int port, PortStatus status);
57 void ProcessUnbindResponseOnUIThread(int port, PortStatus status);
58
59 void UpdateSocketCount(int port, int increment);
60 void UpdateSocketCountOnUIThread(int port, int increment);
46 61
47 int adb_port_; 62 int adb_port_;
48 std::string serial_; 63 std::string serial_;
49 base::MessageLoop* adb_message_loop_; 64 base::MessageLoop* adb_message_loop_;
50 PrefChangeRegistrar pref_change_registrar_; 65 PrefChangeRegistrar pref_change_registrar_;
51 scoped_refptr<AdbWebSocket> web_socket_; 66 scoped_refptr<AdbWebSocket> web_socket_;
52 int command_id_; 67 int command_id_;
53 ForwardingMap forwarding_map_; 68 ForwardingMap forwarding_map_;
69 CommandCallbackMap pending_responses_;
70 PortStatusMap port_status_;
54 base::WeakPtrFactory<TetheringAdbFilter> weak_factory_; 71 base::WeakPtrFactory<TetheringAdbFilter> weak_factory_;
55 72
56 DISALLOW_COPY_AND_ASSIGN(TetheringAdbFilter); 73 DISALLOW_COPY_AND_ASSIGN(TetheringAdbFilter);
57 }; 74 };
58 75
59 class PortForwardingController { 76 class PortForwardingController {
60 public: 77 public:
61 PortForwardingController( 78 PortForwardingController(
62 base::MessageLoop* adb_message_loop, 79 base::MessageLoop* adb_message_loop,
63 PrefService* pref_service); 80 PrefService* pref_service);
64 81
65 virtual ~PortForwardingController(); 82 virtual ~PortForwardingController();
66 83
67 void UpdateDeviceList(const DevToolsAdbBridge::RemoteDevices& devices); 84 void UpdateDeviceList(DevToolsAdbBridge::RemoteDevices& devices);
pfeldman 2013/08/08 16:43:22 Why is that now mutable?
Vladislav Kaznacheev 2013/08/09 08:24:58 Oops. The method calls DevToolsAdbBridge::RemoteDe
68 85
69 private: 86 private:
70 class Connection; 87 class Connection;
71 typedef std::map<std::string, Connection*> Registry; 88 typedef std::map<std::string, Connection*> Registry;
72 89
73 base::MessageLoop* adb_message_loop_; 90 base::MessageLoop* adb_message_loop_;
74 PrefService* pref_service_; 91 PrefService* pref_service_;
75 Registry registry_; 92 Registry registry_;
76 }; 93 };
77 94
78 #endif // CHROME_BROWSER_DEVTOOLS_TETHERING_ADB_FILTER_H_ 95 #endif // CHROME_BROWSER_DEVTOOLS_TETHERING_ADB_FILTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698