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

Unified Diff: device/usb/usb_service.h

Issue 980023002: Move device/usb classes from the FILE thread to UI thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: device/usb/usb_service.h
diff --git a/device/usb/usb_service.h b/device/usb/usb_service.h
index a2dfa9ec9151368a0acde32b39cf07f2168f9c75..5c190ec3898b13c4d80fbd248d65a9b465ffe1ef 100644
--- a/device/usb/usb_service.h
+++ b/device/usb/usb_service.h
@@ -7,13 +7,14 @@
#include <vector>
+#include "base/bind_helpers.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "base/threading/non_thread_safe.h"
namespace base {
-class SingleThreadTaskRunner;
+class SequencedTaskRunner;
}
namespace device {
@@ -24,9 +25,6 @@ class UsbDevice;
// used to manage and dispatch USB events. It is also responsible for device
// discovery on the system, which allows it to re-use device handles to prevent
// competition for the same USB device.
-//
-// All functions on this object must be called from a thread with a
-// MessageLoopForIO (for example, BrowserThread::FILE).
class UsbService : public base::NonThreadSafe {
public:
class Observer {
@@ -40,19 +38,18 @@ class UsbService : public base::NonThreadSafe {
virtual void OnDeviceRemovedCleanup(scoped_refptr<UsbDevice> device);
};
- // The UI task runner reference is used to talk to the PermissionBrokerClient
- // on ChromeOS (UI thread). Returns NULL when initialization fails.
- static UsbService* GetInstance(
- scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner);
+ typedef base::Callback<void(const std::vector<scoped_refptr<UsbDevice>>&)>
+ GetDevicesCallback;
- static void SetInstanceForTest(UsbService* instance);
+ // The file task runner reference is used for blocking I/O operations.
+ // Returns NULL when initialization fails.
+ static UsbService* GetInstance(
+ scoped_refptr<base::SequencedTaskRunner> blocking_task_runner);
virtual scoped_refptr<UsbDevice> GetDeviceById(uint32 unique_id) = 0;
- // Get all of the devices attached to the system, inserting them into
- // |devices|. Clears |devices| before use. The result will be sorted by id
- // in increasing order.
- virtual void GetDevices(std::vector<scoped_refptr<UsbDevice> >* devices) = 0;
+ // Enumerates available devices.
+ virtual void GetDevices(const GetDevicesCallback& callback) = 0;
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
@@ -67,7 +64,7 @@ class UsbService : public base::NonThreadSafe {
ObserverList<Observer, true> observer_list_;
private:
- class Destroyer;
+ friend void base::DeletePointer<UsbService>(UsbService* service);
DISALLOW_COPY_AND_ASSIGN(UsbService);
};

Powered by Google App Engine
This is Rietveld 408576698