| 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 "device/test/usb_test_gadget.h" | 5 #include "device/test/usb_test_gadget.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 : network_task_runner_(network_task_runner) {} | 143 : network_task_runner_(network_task_runner) {} |
| 144 | 144 |
| 145 private: | 145 private: |
| 146 ~URLRequestContextGetter() override {} | 146 ~URLRequestContextGetter() override {} |
| 147 | 147 |
| 148 // net::URLRequestContextGetter implementation | 148 // net::URLRequestContextGetter implementation |
| 149 net::URLRequestContext* GetURLRequestContext() override { | 149 net::URLRequestContext* GetURLRequestContext() override { |
| 150 if (!context_) { | 150 if (!context_) { |
| 151 net::URLRequestContextBuilder context_builder; | 151 net::URLRequestContextBuilder context_builder; |
| 152 context_builder.set_proxy_service(net::ProxyService::CreateDirect()); | 152 context_builder.set_proxy_service(net::ProxyService::CreateDirect()); |
| 153 context_ = context_builder.Build().Pass(); | 153 context_ = context_builder.Build(); |
| 154 } | 154 } |
| 155 return context_.get(); | 155 return context_.get(); |
| 156 } | 156 } |
| 157 | 157 |
| 158 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() | 158 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() |
| 159 const override { | 159 const override { |
| 160 return network_task_runner_; | 160 return network_task_runner_; |
| 161 } | 161 } |
| 162 | 162 |
| 163 scoped_ptr<net::URLRequestContext> context_; | 163 scoped_ptr<net::URLRequestContext> context_; |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 } // namespace | 515 } // namespace |
| 516 | 516 |
| 517 bool UsbTestGadget::IsTestEnabled() { | 517 bool UsbTestGadget::IsTestEnabled() { |
| 518 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 518 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 519 return command_line->HasSwitch(kCommandLineSwitch); | 519 return command_line->HasSwitch(kCommandLineSwitch); |
| 520 } | 520 } |
| 521 | 521 |
| 522 scoped_ptr<UsbTestGadget> UsbTestGadget::Claim( | 522 scoped_ptr<UsbTestGadget> UsbTestGadget::Claim( |
| 523 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) { | 523 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) { |
| 524 UsbGadgetFactory gadget_factory(io_task_runner); | 524 UsbGadgetFactory gadget_factory(io_task_runner); |
| 525 return gadget_factory.WaitForDevice().Pass(); | 525 return gadget_factory.WaitForDevice(); |
| 526 } | 526 } |
| 527 | 527 |
| 528 UsbTestGadgetImpl::UsbTestGadgetImpl( | 528 UsbTestGadgetImpl::UsbTestGadgetImpl( |
| 529 scoped_refptr<net::URLRequestContextGetter> request_context_getter_, | 529 scoped_refptr<net::URLRequestContextGetter> request_context_getter_, |
| 530 UsbService* usb_service, | 530 UsbService* usb_service, |
| 531 scoped_refptr<UsbDevice> device) | 531 scoped_refptr<UsbDevice> device) |
| 532 : device_address_(base::UTF16ToUTF8(device->serial_number())), | 532 : device_address_(base::UTF16ToUTF8(device->serial_number())), |
| 533 device_(device), | 533 device_(device), |
| 534 request_context_getter_(request_context_getter_), | 534 request_context_getter_(request_context_getter_), |
| 535 usb_service_(usb_service) { | 535 usb_service_(usb_service) { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 return false; | 611 return false; |
| 612 } | 612 } |
| 613 | 613 |
| 614 DeviceAddListener add_listener(usb_service_, device_address_, -1); | 614 DeviceAddListener add_listener(usb_service_, device_address_, -1); |
| 615 device_ = add_listener.WaitForAdd(); | 615 device_ = add_listener.WaitForAdd(); |
| 616 DCHECK(device_.get()); | 616 DCHECK(device_.get()); |
| 617 return true; | 617 return true; |
| 618 } | 618 } |
| 619 | 619 |
| 620 } // namespace device | 620 } // namespace device |
| OLD | NEW |