OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "tools/battor_agent/battor_agent.h" | 4 #include "tools/battor_agent/battor_agent.h" |
5 | 5 |
6 #include <iomanip> | 6 #include <iomanip> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
10 #include "tools/battor_agent/battor_connection_impl.h" | 10 #include "tools/battor_agent/battor_connection_impl.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 samples->resize(remaining_bytes / sizeof(RawBattOrSample)); | 101 samples->resize(remaining_bytes / sizeof(RawBattOrSample)); |
102 memcpy(samples->data(), frame_ptr, remaining_bytes); | 102 memcpy(samples->data(), frame_ptr, remaining_bytes); |
103 | 103 |
104 return true; | 104 return true; |
105 } | 105 } |
106 } // namespace | 106 } // namespace |
107 | 107 |
108 BattOrAgent::BattOrAgent( | 108 BattOrAgent::BattOrAgent( |
109 const std::string& path, | 109 const std::string& path, |
110 Listener* listener, | 110 Listener* listener, |
111 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner, | |
112 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner) | 111 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner) |
113 : connection_(new BattOrConnectionImpl(path, | 112 : connection_(new BattOrConnectionImpl(path, |
114 this, | 113 this, |
115 file_thread_task_runner, | |
116 ui_thread_task_runner)), | 114 ui_thread_task_runner)), |
117 listener_(listener), | 115 listener_(listener), |
118 last_action_(Action::INVALID), | 116 last_action_(Action::INVALID), |
119 command_(Command::INVALID), | 117 command_(Command::INVALID), |
120 num_command_attempts_(0) { | 118 num_command_attempts_(0) { |
121 // We don't care what thread the constructor is called on - we only care that | 119 // We don't care what thread the constructor is called on - we only care that |
122 // all of the other method invocations happen on the same thread. | 120 // all of the other method invocations happen on the same thread. |
123 thread_checker_.DetachFromThread(); | 121 thread_checker_.DetachFromThread(); |
124 } | 122 } |
125 | 123 |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 | 622 |
625 void BattOrAgent::SetActionTimeout(uint16_t timeout_seconds) { | 623 void BattOrAgent::SetActionTimeout(uint16_t timeout_seconds) { |
626 timeout_callback_.Reset( | 624 timeout_callback_.Reset( |
627 base::Bind(&BattOrAgent::OnActionTimeout, AsWeakPtr())); | 625 base::Bind(&BattOrAgent::OnActionTimeout, AsWeakPtr())); |
628 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 626 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
629 FROM_HERE, timeout_callback_.callback(), | 627 FROM_HERE, timeout_callback_.callback(), |
630 base::TimeDelta::FromSeconds(timeout_seconds)); | 628 base::TimeDelta::FromSeconds(timeout_seconds)); |
631 } | 629 } |
632 | 630 |
633 } // namespace battor | 631 } // namespace battor |
OLD | NEW |