diff options
author | gdk@chromium.org <gdk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-07 05:34:16 +0000 |
---|---|---|
committer | gdk@chromium.org <gdk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-07 05:34:16 +0000 |
commit | 926957b72bee0ee2b268d946bc0ae25047e92539 (patch) | |
tree | 9ad6c5dec928ebdaf64299aeebecf0505c32df30 /chromeos | |
parent | e94bbcbf1ed35d9636c59962acf7aa00d86fa181 (diff) | |
download | chromium_src-926957b72bee0ee2b268d946bc0ae25047e92539.zip chromium_src-926957b72bee0ee2b268d946bc0ae25047e92539.tar.gz chromium_src-926957b72bee0ee2b268d946bc0ae25047e92539.tar.bz2 |
Cleaning up weak_ptr_factory destruction order.
BUG=none
TEST=none
Review URL: https://chromiumcodereview.appspot.com/10917115
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155319 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
29 files changed, 147 insertions, 74 deletions
diff --git a/chromeos/dbus/bluetooth_adapter_client.cc b/chromeos/dbus/bluetooth_adapter_client.cc index bfbe2a1..f6138f7 100644 --- a/chromeos/dbus/bluetooth_adapter_client.cc +++ b/chromeos/dbus/bluetooth_adapter_client.cc @@ -58,8 +58,8 @@ class BluetoothAdapterClientImpl: public BluetoothAdapterClient, public: explicit BluetoothAdapterClientImpl(dbus::Bus* bus, BluetoothManagerClient* manager_client) - : weak_ptr_factory_(this), - bus_(bus) { + : bus_(bus), + weak_ptr_factory_(this) { DVLOG(1) << "Creating BluetoothAdapterClientImpl"; DCHECK(manager_client); @@ -715,15 +715,17 @@ class BluetoothAdapterClientImpl: public BluetoothAdapterClient, callback.Run(object_path, response); } - // Weak pointer factory for generating 'this' pointers that might live longer - // than we do. - base::WeakPtrFactory<BluetoothAdapterClientImpl> weak_ptr_factory_; - dbus::Bus* bus_; // List of observers interested in event notifications from us. ObserverList<BluetoothAdapterClient::Observer> observers_; + // Weak pointer factory for generating 'this' pointers that might live longer + // than we do. + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. + base::WeakPtrFactory<BluetoothAdapterClientImpl> weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterClientImpl); }; diff --git a/chromeos/dbus/bluetooth_agent_service_provider.cc b/chromeos/dbus/bluetooth_agent_service_provider.cc index aea7291..9543cc5 100644 --- a/chromeos/dbus/bluetooth_agent_service_provider.cc +++ b/chromeos/dbus/bluetooth_agent_service_provider.cc @@ -34,11 +34,11 @@ class BluetoothAgentServiceProviderImpl : public BluetoothAgentServiceProvider { BluetoothAgentServiceProviderImpl(dbus::Bus* bus, const dbus::ObjectPath& object_path, Delegate* delegate) - : weak_ptr_factory_(this), - origin_thread_id_(base::PlatformThread::CurrentId()), + : origin_thread_id_(base::PlatformThread::CurrentId()), bus_(bus), delegate_(delegate), - object_path_(object_path) { + object_path_(object_path), + weak_ptr_factory_(this) { DVLOG(1) << "Creating BluetoothAdapterClientImpl for " << object_path.value(); @@ -509,10 +509,6 @@ class BluetoothAgentServiceProviderImpl : public BluetoothAgentServiceProvider { } } - // Weak pointer factory for generating 'this' pointers that might live longer - // than we do. - base::WeakPtrFactory<BluetoothAgentServiceProviderImpl> weak_ptr_factory_; - // Origin thread (i.e. the UI thread in production). base::PlatformThreadId origin_thread_id_; @@ -532,6 +528,12 @@ class BluetoothAgentServiceProviderImpl : public BluetoothAgentServiceProvider { // D-Bus object we are exporting, owned by this object. scoped_refptr<dbus::ExportedObject> exported_object_; + // Weak pointer factory for generating 'this' pointers that might live longer + // than we do. + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. + base::WeakPtrFactory<BluetoothAgentServiceProviderImpl> weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(BluetoothAgentServiceProviderImpl); }; diff --git a/chromeos/dbus/bluetooth_device_client.cc b/chromeos/dbus/bluetooth_device_client.cc index 10bda3f..df237e8 100644 --- a/chromeos/dbus/bluetooth_device_client.cc +++ b/chromeos/dbus/bluetooth_device_client.cc @@ -55,8 +55,8 @@ class BluetoothDeviceClientImpl: public BluetoothDeviceClient, public: BluetoothDeviceClientImpl(dbus::Bus* bus, BluetoothAdapterClient* adapter_client) - : weak_ptr_factory_(this), - bus_(bus) { + : bus_(bus), + weak_ptr_factory_(this) { DVLOG(1) << "Creating BluetoothDeviceClientImpl"; DCHECK(adapter_client); @@ -449,15 +449,17 @@ class BluetoothDeviceClientImpl: public BluetoothDeviceClient, callback.Run(object_path, response); } - // Weak pointer factory for generating 'this' pointers that might live longer - // than we do. - base::WeakPtrFactory<BluetoothDeviceClientImpl> weak_ptr_factory_; - dbus::Bus* bus_; // List of observers interested in event notifications from us. ObserverList<BluetoothDeviceClient::Observer> observers_; + // Weak pointer factory for generating 'this' pointers that might live longer + // than we do. + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. + base::WeakPtrFactory<BluetoothDeviceClientImpl> weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceClientImpl); }; diff --git a/chromeos/dbus/bluetooth_input_client.cc b/chromeos/dbus/bluetooth_input_client.cc index 31992b7..62d370d 100644 --- a/chromeos/dbus/bluetooth_input_client.cc +++ b/chromeos/dbus/bluetooth_input_client.cc @@ -42,8 +42,8 @@ class BluetoothInputClientImpl: public BluetoothInputClient, public: BluetoothInputClientImpl(dbus::Bus* bus, BluetoothAdapterClient* adapter_client) - : weak_ptr_factory_(this), - bus_(bus) { + : bus_(bus), + weak_ptr_factory_(this) { DVLOG(1) << "Creating BluetoothInputClientImpl"; DCHECK(adapter_client); @@ -226,15 +226,17 @@ class BluetoothInputClientImpl: public BluetoothInputClient, callback.Run(object_path, response); } - // Weak pointer factory for generating 'this' pointers that might live longer - // than we do. - base::WeakPtrFactory<BluetoothInputClientImpl> weak_ptr_factory_; - dbus::Bus* bus_; // List of observers interested in event notifications from us. ObserverList<BluetoothInputClient::Observer> observers_; + // Weak pointer factory for generating 'this' pointers that might live longer + // than we do. + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. + base::WeakPtrFactory<BluetoothInputClientImpl> weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(BluetoothInputClientImpl); }; diff --git a/chromeos/dbus/bluetooth_manager_client.cc b/chromeos/dbus/bluetooth_manager_client.cc index 7ea4a75..bd09f4d 100644 --- a/chromeos/dbus/bluetooth_manager_client.cc +++ b/chromeos/dbus/bluetooth_manager_client.cc @@ -35,8 +35,8 @@ BluetoothManagerClient::Properties::~Properties() { class BluetoothManagerClientImpl : public BluetoothManagerClient { public: explicit BluetoothManagerClientImpl(dbus::Bus* bus) - : weak_ptr_factory_(this), - object_proxy_(NULL) { + : object_proxy_(NULL), + weak_ptr_factory_(this) { DVLOG(1) << "Creating BluetoothManagerClientImpl"; // Create the object proxy. @@ -254,10 +254,6 @@ class BluetoothManagerClientImpl : public BluetoothManagerClient { callback.Run(object_path, success); } - // Weak pointer factory for generating 'this' pointers that might live longer - // than we do. - base::WeakPtrFactory<BluetoothManagerClientImpl> weak_ptr_factory_; - // D-Bus proxy for BlueZ Manager interface. dbus::ObjectProxy* object_proxy_; @@ -267,6 +263,12 @@ class BluetoothManagerClientImpl : public BluetoothManagerClient { // List of observers interested in event notifications from us. ObserverList<Observer> observers_; + // Weak pointer factory for generating 'this' pointers that might live longer + // than we do. + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. + base::WeakPtrFactory<BluetoothManagerClientImpl> weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(BluetoothManagerClientImpl); }; diff --git a/chromeos/dbus/bluetooth_node_client.cc b/chromeos/dbus/bluetooth_node_client.cc index 46111d6..3b70ea1 100644 --- a/chromeos/dbus/bluetooth_node_client.cc +++ b/chromeos/dbus/bluetooth_node_client.cc @@ -40,8 +40,8 @@ class BluetoothNodeClientImpl: public BluetoothNodeClient, public: BluetoothNodeClientImpl(dbus::Bus* bus, BluetoothDeviceClient* device_client) - : weak_ptr_factory_(this), - bus_(bus) { + : bus_(bus), + weak_ptr_factory_(this) { DVLOG(1) << "Creating BluetoothNodeClientImpl"; DCHECK(device_client); @@ -152,15 +152,17 @@ class BluetoothNodeClientImpl: public BluetoothNodeClient, NodePropertyChanged(object_path, property_name)); } - // Weak pointer factory for generating 'this' pointers that might live longer - // than we do. - base::WeakPtrFactory<BluetoothNodeClientImpl> weak_ptr_factory_; - dbus::Bus* bus_; // List of observers interested in event notifications from us. ObserverList<BluetoothNodeClient::Observer> observers_; + // Weak pointer factory for generating 'this' pointers that might live longer + // than we do. + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. + base::WeakPtrFactory<BluetoothNodeClientImpl> weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(BluetoothNodeClientImpl); }; diff --git a/chromeos/dbus/bluetooth_out_of_band_client.cc b/chromeos/dbus/bluetooth_out_of_band_client.cc index 15768ed..1d80e73 100644 --- a/chromeos/dbus/bluetooth_out_of_band_client.cc +++ b/chromeos/dbus/bluetooth_out_of_band_client.cc @@ -22,8 +22,8 @@ namespace chromeos { class BluetoothOutOfBandClientImpl: public BluetoothOutOfBandClient { public: explicit BluetoothOutOfBandClientImpl(dbus::Bus* bus) - : weak_ptr_factory_(this), - bus_(bus) {} + : bus_(bus), + weak_ptr_factory_(this) {} virtual ~BluetoothOutOfBandClientImpl() {} @@ -141,12 +141,14 @@ class BluetoothOutOfBandClientImpl: public BluetoothOutOfBandClient { callback.Run(response != NULL); } + dbus::Bus* bus_; + // Weak pointer factory for generating 'this' pointers that might live longer // than we do. + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. base::WeakPtrFactory<BluetoothOutOfBandClientImpl> weak_ptr_factory_; - dbus::Bus* bus_; - DISALLOW_COPY_AND_ASSIGN(BluetoothOutOfBandClientImpl); }; diff --git a/chromeos/dbus/cashew_client.cc b/chromeos/dbus/cashew_client.cc index 92f3db5..0b67425 100644 --- a/chromeos/dbus/cashew_client.cc +++ b/chromeos/dbus/cashew_client.cc @@ -88,9 +88,12 @@ class CashewClientImpl : public CashewClient { } dbus::ObjectProxy* proxy_; - base::WeakPtrFactory<CashewClientImpl> weak_ptr_factory_; DataPlansUpdateHandler data_plans_update_handler_; + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. + base::WeakPtrFactory<CashewClientImpl> weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(CashewClientImpl); }; diff --git a/chromeos/dbus/cros_disks_client.cc b/chromeos/dbus/cros_disks_client.cc index fafec90..708ce9d 100644 --- a/chromeos/dbus/cros_disks_client.cc +++ b/chromeos/dbus/cros_disks_client.cc @@ -378,6 +378,9 @@ class CrosDisksClientImpl : public CrosDisksClient { } dbus::ObjectProxy* proxy_; + + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. base::WeakPtrFactory<CrosDisksClientImpl> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(CrosDisksClientImpl); diff --git a/chromeos/dbus/cryptohome_client.cc b/chromeos/dbus/cryptohome_client.cc index 7b1f1df..031344a 100644 --- a/chromeos/dbus/cryptohome_client.cc +++ b/chromeos/dbus/cryptohome_client.cc @@ -30,8 +30,8 @@ class CryptohomeClientImpl : public CryptohomeClient { : proxy_(bus->GetObjectProxy( cryptohome::kCryptohomeServiceName, dbus::ObjectPath(cryptohome::kCryptohomeServicePath))), - weak_ptr_factory_(this), - blocking_method_caller_(bus, proxy_) { + blocking_method_caller_(bus, proxy_), + weak_ptr_factory_(this) { proxy_->ConnectToSignal( cryptohome::kCryptohomeInterface, cryptohome::kSignalAsyncCallStatus, @@ -424,10 +424,13 @@ class CryptohomeClientImpl : public CryptohomeClient { } dbus::ObjectProxy* proxy_; - base::WeakPtrFactory<CryptohomeClientImpl> weak_ptr_factory_; BlockingMethodCaller blocking_method_caller_; AsyncCallStatusHandler async_call_status_handler_; + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. + base::WeakPtrFactory<CryptohomeClientImpl> weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(CryptohomeClientImpl); }; @@ -435,10 +438,10 @@ class CryptohomeClientImpl : public CryptohomeClient { class CryptohomeClientStubImpl : public CryptohomeClient { public: CryptohomeClientStubImpl() - : weak_ptr_factory_(this), - async_call_id_(1), + : async_call_id_(1), tpm_is_ready_counter_(0), - locked_(false) { + locked_(false), + weak_ptr_factory_(this) { } virtual ~CryptohomeClientStubImpl() {} @@ -647,12 +650,12 @@ class CryptohomeClientStubImpl : public CryptohomeClient { ++async_call_id_; } - base::WeakPtrFactory<CryptohomeClientStubImpl> weak_ptr_factory_; int async_call_id_; AsyncCallStatusHandler async_call_status_handler_; int tpm_is_ready_counter_; std::map<std::string, std::vector<uint8> > install_attrs_; bool locked_; + base::WeakPtrFactory<CryptohomeClientStubImpl> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(CryptohomeClientStubImpl); }; diff --git a/chromeos/dbus/debug_daemon_client.cc b/chromeos/dbus/debug_daemon_client.cc index 4b7571d..23813a8 100644 --- a/chromeos/dbus/debug_daemon_client.cc +++ b/chromeos/dbus/debug_daemon_client.cc @@ -45,8 +45,8 @@ class PipeReader { explicit PipeReader(IOCompleteCallback callback) : data_stream_(NULL), io_buffer_(new net::IOBufferWithSize(4096)), - weak_ptr_factory_(this), - callback_(callback) { + callback_(callback), + weak_ptr_factory_(this) { pipe_fd_[0] = pipe_fd_[1] = -1; } @@ -125,10 +125,13 @@ class PipeReader { int pipe_fd_[2]; scoped_ptr<net::FileStream> data_stream_; scoped_refptr<net::IOBufferWithSize> io_buffer_; - base::WeakPtrFactory<PipeReader> weak_ptr_factory_; std::string data_; IOCompleteCallback callback_; + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. + base::WeakPtrFactory<PipeReader> weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(PipeReader); }; @@ -141,8 +144,8 @@ class DebugDaemonClientImpl : public DebugDaemonClient { public: explicit DebugDaemonClientImpl(dbus::Bus* bus) : debugdaemon_proxy_(NULL), - weak_ptr_factory_(this), - pipe_reader_(NULL) { + pipe_reader_(NULL), + weak_ptr_factory_(this) { debugdaemon_proxy_ = bus->GetObjectProxy( debugd::kDebugdServiceName, dbus::ObjectPath(debugd::kDebugdServicePath)); @@ -487,9 +490,9 @@ class DebugDaemonClientImpl : public DebugDaemonClient { } dbus::ObjectProxy* debugdaemon_proxy_; - base::WeakPtrFactory<DebugDaemonClientImpl> weak_ptr_factory_; scoped_ptr<PipeReader> pipe_reader_; StopSystemTracingCallback callback_; + base::WeakPtrFactory<DebugDaemonClientImpl> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(DebugDaemonClientImpl); }; diff --git a/chromeos/dbus/flimflam_client_helper.cc b/chromeos/dbus/flimflam_client_helper.cc index 6e9cef3..3696496 100644 --- a/chromeos/dbus/flimflam_client_helper.cc +++ b/chromeos/dbus/flimflam_client_helper.cc @@ -15,9 +15,9 @@ namespace chromeos { FlimflamClientHelper::FlimflamClientHelper(dbus::Bus* bus, dbus::ObjectProxy* proxy) - : weak_ptr_factory_(this), - blocking_method_caller_(bus, proxy), - proxy_(proxy) { + : blocking_method_caller_(bus, proxy), + proxy_(proxy), + weak_ptr_factory_(this) { } FlimflamClientHelper::~FlimflamClientHelper() { diff --git a/chromeos/dbus/flimflam_client_helper.h b/chromeos/dbus/flimflam_client_helper.h index 824096b..c2c0c23 100644 --- a/chromeos/dbus/flimflam_client_helper.h +++ b/chromeos/dbus/flimflam_client_helper.h @@ -146,12 +146,15 @@ class FlimflamClientHelper { void OnError(const ErrorCallback& error_callback, dbus::ErrorResponse* response); - base::WeakPtrFactory<FlimflamClientHelper> weak_ptr_factory_; // TODO(hashimoto): Remove this when we no longer need to make blocking calls. BlockingMethodCaller blocking_method_caller_; dbus::ObjectProxy* proxy_; PropertyChangedHandler property_changed_handler_; + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. + base::WeakPtrFactory<FlimflamClientHelper> weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(FlimflamClientHelper); }; diff --git a/chromeos/dbus/flimflam_device_client.cc b/chromeos/dbus/flimflam_device_client.cc index 54bc630..a6d6286 100644 --- a/chromeos/dbus/flimflam_device_client.cc +++ b/chromeos/dbus/flimflam_device_client.cc @@ -373,10 +373,13 @@ class FlimflamDeviceClientStubImpl : public FlimflamDeviceClient { base::Bind(callback, status)); } - base::WeakPtrFactory<FlimflamDeviceClientStubImpl> weak_ptr_factory_; // Dictionary of <device_name, Dictionary>. base::DictionaryValue stub_devices_; + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. + base::WeakPtrFactory<FlimflamDeviceClientStubImpl> weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(FlimflamDeviceClientStubImpl); }; diff --git a/chromeos/dbus/flimflam_ipconfig_client.cc b/chromeos/dbus/flimflam_ipconfig_client.cc index 9c6ca56..e3f8cbe 100644 --- a/chromeos/dbus/flimflam_ipconfig_client.cc +++ b/chromeos/dbus/flimflam_ipconfig_client.cc @@ -245,9 +245,12 @@ class FlimflamIPConfigClientStubImpl : public FlimflamIPConfigClient { callback.Run(DBUS_METHOD_CALL_SUCCESS, properties_); } - base::WeakPtrFactory<FlimflamIPConfigClientStubImpl> weak_ptr_factory_; base::DictionaryValue properties_; + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. + base::WeakPtrFactory<FlimflamIPConfigClientStubImpl> weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(FlimflamIPConfigClientStubImpl); }; diff --git a/chromeos/dbus/flimflam_manager_client.cc b/chromeos/dbus/flimflam_manager_client.cc index e7cfacb..034d01e 100644 --- a/chromeos/dbus/flimflam_manager_client.cc +++ b/chromeos/dbus/flimflam_manager_client.cc @@ -244,9 +244,12 @@ class FlimflamManagerClientStubImpl : public FlimflamManagerClient { callback.Run(DBUS_METHOD_CALL_SUCCESS, stub_properties_); } - base::WeakPtrFactory<FlimflamManagerClientStubImpl> weak_ptr_factory_; base::DictionaryValue stub_properties_; + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. + base::WeakPtrFactory<FlimflamManagerClientStubImpl> weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(FlimflamManagerClientStubImpl); }; diff --git a/chromeos/dbus/flimflam_network_client.cc b/chromeos/dbus/flimflam_network_client.cc index 53c01f1..2059807 100644 --- a/chromeos/dbus/flimflam_network_client.cc +++ b/chromeos/dbus/flimflam_network_client.cc @@ -120,6 +120,8 @@ class FlimflamNetworkClientStubImpl : public FlimflamNetworkClient { callback.Run(DBUS_METHOD_CALL_SUCCESS, dictionary); } + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. base::WeakPtrFactory<FlimflamNetworkClientStubImpl> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(FlimflamNetworkClientStubImpl); diff --git a/chromeos/dbus/flimflam_profile_client.cc b/chromeos/dbus/flimflam_profile_client.cc index b48f39e..6de3ab2 100644 --- a/chromeos/dbus/flimflam_profile_client.cc +++ b/chromeos/dbus/flimflam_profile_client.cc @@ -164,6 +164,8 @@ class FlimflamProfileClientStubImpl : public FlimflamProfileClient { callback.Run(DBUS_METHOD_CALL_SUCCESS, dictionary); } + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. base::WeakPtrFactory<FlimflamProfileClientStubImpl> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(FlimflamProfileClientStubImpl); diff --git a/chromeos/dbus/flimflam_service_client.cc b/chromeos/dbus/flimflam_service_client.cc index 6360792..15a5b8a 100644 --- a/chromeos/dbus/flimflam_service_client.cc +++ b/chromeos/dbus/flimflam_service_client.cc @@ -257,6 +257,8 @@ class FlimflamServiceClientStubImpl : public FlimflamServiceClient { DBUS_METHOD_CALL_SUCCESS)); } + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. base::WeakPtrFactory<FlimflamServiceClientStubImpl> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(FlimflamServiceClientStubImpl); diff --git a/chromeos/dbus/gsm_sms_client.cc b/chromeos/dbus/gsm_sms_client.cc index 2632c9c..b0510aa 100644 --- a/chromeos/dbus/gsm_sms_client.cc +++ b/chromeos/dbus/gsm_sms_client.cc @@ -152,9 +152,12 @@ class SMSProxy { } dbus::ObjectProxy* proxy_; - base::WeakPtrFactory<SMSProxy> weak_ptr_factory_; SmsReceivedHandler sms_received_handler_; + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. + base::WeakPtrFactory<SMSProxy> weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(SMSProxy); }; diff --git a/chromeos/dbus/image_burner_client.cc b/chromeos/dbus/image_burner_client.cc index 4119bf0..502a8e4 100644 --- a/chromeos/dbus/image_burner_client.cc +++ b/chromeos/dbus/image_burner_client.cc @@ -122,10 +122,13 @@ class ImageBurnerClientImpl : public ImageBurnerClient { } dbus::ObjectProxy* proxy_; - base::WeakPtrFactory<ImageBurnerClientImpl> weak_ptr_factory_; BurnFinishedHandler burn_finished_handler_; BurnProgressUpdateHandler burn_progress_update_handler_; + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. + base::WeakPtrFactory<ImageBurnerClientImpl> weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(ImageBurnerClientImpl); }; diff --git a/chromeos/dbus/introspectable_client.cc b/chromeos/dbus/introspectable_client.cc index 5f66684..dc6639f 100644 --- a/chromeos/dbus/introspectable_client.cc +++ b/chromeos/dbus/introspectable_client.cc @@ -33,8 +33,8 @@ namespace chromeos { class IntrospectableClientImpl : public IntrospectableClient { public: explicit IntrospectableClientImpl(dbus::Bus* bus) - : weak_ptr_factory_(this), - bus_(bus) { + : bus_(bus), + weak_ptr_factory_(this) { DVLOG(1) << "Creating IntrospectableClientImpl"; } @@ -81,12 +81,14 @@ class IntrospectableClientImpl : public IntrospectableClient { callback.Run(service_name, object_path, xml_data, success); } + dbus::Bus* bus_; + // Weak pointer factory for generating 'this' pointers that might live longer // than we do. + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. base::WeakPtrFactory<IntrospectableClientImpl> weak_ptr_factory_; - dbus::Bus* bus_; - DISALLOW_COPY_AND_ASSIGN(IntrospectableClientImpl); }; diff --git a/chromeos/dbus/media_transfer_protocol_daemon_client.cc b/chromeos/dbus/media_transfer_protocol_daemon_client.cc index db15791..954a59a 100644 --- a/chromeos/dbus/media_transfer_protocol_daemon_client.cc +++ b/chromeos/dbus/media_transfer_protocol_daemon_client.cc @@ -414,6 +414,9 @@ class MediaTransferProtocolDaemonClientImpl } dbus::ObjectProxy* proxy_; + + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. base::WeakPtrFactory<MediaTransferProtocolDaemonClientImpl> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(MediaTransferProtocolDaemonClientImpl); diff --git a/chromeos/dbus/modem_messaging_client.cc b/chromeos/dbus/modem_messaging_client.cc index cbb4b77..c542a57 100644 --- a/chromeos/dbus/modem_messaging_client.cc +++ b/chromeos/dbus/modem_messaging_client.cc @@ -33,8 +33,8 @@ class ModemMessagingProxy { const dbus::ObjectPath& object_path) : bus_(bus), proxy_(bus->GetObjectProxy(service_name, object_path)), - weak_ptr_factory_(this), - service_name_(service_name) { + service_name_(service_name), + weak_ptr_factory_(this) { proxy_->ConnectToSignal( modemmanager::kModemManager1MessagingInterface, modemmanager::kSMSAddedSignal, @@ -123,10 +123,13 @@ class ModemMessagingProxy { dbus::Bus* bus_; dbus::ObjectProxy* proxy_; - base::WeakPtrFactory<ModemMessagingProxy> weak_ptr_factory_; std::string service_name_; SmsReceivedHandler sms_received_handler_; + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. + base::WeakPtrFactory<ModemMessagingProxy> weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(ModemMessagingProxy); }; diff --git a/chromeos/dbus/power_manager_client.cc b/chromeos/dbus/power_manager_client.cc index 267ea0c..6b8c4af 100644 --- a/chromeos/dbus/power_manager_client.cc +++ b/chromeos/dbus/power_manager_client.cc @@ -500,6 +500,9 @@ class PowerManagerClientImpl : public PowerManagerClient { dbus::ObjectProxy* power_manager_proxy_; dbus::ObjectProxy* session_manager_proxy_; ObserverList<Observer> observers_; + + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. base::WeakPtrFactory<PowerManagerClientImpl> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(PowerManagerClientImpl); diff --git a/chromeos/dbus/session_manager_client.cc b/chromeos/dbus/session_manager_client.cc index 890a604..ef47500 100644 --- a/chromeos/dbus/session_manager_client.cc +++ b/chromeos/dbus/session_manager_client.cc @@ -323,6 +323,9 @@ class SessionManagerClientImpl : public SessionManagerClient { dbus::ObjectProxy* session_manager_proxy_; ObserverList<Observer> observers_; bool screen_locked_; + + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. base::WeakPtrFactory<SessionManagerClientImpl> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(SessionManagerClientImpl); diff --git a/chromeos/dbus/sms_client.cc b/chromeos/dbus/sms_client.cc index ee9fe10..9aa79f2 100644 --- a/chromeos/dbus/sms_client.cc +++ b/chromeos/dbus/sms_client.cc @@ -71,6 +71,9 @@ class SMSClientImpl : public SMSClient { } dbus::Bus* bus_; + + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. base::WeakPtrFactory<SMSClientImpl> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(SMSClientImpl); diff --git a/chromeos/dbus/speech_synthesizer_client.cc b/chromeos/dbus/speech_synthesizer_client.cc index a6a850a..8326920 100644 --- a/chromeos/dbus/speech_synthesizer_client.cc +++ b/chromeos/dbus/speech_synthesizer_client.cc @@ -98,6 +98,9 @@ class SpeechSynthesizerClientImpl : public SpeechSynthesizerClient { } dbus::ObjectProxy* proxy_; + + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. base::WeakPtrFactory<SpeechSynthesizerClientImpl> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(SpeechSynthesizerClientImpl); diff --git a/chromeos/dbus/update_engine_client.cc b/chromeos/dbus/update_engine_client.cc index 5e3e21a..abe897a 100644 --- a/chromeos/dbus/update_engine_client.cc +++ b/chromeos/dbus/update_engine_client.cc @@ -50,8 +50,8 @@ class UpdateEngineClientImpl : public UpdateEngineClient { public: explicit UpdateEngineClientImpl(dbus::Bus* bus) : update_engine_proxy_(NULL), - weak_ptr_factory_(this), - last_status_() { + last_status_(), + weak_ptr_factory_(this) { update_engine_proxy_ = bus->GetObjectProxy( update_engine::kUpdateEngineServiceName, dbus::ObjectPath(update_engine::kUpdateEngineServicePath)); @@ -242,9 +242,12 @@ class UpdateEngineClientImpl : public UpdateEngineClient { dbus::ObjectProxy* update_engine_proxy_; ObserverList<Observer> observers_; - base::WeakPtrFactory<UpdateEngineClientImpl> weak_ptr_factory_; Status last_status_; + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. + base::WeakPtrFactory<UpdateEngineClientImpl> weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(UpdateEngineClientImpl); }; |