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

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

Issue 1470983002: Make SerialIoHandlerWin::UiThreadHelper final. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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') | no next file » | 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_win.h" 5 #include "device/serial/serial_io_handler_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <setupapi.h> 8 #include <setupapi.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 } // namespace 147 } // namespace
148 148
149 // static 149 // static
150 scoped_refptr<SerialIoHandler> SerialIoHandler::Create( 150 scoped_refptr<SerialIoHandler> SerialIoHandler::Create(
151 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner, 151 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner,
152 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner) { 152 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner) {
153 return new SerialIoHandlerWin(file_thread_task_runner, ui_thread_task_runner); 153 return new SerialIoHandlerWin(file_thread_task_runner, ui_thread_task_runner);
154 } 154 }
155 155
156 class SerialIoHandlerWin::UiThreadHelper : public DeviceMonitorWin::Observer { 156 class SerialIoHandlerWin::UiThreadHelper final
157 : public DeviceMonitorWin::Observer {
157 public: 158 public:
158 UiThreadHelper( 159 UiThreadHelper(
159 base::WeakPtr<SerialIoHandlerWin> io_handler, 160 base::WeakPtr<SerialIoHandlerWin> io_handler,
160 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner) 161 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner)
161 : device_observer_(this), 162 : device_observer_(this),
162 io_handler_(io_handler), 163 io_handler_(io_handler),
163 io_thread_task_runner_(io_thread_task_runner) {} 164 io_thread_task_runner_(io_thread_task_runner) {}
164 165
165 ~UiThreadHelper() { DCHECK(thread_checker_.CalledOnValidThread()); } 166 ~UiThreadHelper() { DCHECK(thread_checker_.CalledOnValidThread()); }
166 167
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 } 362 }
362 return true; 363 return true;
363 } 364 }
364 365
365 SerialIoHandlerWin::SerialIoHandlerWin( 366 SerialIoHandlerWin::SerialIoHandlerWin(
366 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner, 367 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner,
367 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner) 368 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner)
368 : SerialIoHandler(file_thread_task_runner, ui_thread_task_runner), 369 : SerialIoHandler(file_thread_task_runner, ui_thread_task_runner),
369 event_mask_(0), 370 event_mask_(0),
370 is_comm_pending_(false), 371 is_comm_pending_(false),
372 helper_(nullptr),
371 weak_factory_(this) {} 373 weak_factory_(this) {}
372 374
373 SerialIoHandlerWin::~SerialIoHandlerWin() { 375 SerialIoHandlerWin::~SerialIoHandlerWin() {
374 ui_thread_task_runner()->DeleteSoon(FROM_HERE, helper_); 376 ui_thread_task_runner()->DeleteSoon(FROM_HERE, helper_);
375 } 377 }
376 378
377 void SerialIoHandlerWin::OnIOCompleted( 379 void SerialIoHandlerWin::OnIOCompleted(
378 base::MessageLoopForIO::IOContext* context, 380 base::MessageLoopForIO::IOContext* context,
379 DWORD bytes_transferred, 381 DWORD bytes_transferred,
380 DWORD error) { 382 DWORD error) {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 std::string SerialIoHandler::MaybeFixUpPortName(const std::string& port_name) { 533 std::string SerialIoHandler::MaybeFixUpPortName(const std::string& port_name) {
532 // For COM numbers less than 9, CreateFile is called with a string such as 534 // For COM numbers less than 9, CreateFile is called with a string such as
533 // "COM1". For numbers greater than 9, a prefix of "\\\\.\\" must be added. 535 // "COM1". For numbers greater than 9, a prefix of "\\\\.\\" must be added.
534 if (port_name.length() > std::string("COM9").length()) 536 if (port_name.length() > std::string("COM9").length())
535 return std::string("\\\\.\\").append(port_name); 537 return std::string("\\\\.\\").append(port_name);
536 538
537 return port_name; 539 return port_name;
538 } 540 }
539 541
540 } // namespace device 542 } // namespace device
OLDNEW
« no previous file with comments | « device/serial/serial_io_handler_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698