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

Side by Side Diff: device/serial/serial_io_handler.cc

Issue 401563002: Add a partial Mojo serial connection interface and implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 6 years, 5 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
« no previous file with comments | « device/serial/serial_io_handler.h ('k') | device/serial/serial_io_handler_posix.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/serial/serial_io_handler.h" 5 #include "device/serial/serial_io_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 11
12 namespace device { 12 namespace device {
13 13
14 SerialIoHandler::SerialIoHandler() 14 SerialIoHandler::SerialIoHandler(
15 : pending_read_buffer_len_(0), pending_write_buffer_len_(0) { 15 scoped_refptr<base::MessageLoopProxy> file_thread_message_loop)
16 : pending_read_buffer_len_(0),
17 pending_write_buffer_len_(0),
18 file_thread_message_loop_(file_thread_message_loop) {
16 } 19 }
17 20
18 SerialIoHandler::~SerialIoHandler() { 21 SerialIoHandler::~SerialIoHandler() {
19 DCHECK(CalledOnValidThread()); 22 DCHECK(CalledOnValidThread());
20 Close(); 23 Close();
21 } 24 }
22 25
23 void SerialIoHandler::Initialize( 26 void SerialIoHandler::Initialize(const ReadCompleteCallback& read_callback,
24 const ReadCompleteCallback& read_callback, 27 const WriteCompleteCallback& write_callback) {
25 const WriteCompleteCallback& write_callback,
26 scoped_refptr<base::MessageLoopProxy> file_thread_message_loop) {
27 DCHECK(CalledOnValidThread()); 28 DCHECK(CalledOnValidThread());
28 read_complete_ = read_callback; 29 read_complete_ = read_callback;
29 write_complete_ = write_callback; 30 write_complete_ = write_callback;
30 file_thread_message_loop_ = file_thread_message_loop;
31 } 31 }
32 32
33 void SerialIoHandler::Open(const std::string& port, 33 void SerialIoHandler::Open(const std::string& port,
34 const OpenCompleteCallback& callback) { 34 const OpenCompleteCallback& callback) {
35 DCHECK(CalledOnValidThread()); 35 DCHECK(CalledOnValidThread());
36 DCHECK(open_complete_.is_null()); 36 DCHECK(open_complete_.is_null());
37 open_complete_ = callback; 37 open_complete_ = callback;
38 DCHECK(file_thread_message_loop_); 38 DCHECK(file_thread_message_loop_);
39 file_thread_message_loop_->PostTask( 39 file_thread_message_loop_->PostTask(
40 FROM_HERE, 40 FROM_HERE,
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 180 }
181 181
182 void SerialIoHandler::QueueWriteCompleted(int bytes_written, 182 void SerialIoHandler::QueueWriteCompleted(int bytes_written,
183 serial::SendError error) { 183 serial::SendError error) {
184 base::MessageLoop::current()->PostTask( 184 base::MessageLoop::current()->PostTask(
185 FROM_HERE, 185 FROM_HERE,
186 base::Bind(&SerialIoHandler::WriteCompleted, this, bytes_written, error)); 186 base::Bind(&SerialIoHandler::WriteCompleted, this, bytes_written, error));
187 } 187 }
188 188
189 } // namespace device 189 } // namespace device
OLDNEW
« no previous file with comments | « device/serial/serial_io_handler.h ('k') | device/serial/serial_io_handler_posix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698