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

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

Issue 2686803002: Make nested classes of DevToolsDeviceDiscovery RefCountedThreadSafe (Closed)
Patch Set: s/RefCounted/RefCountedThreadSafe/ Created 3 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_DEVTOOLS_DEVICE_DISCOVERY_H_ 5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVICE_DEVTOOLS_DEVICE_DISCOVERY_H_
6 #define CHROME_BROWSER_DEVTOOLS_DEVICE_DEVTOOLS_DEVICE_DISCOVERY_H_ 6 #define CHROME_BROWSER_DEVTOOLS_DEVICE_DEVTOOLS_DEVICE_DISCOVERY_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "chrome/browser/devtools/device/android_device_manager.h" 16 #include "chrome/browser/devtools/device/android_device_manager.h"
17 #include "content/public/browser/devtools_agent_host.h" 17 #include "content/public/browser/devtools_agent_host.h"
18 18
19 class DevToolsDeviceDiscovery { 19 class DevToolsDeviceDiscovery {
20 public: 20 public:
21 class RemotePage : public base::RefCounted<RemotePage> { 21 class RemotePage : public base::RefCountedThreadSafe<RemotePage> {
22 public: 22 public:
23 scoped_refptr<AndroidDeviceManager::Device> device() { return device_; } 23 scoped_refptr<AndroidDeviceManager::Device> device() { return device_; }
24 const std::string& socket() { return browser_id_; } 24 const std::string& socket() { return browser_id_; }
25 const std::string& frontend_url() { return frontend_url_; } 25 const std::string& frontend_url() { return frontend_url_; }
26 scoped_refptr<content::DevToolsAgentHost> CreateTarget(); 26 scoped_refptr<content::DevToolsAgentHost> CreateTarget();
27 27
28 private: 28 private:
29 friend class base::RefCounted<RemotePage>; 29 friend class base::RefCountedThreadSafe<RemotePage>;
30 friend class DevToolsDeviceDiscovery; 30 friend class DevToolsDeviceDiscovery;
31 31
32 RemotePage(scoped_refptr<AndroidDeviceManager::Device> device, 32 RemotePage(scoped_refptr<AndroidDeviceManager::Device> device,
33 const std::string& browser_id, 33 const std::string& browser_id,
34 const base::DictionaryValue& dict); 34 const base::DictionaryValue& dict);
35 35
36 virtual ~RemotePage(); 36 virtual ~RemotePage();
37 37
38 scoped_refptr<AndroidDeviceManager::Device> device_; 38 scoped_refptr<AndroidDeviceManager::Device> device_;
39 std::string browser_id_; 39 std::string browser_id_;
40 std::string frontend_url_; 40 std::string frontend_url_;
41 std::unique_ptr<base::DictionaryValue> dict_; 41 std::unique_ptr<base::DictionaryValue> dict_;
42 42
43 DISALLOW_COPY_AND_ASSIGN(RemotePage); 43 DISALLOW_COPY_AND_ASSIGN(RemotePage);
44 }; 44 };
45 45
46 using RemotePages = std::vector<scoped_refptr<RemotePage>>; 46 using RemotePages = std::vector<scoped_refptr<RemotePage>>;
47 47
48 class RemoteBrowser : public base::RefCounted<RemoteBrowser> { 48 class RemoteBrowser : public base::RefCountedThreadSafe<RemoteBrowser> {
49 public: 49 public:
50 const std::string& serial() { return serial_; } 50 const std::string& serial() { return serial_; }
51 const std::string& socket() { return browser_id_; } 51 const std::string& socket() { return browser_id_; }
52 const std::string& display_name() { return display_name_; } 52 const std::string& display_name() { return display_name_; }
53 const std::string& user() { return user_; } 53 const std::string& user() { return user_; }
54 const std::string& version() { return version_; } 54 const std::string& version() { return version_; }
55 const RemotePages& pages() { return pages_; } 55 const RemotePages& pages() { return pages_; }
56 56
57 bool IsChrome(); 57 bool IsChrome();
58 std::string GetId(); 58 std::string GetId();
59 59
60 using ParsedVersion = std::vector<int>; 60 using ParsedVersion = std::vector<int>;
61 ParsedVersion GetParsedVersion(); 61 ParsedVersion GetParsedVersion();
62 62
63 private: 63 private:
64 friend class base::RefCounted<RemoteBrowser>; 64 friend class base::RefCountedThreadSafe<RemoteBrowser>;
65 friend class DevToolsDeviceDiscovery; 65 friend class DevToolsDeviceDiscovery;
66 66
67 RemoteBrowser(const std::string& serial, 67 RemoteBrowser(const std::string& serial,
68 const AndroidDeviceManager::BrowserInfo& browser_info); 68 const AndroidDeviceManager::BrowserInfo& browser_info);
69 69
70 virtual ~RemoteBrowser(); 70 virtual ~RemoteBrowser();
71 71
72 std::string serial_; 72 std::string serial_;
73 std::string browser_id_; 73 std::string browser_id_;
74 std::string display_name_; 74 std::string display_name_;
75 std::string user_; 75 std::string user_;
76 AndroidDeviceManager::BrowserInfo::Type type_; 76 AndroidDeviceManager::BrowserInfo::Type type_;
77 std::string version_; 77 std::string version_;
78 RemotePages pages_; 78 RemotePages pages_;
79 79
80 DISALLOW_COPY_AND_ASSIGN(RemoteBrowser); 80 DISALLOW_COPY_AND_ASSIGN(RemoteBrowser);
81 }; 81 };
82 82
83 using RemoteBrowsers = std::vector<scoped_refptr<RemoteBrowser>>; 83 using RemoteBrowsers = std::vector<scoped_refptr<RemoteBrowser>>;
84 84
85 class RemoteDevice : public base::RefCounted<RemoteDevice> { 85 class RemoteDevice : public base::RefCountedThreadSafe<RemoteDevice> {
86 public: 86 public:
87 std::string serial() { return serial_; } 87 std::string serial() { return serial_; }
88 std::string model() { return model_; } 88 std::string model() { return model_; }
89 bool is_connected() { return connected_; } 89 bool is_connected() { return connected_; }
90 RemoteBrowsers& browsers() { return browsers_; } 90 RemoteBrowsers& browsers() { return browsers_; }
91 gfx::Size screen_size() { return screen_size_; } 91 gfx::Size screen_size() { return screen_size_; }
92 92
93 private: 93 private:
94 friend class base::RefCounted<RemoteDevice>; 94 friend class base::RefCountedThreadSafe<RemoteDevice>;
95 friend class DevToolsDeviceDiscovery; 95 friend class DevToolsDeviceDiscovery;
96 96
97 RemoteDevice(const std::string& serial, 97 RemoteDevice(const std::string& serial,
98 const AndroidDeviceManager::DeviceInfo& device_info); 98 const AndroidDeviceManager::DeviceInfo& device_info);
99 99
100 virtual ~RemoteDevice(); 100 virtual ~RemoteDevice();
101 101
102 std::string serial_; 102 std::string serial_;
103 std::string model_; 103 std::string model_;
104 bool connected_; 104 bool connected_;
(...skipping 30 matching lines...) Expand all
135 135
136 AndroidDeviceManager* device_manager_; 136 AndroidDeviceManager* device_manager_;
137 const DeviceListCallback callback_; 137 const DeviceListCallback callback_;
138 base::Callback<void(const base::Closure&)> task_scheduler_; 138 base::Callback<void(const base::Closure&)> task_scheduler_;
139 base::WeakPtrFactory<DevToolsDeviceDiscovery> weak_factory_; 139 base::WeakPtrFactory<DevToolsDeviceDiscovery> weak_factory_;
140 140
141 DISALLOW_COPY_AND_ASSIGN(DevToolsDeviceDiscovery); 141 DISALLOW_COPY_AND_ASSIGN(DevToolsDeviceDiscovery);
142 }; 142 };
143 143
144 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_DEVTOOLS_DEVICE_DISCOVERY_H_ 144 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_DEVTOOLS_DEVICE_DISCOVERY_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698