| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 const std::vector<scoped_refptr<HidDeviceInfo>>& devices) { | 139 const std::vector<scoped_refptr<HidDeviceInfo>>& devices) { |
| 140 DCHECK(thread_checker_.CalledOnValidThread()); | 140 DCHECK(thread_checker_.CalledOnValidThread()); |
| 141 std::unique_ptr<base::ListValue> device_list(new base::ListValue()); | 141 std::unique_ptr<base::ListValue> device_list(new base::ListValue()); |
| 142 for (const auto& device : devices) { | 142 for (const auto& device : devices) { |
| 143 const auto device_entry = resource_ids_.find(device->device_id()); | 143 const auto device_entry = resource_ids_.find(device->device_id()); |
| 144 DCHECK(device_entry != resource_ids_.end()); | 144 DCHECK(device_entry != resource_ids_.end()); |
| 145 | 145 |
| 146 hid::HidDeviceInfo device_info; | 146 hid::HidDeviceInfo device_info; |
| 147 device_info.device_id = device_entry->second; | 147 device_info.device_id = device_entry->second; |
| 148 PopulateHidDeviceInfo(&device_info, device); | 148 PopulateHidDeviceInfo(&device_info, device); |
| 149 device_list->Append(device_info.ToValue().release()); | 149 device_list->Append(device_info.ToValue()); |
| 150 } | 150 } |
| 151 return device_list; | 151 return device_list; |
| 152 } | 152 } |
| 153 | 153 |
| 154 scoped_refptr<HidDeviceInfo> HidDeviceManager::GetDeviceInfo(int resource_id) { | 154 scoped_refptr<HidDeviceInfo> HidDeviceManager::GetDeviceInfo(int resource_id) { |
| 155 DCHECK(thread_checker_.CalledOnValidThread()); | 155 DCHECK(thread_checker_.CalledOnValidThread()); |
| 156 HidService* hid_service = device::DeviceClient::Get()->GetHidService(); | 156 HidService* hid_service = device::DeviceClient::Get()->GetHidService(); |
| 157 DCHECK(hid_service); | 157 DCHECK(hid_service); |
| 158 | 158 |
| 159 ResourceIdToDeviceIdMap::const_iterator device_iter = | 159 ResourceIdToDeviceIdMap::const_iterator device_iter = |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 std::unique_ptr<base::ListValue> event_args, | 335 std::unique_ptr<base::ListValue> event_args, |
| 336 scoped_refptr<HidDeviceInfo> device_info) { | 336 scoped_refptr<HidDeviceInfo> device_info) { |
| 337 std::unique_ptr<Event> event( | 337 std::unique_ptr<Event> event( |
| 338 new Event(histogram_value, event_name, std::move(event_args))); | 338 new Event(histogram_value, event_name, std::move(event_args))); |
| 339 event->will_dispatch_callback = base::Bind( | 339 event->will_dispatch_callback = base::Bind( |
| 340 &WillDispatchDeviceEvent, weak_factory_.GetWeakPtr(), device_info); | 340 &WillDispatchDeviceEvent, weak_factory_.GetWeakPtr(), device_info); |
| 341 event_router_->BroadcastEvent(std::move(event)); | 341 event_router_->BroadcastEvent(std::move(event)); |
| 342 } | 342 } |
| 343 | 343 |
| 344 } // namespace extensions | 344 } // namespace extensions |
| OLD | NEW |