| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/hid/hid_device_manager.h" | 5 #include "extensions/browser/api/hid/hid_device_manager.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 if (u2f_filter.Matches(device_info)) { | 141 if (u2f_filter.Matches(device_info)) { |
| 142 return true; | 142 return true; |
| 143 } | 143 } |
| 144 } | 144 } |
| 145 | 145 |
| 146 return false; | 146 return false; |
| 147 } | 147 } |
| 148 | 148 |
| 149 // static | 149 // static |
| 150 bool HidDeviceManager::IsCalledOnValidThread() { | 150 bool HidDeviceManager::IsCalledOnValidThread() { |
| 151 #if defined(OS_MACOSX) | 151 #if defined(OS_WIN) |
| 152 // Migration from FILE thread to UI thread. OS X gets it first. | 152 // TODO(reillyg): Migrate Windows backend from FILE thread to UI thread. |
| 153 return content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE); |
| 154 #else |
| 153 return content::BrowserThread::CurrentlyOn(content::BrowserThread::UI); | 155 return content::BrowserThread::CurrentlyOn(content::BrowserThread::UI); |
| 154 #else | |
| 155 // TODO(reillyg): Migrate Linux/CrOS and Windows as well. | |
| 156 return content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE); | |
| 157 #endif | 156 #endif |
| 158 } | 157 } |
| 159 | 158 |
| 160 void HidDeviceManager::UpdateDevices() { | 159 void HidDeviceManager::UpdateDevices() { |
| 161 DCHECK(IsCalledOnValidThread()); | 160 DCHECK(IsCalledOnValidThread()); |
| 162 HidService* hid_service = device::DeviceClient::Get()->GetHidService(); | 161 HidService* hid_service = device::DeviceClient::Get()->GetHidService(); |
| 163 DCHECK(hid_service); | 162 DCHECK(hid_service); |
| 164 | 163 |
| 165 std::vector<device::HidDeviceInfo> devices; | 164 std::vector<device::HidDeviceInfo> devices; |
| 166 hid_service->GetDevices(&devices); | 165 hid_service->GetDevices(&devices); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 183 new_id = next_resource_id_++; | 182 new_id = next_resource_id_++; |
| 184 } | 183 } |
| 185 new_resource_ids[device_info.device_id] = new_id; | 184 new_resource_ids[device_info.device_id] = new_id; |
| 186 new_device_ids[new_id] = device_info.device_id; | 185 new_device_ids[new_id] = device_info.device_id; |
| 187 } | 186 } |
| 188 device_ids_.swap(new_device_ids); | 187 device_ids_.swap(new_device_ids); |
| 189 resource_ids_.swap(new_resource_ids); | 188 resource_ids_.swap(new_resource_ids); |
| 190 } | 189 } |
| 191 | 190 |
| 192 } // namespace extensions | 191 } // namespace extensions |
| OLD | NEW |