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

Unified Diff: extensions/browser/api/usb/usb_event_router.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: Add more thread assertions. 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
« no previous file with comments | « extensions/browser/api/usb/usb_device_resource.h ('k') | extensions/browser/api/usb/usb_event_router.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/api/usb/usb_event_router.h
diff --git a/extensions/browser/api/usb/usb_event_router.h b/extensions/browser/api/usb/usb_event_router.h
index 5ff750e3296e2fdc511110361ab2368fee149218..6f081a2e2e5d1ac3445e2b9cb67ae653ff40ab2d 100644
--- a/extensions/browser/api/usb/usb_event_router.h
+++ b/extensions/browser/api/usb/usb_event_router.h
@@ -6,6 +6,7 @@
#define EXTENSIONS_BROWSER_API_USB_USB_EVENT_ROUTER_H_
#include "content/public/browser/browser_thread.h"
+#include "device/usb/usb_service.h"
#include "extensions/browser/browser_context_keyed_api_factory.h"
#include "extensions/browser/event_router.h"
@@ -18,7 +19,8 @@ namespace extensions {
// A BrowserContext-scoped object which is registered as an observer of the
// EventRouter and UsbService in order to generate device add/remove events.
class UsbEventRouter : public BrowserContextKeyedAPI,
- public EventRouter::Observer {
+ public EventRouter::Observer,
+ public device::UsbService::Observer {
public:
// BrowserContextKeyedAPI implementation.
static BrowserContextKeyedAPIFactory<UsbEventRouter>* GetFactoryInstance();
@@ -26,8 +28,6 @@ class UsbEventRouter : public BrowserContextKeyedAPI,
private:
friend class BrowserContextKeyedAPIFactory<UsbEventRouter>;
- class FileThreadHelper;
-
explicit UsbEventRouter(content::BrowserContext* context);
~UsbEventRouter() override;
@@ -41,16 +41,17 @@ class UsbEventRouter : public BrowserContextKeyedAPI,
// EventRouter::Observer implementation.
void OnListenerAdded(const EventListenerInfo& details) override;
+ // UsbService::Observer implementation.
+ void OnDeviceAdded(scoped_refptr<device::UsbDevice> device) override;
+ void OnDeviceRemoved(scoped_refptr<device::UsbDevice> device) override;
+
// Broadcasts a device add or remove event for the given device.
void DispatchEvent(const std::string& event_name,
- scoped_refptr<device::UsbDevice> device,
- const base::string16& serial_number);
+ scoped_refptr<device::UsbDevice> device);
content::BrowserContext* const browser_context_;
- scoped_ptr<FileThreadHelper, content::BrowserThread::DeleteOnFileThread>
- helper_;
- base::WeakPtrFactory<UsbEventRouter> weak_factory_;
+ ScopedObserver<device::UsbService, device::UsbService::Observer> observer_;
DISALLOW_COPY_AND_ASSIGN(UsbEventRouter);
};
« no previous file with comments | « extensions/browser/api/usb/usb_device_resource.h ('k') | extensions/browser/api/usb/usb_event_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698