Commit db730725 authored by Nico Weber's avatar Nico Weber

Make SerialIoHandlerWin::UiThreadHelper final.

Fixes the clang/win build after https://codereview.chromium.org/1439443002/
clang rightfully complains that UiThreadHelper has virtual methods, is
deleted polymorphically, and doesn't have a virtual destructor:

..\..\base/sequenced_task_runner_helpers.h(40,5) :  error: delete called on 'const device::SerialIoHandlerWin::UiThreadHelper' that has virtual functions but non-virtual destructor [-Werror,-Wdelete-non-virtual-dtor]
    delete reinterpret_cast<const T*>(object);
    ^
..\..\base/sequenced_task_runner_helpers.h(86,38) :  note: in instantiation of member function 'base::DeleteHelper<device::SerialIoHandlerWin::UiThreadHelper>::DoDelete' requested here
        from_here, &DeleteHelper<T>::DoDelete, object);
                                     ^
..\..\base/sequenced_task_runner.h(126,48) :  note: in instantiation of function template specialization 'base::subtle::DeleteHelperInternal<device::SerialIoHandlerWin::UiThreadHelper, bool>::DeleteViaSequencedTaskRunner<base::SequencedTaskRunner>' requested here
        subtle::DeleteHelperInternal<T, bool>::DeleteViaSequencedTaskRunner(
                                               ^
..\..\device\serial\serial_io_handler_win.cc(374,28) :  note: in instantiation of function template specialization 'base::SequencedTaskRunner::DeleteSoon<device::SerialIoHandlerWin::UiThreadHelper>' requested here
  ui_thread_task_runner()->DeleteSoon(FROM_HERE, helper_);
                           ^

Making the class final fixes this as it makes sure that nobody adds
a subclass of UiThreadHelper.

Also don't mix initializer styles for the different fields of this
class.

No intended behavior change.

BUG=82385
TBR=juncai

Review URL: https://codereview.chromium.org/1470983002 .

Cr-Commit-Position: refs/heads/master@{#361117}
parent 7c6424ea
...@@ -153,7 +153,8 @@ scoped_refptr<SerialIoHandler> SerialIoHandler::Create( ...@@ -153,7 +153,8 @@ scoped_refptr<SerialIoHandler> SerialIoHandler::Create(
return new SerialIoHandlerWin(file_thread_task_runner, ui_thread_task_runner); return new SerialIoHandlerWin(file_thread_task_runner, ui_thread_task_runner);
} }
class SerialIoHandlerWin::UiThreadHelper : public DeviceMonitorWin::Observer { class SerialIoHandlerWin::UiThreadHelper final
: public DeviceMonitorWin::Observer {
public: public:
UiThreadHelper( UiThreadHelper(
base::WeakPtr<SerialIoHandlerWin> io_handler, base::WeakPtr<SerialIoHandlerWin> io_handler,
...@@ -368,6 +369,7 @@ SerialIoHandlerWin::SerialIoHandlerWin( ...@@ -368,6 +369,7 @@ SerialIoHandlerWin::SerialIoHandlerWin(
: SerialIoHandler(file_thread_task_runner, ui_thread_task_runner), : SerialIoHandler(file_thread_task_runner, ui_thread_task_runner),
event_mask_(0), event_mask_(0),
is_comm_pending_(false), is_comm_pending_(false),
helper_(nullptr),
weak_factory_(this) {} weak_factory_(this) {}
SerialIoHandlerWin::~SerialIoHandlerWin() { SerialIoHandlerWin::~SerialIoHandlerWin() {
......
...@@ -66,7 +66,7 @@ class SerialIoHandlerWin : public SerialIoHandler, ...@@ -66,7 +66,7 @@ class SerialIoHandlerWin : public SerialIoHandler,
// The helper lives on the UI thread and holds a weak reference back to the // The helper lives on the UI thread and holds a weak reference back to the
// handler that owns it. // handler that owns it.
UiThreadHelper* helper_ = nullptr; UiThreadHelper* helper_;
base::WeakPtrFactory<SerialIoHandlerWin> weak_factory_; base::WeakPtrFactory<SerialIoHandlerWin> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(SerialIoHandlerWin); DISALLOW_COPY_AND_ASSIGN(SerialIoHandlerWin);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment