| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 session_id_ = base::StringPrintf("%d-%d", process_id, next_session_id++); | 211 session_id_ = base::StringPrintf("%d-%d", process_id, next_session_id++); |
| 212 | 212 |
| 213 observer_.Add(usb_service_); | 213 observer_.Add(usb_service_); |
| 214 } | 214 } |
| 215 | 215 |
| 216 ~UsbGadgetFactory() override {} | 216 ~UsbGadgetFactory() override {} |
| 217 | 217 |
| 218 std::unique_ptr<UsbTestGadget> WaitForDevice() { | 218 std::unique_ptr<UsbTestGadget> WaitForDevice() { |
| 219 EnumerateDevices(); | 219 EnumerateDevices(); |
| 220 run_loop_.Run(); | 220 run_loop_.Run(); |
| 221 return base::WrapUnique( | 221 return base::MakeUnique<UsbTestGadgetImpl>(request_context_getter_, |
| 222 new UsbTestGadgetImpl(request_context_getter_, usb_service_, device_)); | 222 usb_service_, device_); |
| 223 } | 223 } |
| 224 | 224 |
| 225 private: | 225 private: |
| 226 void EnumerateDevices() { | 226 void EnumerateDevices() { |
| 227 if (!device_) { | 227 if (!device_) { |
| 228 usb_service_->GetDevices(base::Bind( | 228 usb_service_->GetDevices(base::Bind( |
| 229 &UsbGadgetFactory::OnDevicesEnumerated, weak_factory_.GetWeakPtr())); | 229 &UsbGadgetFactory::OnDevicesEnumerated, weak_factory_.GetWeakPtr())); |
| 230 } | 230 } |
| 231 } | 231 } |
| 232 | 232 |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 return false; | 613 return false; |
| 614 } | 614 } |
| 615 | 615 |
| 616 DeviceAddListener add_listener(usb_service_, device_address_, -1); | 616 DeviceAddListener add_listener(usb_service_, device_address_, -1); |
| 617 device_ = add_listener.WaitForAdd(); | 617 device_ = add_listener.WaitForAdd(); |
| 618 DCHECK(device_.get()); | 618 DCHECK(device_.get()); |
| 619 return true; | 619 return true; |
| 620 } | 620 } |
| 621 | 621 |
| 622 } // namespace device | 622 } // namespace device |
| OLD | NEW |