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

Side by Side Diff: extensions/browser/api/usb/usb_event_router.cc

Issue 1902873002: Convert //extensions/browser/api from scoped_ptr 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "extensions/browser/api/usb/usb_event_router.h" 5 #include "extensions/browser/api/usb/usb_event_router.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "device/core/device_client.h" 9 #include "device/core/device_client.h"
10 #include "device/usb/usb_device.h" 10 #include "device/usb/usb_device.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 98 }
99 99
100 void UsbEventRouter::DispatchEvent(const std::string& event_name, 100 void UsbEventRouter::DispatchEvent(const std::string& event_name,
101 scoped_refptr<UsbDevice> device) { 101 scoped_refptr<UsbDevice> device) {
102 DCHECK_CURRENTLY_ON(BrowserThread::UI); 102 DCHECK_CURRENTLY_ON(BrowserThread::UI);
103 EventRouter* event_router = EventRouter::Get(browser_context_); 103 EventRouter* event_router = EventRouter::Get(browser_context_);
104 if (event_router) { 104 if (event_router) {
105 usb::Device device_obj; 105 usb::Device device_obj;
106 UsbGuidMap::Get(browser_context_)->GetApiDevice(device, &device_obj); 106 UsbGuidMap::Get(browser_context_)->GetApiDevice(device, &device_obj);
107 107
108 scoped_ptr<Event> event; 108 std::unique_ptr<Event> event;
109 if (event_name == usb::OnDeviceAdded::kEventName) { 109 if (event_name == usb::OnDeviceAdded::kEventName) {
110 event.reset(new Event(events::USB_ON_DEVICE_ADDED, 110 event.reset(new Event(events::USB_ON_DEVICE_ADDED,
111 usb::OnDeviceAdded::kEventName, 111 usb::OnDeviceAdded::kEventName,
112 usb::OnDeviceAdded::Create(device_obj))); 112 usb::OnDeviceAdded::Create(device_obj)));
113 } else { 113 } else {
114 DCHECK(event_name == usb::OnDeviceRemoved::kEventName); 114 DCHECK(event_name == usb::OnDeviceRemoved::kEventName);
115 event.reset(new Event(events::USB_ON_DEVICE_REMOVED, 115 event.reset(new Event(events::USB_ON_DEVICE_REMOVED,
116 usb::OnDeviceRemoved::kEventName, 116 usb::OnDeviceRemoved::kEventName,
117 usb::OnDeviceRemoved::Create(device_obj))); 117 usb::OnDeviceRemoved::Create(device_obj)));
118 } 118 }
119 119
120 event->will_dispatch_callback = 120 event->will_dispatch_callback =
121 base::Bind(&WillDispatchDeviceEvent, device); 121 base::Bind(&WillDispatchDeviceEvent, device);
122 event_router->BroadcastEvent(std::move(event)); 122 event_router->BroadcastEvent(std::move(event));
123 } 123 }
124 } 124 }
125 125
126 template <> 126 template <>
127 void BrowserContextKeyedAPIFactory< 127 void BrowserContextKeyedAPIFactory<
128 UsbEventRouter>::DeclareFactoryDependencies() { 128 UsbEventRouter>::DeclareFactoryDependencies() {
129 DependsOn(DevicePermissionsManagerFactory::GetInstance()); 129 DependsOn(DevicePermissionsManagerFactory::GetInstance());
130 DependsOn(EventRouterFactory::GetInstance()); 130 DependsOn(EventRouterFactory::GetInstance());
131 DependsOn(UsbGuidMap::GetFactoryInstance()); 131 DependsOn(UsbGuidMap::GetFactoryInstance());
132 } 132 }
133 133
134 } // extensions 134 } // extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698