Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: tools/battor_agent/battor_connection_impl.cc

Issue 2914173002: Removing file_thread_task_runner parameter from SerialIoHandler (Closed)
Patch Set: removed unused variable Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 4
5 #include "tools/battor_agent/battor_connection_impl.h" 5 #include "tools/battor_agent/battor_connection_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/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 default: 54 default:
55 return 0; 55 return 0;
56 } 56 }
57 } 57 }
58 58
59 } // namespace 59 } // namespace
60 60
61 BattOrConnectionImpl::BattOrConnectionImpl( 61 BattOrConnectionImpl::BattOrConnectionImpl(
62 const std::string& path, 62 const std::string& path,
63 BattOrConnection::Listener* listener, 63 BattOrConnection::Listener* listener,
64 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner,
65 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner) 64 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner)
66 : BattOrConnection(listener), 65 : BattOrConnection(listener),
67 path_(path), 66 path_(path),
68 file_thread_task_runner_(file_thread_task_runner),
69 ui_thread_task_runner_(ui_thread_task_runner) { 67 ui_thread_task_runner_(ui_thread_task_runner) {
70 std::string serial_log_path = 68 std::string serial_log_path =
71 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 69 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
72 kSerialLogPathSwitch); 70 kSerialLogPathSwitch);
73 if (!serial_log_path.empty()) { 71 if (!serial_log_path.empty()) {
74 serial_log_.open(serial_log_path.c_str(), 72 serial_log_.open(serial_log_path.c_str(),
75 std::fstream::out | std::fstream::trunc); 73 std::fstream::out | std::fstream::trunc);
76 } 74 }
77 } 75 }
78 76
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 void BattOrConnectionImpl::CancelReadMessage() { 184 void BattOrConnectionImpl::CancelReadMessage() {
187 io_handler_->CancelRead(device::serial::ReceiveError::TIMEOUT); 185 io_handler_->CancelRead(device::serial::ReceiveError::TIMEOUT);
188 } 186 }
189 187
190 void BattOrConnectionImpl::Flush() { 188 void BattOrConnectionImpl::Flush() {
191 io_handler_->Flush(); 189 io_handler_->Flush();
192 already_read_buffer_.clear(); 190 already_read_buffer_.clear();
193 } 191 }
194 192
195 scoped_refptr<device::SerialIoHandler> BattOrConnectionImpl::CreateIoHandler() { 193 scoped_refptr<device::SerialIoHandler> BattOrConnectionImpl::CreateIoHandler() {
196 return device::SerialIoHandler::Create(file_thread_task_runner_, 194 return device::SerialIoHandler::Create(ui_thread_task_runner_);
197 ui_thread_task_runner_);
198 } 195 }
199 196
200 void BattOrConnectionImpl::BeginReadBytes(size_t max_bytes_to_read) { 197 void BattOrConnectionImpl::BeginReadBytes(size_t max_bytes_to_read) {
201 LogSerial( 198 LogSerial(
202 StringPrintf("Starting read of up to %zu bytes.", max_bytes_to_read)); 199 StringPrintf("Starting read of up to %zu bytes.", max_bytes_to_read));
203 200
204 pending_read_buffer_ = 201 pending_read_buffer_ =
205 make_scoped_refptr(new net::IOBuffer(max_bytes_to_read)); 202 make_scoped_refptr(new net::IOBuffer(max_bytes_to_read));
206 203
207 auto on_receive_buffer_filled = 204 auto on_receive_buffer_filled =
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 base::ThreadTaskRunnerHandle::Get()->PostTask( 345 base::ThreadTaskRunnerHandle::Get()->PostTask(
349 FROM_HERE, 346 FROM_HERE,
350 base::Bind(&Listener::OnBytesSent, base::Unretained(listener_), success)); 347 base::Bind(&Listener::OnBytesSent, base::Unretained(listener_), success));
351 } 348 }
352 349
353 void BattOrConnectionImpl::LogSerial(const std::string& str) { 350 void BattOrConnectionImpl::LogSerial(const std::string& str) {
354 serial_log_ << str << std::endl << std::endl; 351 serial_log_ << str << std::endl << std::endl;
355 } 352 }
356 353
357 } // namespace battor 354 } // namespace battor
OLDNEW
« no previous file with comments | « tools/battor_agent/battor_connection_impl.h ('k') | tools/battor_agent/battor_connection_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698