OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/test/chromedriver/chrome/adb_impl.h" | 5 #include "chrome/test/chromedriver/chrome/adb_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/json/string_escape.h" | 9 #include "base/json/string_escape.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/string_split.h" | 15 #include "base/strings/string_split.h" |
16 #include "base/strings/string_tokenizer.h" | 16 #include "base/strings/string_tokenizer.h" |
17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
19 #include "base/synchronization/waitable_event.h" | 19 #include "base/synchronization/waitable_event.h" |
20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
21 #include "chrome/test/chromedriver/chrome/status.h" | 21 #include "chrome/test/chromedriver/chrome/status.h" |
22 #include "chrome/test/chromedriver/net/adb_client_socket.h" | 22 #include "chrome/test/chromedriver/net/adb_client_socket.h" |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 // This class is bound in the callback to AdbQuery and isn't freed until the | 26 // This class is bound in the callback to AdbQuery and isn't freed until the |
27 // callback is run, even if the function that creates the buffer times out. | 27 // callback is run, even if the function that creates the buffer times out. |
28 class ResponseBuffer : public base::RefCountedThreadSafe<ResponseBuffer> { | 28 class ResponseBuffer : public base::RefCountedThreadSafe<ResponseBuffer> { |
29 public: | 29 public: |
30 ResponseBuffer() : ready_(true, false) {} | 30 ResponseBuffer() |
| 31 : ready_(base::WaitableEvent::ResetPolicy::MANUAL, |
| 32 base::WaitableEvent::InitialState::NOT_SIGNALED) {} |
31 | 33 |
32 void OnResponse(int result, const std::string& response) { | 34 void OnResponse(int result, const std::string& response) { |
33 response_ = response; | 35 response_ = response; |
34 result_ = result; | 36 result_ = result; |
35 ready_.Signal(); | 37 ready_.Signal(); |
36 } | 38 } |
37 | 39 |
38 Status GetResponse( | 40 Status GetResponse( |
39 std::string* response, const base::TimeDelta& timeout) { | 41 std::string* response, const base::TimeDelta& timeout) { |
40 base::TimeTicks deadline = base::TimeTicks::Now() + timeout; | 42 base::TimeTicks deadline = base::TimeTicks::Now() + timeout; |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 | 247 |
246 Status AdbImpl::ExecuteHostShellCommand( | 248 Status AdbImpl::ExecuteHostShellCommand( |
247 const std::string& device_serial, | 249 const std::string& device_serial, |
248 const std::string& shell_command, | 250 const std::string& shell_command, |
249 std::string* response) { | 251 std::string* response) { |
250 return ExecuteCommand( | 252 return ExecuteCommand( |
251 "host:transport:" + device_serial + "|shell:" + shell_command, | 253 "host:transport:" + device_serial + "|shell:" + shell_command, |
252 response); | 254 response); |
253 } | 255 } |
254 | 256 |
OLD | NEW |