Index: tools/android/forwarder2/device_controller.h |
diff --git a/tools/android/forwarder2/device_controller.h b/tools/android/forwarder2/device_controller.h |
index b1441d81a789c18fba3dc22f8a0224859c63f571..567a08d936b695625e95ccf6477bc3edcecbf006 100644 |
--- a/tools/android/forwarder2/device_controller.h |
+++ b/tools/android/forwarder2/device_controller.h |
@@ -49,7 +49,6 @@ class DeviceController { |
const base::WeakPtr<DeviceController>& device_controller_ptr, |
scoped_ptr<DeviceListener> device_listener); |
- base::WeakPtrFactory<DeviceController> weak_ptr_factory_; |
const scoped_ptr<Socket> host_socket_; |
// Used to notify the controller to exit. |
const int exit_notifier_fd_; |
@@ -58,6 +57,12 @@ class DeviceController { |
const scoped_refptr<base::SingleThreadTaskRunner> construction_task_runner_; |
ListenersMap listeners_; |
+ //WeakPtrFactory's documentation says: |
+ // Member variables should appear before the WeakPtrFactory, to ensure |
+ // that any WeakPtrs to Controller are invalidated before its members |
+ // variable's destructors are executed, rendering them invalid. |
+ base::WeakPtrFactory<DeviceController> weak_ptr_factory_; |
+ |
DISALLOW_COPY_AND_ASSIGN(DeviceController); |
}; |