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

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

Issue 1107013002: [device] Replace MessageLoopProxy usage with ThreadTaskRunnerHandle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Review Comments : Removal of message_loop_proxy header file Created 5 years, 7 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_win.h ('k') | device/serial/serial_service_impl.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 <windows.h> 5 #include <windows.h>
6 6
7 #include "device/serial/serial_io_handler_win.h" 7 #include "device/serial/serial_io_handler_win.h"
8 8
9 namespace device { 9 namespace device {
10 10
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 case ONESTOPBIT: 127 case ONESTOPBIT:
128 default: 128 default:
129 return serial::STOP_BITS_ONE; 129 return serial::STOP_BITS_ONE;
130 } 130 }
131 } 131 }
132 132
133 } // namespace 133 } // namespace
134 134
135 // static 135 // static
136 scoped_refptr<SerialIoHandler> SerialIoHandler::Create( 136 scoped_refptr<SerialIoHandler> SerialIoHandler::Create(
137 scoped_refptr<base::MessageLoopProxy> file_thread_message_loop, 137 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner,
138 scoped_refptr<base::MessageLoopProxy> ui_thread_message_loop) { 138 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner) {
139 return new SerialIoHandlerWin(file_thread_message_loop, 139 return new SerialIoHandlerWin(file_thread_task_runner, ui_thread_task_runner);
140 ui_thread_message_loop);
141 } 140 }
142 141
143 bool SerialIoHandlerWin::PostOpen() { 142 bool SerialIoHandlerWin::PostOpen() {
144 DCHECK(!comm_context_); 143 DCHECK(!comm_context_);
145 DCHECK(!read_context_); 144 DCHECK(!read_context_);
146 DCHECK(!write_context_); 145 DCHECK(!write_context_);
147 146
148 base::MessageLoopForIO::current()->RegisterIOHandler(file().GetPlatformFile(), 147 base::MessageLoopForIO::current()->RegisterIOHandler(file().GetPlatformFile(),
149 this); 148 this);
150 149
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 } 267 }
269 268
270 if (!SetCommState(file().GetPlatformFile(), &config)) { 269 if (!SetCommState(file().GetPlatformFile(), &config)) {
271 VPLOG(1) << "Failed to set serial port info"; 270 VPLOG(1) << "Failed to set serial port info";
272 return false; 271 return false;
273 } 272 }
274 return true; 273 return true;
275 } 274 }
276 275
277 SerialIoHandlerWin::SerialIoHandlerWin( 276 SerialIoHandlerWin::SerialIoHandlerWin(
278 scoped_refptr<base::MessageLoopProxy> file_thread_message_loop, 277 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner,
279 scoped_refptr<base::MessageLoopProxy> ui_thread_message_loop) 278 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner)
280 : SerialIoHandler(file_thread_message_loop, ui_thread_message_loop), 279 : SerialIoHandler(file_thread_task_runner, ui_thread_task_runner),
281 event_mask_(0), 280 event_mask_(0),
282 is_comm_pending_(false) { 281 is_comm_pending_(false) {
283 } 282 }
284 283
285 SerialIoHandlerWin::~SerialIoHandlerWin() { 284 SerialIoHandlerWin::~SerialIoHandlerWin() {
286 } 285 }
287 286
288 void SerialIoHandlerWin::OnIOCompleted( 287 void SerialIoHandlerWin::OnIOCompleted(
289 base::MessageLoopForIO::IOContext* context, 288 base::MessageLoopForIO::IOContext* context,
290 DWORD bytes_transferred, 289 DWORD bytes_transferred,
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 std::string SerialIoHandler::MaybeFixUpPortName(const std::string& port_name) { 392 std::string SerialIoHandler::MaybeFixUpPortName(const std::string& port_name) {
394 // For COM numbers less than 9, CreateFile is called with a string such as 393 // For COM numbers less than 9, CreateFile is called with a string such as
395 // "COM1". For numbers greater than 9, a prefix of "\\\\.\\" must be added. 394 // "COM1". For numbers greater than 9, a prefix of "\\\\.\\" must be added.
396 if (port_name.length() > std::string("COM9").length()) 395 if (port_name.length() > std::string("COM9").length())
397 return std::string("\\\\.\\").append(port_name); 396 return std::string("\\\\.\\").append(port_name);
398 397
399 return port_name; 398 return port_name;
400 } 399 }
401 400
402 } // namespace device 401 } // namespace device
OLDNEW
« no previous file with comments | « device/serial/serial_io_handler_win.h ('k') | device/serial/serial_service_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698