Commit 945f5aa3 authored by mohan.reddy's avatar mohan.reddy Committed by Commit bot

Changing the order of initialization WeakPtrFactory

Changing in the intialization order of WeakPtrFactory such that all
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.

BUG=303818

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

Cr-Commit-Position: refs/heads/master@{#294319}
parent a4eb244b
...@@ -327,7 +327,6 @@ void CrasAudioHandler::LogErrors() { ...@@ -327,7 +327,6 @@ void CrasAudioHandler::LogErrors() {
CrasAudioHandler::CrasAudioHandler( CrasAudioHandler::CrasAudioHandler(
scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler) scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler)
: audio_pref_handler_(audio_pref_handler), : audio_pref_handler_(audio_pref_handler),
weak_ptr_factory_(this),
output_mute_on_(false), output_mute_on_(false),
input_mute_on_(false), input_mute_on_(false),
output_volume_(0), output_volume_(0),
...@@ -338,7 +337,8 @@ CrasAudioHandler::CrasAudioHandler( ...@@ -338,7 +337,8 @@ CrasAudioHandler::CrasAudioHandler(
has_alternative_output_(false), has_alternative_output_(false),
output_mute_locked_(false), output_mute_locked_(false),
input_mute_locked_(false), input_mute_locked_(false),
log_errors_(false) { log_errors_(false),
weak_ptr_factory_(this) {
if (!audio_pref_handler.get()) if (!audio_pref_handler.get())
return; return;
// If the DBusThreadManager or the CrasAudioClient aren't available, there // If the DBusThreadManager or the CrasAudioClient aren't available, there
......
...@@ -255,7 +255,6 @@ class CHROMEOS_EXPORT CrasAudioHandler : public CrasAudioClient::Observer, ...@@ -255,7 +255,6 @@ class CHROMEOS_EXPORT CrasAudioHandler : public CrasAudioClient::Observer,
AudioDevice GetSanitizedAudioDevice(const AudioNode& node); AudioDevice GetSanitizedAudioDevice(const AudioNode& node);
scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler_; scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler_;
base::WeakPtrFactory<CrasAudioHandler> weak_ptr_factory_;
ObserverList<AudioObserver> observers_; ObserverList<AudioObserver> observers_;
// Audio data and state. // Audio data and state.
...@@ -279,6 +278,8 @@ class CHROMEOS_EXPORT CrasAudioHandler : public CrasAudioClient::Observer, ...@@ -279,6 +278,8 @@ class CHROMEOS_EXPORT CrasAudioHandler : public CrasAudioClient::Observer,
// Failures are not logged at startup, since CRAS may not be running yet. // Failures are not logged at startup, since CRAS may not be running yet.
bool log_errors_; bool log_errors_;
base::WeakPtrFactory<CrasAudioHandler> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(CrasAudioHandler); DISALLOW_COPY_AND_ASSIGN(CrasAudioHandler);
}; };
......
...@@ -34,8 +34,8 @@ OnlineAttempt::OnlineAttempt(AuthAttemptState* current_attempt, ...@@ -34,8 +34,8 @@ OnlineAttempt::OnlineAttempt(AuthAttemptState* current_attempt,
: message_loop_(base::MessageLoopProxy::current()), : message_loop_(base::MessageLoopProxy::current()),
attempt_(current_attempt), attempt_(current_attempt),
resolver_(callback), resolver_(callback),
weak_factory_(this), try_again_(true),
try_again_(true) { weak_factory_(this) {
DCHECK(attempt_->user_type == user_manager::USER_TYPE_REGULAR); DCHECK(attempt_->user_type == user_manager::USER_TYPE_REGULAR);
} }
......
...@@ -68,12 +68,12 @@ class CHROMEOS_EXPORT OnlineAttempt : public GaiaAuthConsumer { ...@@ -68,12 +68,12 @@ class CHROMEOS_EXPORT OnlineAttempt : public GaiaAuthConsumer {
// Handles ClientLogin communications with Gaia. // Handles ClientLogin communications with Gaia.
scoped_ptr<GaiaAuthFetcher> client_fetcher_; scoped_ptr<GaiaAuthFetcher> client_fetcher_;
// Used to cancel the CancelClientLogin closure.
base::WeakPtrFactory<OnlineAttempt> weak_factory_;
// Whether we're willing to re-try the ClientLogin attempt. // Whether we're willing to re-try the ClientLogin attempt.
bool try_again_; bool try_again_;
// Used to cancel the CancelClientLogin closure.
base::WeakPtrFactory<OnlineAttempt> weak_factory_;
friend class OnlineAttemptTest; friend class OnlineAttemptTest;
DISALLOW_COPY_AND_ASSIGN(OnlineAttempt); DISALLOW_COPY_AND_ASSIGN(OnlineAttempt);
}; };
......
...@@ -20,7 +20,7 @@ const int kTpmCheckIntervalMs = 500; ...@@ -20,7 +20,7 @@ const int kTpmCheckIntervalMs = 500;
} // namespace } // namespace
TpmPasswordFetcher::TpmPasswordFetcher(TpmPasswordFetcherDelegate* delegate) TpmPasswordFetcher::TpmPasswordFetcher(TpmPasswordFetcherDelegate* delegate)
: weak_factory_(this), delegate_(delegate) { : delegate_(delegate), weak_factory_(this) {
DCHECK(delegate_); DCHECK(delegate_);
} }
......
...@@ -45,9 +45,10 @@ class CHROMEOS_EXPORT TpmPasswordFetcher { ...@@ -45,9 +45,10 @@ class CHROMEOS_EXPORT TpmPasswordFetcher {
// Posts a task to call Fetch() later. // Posts a task to call Fetch() later.
void RescheduleFetch(); void RescheduleFetch();
base::WeakPtrFactory<TpmPasswordFetcher> weak_factory_;
TpmPasswordFetcherDelegate* delegate_; TpmPasswordFetcherDelegate* delegate_;
base::WeakPtrFactory<TpmPasswordFetcher> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(TpmPasswordFetcher); DISALLOW_COPY_AND_ASSIGN(TpmPasswordFetcher);
}; };
......
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