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

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

Issue 1440593004: Make operators on scoped_ptr match the ones defined for std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrequals: followupfix-after-rebase Created 5 years, 1 month 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 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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 } 275 }
276 276
277 SerialIoHandlerWin::~SerialIoHandlerWin() { 277 SerialIoHandlerWin::~SerialIoHandlerWin() {
278 } 278 }
279 279
280 void SerialIoHandlerWin::OnIOCompleted( 280 void SerialIoHandlerWin::OnIOCompleted(
281 base::MessageLoopForIO::IOContext* context, 281 base::MessageLoopForIO::IOContext* context,
282 DWORD bytes_transferred, 282 DWORD bytes_transferred,
283 DWORD error) { 283 DWORD error) {
284 DCHECK(CalledOnValidThread()); 284 DCHECK(CalledOnValidThread());
285 if (context == comm_context_) { 285 if (context == comm_context_.get()) {
286 DWORD errors; 286 DWORD errors;
287 COMSTAT status; 287 COMSTAT status;
288 if (!ClearCommError(file().GetPlatformFile(), &errors, &status) || 288 if (!ClearCommError(file().GetPlatformFile(), &errors, &status) ||
289 errors != 0) { 289 errors != 0) {
290 if (errors & CE_BREAK) { 290 if (errors & CE_BREAK) {
291 ReadCompleted(0, serial::RECEIVE_ERROR_BREAK); 291 ReadCompleted(0, serial::RECEIVE_ERROR_BREAK);
292 } else if (errors & CE_FRAME) { 292 } else if (errors & CE_FRAME) {
293 ReadCompleted(0, serial::RECEIVE_ERROR_FRAME_ERROR); 293 ReadCompleted(0, serial::RECEIVE_ERROR_FRAME_ERROR);
294 } else if (errors & CE_OVERRUN) { 294 } else if (errors & CE_OVERRUN) {
295 ReadCompleted(0, serial::RECEIVE_ERROR_OVERRUN); 295 ReadCompleted(0, serial::RECEIVE_ERROR_OVERRUN);
(...skipping 15 matching lines...) Expand all
311 BOOL ok = ::ReadFile(file().GetPlatformFile(), 311 BOOL ok = ::ReadFile(file().GetPlatformFile(),
312 pending_read_buffer(), 312 pending_read_buffer(),
313 pending_read_buffer_len(), 313 pending_read_buffer_len(),
314 NULL, 314 NULL,
315 &read_context_->overlapped); 315 &read_context_->overlapped);
316 if (!ok && GetLastError() != ERROR_IO_PENDING) { 316 if (!ok && GetLastError() != ERROR_IO_PENDING) {
317 VPLOG(1) << "Read failed"; 317 VPLOG(1) << "Read failed";
318 ReadCompleted(0, serial::RECEIVE_ERROR_SYSTEM_ERROR); 318 ReadCompleted(0, serial::RECEIVE_ERROR_SYSTEM_ERROR);
319 } 319 }
320 } 320 }
321 } else if (context == read_context_) { 321 } else if (context == read_context_.get()) {
322 if (read_canceled()) { 322 if (read_canceled()) {
323 ReadCompleted(bytes_transferred, read_cancel_reason()); 323 ReadCompleted(bytes_transferred, read_cancel_reason());
324 } else if (error != ERROR_SUCCESS && error != ERROR_OPERATION_ABORTED) { 324 } else if (error != ERROR_SUCCESS && error != ERROR_OPERATION_ABORTED) {
325 ReadCompleted(0, serial::RECEIVE_ERROR_SYSTEM_ERROR); 325 ReadCompleted(0, serial::RECEIVE_ERROR_SYSTEM_ERROR);
326 } else { 326 } else {
327 ReadCompleted(bytes_transferred, 327 ReadCompleted(bytes_transferred,
328 error == ERROR_SUCCESS 328 error == ERROR_SUCCESS
329 ? serial::RECEIVE_ERROR_NONE 329 ? serial::RECEIVE_ERROR_NONE
330 : serial::RECEIVE_ERROR_SYSTEM_ERROR); 330 : serial::RECEIVE_ERROR_SYSTEM_ERROR);
331 } 331 }
332 } else if (context == write_context_) { 332 } else if (context == write_context_.get()) {
333 DCHECK(pending_write_buffer()); 333 DCHECK(pending_write_buffer());
334 if (write_canceled()) { 334 if (write_canceled()) {
335 WriteCompleted(0, write_cancel_reason()); 335 WriteCompleted(0, write_cancel_reason());
336 } else if (error != ERROR_SUCCESS && error != ERROR_OPERATION_ABORTED) { 336 } else if (error != ERROR_SUCCESS && error != ERROR_OPERATION_ABORTED) {
337 WriteCompleted(0, serial::SEND_ERROR_SYSTEM_ERROR); 337 WriteCompleted(0, serial::SEND_ERROR_SYSTEM_ERROR);
338 if (error == ERROR_GEN_FAILURE && IsReadPending()) { 338 if (error == ERROR_GEN_FAILURE && IsReadPending()) {
339 // For devices using drivers such as FTDI, CP2xxx, when device is 339 // For devices using drivers such as FTDI, CP2xxx, when device is
340 // disconnected, the context is comm_context_ and the error is 340 // disconnected, the context is comm_context_ and the error is
341 // ERROR_OPERATION_ABORTED. 341 // ERROR_OPERATION_ABORTED.
342 // However, for devices using CDC-ACM driver, when device is 342 // However, for devices using CDC-ACM driver, when device is
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 std::string SerialIoHandler::MaybeFixUpPortName(const std::string& port_name) { 434 std::string SerialIoHandler::MaybeFixUpPortName(const std::string& port_name) {
435 // For COM numbers less than 9, CreateFile is called with a string such as 435 // For COM numbers less than 9, CreateFile is called with a string such as
436 // "COM1". For numbers greater than 9, a prefix of "\\\\.\\" must be added. 436 // "COM1". For numbers greater than 9, a prefix of "\\\\.\\" must be added.
437 if (port_name.length() > std::string("COM9").length()) 437 if (port_name.length() > std::string("COM9").length())
438 return std::string("\\\\.\\").append(port_name); 438 return std::string("\\\\.\\").append(port_name);
439 439
440 return port_name; 440 return port_name;
441 } 441 }
442 442
443 } // namespace device 443 } // namespace device
OLDNEW
« no previous file with comments | « content/common/discardable_shared_memory_heap.cc ('k') | ios/chrome/browser/updatable_config/updatable_config_base.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698