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

Side by Side Diff: chrome/browser/devtools/device/android_device_manager.h

Issue 449883002: DevTools: Removed refcounting from AndroidWebSocket (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: PortForwardingController::Connection lifetime. Rebased Created 6 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
OLDNEW
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"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 ~DeviceInfo(); 46 ~DeviceInfo();
47 47
48 std::string model; 48 std::string model;
49 bool connected; 49 bool connected;
50 gfx::Size screen_size; 50 gfx::Size screen_size;
51 std::vector<BrowserInfo> browser_info; 51 std::vector<BrowserInfo> browser_info;
52 }; 52 };
53 53
54 typedef base::Callback<void(const DeviceInfo&)> DeviceInfoCallback; 54 typedef base::Callback<void(const DeviceInfo&)> DeviceInfoCallback;
55 55
56 class AndroidWebSocket : public base::RefCountedThreadSafe<AndroidWebSocket> { 56 class AndroidWebSocket {
57 public: 57 public:
58 class Delegate { 58 class Delegate {
59 public: 59 public:
60 virtual void OnSocketOpened() = 0; 60 virtual void OnSocketOpened() = 0;
61 virtual void OnFrameRead(const std::string& message) = 0; 61 virtual void OnFrameRead(const std::string& message) = 0;
62 virtual void OnSocketClosed(bool closed_by_device) = 0; 62 virtual void OnSocketClosed() = 0;
63 63
64 protected: 64 protected:
65 virtual ~Delegate() {} 65 virtual ~Delegate() {}
66 }; 66 };
67 67
68 AndroidWebSocket() {} 68 AndroidWebSocket() {}
69
70 virtual void Connect() = 0;
71 virtual void Disconnect() = 0;
72 virtual void SendFrame(const std::string& message) = 0;
73 virtual void ClearDelegate() = 0;
74
75 protected:
76 virtual ~AndroidWebSocket() {} 69 virtual ~AndroidWebSocket() {}
77 70
78 private: 71 virtual void SendFrame(const std::string& message) = 0;
79 friend class base::RefCountedThreadSafe<AndroidWebSocket>;
80
81 DISALLOW_COPY_AND_ASSIGN(AndroidWebSocket);
dgozman 2014/08/08 14:17:28 Don't remove this.
vkuzkokov 2014/08/08 15:59:43 Class with pure virtual methods can't be copied or
82 }; 72 };
83 73
84 class DeviceProvider; 74 class DeviceProvider;
85 75
86 class Device : public base::RefCountedThreadSafe<Device>, 76 class Device : public base::RefCountedThreadSafe<Device>,
87 public base::NonThreadSafe { 77 public base::NonThreadSafe {
88 public: 78 public:
89 typedef AndroidDeviceManager::DeviceInfoCallback DeviceInfoCallback; 79 typedef AndroidDeviceManager::DeviceInfoCallback DeviceInfoCallback;
90 typedef AndroidDeviceManager::CommandCallback CommandCallback; 80 typedef AndroidDeviceManager::CommandCallback CommandCallback;
91 typedef AndroidDeviceManager::SocketCallback SocketCallback; 81 typedef AndroidDeviceManager::SocketCallback SocketCallback;
92 82
93 void QueryDeviceInfo(const DeviceInfoCallback& callback); 83 void QueryDeviceInfo(const DeviceInfoCallback& callback);
94 84
95 void OpenSocket(const std::string& socket_name, 85 void OpenSocket(const std::string& socket_name,
96 const SocketCallback& callback); 86 const SocketCallback& callback);
97 87
98 void SendJsonRequest(const std::string& socket_name, 88 void SendJsonRequest(const std::string& socket_name,
99 const std::string& request, 89 const std::string& request,
100 const CommandCallback& callback); 90 const CommandCallback& callback);
101 91
102 void HttpUpgrade(const std::string& socket_name, 92 void HttpUpgrade(const std::string& socket_name,
103 const std::string& url, 93 const std::string& url,
104 const SocketCallback& callback); 94 const SocketCallback& callback);
105 95
106 scoped_refptr<AndroidWebSocket> CreateWebSocket( 96 AndroidWebSocket* CreateWebSocket(
107 const std::string& socket_name, 97 const std::string& socket_name,
108 const std::string& url, 98 const std::string& url,
109 AndroidWebSocket::Delegate* delegate); 99 AndroidWebSocket::Delegate* delegate);
110 100
111 std::string serial() { return serial_; } 101 std::string serial() { return serial_; }
112 102
113 private: 103 private:
114 friend class AndroidDeviceManager; 104 friend class AndroidDeviceManager;
115 Device(scoped_refptr<base::MessageLoopProxy> device_message_loop, 105 Device(scoped_refptr<base::MessageLoopProxy> device_message_loop,
116 scoped_refptr<DeviceProvider> provider, 106 scoped_refptr<DeviceProvider> provider,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 DeviceDescriptors* descriptors); 198 DeviceDescriptors* descriptors);
209 199
210 typedef std::map<std::string, base::WeakPtr<Device> > DeviceWeakMap; 200 typedef std::map<std::string, base::WeakPtr<Device> > DeviceWeakMap;
211 201
212 scoped_refptr<HandlerThread> handler_thread_; 202 scoped_refptr<HandlerThread> handler_thread_;
213 DeviceProviders providers_; 203 DeviceProviders providers_;
214 DeviceWeakMap devices_; 204 DeviceWeakMap devices_;
215 }; 205 };
216 206
217 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_ANDROID_DEVICE_MANAGER_H_ 207 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_ANDROID_DEVICE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698