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

Unified Diff: extensions/browser/api/hid/hid_device_manager.cc

Issue 604843003: Check that extensions::HidDeviceManager is used from the FILE thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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/hid/hid_device_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/api/hid/hid_device_manager.cc
diff --git a/extensions/browser/api/hid/hid_device_manager.cc b/extensions/browser/api/hid/hid_device_manager.cc
index 1c2502591e46867cfcdc047dbfd6173bc9b3a361..06731bde671ed0febfb5386bbdda3181174020a6 100644
--- a/extensions/browser/api/hid/hid_device_manager.cc
+++ b/extensions/browser/api/hid/hid_device_manager.cc
@@ -8,6 +8,7 @@
#include <vector>
#include "base/lazy_instance.h"
+#include "content/public/browser/browser_thread.h"
#include "device/core/device_client.h"
#include "device/hid/hid_device_filter.h"
#include "device/hid/hid_service.h"
@@ -38,6 +39,7 @@ HidDeviceManager::GetFactoryInstance() {
scoped_ptr<base::ListValue> HidDeviceManager::GetApiDevices(
const Extension* extension,
const std::vector<HidDeviceFilter>& filters) {
+ DCHECK(IsCalledOnValidThread());
UpdateDevices();
HidService* hid_service = device::DeviceClient::Get()->GetHidService();
@@ -107,6 +109,7 @@ scoped_ptr<base::ListValue> HidDeviceManager::GetApiDevices(
bool HidDeviceManager::GetDeviceInfo(int resource_id,
device::HidDeviceInfo* device_info) {
+ DCHECK(IsCalledOnValidThread());
UpdateDevices();
HidService* hid_service = device::DeviceClient::Get()->GetHidService();
DCHECK(hid_service);
@@ -121,6 +124,7 @@ bool HidDeviceManager::GetDeviceInfo(int resource_id,
bool HidDeviceManager::HasPermission(const Extension* extension,
const device::HidDeviceInfo& device_info) {
+ DCHECK(IsCalledOnValidThread());
UsbDevicePermission::CheckParam usbParam(
device_info.vendor_id,
device_info.product_id,
@@ -142,8 +146,13 @@ bool HidDeviceManager::HasPermission(const Extension* extension,
return false;
}
+// static
+bool HidDeviceManager::IsCalledOnValidThread() {
+ return content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE);
+}
+
void HidDeviceManager::UpdateDevices() {
- thread_checker_.CalledOnValidThread();
+ DCHECK(IsCalledOnValidThread());
HidService* hid_service = device::DeviceClient::Get()->GetHidService();
DCHECK(hid_service);
« no previous file with comments | « extensions/browser/api/hid/hid_device_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698