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

Unified Diff: tools/android/forwarder2/device_controller.h

Issue 555093002: Fix WeakPtrFactory ordering problems in src/tools (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added the comment explaining WeakPtrFactory ordering Created 6 years, 3 months 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
« no previous file with comments | « no previous file | tools/android/forwarder2/device_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
};
« no previous file with comments | « no previous file | tools/android/forwarder2/device_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698