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" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 while (!gadget->FindUnclaimed()) { | 134 while (!gadget->FindUnclaimed()) { |
135 if (--retries == 0) { | 135 if (--retries == 0) { |
136 LOG(ERROR) << "Failed to find an unclaimed device."; | 136 LOG(ERROR) << "Failed to find an unclaimed device."; |
137 return scoped_ptr<UsbTestGadget>(); | 137 return scoped_ptr<UsbTestGadget>(); |
138 } | 138 } |
139 PlatformThread::Sleep(TimeDelta::FromMilliseconds(kRetryPeriod)); | 139 PlatformThread::Sleep(TimeDelta::FromMilliseconds(kRetryPeriod)); |
140 } | 140 } |
141 VLOG(1) << "It took " << (kClaimRetries - retries) | 141 VLOG(1) << "It took " << (kClaimRetries - retries) |
142 << " retries to find an unclaimed device."; | 142 << " retries to find an unclaimed device."; |
143 | 143 |
144 return gadget.PassAs<UsbTestGadget>(); | 144 return gadget.Pass(); |
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::Process::Current().pid(); |
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); |
(...skipping 19 matching lines...) Expand all Loading... |
174 const GURL& url, net::URLFetcher::RequestType request_type, | 174 const GURL& url, net::URLFetcher::RequestType request_type, |
175 net::URLFetcherDelegate* delegate) { | 175 net::URLFetcherDelegate* delegate) { |
176 scoped_ptr<net::URLFetcher> url_fetcher( | 176 scoped_ptr<net::URLFetcher> url_fetcher( |
177 net::URLFetcher::Create(url, request_type, delegate)); | 177 net::URLFetcher::Create(url, request_type, delegate)); |
178 | 178 |
179 url_fetcher->SetRequestContext( | 179 url_fetcher->SetRequestContext( |
180 new net::TrivialURLRequestContextGetter( | 180 new net::TrivialURLRequestContextGetter( |
181 request_context_.get(), | 181 request_context_.get(), |
182 base::MessageLoop::current()->message_loop_proxy())); | 182 base::MessageLoop::current()->message_loop_proxy())); |
183 | 183 |
184 return url_fetcher.PassAs<net::URLFetcher>(); | 184 return url_fetcher; |
185 } | 185 } |
186 | 186 |
187 int UsbTestGadgetImpl::SimplePOSTRequest(const GURL& url, | 187 int UsbTestGadgetImpl::SimplePOSTRequest(const GURL& url, |
188 const std::string& form_data) { | 188 const std::string& form_data) { |
189 Delegate delegate; | 189 Delegate delegate; |
190 scoped_ptr<net::URLFetcher> url_fetcher = | 190 scoped_ptr<net::URLFetcher> url_fetcher = |
191 CreateURLFetcher(url, net::URLFetcher::POST, &delegate); | 191 CreateURLFetcher(url, net::URLFetcher::POST, &delegate); |
192 | 192 |
193 url_fetcher->SetUploadData("application/x-www-form-urlencoded", form_data); | 193 url_fetcher->SetUploadData("application/x-www-form-urlencoded", form_data); |
194 url_fetcher->Start(); | 194 url_fetcher->Start(); |
(...skipping 319 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 |