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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/files/file.h" | 12 #include "base/files/file.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/path_service.h" | 18 #include "base/path_service.h" |
19 #include "base/process/process.h" | 19 #include "base/process/process_handle.h" |
20 #include "base/run_loop.h" | 20 #include "base/run_loop.h" |
21 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
22 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
23 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
24 #include "base/threading/platform_thread.h" | 24 #include "base/threading/platform_thread.h" |
25 #include "base/time/time.h" | 25 #include "base/time/time.h" |
26 #include "device/usb/usb_device.h" | 26 #include "device/usb/usb_device.h" |
27 #include "device/usb/usb_device_handle.h" | 27 #include "device/usb/usb_device_handle.h" |
28 #include "device/usb/usb_service.h" | 28 #include "device/usb/usb_service.h" |
29 #include "net/proxy/proxy_service.h" | 29 #include "net/proxy/proxy_service.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 << " retries to find an unclaimed device."; | 142 << " retries to find an unclaimed device."; |
143 | 143 |
144 return gadget.PassAs<UsbTestGadget>(); | 144 return gadget.PassAs<UsbTestGadget>(); |
145 } | 145 } |
146 | 146 |
147 UsbTestGadgetImpl::UsbTestGadgetImpl() { | 147 UsbTestGadgetImpl::UsbTestGadgetImpl() { |
148 net::URLRequestContextBuilder context_builder; | 148 net::URLRequestContextBuilder context_builder; |
149 context_builder.set_proxy_service(net::ProxyService::CreateDirect()); | 149 context_builder.set_proxy_service(net::ProxyService::CreateDirect()); |
150 request_context_.reset(context_builder.Build()); | 150 request_context_.reset(context_builder.Build()); |
151 | 151 |
152 base::ProcessId process_id = base::Process::Current().pid(); | 152 base::ProcessId process_id = base::GetCurrentProcId(); |
153 session_id_ = base::StringPrintf( | 153 session_id_ = base::StringPrintf( |
154 "%s:%p", base::HexEncode(&process_id, sizeof(process_id)).c_str(), this); | 154 "%s:%p", base::HexEncode(&process_id, sizeof(process_id)).c_str(), this); |
155 | 155 |
156 usb_service_ = UsbService::GetInstance(NULL); | 156 usb_service_ = UsbService::GetInstance(NULL); |
157 } | 157 } |
158 | 158 |
159 UsbTestGadgetImpl::~UsbTestGadgetImpl() { | 159 UsbTestGadgetImpl::~UsbTestGadgetImpl() { |
160 if (!device_address_.empty()) { | 160 if (!device_address_.empty()) { |
161 Unclaim(); | 161 Unclaim(); |
162 } | 162 } |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 } | 514 } |
515 PlatformThread::Sleep(TimeDelta::FromMilliseconds(kRetryPeriod)); | 515 PlatformThread::Sleep(TimeDelta::FromMilliseconds(kRetryPeriod)); |
516 } | 516 } |
517 VLOG(1) << "It took " << (kDisconnectRetries - retries) | 517 VLOG(1) << "It took " << (kDisconnectRetries - retries) |
518 << " retries for the device to reconnect."; | 518 << " retries for the device to reconnect."; |
519 | 519 |
520 return true; | 520 return true; |
521 } | 521 } |
522 | 522 |
523 } // namespace device | 523 } // namespace device |
OLD | NEW |