| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 const GetApiDevicesCallback& callback) { | 123 const GetApiDevicesCallback& callback) { |
| 124 DCHECK(thread_checker_.CalledOnValidThread()); | 124 DCHECK(thread_checker_.CalledOnValidThread()); |
| 125 LazyInitialize(); | 125 LazyInitialize(); |
| 126 | 126 |
| 127 if (enumeration_ready_) { | 127 if (enumeration_ready_) { |
| 128 std::unique_ptr<base::ListValue> devices = | 128 std::unique_ptr<base::ListValue> devices = |
| 129 CreateApiDeviceList(extension, filters); | 129 CreateApiDeviceList(extension, filters); |
| 130 base::ThreadTaskRunnerHandle::Get()->PostTask( | 130 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 131 FROM_HERE, base::Bind(callback, base::Passed(&devices))); | 131 FROM_HERE, base::Bind(callback, base::Passed(&devices))); |
| 132 } else { | 132 } else { |
| 133 pending_enumerations_.push_back(base::WrapUnique( | 133 pending_enumerations_.push_back( |
| 134 new GetApiDevicesParams(extension, filters, callback))); | 134 base::MakeUnique<GetApiDevicesParams>(extension, filters, callback)); |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 | 137 |
| 138 std::unique_ptr<base::ListValue> HidDeviceManager::GetApiDevicesFromList( | 138 std::unique_ptr<base::ListValue> HidDeviceManager::GetApiDevicesFromList( |
| 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()); |
| (...skipping 190 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 |