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

Side by Side Diff: device/core/device_monitor_win.cc

Issue 1874313002: Convert device to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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 #include "device/core/device_monitor_win.h" 5 #include "device/core/device_monitor_win.h"
6 6
7 #include <dbt.h>
7 #include <windows.h> 8 #include <windows.h>
8 #include <dbt.h> 9
9 #include <map> 10 #include <map>
11 #include <memory>
10 12
11 #include "base/at_exit.h" 13 #include "base/at_exit.h"
12 #include "base/bind.h" 14 #include "base/bind.h"
13 #include "base/macros.h" 15 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
16 #include "base/strings/sys_string_conversions.h" 17 #include "base/strings/sys_string_conversions.h"
17 #include "base/win/message_window.h" 18 #include "base/win/message_window.h"
18 19
19 namespace device { 20 namespace device {
20 21
21 class DeviceMonitorMessageWindow; 22 class DeviceMonitorMessageWindow;
22 23
23 namespace { 24 namespace {
24 25
(...skipping 23 matching lines...) Expand all
48 base::Unretained(g_message_window))); 49 base::Unretained(g_message_window)));
49 } else { 50 } else {
50 delete g_message_window; 51 delete g_message_window;
51 g_message_window = nullptr; 52 g_message_window = nullptr;
52 } 53 }
53 } 54 }
54 return g_message_window; 55 return g_message_window;
55 } 56 }
56 57
57 DeviceMonitorWin* GetForDeviceInterface(const GUID& device_interface) { 58 DeviceMonitorWin* GetForDeviceInterface(const GUID& device_interface) {
58 scoped_ptr<DeviceMonitorWin>& device_monitor = 59 std::unique_ptr<DeviceMonitorWin>& device_monitor =
59 device_monitors_[device_interface]; 60 device_monitors_[device_interface];
60 if (!device_monitor) { 61 if (!device_monitor) {
61 device_monitor.reset(new DeviceMonitorWin()); 62 device_monitor.reset(new DeviceMonitorWin());
62 } 63 }
63 return device_monitor.get(); 64 return device_monitor.get();
64 } 65 }
65 66
66 DeviceMonitorWin* GetForAllInterfaces() { return &all_device_monitor_; } 67 DeviceMonitorWin* GetForAllInterfaces() { return &all_device_monitor_; }
67 68
68 private: 69 private:
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 device_path); 132 device_path);
132 } else { 133 } else {
133 return false; 134 return false;
134 } 135 }
135 *result = NULL; 136 *result = NULL;
136 return true; 137 return true;
137 } 138 }
138 return false; 139 return false;
139 } 140 }
140 141
141 std::map<GUID, scoped_ptr<DeviceMonitorWin>, CompareGUID> device_monitors_; 142 std::map<GUID, std::unique_ptr<DeviceMonitorWin>, CompareGUID>
143 device_monitors_;
142 DeviceMonitorWin all_device_monitor_; 144 DeviceMonitorWin all_device_monitor_;
143 scoped_ptr<base::win::MessageWindow> window_; 145 std::unique_ptr<base::win::MessageWindow> window_;
144 HDEVNOTIFY notify_handle_ = NULL; 146 HDEVNOTIFY notify_handle_ = NULL;
145 147
146 DISALLOW_COPY_AND_ASSIGN(DeviceMonitorMessageWindow); 148 DISALLOW_COPY_AND_ASSIGN(DeviceMonitorMessageWindow);
147 }; 149 };
148 150
149 void DeviceMonitorWin::Observer::OnDeviceAdded(const GUID& class_guid, 151 void DeviceMonitorWin::Observer::OnDeviceAdded(const GUID& class_guid,
150 const std::string& device_path) { 152 const std::string& device_path) {
151 } 153 }
152 154
153 void DeviceMonitorWin::Observer::OnDeviceRemoved( 155 void DeviceMonitorWin::Observer::OnDeviceRemoved(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 OnDeviceAdded(class_guid, device_path)); 198 OnDeviceAdded(class_guid, device_path));
197 } 199 }
198 200
199 void DeviceMonitorWin::NotifyDeviceRemoved(const GUID& class_guid, 201 void DeviceMonitorWin::NotifyDeviceRemoved(const GUID& class_guid,
200 const std::string& device_path) { 202 const std::string& device_path) {
201 FOR_EACH_OBSERVER(Observer, observer_list_, 203 FOR_EACH_OBSERVER(Observer, observer_list_,
202 OnDeviceRemoved(class_guid, device_path)); 204 OnDeviceRemoved(class_guid, device_path));
203 } 205 }
204 206
205 } // namespace device 207 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.h ('k') | device/core/mock_device_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698