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

Unified Diff: device/serial/serial_io_handler_win.h

Issue 1439443002: Reland: Add code to deal with serial device disconnection detection on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated code to call thread helper from UI thread 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 side-by-side diff with in-line comments
Download patch
Index: device/serial/serial_io_handler_win.h
diff --git a/device/serial/serial_io_handler_win.h b/device/serial/serial_io_handler_win.h
index 7f438b53ae4a83f74252bfe6013407d625da4a76..6c160addefe2d607423b7728837d8ece10c9df1a 100644
--- a/device/serial/serial_io_handler_win.h
+++ b/device/serial/serial_io_handler_win.h
@@ -15,6 +15,9 @@ namespace device {
class SerialIoHandlerWin : public SerialIoHandler,
public base::MessageLoopForIO::IOHandler {
+ public:
+ class UiThreadHelper;
Reilly Grant (use Gerrit) 2015/11/11 20:43:59 This class should be private.
juncai 2015/11/12 05:27:08 Done.
+
protected:
// SerialIoHandler implementation.
void ReadImpl() override;
@@ -44,6 +47,8 @@ class SerialIoHandlerWin : public SerialIoHandler,
DWORD bytes_transfered,
DWORD error) override;
+ void RemoveDevice(const std::string& device_path);
Reilly Grant (use Gerrit) 2015/11/11 20:43:59 s/RemoveDevice/OnDeviceRemoved/
juncai 2015/11/12 05:27:08 Done.
+
// Context used for asynchronous WaitCommEvent calls.
scoped_ptr<base::MessageLoopForIO::IOContext> comm_context_;
@@ -61,6 +66,11 @@ class SerialIoHandlerWin : public SerialIoHandler,
// after a corresponding WaitCommEvent has completed.
bool is_comm_pending_;
+ // The helper lives on the UI thread and holds a weak reference back to the
+ // handler that owns it.
+ UiThreadHelper* helper_;
+ base::WeakPtrFactory<SerialIoHandlerWin> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(SerialIoHandlerWin);
};

Powered by Google App Engine
This is Rietveld 408576698