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

Side by Side Diff: device/usb/usb_service.cc

Issue 891853002: Add a UsbService::Observer function for cleanup actions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 | « device/usb/usb_service.h ('k') | extensions/browser/api/device_permissions_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "device/usb/usb_service.h" 5 #include "device/usb/usb_service.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "device/usb/usb_device.h" 8 #include "device/usb/usb_device.h"
9 #include "device/usb/usb_service_impl.h" 9 #include "device/usb/usb_service_impl.h"
10 10
(...skipping 26 matching lines...) Expand all
37 37
38 UsbService* usb_service_; 38 UsbService* usb_service_;
39 }; 39 };
40 40
41 void UsbService::Observer::OnDeviceAdded(scoped_refptr<UsbDevice> device) { 41 void UsbService::Observer::OnDeviceAdded(scoped_refptr<UsbDevice> device) {
42 } 42 }
43 43
44 void UsbService::Observer::OnDeviceRemoved(scoped_refptr<UsbDevice> device) { 44 void UsbService::Observer::OnDeviceRemoved(scoped_refptr<UsbDevice> device) {
45 } 45 }
46 46
47 void UsbService::Observer::OnDeviceRemovedCleanup(
48 scoped_refptr<UsbDevice> device) {
49 }
50
47 // static 51 // static
48 UsbService* UsbService::GetInstance( 52 UsbService* UsbService::GetInstance(
49 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { 53 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) {
50 if (!g_service) { 54 if (!g_service) {
51 g_service = UsbServiceImpl::Create(ui_task_runner); 55 g_service = UsbServiceImpl::Create(ui_task_runner);
52 // This object will clean itself up when the message loop is destroyed. 56 // This object will clean itself up when the message loop is destroyed.
53 new Destroyer(g_service); 57 new Destroyer(g_service);
54 } 58 }
55 return g_service; 59 return g_service;
56 } 60 }
(...skipping 21 matching lines...) Expand all
78 } 82 }
79 83
80 void UsbService::NotifyDeviceAdded(scoped_refptr<UsbDevice> device) { 84 void UsbService::NotifyDeviceAdded(scoped_refptr<UsbDevice> device) {
81 DCHECK(CalledOnValidThread()); 85 DCHECK(CalledOnValidThread());
82 FOR_EACH_OBSERVER(Observer, observer_list_, OnDeviceAdded(device)); 86 FOR_EACH_OBSERVER(Observer, observer_list_, OnDeviceAdded(device));
83 } 87 }
84 88
85 void UsbService::NotifyDeviceRemoved(scoped_refptr<UsbDevice> device) { 89 void UsbService::NotifyDeviceRemoved(scoped_refptr<UsbDevice> device) {
86 DCHECK(CalledOnValidThread()); 90 DCHECK(CalledOnValidThread());
87 FOR_EACH_OBSERVER(Observer, observer_list_, OnDeviceRemoved(device)); 91 FOR_EACH_OBSERVER(Observer, observer_list_, OnDeviceRemoved(device));
92 FOR_EACH_OBSERVER(Observer, observer_list_, OnDeviceRemovedCleanup(device));
88 } 93 }
89 94
90 } // namespace device 95 } // namespace device
OLDNEW
« no previous file with comments | « device/usb/usb_service.h ('k') | extensions/browser/api/device_permissions_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698