summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-11 17:41:50 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-11 17:41:50 +0000
commit3189377958c9c0df4383d1c65bb8a473d13ff7ac (patch)
tree7653187c9456ca7ac2cc4a2560aae34e12674cc5
parent18397cf678b5a11795fa0a6e8b0e5e8c4d502e98 (diff)
downloadchromium_src-3189377958c9c0df4383d1c65bb8a473d13ff7ac.zip
chromium_src-3189377958c9c0df4383d1c65bb8a473d13ff7ac.tar.gz
chromium_src-3189377958c9c0df4383d1c65bb8a473d13ff7ac.tar.bz2
base::Bind: Cleanup in chromeos/login.
BUG=none TEST=none R=csilv@chromium.org Review URL: http://codereview.chromium.org/8214003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104911 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/login/camera.cc58
-rw-r--r--chrome/browser/chromeos/login/camera.h5
-rw-r--r--chrome/browser/chromeos/login/cryptohome_op.cc39
-rw-r--r--chrome/browser/chromeos/login/cryptohome_op.h2
-rw-r--r--chrome/browser/chromeos/login/cryptohome_op_unittest.cc3
-rw-r--r--chrome/browser/chromeos/login/existing_user_controller.cc23
-rw-r--r--chrome/browser/chromeos/login/existing_user_controller.h3
-rw-r--r--chrome/browser/chromeos/login/google_authenticator.cc6
-rw-r--r--chrome/browser/chromeos/login/google_authenticator_unittest.cc13
-rw-r--r--chrome/browser/chromeos/login/image_decoder.cc5
-rw-r--r--chrome/browser/chromeos/login/login_performer.cc52
-rw-r--r--chrome/browser/chromeos/login/login_performer.h4
-rw-r--r--chrome/browser/chromeos/login/mock_auth_response_handler.cc9
-rw-r--r--chrome/browser/chromeos/login/mock_authenticator.cc11
-rw-r--r--chrome/browser/chromeos/login/mock_url_fetchers.cc7
-rw-r--r--chrome/browser/chromeos/login/mock_url_fetchers.h5
-rw-r--r--chrome/browser/chromeos/login/new_user_view.cc9
-rw-r--r--chrome/browser/chromeos/login/new_user_view.h3
-rw-r--r--chrome/browser/chromeos/login/online_attempt.cc35
-rw-r--r--chrome/browser/chromeos/login/online_attempt.h5
-rw-r--r--chrome/browser/chromeos/login/online_attempt_unittest.cc24
-rw-r--r--chrome/browser/chromeos/login/owner_manager.cc28
-rw-r--r--chrome/browser/chromeos/login/owner_manager_unittest.cc48
-rw-r--r--chrome/browser/chromeos/login/ownership_service.cc39
-rw-r--r--chrome/browser/chromeos/login/ownership_status_checker.cc26
-rw-r--r--chrome/browser/chromeos/login/ownership_status_checker.h10
-rw-r--r--chrome/browser/chromeos/login/parallel_authenticator.cc100
-rw-r--r--chrome/browser/chromeos/login/parallel_authenticator_unittest.cc7
-rw-r--r--chrome/browser/chromeos/login/screen_locker.cc14
-rw-r--r--chrome/browser/chromeos/login/signed_settings.cc66
-rw-r--r--chrome/browser/chromeos/login/tpm_password_fetcher.cc7
-rw-r--r--chrome/browser/chromeos/login/tpm_password_fetcher.h4
-rw-r--r--chrome/browser/chromeos/login/user_image_loader.cc19
-rw-r--r--chrome/browser/chromeos/login/user_manager.cc49
-rw-r--r--chrome/browser/chromeos/login/user_manager.h4
-rw-r--r--chrome/browser/chromeos/login/wizard_controller.cc10
-rw-r--r--chrome/browser/chromeos/user_cros_settings_provider.cc34
-rw-r--r--chrome/browser/chromeos/user_cros_settings_provider.h13
38 files changed, 347 insertions, 452 deletions
diff --git a/chrome/browser/chromeos/login/camera.cc b/chrome/browser/chromeos/login/camera.cc
index 29c0be8..6c2bf45 100644
--- a/chrome/browser/chromeos/login/camera.cc
+++ b/chrome/browser/chromeos/login/camera.cc
@@ -20,6 +20,7 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/bind.h"
#include "base/logging.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
@@ -151,22 +152,16 @@ void Camera::ReportFailure() {
DCHECK(IsOnCameraThread());
if (device_descriptor_ == -1) {
BrowserThread::PostTask(
- BrowserThread::UI,
- FROM_HERE,
- NewRunnableMethod(this,
- &Camera::OnInitializeFailure));
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&Camera::OnInitializeFailure, this));
} else if (!is_capturing_) {
BrowserThread::PostTask(
- BrowserThread::UI,
- FROM_HERE,
- NewRunnableMethod(this,
- &Camera::OnStartCapturingFailure));
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&Camera::OnStartCapturingFailure, this));
} else {
BrowserThread::PostTask(
- BrowserThread::UI,
- FROM_HERE,
- NewRunnableMethod(this,
- &Camera::OnCaptureFailure));
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&Camera::OnCaptureFailure, this));
}
}
@@ -177,10 +172,7 @@ void Camera::Initialize(
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
PostCameraTaskWithDelay(
FROM_HERE,
- NewRunnableMethod(this,
- &Camera::DoInitialize,
- desired_width,
- desired_height),
+ base::Bind(&Camera::DoInitialize, this, desired_width, desired_height),
delay_in_ms);
}
@@ -253,14 +245,13 @@ void Camera::DoInitialize(int desired_width, int desired_height) {
desired_width_ = desired_width;
desired_height_ = desired_height;
BrowserThread::PostTask(
- BrowserThread::UI,
- FROM_HERE,
- NewRunnableMethod(this, &Camera::OnInitializeSuccess));
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&Camera::OnInitializeSuccess, this));
}
void Camera::Uninitialize() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- PostCameraTask(FROM_HERE, NewRunnableMethod(this, &Camera::DoUninitialize));
+ PostCameraTask(FROM_HERE, base::Bind(&Camera::DoUninitialize, this));
}
void Camera::DoUninitialize() {
@@ -278,8 +269,7 @@ void Camera::DoUninitialize() {
void Camera::StartCapturing() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- PostCameraTask(FROM_HERE,
- NewRunnableMethod(this, &Camera::DoStartCapturing));
+ PostCameraTask(FROM_HERE, base::Bind(&Camera::DoStartCapturing, this));
}
void Camera::DoStartCapturing() {
@@ -309,19 +299,15 @@ void Camera::DoStartCapturing() {
// No need to post DidProcessCameraThreadMethod() as this method is
// being posted instead.
BrowserThread::PostTask(
- BrowserThread::UI,
- FROM_HERE,
- NewRunnableMethod(this,
- &Camera::OnStartCapturingSuccess));
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&Camera::OnStartCapturingSuccess, this));
is_capturing_ = true;
- PostCameraTask(FROM_HERE,
- NewRunnableMethod(this, &Camera::OnCapture));
+ PostCameraTask(FROM_HERE, base::Bind(&Camera::OnCapture, this));
}
void Camera::StopCapturing() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- PostCameraTask(FROM_HERE,
- NewRunnableMethod(this, &Camera::DoStopCapturing));
+ PostCameraTask(FROM_HERE, base::Bind(&Camera::DoStopCapturing, this));
}
void Camera::DoStopCapturing() {
@@ -447,8 +433,7 @@ void Camera::OnCapture() {
// EAGAIN - continue select loop.
} while (!ReadFrame());
- PostCameraTask(FROM_HERE,
- NewRunnableMethod(this, &Camera::OnCapture));
+ PostCameraTask(FROM_HERE, base::Bind(&Camera::OnCapture, this));
}
bool Camera::ReadFrame() {
@@ -545,9 +530,8 @@ void Camera::ProcessImage(void* data) {
frame_image_.swap(image);
}
BrowserThread::PostTask(
- BrowserThread::UI,
- FROM_HERE,
- NewRunnableMethod(this, &Camera::OnCaptureSuccess));
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&Camera::OnCaptureSuccess, this));
}
void Camera::OnInitializeSuccess() {
@@ -592,13 +576,13 @@ bool Camera::IsOnCameraThread() const {
}
void Camera::PostCameraTask(const tracked_objects::Location& from_here,
- Task* task) {
+ const base::Closure& task) {
PostCameraTaskWithDelay(from_here, task, 0);
}
void Camera::PostCameraTaskWithDelay(
const tracked_objects::Location& from_here,
- Task* task,
+ const base::Closure& task,
int64 delay_in_ms) {
base::AutoLock lock(thread_lock_);
if (!thread_)
diff --git a/chrome/browser/chromeos/login/camera.h b/chrome/browser/chromeos/login/camera.h
index 038d210..9f78a31 100644
--- a/chrome/browser/chromeos/login/camera.h
+++ b/chrome/browser/chromeos/login/camera.h
@@ -10,6 +10,7 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/lock.h"
#include "base/threading/thread.h"
@@ -136,12 +137,12 @@ class Camera : public base::RefCountedThreadSafe<Camera> {
// Posts task to camera thread.
void PostCameraTask(
const tracked_objects::Location& from_here,
- Task* task);
+ const base::Closure& task);
// Same as above but the task is delayed.
void PostCameraTaskWithDelay(
const tracked_objects::Location& from_here,
- Task* task,
+ const base::Closure& task,
int64 delay_in_ms);
// Defines a buffer in memory where one frame from the camera is stored.
diff --git a/chrome/browser/chromeos/login/cryptohome_op.cc b/chrome/browser/chromeos/login/cryptohome_op.cc
index 56c9c39..00ac12c 100644
--- a/chrome/browser/chromeos/login/cryptohome_op.cc
+++ b/chrome/browser/chromeos/login/cryptohome_op.cc
@@ -6,6 +6,7 @@
#include <string>
+#include "base/bind.h"
#include "chrome/browser/chromeos/boot_times_loader.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/cryptohome_library.h"
@@ -29,9 +30,7 @@ void CryptohomeOp::OnComplete(bool success, int return_code) {
"CryptohomeMount-End", false);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(this,
- &CryptohomeOp::TriggerResolve,
- success, return_code));
+ base::Bind(&CryptohomeOp::TriggerResolve, this, success, return_code));
}
void CryptohomeOp::TriggerResolve(bool success, int return_code) {
@@ -51,15 +50,13 @@ class MountAttempt : public CryptohomeOp {
virtual ~MountAttempt() {}
- bool Initiate() {
+ void Initiate() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
chromeos::BootTimesLoader::Get()->AddLoginTimeMarker(
"CryptohomeMount-Start", false);
CryptohomeLibrary* lib = CrosLibrary::Get()->GetCryptohomeLibrary();
- return lib->AsyncMount(attempt_->username,
- attempt_->ascii_hash,
- create_if_missing_,
- this);
+ lib->AsyncMount(attempt_->username, attempt_->ascii_hash,
+ create_if_missing_, this);
}
private:
@@ -76,10 +73,10 @@ class MountGuestAttempt : public CryptohomeOp {
virtual ~MountGuestAttempt() {}
- bool Initiate() {
+ void Initiate() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
CryptohomeLibrary* lib = CrosLibrary::Get()->GetCryptohomeLibrary();
- return lib->AsyncMountForBwsi(this);
+ lib->AsyncMountForBwsi(this);
}
private:
@@ -100,19 +97,15 @@ class MigrateAttempt : public CryptohomeOp {
virtual ~MigrateAttempt() {}
- bool Initiate() {
+ void Initiate() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
CryptohomeLibrary* lib = CrosLibrary::Get()->GetCryptohomeLibrary();
if (is_old_hash_) {
- return lib->AsyncMigrateKey(attempt_->username,
- hash_,
- attempt_->ascii_hash,
- this);
+ lib->AsyncMigrateKey(attempt_->username, hash_, attempt_->ascii_hash,
+ this);
} else {
- return lib->AsyncMigrateKey(attempt_->username,
- attempt_->ascii_hash,
- hash_,
- this);
+ lib->AsyncMigrateKey(attempt_->username, attempt_->ascii_hash, hash_,
+ this);
}
}
@@ -132,10 +125,10 @@ class RemoveAttempt : public CryptohomeOp {
virtual ~RemoveAttempt() {}
- bool Initiate() {
+ void Initiate() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
CryptohomeLibrary* lib = CrosLibrary::Get()->GetCryptohomeLibrary();
- return lib->AsyncRemove(attempt_->username, this);
+ lib->AsyncRemove(attempt_->username, this);
}
private:
@@ -151,10 +144,10 @@ class CheckKeyAttempt : public CryptohomeOp {
virtual ~CheckKeyAttempt() {}
- bool Initiate() {
+ void Initiate() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
CryptohomeLibrary* lib = CrosLibrary::Get()->GetCryptohomeLibrary();
- return lib->AsyncCheckKey(attempt_->username, attempt_->ascii_hash, this);
+ lib->AsyncCheckKey(attempt_->username, attempt_->ascii_hash, this);
}
private:
diff --git a/chrome/browser/chromeos/login/cryptohome_op.h b/chrome/browser/chromeos/login/cryptohome_op.h
index ebea4b8..d3d81f7 100644
--- a/chrome/browser/chromeos/login/cryptohome_op.h
+++ b/chrome/browser/chromeos/login/cryptohome_op.h
@@ -39,7 +39,7 @@ class CryptohomeOp
AuthAttemptState* current_attempt,
AuthAttemptStateResolver* callback);
- virtual bool Initiate() = 0;
+ virtual void Initiate() = 0;
// Implementation of CryptohomeLibrary::Delegate.
virtual void OnComplete(bool success, int return_code);
diff --git a/chrome/browser/chromeos/login/cryptohome_op_unittest.cc b/chrome/browser/chromeos/login/cryptohome_op_unittest.cc
index 3ea6908..664e3d9 100644
--- a/chrome/browser/chromeos/login/cryptohome_op_unittest.cc
+++ b/chrome/browser/chromeos/login/cryptohome_op_unittest.cc
@@ -115,7 +115,8 @@ class CryptohomeOpTest : public ::testing::Test {
.Times(1)
.RetiresOnSaturation();
- EXPECT_TRUE(op->Initiate());
+ op->Initiate();
+
// Force IO thread to finish tasks so I can verify |state_|.
io_thread_.Stop();
diff --git a/chrome/browser/chromeos/login/existing_user_controller.cc b/chrome/browser/chromeos/login/existing_user_controller.cc
index 75eefb3f..b37526a 100644
--- a/chrome/browser/chromeos/login/existing_user_controller.cc
+++ b/chrome/browser/chromeos/login/existing_user_controller.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/chromeos/login/existing_user_controller.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "base/logging.h"
#include "base/message_loop.h"
@@ -79,7 +81,7 @@ ExistingUserController::ExistingUserController(LoginDisplayHost* host)
host_(host),
num_login_attempts_(0),
user_settings_(new UserCrosSettingsProvider),
- method_factory_(this),
+ weak_factory_(this),
is_owner_login_(false) {
DCHECK(current_controller_ == NULL);
current_controller_ = this;
@@ -231,8 +233,8 @@ void ExistingUserController::LoginAsGuest() {
// Check allow_guest in case this call is fired from key accelerator.
// Must not proceed without signature verification.
bool trusted_setting_available = user_settings_->RequestTrustedAllowGuest(
- method_factory_.NewRunnableMethod(
- &ExistingUserController::LoginAsGuest));
+ base::Bind(&ExistingUserController::LoginAsGuest,
+ weak_factory_.GetWeakPtr()));
if (!trusted_setting_available) {
// Value of AllowGuest setting is still not verified.
// Another attempt will be invoked again after verification completion.
@@ -260,8 +262,10 @@ void ExistingUserController::OnUserSelected(const std::string& username) {
void ExistingUserController::OnStartEnterpriseEnrollment() {
CommandLine* command_line = CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kEnableDevicePolicy)) {
- ownership_checker_.reset(new OwnershipStatusChecker(NewCallback(
- this, &ExistingUserController::OnEnrollmentOwnershipCheckCompleted)));
+ ownership_checker_.reset(new OwnershipStatusChecker(
+ base::Bind(
+ &ExistingUserController::OnEnrollmentOwnershipCheckCompleted,
+ base::Unretained(this))));
}
}
@@ -469,9 +473,8 @@ void ExistingUserController::OnPasswordChangeDetected(
const GaiaAuthConsumer::ClientLoginResult& credentials) {
// Must not proceed without signature verification.
bool trusted_setting_available = user_settings_->RequestTrustedOwner(
- method_factory_.NewRunnableMethod(
- &ExistingUserController::OnPasswordChangeDetected,
- credentials));
+ base::Bind(&ExistingUserController::OnPasswordChangeDetected,
+ weak_factory_.GetWeakPtr(), credentials));
if (!trusted_setting_available) {
// Value of owner email is still not verified.
// Another attempt will be invoked after verification completion.
@@ -575,8 +578,8 @@ void ExistingUserController::ShowError(int error_id,
void ExistingUserController::StartAutomaticFreeDiskSpaceControl() {
bool trusted_owner_available = user_settings_->RequestTrustedOwner(
- method_factory_.NewRunnableMethod(
- &ExistingUserController::StartAutomaticFreeDiskSpaceControl));
+ base::Bind(&ExistingUserController::StartAutomaticFreeDiskSpaceControl,
+ weak_factory_.GetWeakPtr()));
if (!trusted_owner_available) {
// Value of owner email is still not verified.
// Another attempt will be invoked after verification completion.
diff --git a/chrome/browser/chromeos/login/existing_user_controller.h b/chrome/browser/chromeos/login/existing_user_controller.h
index efb8ae9..456c523 100644
--- a/chrome/browser/chromeos/login/existing_user_controller.h
+++ b/chrome/browser/chromeos/login/existing_user_controller.h
@@ -10,6 +10,7 @@
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "base/string16.h"
#include "base/task.h"
#include "base/timer.h"
@@ -185,7 +186,7 @@ class ExistingUserController : public LoginDisplay::Delegate,
NotificationRegistrar registrar_;
// Factory of callbacks.
- ScopedRunnableMethodFactory<ExistingUserController> method_factory_;
+ base::WeakPtrFactory<ExistingUserController> weak_factory_;
// Whether everything is ready to launch the browser.
bool ready_for_browser_launch_;
diff --git a/chrome/browser/chromeos/login/google_authenticator.cc b/chrome/browser/chromeos/login/google_authenticator.cc
index 196e606..48488ff 100644
--- a/chrome/browser/chromeos/login/google_authenticator.cc
+++ b/chrome/browser/chromeos/login/google_authenticator.cc
@@ -7,6 +7,7 @@
#include <string>
#include <vector>
+#include "base/bind.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/logging.h"
@@ -75,9 +76,8 @@ void GoogleAuthenticator::CancelClientLogin() {
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(this,
- &GoogleAuthenticator::LoadLocalaccount,
- std::string(kLocalaccountFile)));
+ base::Bind(&GoogleAuthenticator::LoadLocalaccount, this,
+ std::string(kLocalaccountFile)));
CheckOffline(LoginFailure(LoginFailure::LOGIN_TIMED_OUT));
}
diff --git a/chrome/browser/chromeos/login/google_authenticator_unittest.cc b/chrome/browser/chromeos/login/google_authenticator_unittest.cc
index d69b23d..a43eaf4 100644
--- a/chrome/browser/chromeos/login/google_authenticator_unittest.cc
+++ b/chrome/browser/chromeos/login/google_authenticator_unittest.cc
@@ -7,6 +7,7 @@
#include <string>
#include <vector>
+#include "base/bind.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/memory/scoped_ptr.h"
@@ -126,9 +127,7 @@ class GoogleAuthenticatorTest : public testing::Test {
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(auth,
- &GoogleAuthenticator::LoadLocalaccount,
- filename));
+ base::Bind(&GoogleAuthenticator::LoadLocalaccount, auth, filename));
}
void PrepForLogin(GoogleAuthenticator* auth) {
@@ -150,8 +149,7 @@ class GoogleAuthenticatorTest : public testing::Test {
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
- NewRunnableMethod(auth,
- &GoogleAuthenticator::CancelClientLogin));
+ base::Bind(&GoogleAuthenticator::CancelClientLogin, auth));
}
MessageLoop message_loop_ui_;
@@ -529,9 +527,8 @@ TEST_F(GoogleAuthenticatorTest, LocalaccountLogin) {
// haven't yet gotten off disk.
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(auth.get(),
- &GoogleAuthenticator::CheckLocalaccount,
- LoginFailure(LoginFailure::LOGIN_TIMED_OUT)));
+ base::Bind(&GoogleAuthenticator::CheckLocalaccount, auth.get(),
+ LoginFailure(LoginFailure::LOGIN_TIMED_OUT)));
message_loop_ui_.RunAllPending();
// The foregoing has now rescheduled itself in a few ms because we don't
// yet have the localaccount loaded off disk.
diff --git a/chrome/browser/chromeos/login/image_decoder.cc b/chrome/browser/chromeos/login/image_decoder.cc
index a671ab7..1c17940 100644
--- a/chrome/browser/chromeos/login/image_decoder.cc
+++ b/chrome/browser/chromeos/login/image_decoder.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/chromeos/login/image_decoder.h"
+#include "base/bind.h"
#include "chrome/browser/browser_process.h"
#include "chrome/common/chrome_utility_messages.h"
#include "content/browser/browser_thread.h"
@@ -26,9 +27,7 @@ void ImageDecoder::Start() {
}
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(
- this, &ImageDecoder::DecodeImageInSandbox,
- image_data_));
+ base::Bind(&ImageDecoder::DecodeImageInSandbox, this, image_data_));
}
bool ImageDecoder::OnMessageReceived(const IPC::Message& message) {
diff --git a/chrome/browser/chromeos/login/login_performer.cc b/chrome/browser/chromeos/login/login_performer.cc
index 161684d..0854394 100644
--- a/chrome/browser/chromeos/login/login_performer.cc
+++ b/chrome/browser/chromeos/login/login_performer.cc
@@ -6,6 +6,7 @@
#include <string>
+#include "base/bind.h"
#include "base/command_line.h"
#include "base/logging.h"
#include "base/message_loop.h"
@@ -55,7 +56,7 @@ LoginPerformer::LoginPerformer(Delegate* delegate)
switches::kWebUILogin) &&
!CommandLine::ForCurrentProcess()->HasSwitch(
switches::kSkipOAuthLogin)),
- method_factory_(this) {
+ weak_factory_(this) {
DCHECK(default_performer_ == NULL)
<< "LoginPerformer should have only one instance.";
default_performer_ = this;
@@ -279,9 +280,8 @@ void LoginPerformer::CompleteLogin(const std::string& username,
// Must not proceed without signature verification.
UserCrosSettingsProvider user_settings;
bool trusted_setting_available = user_settings.RequestTrustedAllowNewUser(
- method_factory_.NewRunnableMethod(&LoginPerformer::CompleteLogin,
- username,
- password));
+ base::Bind(&LoginPerformer::CompleteLogin, weak_factory_.GetWeakPtr(),
+ username, password));
if (!trusted_setting_available) {
// Value of AllowNewUser setting is still not verified.
// Another attempt will be invoked after verification completion.
@@ -327,9 +327,8 @@ void LoginPerformer::Login(const std::string& username,
// Must not proceed without signature verification.
UserCrosSettingsProvider user_settings;
bool trusted_setting_available = user_settings.RequestTrustedAllowNewUser(
- method_factory_.NewRunnableMethod(&LoginPerformer::Login,
- username,
- password));
+ base::Bind(&LoginPerformer::Login, weak_factory_.GetWeakPtr(), username,
+ password));
if (!trusted_setting_available) {
// Value of AllowNewUser setting is still not verified.
// Another attempt will be invoked after verification completion.
@@ -367,26 +366,22 @@ void LoginPerformer::LoginOffTheRecord() {
authenticator_ = LoginUtils::Get()->CreateAuthenticator(this);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(authenticator_.get(),
- &Authenticator::LoginOffTheRecord));
+ base::Bind(&Authenticator::LoginOffTheRecord, authenticator_.get()));
}
void LoginPerformer::RecoverEncryptedData(const std::string& old_password) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(authenticator_.get(),
- &Authenticator::RecoverEncryptedData,
- old_password,
- cached_credentials_));
+ base::Bind(&Authenticator::RecoverEncryptedData, authenticator_.get(),
+ old_password, cached_credentials_));
cached_credentials_ = GaiaAuthConsumer::ClientLoginResult();
}
void LoginPerformer::ResyncEncryptedData() {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(authenticator_.get(),
- &Authenticator::ResyncEncryptedData,
- cached_credentials_));
+ base::Bind(&Authenticator::ResyncEncryptedData, authenticator_.get(),
+ cached_credentials_));
cached_credentials_ = GaiaAuthConsumer::ClientLoginResult();
}
@@ -551,11 +546,8 @@ void LoginPerformer::StartLoginCompletion() {
authenticator_ = LoginUtils::Get()->CreateAuthenticator(this);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(authenticator_.get(),
- &Authenticator::CompleteLogin,
- profile,
- username_,
- password_));
+ base::Bind(&Authenticator::CompleteLogin, authenticator_.get(), profile,
+ username_, password_));
password_.clear();
}
@@ -568,13 +560,8 @@ void LoginPerformer::StartAuthentication() {
authenticator_ = LoginUtils::Get()->CreateAuthenticator(this);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(authenticator_.get(),
- &Authenticator::AuthenticateToLogin,
- profile,
- username_,
- password_,
- captcha_token_,
- captcha_));
+ base::Bind(&Authenticator::AuthenticateToLogin, authenticator_.get(),
+ profile, username_, password_, captcha_token_, captcha_));
} else {
DCHECK(authenticator_.get())
<< "Authenticator instance doesn't exist for login attempt retry.";
@@ -582,13 +569,8 @@ void LoginPerformer::StartAuthentication() {
// retry online auth, using existing Authenticator instance.
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(authenticator_.get(),
- &Authenticator::RetryAuth,
- profile,
- username_,
- password_,
- captcha_token_,
- captcha_));
+ base::Bind(&Authenticator::RetryAuth, authenticator_.get(), profile,
+ username_, password_, captcha_token_, captcha_));
}
password_.clear();
}
diff --git a/chrome/browser/chromeos/login/login_performer.h b/chrome/browser/chromeos/login/login_performer.h
index 4524ea6..c1f8edd 100644
--- a/chrome/browser/chromeos/login/login_performer.h
+++ b/chrome/browser/chromeos/login/login_performer.h
@@ -9,7 +9,7 @@
#include <string>
#include "base/basictypes.h"
-#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
#include "base/task.h"
#include "chrome/browser/chromeos/login/authenticator.h"
#include "chrome/browser/chromeos/login/login_status_consumer.h"
@@ -212,7 +212,7 @@ class LoginPerformer : public LoginStatusConsumer,
// True if we use OAuth during authorization process.
bool using_oauth_;
- ScopedRunnableMethodFactory<LoginPerformer> method_factory_;
+ base::WeakPtrFactory<LoginPerformer> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(LoginPerformer);
};
diff --git a/chrome/browser/chromeos/login/mock_auth_response_handler.cc b/chrome/browser/chromeos/login/mock_auth_response_handler.cc
index 83c3aed..9947d83 100644
--- a/chrome/browser/chromeos/login/mock_auth_response_handler.cc
+++ b/chrome/browser/chromeos/login/mock_auth_response_handler.cc
@@ -6,6 +6,7 @@
#include <string>
+#include "base/bind.h"
#include "base/message_loop.h"
#include "content/common/net/url_fetcher.h"
#include "googleurl/src/gurl.h"
@@ -53,12 +54,8 @@ URLFetcher* MockAuthResponseHandler::MockNetwork(
URLFetcher::Delegate* delegate) {
MessageLoop::current()->PostTask(
FROM_HERE,
- NewRunnableFunction(MockAuthResponseHandler::CompleteFetch,
- delegate,
- remote_,
- status_,
- http_response_code_,
- data_));
+ base::Bind(MockAuthResponseHandler::CompleteFetch, delegate, remote_,
+ status_, http_response_code_, data_));
return new URLFetcher(GURL(), URLFetcher::GET, delegate);
}
diff --git a/chrome/browser/chromeos/login/mock_authenticator.cc b/chrome/browser/chromeos/login/mock_authenticator.cc
index 2b276e1..a224b91 100644
--- a/chrome/browser/chromeos/login/mock_authenticator.cc
+++ b/chrome/browser/chromeos/login/mock_authenticator.cc
@@ -4,6 +4,9 @@
#include "chrome/browser/chromeos/login/mock_authenticator.h"
+#include "base/bind.h"
+#include "content/browser/browser_thread.h"
+
namespace chromeos {
void MockAuthenticator::AuthenticateToLogin(Profile* profile,
@@ -13,14 +16,14 @@ void MockAuthenticator::AuthenticateToLogin(Profile* profile,
const std::string& login_captcha) {
if (expected_username_ == username && expected_password_ == password) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this, &MockAuthenticator::OnLoginSuccess,
- GaiaAuthConsumer::ClientLoginResult(), false));
+ base::Bind(&MockAuthenticator::OnLoginSuccess, this,
+ GaiaAuthConsumer::ClientLoginResult(), false));
}
GoogleServiceAuthError error(
GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this, &MockAuthenticator::OnLoginFailure,
- LoginFailure::FromNetworkAuthFailure(error)));
+ base::Bind(&MockAuthenticator::OnLoginFailure, this,
+ LoginFailure::FromNetworkAuthFailure(error)));
}
void MockAuthenticator::CompleteLogin(Profile* profile,
diff --git a/chrome/browser/chromeos/login/mock_url_fetchers.cc b/chrome/browser/chromeos/login/mock_url_fetchers.cc
index 4e922b1..70e2276 100644
--- a/chrome/browser/chromeos/login/mock_url_fetchers.cc
+++ b/chrome/browser/chromeos/login/mock_url_fetchers.cc
@@ -6,6 +6,7 @@
#include <errno.h>
+#include "base/bind.h"
#include "base/message_loop.h"
#include "base/stringprintf.h"
#include "chrome/common/net/http_return.h"
@@ -24,7 +25,7 @@ ExpectCanceledFetcher::ExpectCanceledFetcher(
URLFetcher::RequestType request_type,
URLFetcher::Delegate* d)
: URLFetcher(url, request_type, d),
- ALLOW_THIS_IN_INITIALIZER_LIST(complete_fetch_factory_(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
}
ExpectCanceledFetcher::~ExpectCanceledFetcher() {
@@ -33,8 +34,8 @@ ExpectCanceledFetcher::~ExpectCanceledFetcher() {
void ExpectCanceledFetcher::Start() {
MessageLoop::current()->PostDelayedTask(
FROM_HERE,
- complete_fetch_factory_.NewRunnableMethod(
- &ExpectCanceledFetcher::CompleteFetch),
+ base::Bind(&ExpectCanceledFetcher::CompleteFetch,
+ weak_factory_.GetWeakPtr()),
100);
}
diff --git a/chrome/browser/chromeos/login/mock_url_fetchers.h b/chrome/browser/chromeos/login/mock_url_fetchers.h
index b82c977..2be8891 100644
--- a/chrome/browser/chromeos/login/mock_url_fetchers.h
+++ b/chrome/browser/chromeos/login/mock_url_fetchers.h
@@ -8,6 +8,7 @@
#include <string>
+#include "base/memory/weak_ptr.h"
#include "base/message_loop.h"
#include "base/task.h"
#include "content/common/net/url_fetcher.h"
@@ -16,7 +17,7 @@
namespace chromeos {
-// Simulates a URL fetch by posting a delayed task. This fetch expects to be
+// Simulates a URL fetch by posting a delayed task. This fetch expects to be
// canceled, and fails the test if it is not
class ExpectCanceledFetcher : public URLFetcher {
public:
@@ -32,7 +33,7 @@ class ExpectCanceledFetcher : public URLFetcher {
void CompleteFetch();
private:
- ScopedRunnableMethodFactory<ExpectCanceledFetcher> complete_fetch_factory_;
+ base::WeakPtrFactory<ExpectCanceledFetcher> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(ExpectCanceledFetcher);
};
diff --git a/chrome/browser/chromeos/login/new_user_view.cc b/chrome/browser/chromeos/login/new_user_view.cc
index 3859978..afb2ac2 100644
--- a/chrome/browser/chromeos/login/new_user_view.cc
+++ b/chrome/browser/chromeos/login/new_user_view.cc
@@ -10,6 +10,7 @@
#include <algorithm>
#include <vector>
+#include "base/bind.h"
#include "base/callback.h"
#include "base/command_line.h"
#include "base/message_loop.h"
@@ -123,7 +124,7 @@ NewUserView::NewUserView(Delegate* delegate,
accel_login_off_the_record_(ui::VKEY_B, false, false, true),
accel_toggle_accessibility_(WizardAccessibilityHelper::GetAccelerator()),
delegate_(delegate),
- ALLOW_THIS_IN_INITIALIZER_LIST(focus_grabber_factory_(this)),
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
login_in_process_(false),
need_border_(need_border),
need_guest_link_(false),
@@ -338,9 +339,9 @@ void NewUserView::ViewHierarchyChanged(bool is_add,
View *parent,
View *child) {
if (is_add && (child == username_field_ || child == password_field_)) {
- MessageLoop::current()->PostTask(FROM_HERE,
- focus_grabber_factory_.NewRunnableMethod(
- &NewUserView::Layout));
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&NewUserView::Layout, weak_factory_.GetWeakPtr()));
}
}
diff --git a/chrome/browser/chromeos/login/new_user_view.h b/chrome/browser/chromeos/login/new_user_view.h
index dc4c0fa..a68fead 100644
--- a/chrome/browser/chromeos/login/new_user_view.h
+++ b/chrome/browser/chromeos/login/new_user_view.h
@@ -8,6 +8,7 @@
#include <string>
+#include "base/memory/weak_ptr.h"
#include "base/task.h"
#include "chrome/browser/chromeos/login/helper.h"
#include "chrome/browser/chromeos/login/language_switch_menu.h"
@@ -168,7 +169,7 @@ class NewUserView : public ThrobberHostView,
// Notifications receiver.
Delegate* delegate_;
- ScopedRunnableMethodFactory<NewUserView> focus_grabber_factory_;
+ base::WeakPtrFactory<NewUserView> weak_factory_;
LanguageSwitchMenu language_switch_menu_;
diff --git a/chrome/browser/chromeos/login/online_attempt.cc b/chrome/browser/chromeos/login/online_attempt.cc
index c3aff960..c5015f3 100644
--- a/chrome/browser/chromeos/login/online_attempt.cc
+++ b/chrome/browser/chromeos/login/online_attempt.cc
@@ -6,6 +6,7 @@
#include <string>
+#include "base/bind.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
@@ -41,7 +42,7 @@ OnlineAttempt::OnlineAttempt(bool using_oauth,
: using_oauth_(using_oauth),
attempt_(current_attempt),
resolver_(callback),
- fetch_canceler_(NULL),
+ weak_factory_(this),
try_again_(true) {
CHECK(chromeos::CrosLibrary::Get()->EnsureLoaded());
}
@@ -70,17 +71,15 @@ void OnlineAttempt::Initiate(Profile* auth_profile) {
}
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(this, &OnlineAttempt::TryClientLogin));
+ base::Bind(&OnlineAttempt::TryClientLogin, this));
}
void OnlineAttempt::OnClientLoginSuccess(
const GaiaAuthConsumer::ClientLoginResult& credentials) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
VLOG(1) << "Online login successful!";
- if (fetch_canceler_) {
- fetch_canceler_->Cancel();
- fetch_canceler_ = NULL;
- }
+
+ weak_factory_.InvalidateWeakPtrs();
if (attempt_->hosted_policy() == GaiaAuthFetcher::HostedAccountsAllowed &&
attempt_->is_first_time_user()) {
@@ -101,10 +100,9 @@ void OnlineAttempt::OnClientLoginSuccess(
void OnlineAttempt::OnClientLoginFailure(
const GoogleServiceAuthError& error) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- if (fetch_canceler_) {
- fetch_canceler_->Cancel();
- fetch_canceler_ = NULL;
- }
+
+ weak_factory_.InvalidateWeakPtrs();
+
if (error.state() == GoogleServiceAuthError::REQUEST_CANCELED) {
if (try_again_) {
try_again_ = false;
@@ -156,10 +154,12 @@ void OnlineAttempt::OnOAuthLoginFailure(const GoogleServiceAuthError& error) {
void OnlineAttempt::TryClientLogin() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- fetch_canceler_ = NewRunnableMethod(this, &OnlineAttempt::CancelClientLogin);
- BrowserThread::PostDelayedTask(BrowserThread::IO, FROM_HERE,
- fetch_canceler_,
- kClientLoginTimeoutMs);
+
+ BrowserThread::PostDelayedTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&OnlineAttempt::CancelClientLogin, weak_factory_.GetWeakPtr()),
+ kClientLoginTimeoutMs);
+
if (using_oauth_) {
if (!attempt_->oauth1_access_token().length() ||
!attempt_->oauth1_access_secret().length()) {
@@ -191,19 +191,14 @@ bool OnlineAttempt::HasPendingFetch() {
}
void OnlineAttempt::CancelRequest() {
- if (using_oauth_)
- oauth_fetcher_->HasPendingFetch();
- else
- client_fetcher_->HasPendingFetch();
+ weak_factory_.InvalidateWeakPtrs();
}
-
void OnlineAttempt::CancelClientLogin() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (HasPendingFetch()) {
LOG(WARNING) << "Canceling ClientLogin attempt.";
CancelRequest();
- fetch_canceler_ = NULL;
TriggerResolve(GaiaAuthConsumer::ClientLoginResult(),
LoginFailure(LoginFailure::LOGIN_TIMED_OUT));
diff --git a/chrome/browser/chromeos/login/online_attempt.h b/chrome/browser/chromeos/login/online_attempt.h
index 4040a35..b0ebf4f 100644
--- a/chrome/browser/chromeos/login/online_attempt.h
+++ b/chrome/browser/chromeos/login/online_attempt.h
@@ -12,6 +12,7 @@
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "chrome/browser/chromeos/login/login_status_consumer.h"
#include "chrome/browser/net/gaia/gaia_oauth_consumer.h"
#include "chrome/browser/net/gaia/gaia_oauth_fetcher.h"
@@ -82,7 +83,9 @@ class OnlineAttempt
scoped_ptr<GaiaAuthFetcher> client_fetcher_;
// Handles OAuthLogin communications with Gaia.
scoped_ptr<GaiaOAuthFetcher> oauth_fetcher_;
- CancelableTask* fetch_canceler_;
+
+ // Used to cancel the CancelClientLogin closure.
+ base::WeakPtrFactory<OnlineAttempt> weak_factory_;
// Whether we're willing to re-try the ClientLogin attempt.
bool try_again_;
diff --git a/chrome/browser/chromeos/login/online_attempt_unittest.cc b/chrome/browser/chromeos/login/online_attempt_unittest.cc
index 3a133cc..3b67c14 100644
--- a/chrome/browser/chromeos/login/online_attempt_unittest.cc
+++ b/chrome/browser/chromeos/login/online_attempt_unittest.cc
@@ -4,6 +4,7 @@
#include <string>
+#include "base/bind.h"
#include "base/memory/ref_counted.h"
#include "base/message_loop.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
@@ -71,9 +72,8 @@ class OnlineAttemptTest : public testing::Test {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(attempt_.get(),
- &OnlineAttempt::OnClientLoginFailure,
- error));
+ base::Bind(&OnlineAttempt::OnClientLoginFailure, attempt_.get(),
+ error));
// Force IO thread to finish tasks so I can verify |state_|.
io_thread_.Stop();
EXPECT_TRUE(error == state_.online_outcome().error());
@@ -81,10 +81,8 @@ class OnlineAttemptTest : public testing::Test {
void CancelLogin(OnlineAttempt* auth) {
BrowserThread::PostTask(
- BrowserThread::IO,
- FROM_HERE,
- NewRunnableMethod(auth,
- &OnlineAttempt::CancelClientLogin));
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&OnlineAttempt::CancelClientLogin, auth));
}
static void Quit() {
@@ -115,9 +113,7 @@ TEST_F(OnlineAttemptTest, LoginSuccess) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(attempt_.get(),
- &OnlineAttempt::OnClientLoginSuccess,
- result));
+ base::Bind(&OnlineAttempt::OnClientLoginSuccess, attempt_.get(), result));
// Force IO thread to finish tasks so I can verify |state_|.
io_thread_.Stop();
EXPECT_TRUE(result == state_.credentials());
@@ -139,7 +135,7 @@ TEST_F(OnlineAttemptTest, LoginCancelRetry) {
attempt_->Initiate(&profile);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
- NewRunnableFunction(&OnlineAttemptTest::RunThreadTest));
+ base::Bind(&OnlineAttemptTest::RunThreadTest));
MessageLoop::current()->Run();
@@ -164,7 +160,7 @@ TEST_F(OnlineAttemptTest, LoginTimeout) {
attempt_->Initiate(&profile);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
- NewRunnableFunction(&OnlineAttemptTest::RunThreadTest));
+ base::Bind(&OnlineAttemptTest::RunThreadTest));
// Post a task to cancel the login attempt.
CancelLogin(attempt_.get());
@@ -193,7 +189,7 @@ TEST_F(OnlineAttemptTest, HostedLoginRejected) {
attempt_->Initiate(&profile);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
- NewRunnableFunction(&OnlineAttemptTest::RunThreadTest));
+ base::Bind(&OnlineAttemptTest::RunThreadTest));
MessageLoop::current()->Run();
@@ -217,7 +213,7 @@ TEST_F(OnlineAttemptTest, FullLogin) {
attempt_->Initiate(&profile);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
- NewRunnableFunction(&OnlineAttemptTest::RunThreadTest));
+ base::Bind(&OnlineAttemptTest::RunThreadTest));
MessageLoop::current()->Run();
diff --git a/chrome/browser/chromeos/login/owner_manager.cc b/chrome/browser/chromeos/login/owner_manager.cc
index 14429f5..a408c53 100644
--- a/chrome/browser/chromeos/login/owner_manager.cc
+++ b/chrome/browser/chromeos/login/owner_manager.cc
@@ -7,6 +7,7 @@
#include <string>
#include <vector>
+#include "base/bind.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "chrome/browser/browser_process.h"
@@ -35,7 +36,7 @@ void OwnerManager::UpdateOwnerKey(const BrowserThread::ID thread_id,
BrowserThread::PostTask(
thread_id, FROM_HERE,
- NewRunnableMethod(this, &OwnerManager::CallKeyUpdateDelegate, d));
+ base::Bind(&OwnerManager::CallKeyUpdateDelegate, this, d));
}
void OwnerManager::LoadOwnerKey() {
@@ -54,10 +55,8 @@ void OwnerManager::LoadOwnerKey() {
// that we're done with this attempt.
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this,
- &OwnerManager::SendNotification,
- result,
- NotificationService::NoDetails()));
+ base::Bind(&OwnerManager::SendNotification, this, result,
+ NotificationService::NoDetails()));
}
bool OwnerManager::EnsurePublicKey() {
@@ -87,9 +86,8 @@ void OwnerManager::Sign(const BrowserThread::ID thread_id,
if (!(EnsurePublicKey() && EnsurePrivateKey())) {
BrowserThread::PostTask(
thread_id, FROM_HERE,
- NewRunnableMethod(this,
- &OwnerManager::CallDelegate,
- d, KEY_UNAVAILABLE, std::vector<uint8>()));
+ base::Bind(&OwnerManager::CallDelegate, this, d, KEY_UNAVAILABLE,
+ std::vector<uint8>()));
BootTimesLoader::Get()->AddLoginTimeMarker("SignEnd", false);
return;
}
@@ -103,9 +101,7 @@ void OwnerManager::Sign(const BrowserThread::ID thread_id,
BrowserThread::PostTask(
thread_id, FROM_HERE,
- NewRunnableMethod(this,
- &OwnerManager::CallDelegate,
- d, return_code, signature));
+ base::Bind(&OwnerManager::CallDelegate, this, d, return_code, signature));
BootTimesLoader::Get()->AddLoginTimeMarker("SignEnd", false);
}
@@ -119,9 +115,8 @@ void OwnerManager::Verify(const BrowserThread::ID thread_id,
if (!EnsurePublicKey()) {
BrowserThread::PostTask(
thread_id, FROM_HERE,
- NewRunnableMethod(this,
- &OwnerManager::CallDelegate,
- d, KEY_UNAVAILABLE, std::vector<uint8>()));
+ base::Bind(&OwnerManager::CallDelegate, this, d, KEY_UNAVAILABLE,
+ std::vector<uint8>()));
BootTimesLoader::Get()->AddLoginTimeMarker("VerifyEnd", false);
return;
}
@@ -133,9 +128,8 @@ void OwnerManager::Verify(const BrowserThread::ID thread_id,
}
BrowserThread::PostTask(
thread_id, FROM_HERE,
- NewRunnableMethod(this,
- &OwnerManager::CallDelegate,
- d, return_code, std::vector<uint8>()));
+ base::Bind(&OwnerManager::CallDelegate, this, d, return_code,
+ std::vector<uint8>()));
BootTimesLoader::Get()->AddLoginTimeMarker("VerifyEnd", false);
}
diff --git a/chrome/browser/chromeos/login/owner_manager_unittest.cc b/chrome/browser/chromeos/login/owner_manager_unittest.cc
index f9a0e0b..9793886 100644
--- a/chrome/browser/chromeos/login/owner_manager_unittest.cc
+++ b/chrome/browser/chromeos/login/owner_manager_unittest.cc
@@ -7,6 +7,7 @@
#include <string>
+#include "base/bind.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/logging.h"
@@ -176,11 +177,8 @@ TEST_F(OwnerManagerTest, UpdateOwnerKey) {
MockKeyUpdateUser delegate(&event);
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(manager.get(),
- &OwnerManager::UpdateOwnerKey,
- BrowserThread::UI,
- std::vector<uint8>(),
- &delegate));
+ base::Bind(&OwnerManager::UpdateOwnerKey, manager.get(),
+ BrowserThread::UI, std::vector<uint8>(), &delegate));
while (!event.IsSignaled())
message_loop_.RunAllPending();
}
@@ -199,8 +197,7 @@ TEST_F(OwnerManagerTest, LoadOwnerKeyFail) {
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(manager.get(),
- &OwnerManager::LoadOwnerKey));
+ base::Bind(&OwnerManager::LoadOwnerKey, manager.get()));
while (!event.IsSignaled())
message_loop_.RunAllPending();
}
@@ -218,8 +215,7 @@ TEST_F(OwnerManagerTest, AlreadyLoadedOwnerKey) {
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(manager.get(),
- &OwnerManager::LoadOwnerKey));
+ base::Bind(&OwnerManager::LoadOwnerKey, manager.get()));
while (!event.IsSignaled())
message_loop_.RunAllPending();
}
@@ -239,8 +235,7 @@ TEST_F(OwnerManagerTest, LoadOwnerKey) {
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(manager.get(),
- &OwnerManager::LoadOwnerKey));
+ base::Bind(&OwnerManager::LoadOwnerKey, manager.get()));
while (!event.IsSignaled())
message_loop_.RunAllPending();
}
@@ -262,12 +257,8 @@ TEST_F(OwnerManagerTest, GetKeyFailDuringVerify) {
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(manager.get(),
- &OwnerManager::Verify,
- BrowserThread::UI,
- std::string(),
- std::vector<uint8>(),
- &delegate));
+ base::Bind(&OwnerManager::Verify, manager.get(), BrowserThread::UI,
+ std::string(), std::vector<uint8>(), &delegate));
while (!event.IsSignaled())
message_loop_.RunAllPending();
}
@@ -290,12 +281,8 @@ TEST_F(OwnerManagerTest, AlreadyHaveKeysVerify) {
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(manager.get(),
- &OwnerManager::Verify,
- BrowserThread::UI,
- data,
- sig,
- &delegate));
+ base::Bind(&OwnerManager::Verify, manager.get(), BrowserThread::UI, data,
+ sig, &delegate));
while (!event.IsSignaled())
message_loop_.RunAllPending();
}
@@ -323,12 +310,8 @@ TEST_F(OwnerManagerTest, GetKeyAndVerify) {
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(manager.get(),
- &OwnerManager::Verify,
- BrowserThread::UI,
- data,
- sig,
- &delegate));
+ base::Bind(&OwnerManager::Verify, manager.get(), BrowserThread::UI, data,
+ sig, &delegate));
while (!event.IsSignaled())
message_loop_.RunAllPending();
}
@@ -352,11 +335,8 @@ TEST_F(OwnerManagerTest, AlreadyHaveKeysSign) {
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(manager.get(),
- &OwnerManager::Sign,
- BrowserThread::UI,
- data,
- &delegate));
+ base::Bind(&OwnerManager::Sign, manager.get(), BrowserThread::UI, data,
+ &delegate));
while (!event.IsSignaled())
message_loop_.RunAllPending();
}
diff --git a/chrome/browser/chromeos/login/ownership_service.cc b/chrome/browser/chromeos/login/ownership_service.cc
index 55ff741..954e62a 100644
--- a/chrome/browser/chromeos/login/ownership_service.cc
+++ b/chrome/browser/chromeos/login/ownership_service.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/chromeos/login/ownership_service.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/lazy_instance.h"
@@ -12,10 +14,6 @@
#include "chrome/common/chrome_notification_types.h"
#include "content/browser/browser_thread.h"
-// We want to use NewRunnableMethod for non-static methods of this class but
-// need to disable reference counting since it is singleton.
-DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::OwnershipService);
-
namespace chromeos {
static base::LazyInstance<OwnershipService> g_ownership_service(
@@ -45,9 +43,8 @@ void OwnershipService::Prewarm() {
if (g_ownership_service == this) {
// Start getting ownership status.
BrowserThread::PostTask(
- BrowserThread::FILE,
- FROM_HERE,
- NewRunnableMethod(this, &OwnershipService::FetchStatus));
+ BrowserThread::FILE, FROM_HERE,
+ base::Bind(&OwnershipService::FetchStatus, base::Unretained(this)));
} else {
// This can happen only for particular test: OwnershipServiceTest. It uses
// mocks and for that uses OwnershipService not as a regular singleton but
@@ -100,7 +97,7 @@ OwnershipService::Status OwnershipService::GetStatus(bool blocking) {
void OwnershipService::StartLoadOwnerKeyAttempt() {
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
- NewRunnableFunction(&TryLoadOwnerKeyAttempt, this));
+ base::Bind(&TryLoadOwnerKeyAttempt, base::Unretained(this)));
}
void OwnershipService::StartUpdateOwnerKey(const std::vector<uint8>& new_key,
@@ -110,11 +107,8 @@ void OwnershipService::StartUpdateOwnerKey(const std::vector<uint8>& new_key,
thread_id = BrowserThread::UI;
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
- NewRunnableFunction(&OwnershipService::UpdateOwnerKey,
- this,
- thread_id,
- new_key,
- d));
+ base::Bind(&OwnershipService::UpdateOwnerKey, base::Unretained(this),
+ thread_id, new_key, d));
return;
}
@@ -125,11 +119,8 @@ void OwnershipService::StartSigningAttempt(const std::string& data,
thread_id = BrowserThread::UI;
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
- NewRunnableFunction(&OwnershipService::TrySigningAttempt,
- this,
- thread_id,
- data,
- d));
+ base::Bind(&OwnershipService::TrySigningAttempt, base::Unretained(this),
+ thread_id, data, d));
return;
}
@@ -141,12 +132,8 @@ void OwnershipService::StartVerifyAttempt(const std::string& data,
thread_id = BrowserThread::UI;
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
- NewRunnableFunction(&OwnershipService::TryVerifyAttempt,
- this,
- thread_id,
- data,
- signature,
- d));
+ base::Bind(&OwnershipService::TryVerifyAttempt, base::Unretained(this),
+ thread_id, data, signature, d));
return;
}
@@ -196,7 +183,7 @@ void OwnershipService::TrySigningAttempt(OwnershipService* service,
LOG(ERROR) << "Device not yet owned";
BrowserThread::PostTask(
thread_id, FROM_HERE,
- NewRunnableFunction(&OwnershipService::FailAttempt, d));
+ base::Bind(&OwnershipService::FailAttempt, d));
return;
}
service->manager()->Sign(thread_id, data, d);
@@ -213,7 +200,7 @@ void OwnershipService::TryVerifyAttempt(OwnershipService* service,
LOG(ERROR) << "Device not yet owned";
BrowserThread::PostTask(
thread_id, FROM_HERE,
- NewRunnableFunction(&OwnershipService::FailAttempt, d));
+ base::Bind(&OwnershipService::FailAttempt, d));
return;
}
service->manager()->Verify(thread_id, data, signature, d);
diff --git a/chrome/browser/chromeos/login/ownership_status_checker.cc b/chrome/browser/chromeos/login/ownership_status_checker.cc
index 7e7a7e1..4b7b98e 100644
--- a/chrome/browser/chromeos/login/ownership_status_checker.cc
+++ b/chrome/browser/chromeos/login/ownership_status_checker.cc
@@ -4,11 +4,12 @@
#include "chrome/browser/chromeos/login/ownership_status_checker.h"
+#include "base/bind.h"
#include "content/browser/browser_thread.h"
namespace chromeos {
-OwnershipStatusChecker::OwnershipStatusChecker(Callback* callback)
+OwnershipStatusChecker::OwnershipStatusChecker(const Callback& callback)
: core_(new Core(callback)) {
core_->Check();
}
@@ -17,7 +18,7 @@ OwnershipStatusChecker::~OwnershipStatusChecker() {
core_->Cancel();
}
-OwnershipStatusChecker::Core::Core(Callback* callback)
+OwnershipStatusChecker::Core::Core(const Callback& callback)
: callback_(callback),
origin_loop_(base::MessageLoopProxy::current()) {
}
@@ -35,21 +36,19 @@ void OwnershipStatusChecker::Core::Check() {
// Take a spin on the message loop in order to avoid reentrancy in callers.
origin_loop_->PostTask(
FROM_HERE,
- NewRunnableMethod(this,
- &OwnershipStatusChecker::Core::ReportResult,
- status, false));
+ base::Bind(&OwnershipStatusChecker::Core::ReportResult, this, status,
+ false));
} else {
// Switch to the file thread to make the blocking call.
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(this,
- &OwnershipStatusChecker::Core::CheckOnFileThread));
+ base::Bind(&OwnershipStatusChecker::Core::CheckOnFileThread, this));
}
}
void OwnershipStatusChecker::Core::Cancel() {
DCHECK(origin_loop_->BelongsToCurrentThread());
- callback_.reset();
+ callback_.Reset();
}
void OwnershipStatusChecker::Core::CheckOnFileThread() {
@@ -60,17 +59,16 @@ void OwnershipStatusChecker::Core::CheckOnFileThread() {
OwnershipService::GetSharedInstance()->CurrentUserIsOwner();
origin_loop_->PostTask(
FROM_HERE,
- NewRunnableMethod(this,
- &OwnershipStatusChecker::Core::ReportResult,
- status, current_user_is_owner));
+ base::Bind(&OwnershipStatusChecker::Core::ReportResult, this, status,
+ current_user_is_owner));
}
void OwnershipStatusChecker::Core::ReportResult(
OwnershipService::Status status, bool current_user_is_owner) {
DCHECK(origin_loop_->BelongsToCurrentThread());
- if (callback_.get()) {
- callback_->Run(status, current_user_is_owner);
- callback_.reset();
+ if (!callback_.is_null()) {
+ callback_.Run(status, current_user_is_owner);
+ callback_.Reset();
}
}
diff --git a/chrome/browser/chromeos/login/ownership_status_checker.h b/chrome/browser/chromeos/login/ownership_status_checker.h
index d94bdef..cbf2eae 100644
--- a/chrome/browser/chromeos/login/ownership_status_checker.h
+++ b/chrome/browser/chromeos/login/ownership_status_checker.h
@@ -7,7 +7,7 @@
#pragma once
#include "base/basictypes.h"
-#include "base/callback_old.h"
+#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop_proxy.h"
@@ -25,16 +25,16 @@ class OwnershipStatusChecker {
// Callback function type. The status code is guaranteed to be different from
// OWNERSHIP_UNKNOWN. The bool parameter is true iff the current logged in
// user is the owner.
- typedef Callback2<OwnershipService::Status, bool>::Type Callback;
+ typedef base::Callback<void(OwnershipService::Status, bool)> Callback;
- explicit OwnershipStatusChecker(Callback* callback);
+ explicit OwnershipStatusChecker(const Callback& callback);
~OwnershipStatusChecker();
private:
// The refcounted core that handles the thread switching.
class Core : public base::RefCountedThreadSafe<Core> {
public:
- explicit Core(Callback* callback);
+ explicit Core(const Callback& callback);
~Core();
// Starts the check.
@@ -48,7 +48,7 @@ class OwnershipStatusChecker {
void ReportResult(OwnershipService::Status status,
bool current_user_is_owner);
- scoped_ptr<Callback> callback_;
+ Callback callback_;
scoped_refptr<base::MessageLoopProxy> origin_loop_;
DISALLOW_COPY_AND_ASSIGN(Core);
diff --git a/chrome/browser/chromeos/login/parallel_authenticator.cc b/chrome/browser/chromeos/login/parallel_authenticator.cc
index cb130e3..d7b11c8 100644
--- a/chrome/browser/chromeos/login/parallel_authenticator.cc
+++ b/chrome/browser/chromeos/login/parallel_authenticator.cc
@@ -7,6 +7,7 @@
#include <string>
#include <vector>
+#include "base/bind.h"
#include "base/command_line.h"
#include "base/file_path.h"
#include "base/file_util.h"
@@ -126,8 +127,8 @@ void ParallelAuthenticator::AuthenticateToLogin(
// Sadly, this MUST be on the UI thread due to sending DBus traffic :-/
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(mounter_.get(), &CryptohomeOp::Initiate));
+ base::Bind(&CryptohomeOp::Initiate, mounter_.get()));
// ClientLogin authentication check should happen immediately here.
// We should not try OAuthLogin check until the profile loads.
if (!using_oauth_) {
@@ -140,9 +141,8 @@ void ParallelAuthenticator::AuthenticateToLogin(
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(this,
- &ParallelAuthenticator::LoadLocalaccount,
- std::string(kLocalaccountFile)));
+ base::Bind(&ParallelAuthenticator::LoadLocalaccount, this,
+ std::string(kLocalaccountFile)));
}
void ParallelAuthenticator::CompleteLogin(Profile* profile,
@@ -161,7 +161,7 @@ void ParallelAuthenticator::CompleteLogin(Profile* profile,
// Sadly, this MUST be on the UI thread due to sending DBus traffic :-/
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(mounter_.get(), &CryptohomeOp::Initiate));
+ base::Bind(&CryptohomeOp::Initiate, mounter_.get()));
if (!using_oauth_) {
// Test automation needs to disable oauth, but that leads to other
@@ -178,15 +178,13 @@ void ParallelAuthenticator::CompleteLogin(Profile* profile,
// parallel.
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(this,
- &ParallelAuthenticator::ResolveLoginCompletionStatus));
+ base::Bind(&ParallelAuthenticator::ResolveLoginCompletionStatus, this));
}
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(this,
- &ParallelAuthenticator::LoadLocalaccount,
- std::string(kLocalaccountFile)));
+ base::Bind(&ParallelAuthenticator::LoadLocalaccount, this,
+ std::string(kLocalaccountFile)));
}
void ParallelAuthenticator::AuthenticateToUnlock(const std::string& username,
@@ -196,15 +194,14 @@ void ParallelAuthenticator::AuthenticateToUnlock(const std::string& username,
HashPassword(password)));
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(this,
- &ParallelAuthenticator::LoadLocalaccount,
- std::string(kLocalaccountFile)));
+ base::Bind(&ParallelAuthenticator::LoadLocalaccount, this,
+ std::string(kLocalaccountFile)));
key_checker_ = CryptohomeOp::CreateCheckKeyAttempt(current_state_.get(),
this);
// Sadly, this MUST be on the UI thread due to sending DBus traffic :-/
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(key_checker_.get(), &CryptohomeOp::Initiate));
+ base::Bind(&CryptohomeOp::Initiate, key_checker_.get()));
}
void ParallelAuthenticator::LoginOffTheRecord() {
@@ -261,9 +258,7 @@ void ParallelAuthenticator::CheckLocalaccount(const LoginFailure& error) {
if (!checked_for_localaccount_) {
BrowserThread::PostDelayedTask(
BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(this,
- &ParallelAuthenticator::CheckLocalaccount,
- error),
+ base::Bind(&ParallelAuthenticator::CheckLocalaccount, this, error),
kLocalaccountRetryIntervalMs);
return;
}
@@ -276,18 +271,18 @@ void ParallelAuthenticator::CheckLocalaccount(const LoginFailure& error) {
CryptohomeOp::CreateMountGuestAttempt(current_state_.get(), this);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(guest_mounter_.get(), &CryptohomeOp::Initiate));
+ base::Bind(&CryptohomeOp::Initiate, guest_mounter_.get()));
} else {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this, &ParallelAuthenticator::OnLoginSuccess,
- GaiaAuthConsumer::ClientLoginResult(), false));
+ base::Bind(&ParallelAuthenticator::OnLoginSuccess, this,
+ GaiaAuthConsumer::ClientLoginResult(), false));
}
} else {
// Not the localaccount. Fail, passing along cached error info.
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this, &ParallelAuthenticator::OnLoginFailure, error));
+ base::Bind(&ParallelAuthenticator::OnLoginFailure, this, error));
}
}
@@ -322,9 +317,8 @@ void ParallelAuthenticator::RecoverEncryptedData(
old_hash);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(this,
- &ParallelAuthenticator::ResyncRecoverHelper,
- key_migrator_));
+ base::Bind(&ParallelAuthenticator::ResyncRecoverHelper, this,
+ key_migrator_));
}
void ParallelAuthenticator::ResyncEncryptedData(
@@ -333,9 +327,8 @@ void ParallelAuthenticator::ResyncEncryptedData(
CryptohomeOp::CreateRemoveAttempt(current_state_.get(), this);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(this,
- &ParallelAuthenticator::ResyncRecoverHelper,
- data_remover_));
+ base::Bind(&ParallelAuthenticator::ResyncRecoverHelper, this,
+ data_remover_));
}
void ParallelAuthenticator::ResyncRecoverHelper(CryptohomeOp* to_initiate) {
@@ -343,7 +336,7 @@ void ParallelAuthenticator::ResyncRecoverHelper(CryptohomeOp* to_initiate) {
current_state_->ResetCryptohomeStatus();
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(to_initiate, &CryptohomeOp::Initiate));
+ base::Bind(&CryptohomeOp::Initiate, to_initiate));
}
void ParallelAuthenticator::RetryAuth(Profile* profile,
@@ -400,26 +393,24 @@ void ParallelAuthenticator::Resolve() {
// the appropriate failure.
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(
- this,
- &ParallelAuthenticator::OnLoginFailure,
- LoginFailure(LoginFailure::COULD_NOT_MOUNT_CRYPTOHOME)));
+ base::Bind(&ParallelAuthenticator::OnLoginFailure, this,
+ LoginFailure(LoginFailure::COULD_NOT_MOUNT_CRYPTOHOME)));
break;
case FAILED_REMOVE:
// In this case, we tried to remove the user's old cryptohome at her
// request, and the remove failed.
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this, &ParallelAuthenticator::OnLoginFailure,
- LoginFailure(LoginFailure::DATA_REMOVAL_FAILED)));
+ base::Bind(&ParallelAuthenticator::OnLoginFailure, this,
+ LoginFailure(LoginFailure::DATA_REMOVAL_FAILED)));
break;
case FAILED_TMPFS:
// In this case, we tried to mount a tmpfs for BWSI or the localaccount
// user and failed.
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this, &ParallelAuthenticator::OnLoginFailure,
- LoginFailure(LoginFailure::COULD_NOT_MOUNT_TMPFS)));
+ base::Bind(&ParallelAuthenticator::OnLoginFailure, this,
+ LoginFailure(LoginFailure::COULD_NOT_MOUNT_TMPFS)));
break;
case CREATE_NEW:
create = true;
@@ -430,14 +421,13 @@ void ParallelAuthenticator::Resolve() {
create);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(mounter_.get(), &CryptohomeOp::Initiate));
+ base::Bind(&CryptohomeOp::Initiate, mounter_.get()));
break;
case NEED_OLD_PW:
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this,
- &ParallelAuthenticator::OnPasswordChangeDetected,
- current_state_->credentials()));
+ base::Bind(&ParallelAuthenticator::OnPasswordChangeDetected, this,
+ current_state_->credentials()));
break;
case ONLINE_FAILED:
// In this case, we know online login was rejected because the account
@@ -458,8 +448,8 @@ void ParallelAuthenticator::Resolve() {
// OnLoginSuccess(..., ..., true) -> OnLoginFailure().
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this, &ParallelAuthenticator::OnLoginSuccess,
- current_state_->credentials(), true));
+ base::Bind(&ParallelAuthenticator::OnLoginSuccess, this,
+ current_state_->credentials(), true));
}
}
const LoginFailure& login_failure =
@@ -467,18 +457,16 @@ void ParallelAuthenticator::Resolve() {
current_state_->online_outcome();
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this, &ParallelAuthenticator::OnLoginFailure,
- login_failure));
+ base::Bind(&ParallelAuthenticator::OnLoginFailure, this,
+ login_failure));
// Check if we couldn't verify OAuth token here.
if (using_oauth_ &&
login_failure.reason() == LoginFailure::NETWORK_AUTH_FAILED) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this,
- &ParallelAuthenticator::RecordOAuthCheckFailure,
- (reauth_state_.get() ?
- reauth_state_->username :
- current_state_->username)));
+ base::Bind(&ParallelAuthenticator::RecordOAuthCheckFailure, this,
+ (reauth_state_.get() ? reauth_state_->username :
+ current_state_->username)));
}
break;
}
@@ -490,7 +478,7 @@ void ParallelAuthenticator::Resolve() {
current_state_->ascii_hash);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(key_migrator_.get(), &CryptohomeOp::Initiate));
+ base::Bind(&CryptohomeOp::Initiate, key_migrator_.get()));
break;
case OFFLINE_LOGIN:
VLOG(2) << "Offline login";
@@ -510,22 +498,20 @@ void ParallelAuthenticator::Resolve() {
VLOG(2) << "Online login";
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this, &ParallelAuthenticator::OnLoginSuccess,
- current_state_->credentials(), request_pending));
+ base::Bind(&ParallelAuthenticator::OnLoginSuccess, this,
+ current_state_->credentials(), request_pending));
break;
case LOCAL_LOGIN:
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(
- this,
- &ParallelAuthenticator::OnOffTheRecordLoginSuccess));
+ base::Bind(&ParallelAuthenticator::OnOffTheRecordLoginSuccess, this));
break;
case LOGIN_FAILED:
current_state_->ResetCryptohomeStatus();
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(this, &ParallelAuthenticator::CheckLocalaccount,
- current_state_->online_outcome()));
+ base::Bind(&ParallelAuthenticator::CheckLocalaccount, this,
+ current_state_->online_outcome()));
break;
default:
NOTREACHED();
diff --git a/chrome/browser/chromeos/login/parallel_authenticator_unittest.cc b/chrome/browser/chromeos/login/parallel_authenticator_unittest.cc
index ae21abf..38adbda 100644
--- a/chrome/browser/chromeos/login/parallel_authenticator_unittest.cc
+++ b/chrome/browser/chromeos/login/parallel_authenticator_unittest.cc
@@ -7,6 +7,7 @@
#include <string>
#include <vector>
+#include "base/bind.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/memory/scoped_ptr.h"
@@ -155,9 +156,7 @@ class ParallelAuthenticatorTest : public testing::Test {
const std::string& filename) {
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(auth,
- &ParallelAuthenticator::LoadLocalaccount,
- filename));
+ base::Bind(&ParallelAuthenticator::LoadLocalaccount, auth, filename));
file_thread_.Stop();
file_thread_.Start();
}
@@ -214,7 +213,7 @@ class ParallelAuthenticatorTest : public testing::Test {
void RunResolve(ParallelAuthenticator* auth, MessageLoop* loop) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(auth, &ParallelAuthenticator::Resolve));
+ base::Bind(&ParallelAuthenticator::Resolve, auth));
loop->Run();
}
diff --git a/chrome/browser/chromeos/login/screen_locker.cc b/chrome/browser/chromeos/login/screen_locker.cc
index d5a07d2..17b939d 100644
--- a/chrome/browser/chromeos/login/screen_locker.cc
+++ b/chrome/browser/chromeos/login/screen_locker.cc
@@ -13,8 +13,10 @@
// Evil hack to undo X11 evil #define. See crosbug.com/
#undef Status
+#include "base/bind.h"
#include "base/command_line.h"
#include "base/lazy_instance.h"
+#include "base/memory/weak_ptr.h"
#include "base/message_loop.h"
#include "base/metrics/histogram.h"
#include "base/string_util.h"
@@ -299,7 +301,7 @@ class GrabWidget : public views::NativeWidgetGtk {
explicit GrabWidget(chromeos::ScreenLocker* screen_locker)
: views::NativeWidgetGtk(new views::Widget),
screen_locker_(screen_locker),
- ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)),
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
grab_failure_count_(0),
kbd_grab_status_(GDK_GRAB_INVALID_TIME),
mouse_grab_status_(GDK_GRAB_INVALID_TIME),
@@ -399,7 +401,7 @@ class GrabWidget : public views::NativeWidgetGtk {
}
chromeos::ScreenLocker* screen_locker_;
- ScopedRunnableMethodFactory<GrabWidget> task_factory_;
+ base::WeakPtrFactory<GrabWidget> weak_factory_;
// The number times the widget tried to grab all focus.
int grab_failure_count_;
@@ -442,7 +444,7 @@ void GrabWidget::TryGrabAllInputs() {
gdk_x11_ungrab_server();
MessageLoop::current()->PostDelayedTask(
FROM_HERE,
- task_factory_.NewRunnableMethod(&GrabWidget::TryGrabAllInputs),
+ base::Bind(&GrabWidget::TryGrabAllInputs, weak_factory_.GetWeakPtr()),
kRetryGrabIntervalMs);
} else {
gdk_x11_ungrab_server();
@@ -985,10 +987,8 @@ void ScreenLocker::Authenticate(const string16& password) {
} else {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(authenticator_.get(),
- &Authenticator::AuthenticateToUnlock,
- user_.email(),
- UTF16ToUTF8(password)));
+ base::Bind(&Authenticator::AuthenticateToUnlock, authenticator_.get(),
+ user_.email(), UTF16ToUTF8(password)));
}
}
diff --git a/chrome/browser/chromeos/login/signed_settings.cc b/chrome/browser/chromeos/login/signed_settings.cc
index 3e25a9c..9c3eed1 100644
--- a/chrome/browser/chromeos/login/signed_settings.cc
+++ b/chrome/browser/chromeos/login/signed_settings.cc
@@ -7,6 +7,7 @@
#include <string>
#include <vector>
+#include "base/bind.h"
#include "base/memory/ref_counted.h"
#include "base/stringprintf.h"
#include "base/threading/thread_restrictions.h"
@@ -364,14 +365,13 @@ void CheckWhitelistOp::Execute() {
void CheckWhitelistOp::Fail(SignedSettings::ReturnCode code) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this, &CheckWhitelistOp::PerformCallback, code, false));
+ base::Bind(&CheckWhitelistOp::PerformCallback, this, code, false));
}
void CheckWhitelistOp::Succeed(bool value) {
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this,
- &CheckWhitelistOp::PerformCallback,
- SUCCESS, value));
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&CheckWhitelistOp::PerformCallback, this, SUCCESS, value));
}
void CheckWhitelistOp::OnKeyOpComplete(
@@ -382,9 +382,8 @@ void CheckWhitelistOp::OnKeyOpComplete(
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this,
- &CheckWhitelistOp::OnKeyOpComplete,
- return_code, payload));
+ base::Bind(&CheckWhitelistOp::OnKeyOpComplete, this, return_code,
+ payload));
return;
}
if (return_code == OwnerManager::SUCCESS) {
@@ -447,13 +446,13 @@ void WhitelistOp::Execute() {
void WhitelistOp::Fail(SignedSettings::ReturnCode code) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this, &WhitelistOp::PerformCallback, code, false));
+ base::Bind(&WhitelistOp::PerformCallback, this, code, false));
}
void WhitelistOp::Succeed(bool value) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this, &WhitelistOp::PerformCallback, SUCCESS, value));
+ base::Bind(&WhitelistOp::PerformCallback, this, SUCCESS, value));
}
void WhitelistOp::OnKeyOpComplete(const OwnerManager::KeyOpCode return_code,
@@ -462,9 +461,7 @@ void WhitelistOp::OnKeyOpComplete(const OwnerManager::KeyOpCode return_code,
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this,
- &WhitelistOp::OnKeyOpComplete,
- return_code, sig));
+ base::Bind(&WhitelistOp::OnKeyOpComplete, this, return_code, sig));
return;
}
VLOG(2) << "WhitelistOp::OnKeyOpComplete return_code = " << return_code;
@@ -559,14 +556,13 @@ void StorePropertyOp::Execute() {
void StorePropertyOp::Fail(SignedSettings::ReturnCode code) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this, &StorePropertyOp::PerformCallback, code, false));
+ base::Bind(&StorePropertyOp::PerformCallback, this, code, false));
}
void StorePropertyOp::Succeed(bool value) {
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this,
- &StorePropertyOp::PerformCallback,
- SUCCESS, value));
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&StorePropertyOp::PerformCallback, this, SUCCESS, value));
}
void StorePropertyOp::OnKeyOpComplete(const OwnerManager::KeyOpCode return_code,
@@ -575,9 +571,7 @@ void StorePropertyOp::OnKeyOpComplete(const OwnerManager::KeyOpCode return_code,
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this,
- &StorePropertyOp::OnKeyOpComplete,
- return_code, sig));
+ base::Bind(&StorePropertyOp::OnKeyOpComplete, this, return_code, sig));
return;
}
VLOG(2) << "StorePropertyOp::OnKeyOpComplete return_code = " << return_code;
@@ -691,16 +685,14 @@ void RetrievePropertyOp::Execute() {
void RetrievePropertyOp::Fail(SignedSettings::ReturnCode code) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this,
- &RetrievePropertyOp::PerformCallback,
- code, std::string()));
+ base::Bind(&RetrievePropertyOp::PerformCallback, this, code,
+ std::string()));
}
void RetrievePropertyOp::Succeed(const std::string& value) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this,
- &RetrievePropertyOp::PerformCallback, SUCCESS, value));
+ base::Bind(&RetrievePropertyOp::PerformCallback, this, SUCCESS, value));
}
// DEPRECATED.
@@ -814,7 +806,7 @@ void StorePolicyOp::Execute() {
void StorePolicyOp::Fail(SignedSettings::ReturnCode code) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this, &StorePolicyOp::PerformCallback, code, false));
+ base::Bind(&StorePolicyOp::PerformCallback, this, code, false));
}
void StorePolicyOp::Succeed(bool ignored) {
@@ -829,7 +821,7 @@ void StorePolicyOp::Succeed(bool ignored) {
}
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this, &StorePolicyOp::PerformCallback, code, to_ret));
+ base::Bind(&StorePolicyOp::PerformCallback, this, code, to_ret));
}
void StorePolicyOp::OnKeyOpComplete(const OwnerManager::KeyOpCode return_code,
@@ -838,9 +830,8 @@ void StorePolicyOp::OnKeyOpComplete(const OwnerManager::KeyOpCode return_code,
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this,
- &StorePolicyOp::OnKeyOpComplete,
- return_code, payload));
+ base::Bind(&StorePolicyOp::OnKeyOpComplete, this, return_code,
+ payload));
return;
}
VLOG(2) << "StorePolicyOp::OnKeyOpComplete return_code = " << return_code;
@@ -892,8 +883,8 @@ void RetrievePolicyOp::Fail(SignedSettings::ReturnCode code) {
VLOG(2) << "RetrievePolicyOp::Execute() failed with " << code;
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this, &RetrievePolicyOp::PerformCallback, code,
- em::PolicyFetchResponse()));
+ base::Bind(&RetrievePolicyOp::PerformCallback, this, code,
+ em::PolicyFetchResponse()));
}
void RetrievePolicyOp::Succeed(const em::PolicyFetchResponse& value) {
@@ -902,9 +893,7 @@ void RetrievePolicyOp::Succeed(const em::PolicyFetchResponse& value) {
service_->set_cached_policy(poldata);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this,
- &RetrievePolicyOp::PerformCallback,
- SUCCESS, value));
+ base::Bind(&RetrievePolicyOp::PerformCallback, this, SUCCESS, value));
} else {
Fail(NOT_FOUND);
}
@@ -916,9 +905,8 @@ void RetrievePolicyOp::OnKeyOpComplete(
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this,
- &RetrievePolicyOp::OnKeyOpComplete,
- return_code, payload));
+ base::Bind(&RetrievePolicyOp::OnKeyOpComplete, this, return_code,
+ payload));
return;
}
// Now, sure we're on the UI thread.
diff --git a/chrome/browser/chromeos/login/tpm_password_fetcher.cc b/chrome/browser/chromeos/login/tpm_password_fetcher.cc
index 1ca2786..0c5bca5 100644
--- a/chrome/browser/chromeos/login/tpm_password_fetcher.cc
+++ b/chrome/browser/chromeos/login/tpm_password_fetcher.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/chromeos/login/tpm_password_fetcher.h"
+#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/message_loop.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
@@ -19,7 +20,7 @@ const int kTpmCheckIntervalMs = 500;
} // namespace
TpmPasswordFetcher::TpmPasswordFetcher(TpmPasswordFetcherDelegate* delegate)
- : ALLOW_THIS_IN_INITIALIZER_LIST(runnable_method_factory_(this)),
+ : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
delegate_(delegate) {
DCHECK(delegate_);
}
@@ -29,7 +30,7 @@ TpmPasswordFetcher::~TpmPasswordFetcher() {
void TpmPasswordFetcher::Fetch() {
// Since this method is also called directly.
- runnable_method_factory_.RevokeAll();
+ weak_factory_.InvalidateWeakPtrs();
std::string password;
@@ -48,7 +49,7 @@ void TpmPasswordFetcher::Fetch() {
// Password hasn't been acquired, reschedule fetch.
MessageLoop::current()->PostDelayedTask(
FROM_HERE,
- runnable_method_factory_.NewRunnableMethod(&TpmPasswordFetcher::Fetch),
+ base::Bind(&TpmPasswordFetcher::Fetch, weak_factory_.GetWeakPtr()),
kTpmCheckIntervalMs);
}
}
diff --git a/chrome/browser/chromeos/login/tpm_password_fetcher.h b/chrome/browser/chromeos/login/tpm_password_fetcher.h
index f67cea8..b30783d 100644
--- a/chrome/browser/chromeos/login/tpm_password_fetcher.h
+++ b/chrome/browser/chromeos/login/tpm_password_fetcher.h
@@ -6,7 +6,9 @@
#define CHROME_BROWSER_CHROMEOS_LOGIN_TPM_PASSWORD_FETCHER_H_
#include <string>
+
#include "base/basictypes.h"
+#include "base/memory/weak_ptr.h"
#include "base/task.h"
namespace chromeos {
@@ -32,7 +34,7 @@ class TpmPasswordFetcher {
void Fetch();
private:
- ScopedRunnableMethodFactory<TpmPasswordFetcher> runnable_method_factory_;
+ base::WeakPtrFactory<TpmPasswordFetcher> weak_factory_;
TpmPasswordFetcherDelegate* delegate_;
DISALLOW_COPY_AND_ASSIGN(TpmPasswordFetcher);
diff --git a/chrome/browser/chromeos/login/user_image_loader.cc b/chrome/browser/chromeos/login/user_image_loader.cc
index 97d05c4..d306f89 100644
--- a/chrome/browser/chromeos/login/user_image_loader.cc
+++ b/chrome/browser/chromeos/login/user_image_loader.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/chromeos/login/user_image_loader.h"
+#include "base/bind.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/message_loop.h"
@@ -32,12 +33,9 @@ void UserImageLoader::Start(const std::string& username,
target_message_loop_ = MessageLoop::current();
ImageInfo image_info(username, image_index, should_save_image);
- BrowserThread::PostTask(BrowserThread::FILE,
- FROM_HERE,
- NewRunnableMethod(this,
- &UserImageLoader::LoadImage,
- filename,
- image_info));
+ BrowserThread::PostTask(
+ BrowserThread::FILE, FROM_HERE,
+ base::Bind(&UserImageLoader::LoadImage, this, filename, image_info));
}
void UserImageLoader::LoadImage(const std::string& filepath,
@@ -76,11 +74,10 @@ void UserImageLoader::OnImageDecoded(const ImageDecoder* decoder,
login::kUserImageSize,
login::kUserImageSize);
}
- target_message_loop_->PostTask(FROM_HERE,
- NewRunnableMethod(this,
- &UserImageLoader::NotifyDelegate,
- final_image,
- image_info));
+ target_message_loop_->PostTask(
+ FROM_HERE,
+ base::Bind(&UserImageLoader::NotifyDelegate, this, final_image,
+ image_info));
image_info_map_.erase(info_it);
}
diff --git a/chrome/browser/chromeos/login/user_manager.cc b/chrome/browser/chromeos/login/user_manager.cc
index 57075a0..9271da0 100644
--- a/chrome/browser/chromeos/login/user_manager.cc
+++ b/chrome/browser/chromeos/login/user_manager.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/chromeos/login/user_manager.h"
+#include "base/bind.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/file_path.h"
@@ -11,6 +12,7 @@
#include "base/lazy_instance.h"
#include "base/location.h"
#include "base/logging.h"
+#include "base/memory/weak_ptr.h"
#include "base/metrics/histogram.h"
#include "base/path_service.h"
#include "base/rand_util.h"
@@ -145,10 +147,9 @@ void SaveImageToFile(const SkBitmap& image,
}
BrowserThread::PostTask(
- BrowserThread::UI,
- FROM_HERE,
- NewRunnableFunction(&SaveImageToLocalState,
- username, image_path.value(), image_index));
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&SaveImageToLocalState, username, image_path.value(),
+ image_index));
}
// Deletes user's image file. Runs on FILE thread.
@@ -186,9 +187,8 @@ void CheckOwnership() {
// UserManager should be accessed only on UI thread.
BrowserThread::PostTask(
- BrowserThread::UI,
- FROM_HERE,
- NewRunnableFunction(&UpdateOwnership, is_owner));
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&UpdateOwnership, is_owner));
}
// Used to handle the asynchronous response of deleting a cryptohome directory.
@@ -200,7 +200,7 @@ class RemoveAttempt : public CryptohomeLibrary::Delegate {
chromeos::RemoveUserDelegate* delegate)
: user_email_(user_email),
delegate_(delegate),
- method_factory_(this) {
+ weak_factory_(this) {
RemoveUser();
}
@@ -211,7 +211,7 @@ class RemoveAttempt : public CryptohomeLibrary::Delegate {
// Must not proceed without signature verification.
UserCrosSettingsProvider user_settings;
bool trusted_owner_available = user_settings.RequestTrustedOwner(
- method_factory_.NewRunnableMethod(&RemoveAttempt::RemoveUser));
+ base::Bind(&RemoveAttempt::RemoveUser, weak_factory_.GetWeakPtr()));
if (!trusted_owner_available) {
// Value of owner email is still not verified.
// Another attempt will be invoked after verification completion.
@@ -255,7 +255,7 @@ class RemoveAttempt : public CryptohomeLibrary::Delegate {
chromeos::RemoveUserDelegate* delegate_;
// Factory of callbacks.
- ScopedRunnableMethodFactory<RemoveAttempt> method_factory_;
+ base::WeakPtrFactory<RemoveAttempt> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(RemoveAttempt);
};
@@ -464,10 +464,9 @@ void UserManager::UserLoggedIn(const std::string& email) {
int image_index = logged_in_user_.default_image_index();
if (image_index == User::kProfileImageIndex) {
BrowserThread::PostDelayedTask(
- BrowserThread::UI,
- FROM_HERE,
- method_factory_.NewRunnableMethod(
- &UserManager::DownloadProfileImage),
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&UserManager::DownloadProfileImage,
+ weak_factory_.GetWeakPtr()),
kProfileImageDownloadDelayMs);
}
@@ -545,10 +544,8 @@ void UserManager::RemoveUserFromList(const std::string& email) {
if (!IsDefaultImagePath(image_path_string, &default_image_id)) {
FilePath image_path(image_path_string);
BrowserThread::PostTask(
- BrowserThread::FILE,
- FROM_HERE,
- NewRunnableFunction(&DeleteUserImage,
- image_path));
+ BrowserThread::FILE, FROM_HERE,
+ base::Bind(&DeleteUserImage, image_path));
}
}
@@ -603,10 +600,8 @@ void UserManager::SaveUserImage(const std::string& username,
DVLOG(1) << "Saving user image to " << image_path.value();
BrowserThread::PostTask(
- BrowserThread::FILE,
- FROM_HERE,
- NewRunnableFunction(&SaveImageToFile,
- image, image_path, username, image_index));
+ BrowserThread::FILE, FROM_HERE,
+ base::Bind(&SaveImageToFile, image, image_path, username, image_index));
}
void UserManager::SaveUserOAuthStatus(const std::string& username,
@@ -702,7 +697,7 @@ UserManager::UserManager()
current_user_is_owner_(false),
current_user_is_new_(false),
user_is_logged_in_(false),
- ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
registrar_.Add(this, chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED,
NotificationService::AllSources());
}
@@ -776,16 +771,16 @@ void UserManager::NotifyOnLogin() {
}
// Schedules current user ownership check on file thread.
- BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
- NewRunnableFunction(&CheckOwnership));
+ BrowserThread::PostTask(
+ BrowserThread::FILE, FROM_HERE, base::Bind(&CheckOwnership));
}
void UserManager::Observe(int type,
const NotificationSource& source,
const NotificationDetails& details) {
if (type == chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED) {
- BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
- NewRunnableFunction(&CheckOwnership));
+ BrowserThread::PostTask(
+ BrowserThread::FILE, FROM_HERE, base::Bind(&CheckOwnership));
}
}
diff --git a/chrome/browser/chromeos/login/user_manager.h b/chrome/browser/chromeos/login/user_manager.h
index 4ef7be1..30e6330 100644
--- a/chrome/browser/chromeos/login/user_manager.h
+++ b/chrome/browser/chromeos/login/user_manager.h
@@ -11,8 +11,8 @@
#include "base/basictypes.h"
#include "base/hash_tables.h"
-#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/synchronization/lock.h"
#include "base/task.h"
@@ -272,7 +272,7 @@ class UserManager : public UserImageLoader::Delegate,
// Download user profile image on login to update it if it's changed.
scoped_ptr<ProfileImageDownloader> profile_image_downloader_;
- ScopedRunnableMethodFactory<UserManager> method_factory_;
+ base::WeakPtrFactory<UserManager> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(UserManager);
};
diff --git a/chrome/browser/chromeos/login/wizard_controller.cc b/chrome/browser/chromeos/login/wizard_controller.cc
index dbbf636..d13fa2c 100644
--- a/chrome/browser/chromeos/login/wizard_controller.cc
+++ b/chrome/browser/chromeos/login/wizard_controller.cc
@@ -10,6 +10,7 @@
#include <string>
#include <vector>
+#include "base/bind.h"
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/logging.h"
@@ -435,9 +436,8 @@ void WizardController::OnUserImageSelected() {
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
- NewRunnableFunction(&chromeos::LoginUtils::DoBrowserLaunch,
- ProfileManager::GetDefaultProfile(),
- host_));
+ base::Bind(&chromeos::LoginUtils::DoBrowserLaunch,
+ ProfileManager::GetDefaultProfile(), host_));
host_ = NULL;
// TODO(avayvod): Sync image with Google Sync.
}
@@ -591,7 +591,7 @@ bool WizardController::IsDeviceRegistered() {
BrowserThread::PostTask(
BrowserThread::FILE,
FROM_HERE,
- NewRunnableFunction(&CreateOobeCompleteFlagFile));
+ base::Bind(&CreateOobeCompleteFlagFile));
return true;
} else if (value == 0) {
return false;
@@ -612,7 +612,7 @@ void WizardController::MarkDeviceRegistered() {
BrowserThread::PostTask(
BrowserThread::FILE,
FROM_HERE,
- NewRunnableFunction(&CreateOobeCompleteFlagFile));
+ base::Bind(&CreateOobeCompleteFlagFile));
}
// static
diff --git a/chrome/browser/chromeos/user_cros_settings_provider.cc b/chrome/browser/chromeos/user_cros_settings_provider.cc
index 764c846..d6e4df2 100644
--- a/chrome/browser/chromeos/user_cros_settings_provider.cc
+++ b/chrome/browser/chromeos/user_cros_settings_provider.cc
@@ -7,6 +7,9 @@
#include <map>
#include <set>
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/callback.h"
#include "base/hash_tables.h"
#include "base/logging.h"
#include "base/memory/singleton.h"
@@ -80,8 +83,8 @@ class MigrationHelper : public NotificationObserver {
}
void MigrateValues(void) {
- ownership_checker_.reset(new OwnershipStatusChecker(NewCallback(
- this, &MigrationHelper::DoMigrateValues)));
+ ownership_checker_.reset(new OwnershipStatusChecker(
+ base::Bind(&MigrationHelper::DoMigrateValues, base::Unretained(this))));
}
// NotificationObserver overrides:
@@ -269,12 +272,12 @@ class UserCrosSettingsTrust : public SignedSettingsHelper::Callback {
return false;
}
- bool RequestTrustedEntity(const std::string& name, Task* callback) {
+ bool RequestTrustedEntity(const std::string& name,
+ const base::Closure& callback) {
if (RequestTrustedEntity(name)) {
- delete callback;
return true;
} else {
- if (callback)
+ if (!callback.is_null())
callbacks_[name].push_back(callback);
return false;
}
@@ -491,7 +494,7 @@ class UserCrosSettingsTrust : public SignedSettingsHelper::Callback {
}
prefs->SetBoolean((name + kTrustedSuffix).c_str(), true);
{
- std::vector<Task*>& callbacks_vector = callbacks_[name];
+ std::vector<base::Closure>& callbacks_vector = callbacks_[name];
for (size_t i = 0; i < callbacks_vector.size(); ++i)
MessageLoop::current()->PostTask(FROM_HERE, callbacks_vector[i]);
callbacks_vector.clear();
@@ -533,7 +536,7 @@ class UserCrosSettingsTrust : public SignedSettingsHelper::Callback {
}
// Pending callbacks that need to be invoked after settings verification.
- base::hash_map< std::string, std::vector< Task* > > callbacks_;
+ base::hash_map<std::string, std::vector<base::Closure> > callbacks_;
OwnershipService* ownership_service_;
MigrationHelper migration_helper_;
@@ -573,33 +576,38 @@ void UserCrosSettingsProvider::RegisterPrefs(PrefService* local_state) {
RegisterSetting(local_state, kListSettings[i]);
}
-bool UserCrosSettingsProvider::RequestTrustedAllowGuest(Task* callback) {
+bool UserCrosSettingsProvider::RequestTrustedAllowGuest(
+ const base::Closure& callback) {
return UserCrosSettingsTrust::GetInstance()->RequestTrustedEntity(
kAccountsPrefAllowGuest, callback);
}
-bool UserCrosSettingsProvider::RequestTrustedAllowNewUser(Task* callback) {
+bool UserCrosSettingsProvider::RequestTrustedAllowNewUser(
+ const base::Closure& callback) {
return UserCrosSettingsTrust::GetInstance()->RequestTrustedEntity(
kAccountsPrefAllowNewUser, callback);
}
-bool UserCrosSettingsProvider::RequestTrustedShowUsersOnSignin(Task* callback) {
+bool UserCrosSettingsProvider::RequestTrustedShowUsersOnSignin(
+ const base::Closure& callback) {
return UserCrosSettingsTrust::GetInstance()->RequestTrustedEntity(
kAccountsPrefShowUserNamesOnSignIn, callback);
}
bool UserCrosSettingsProvider::RequestTrustedDataRoamingEnabled(
- Task* callback) {
+ const base::Closure& callback) {
return UserCrosSettingsTrust::GetInstance()->RequestTrustedEntity(
kSignedDataRoamingEnabled, callback);
}
-bool UserCrosSettingsProvider::RequestTrustedOwner(Task* callback) {
+bool UserCrosSettingsProvider::RequestTrustedOwner(
+ const base::Closure& callback) {
return UserCrosSettingsTrust::GetInstance()->RequestTrustedEntity(
kDeviceOwner, callback);
}
-bool UserCrosSettingsProvider::RequestTrustedReportingEnabled(Task* callback) {
+bool UserCrosSettingsProvider::RequestTrustedReportingEnabled(
+ const base::Closure& callback) {
return UserCrosSettingsTrust::GetInstance()->RequestTrustedEntity(
kStatsReportingPref, callback);
}
diff --git a/chrome/browser/chromeos/user_cros_settings_provider.h b/chrome/browser/chromeos/user_cros_settings_provider.h
index 0aa70a9..0c218f1 100644
--- a/chrome/browser/chromeos/user_cros_settings_provider.h
+++ b/chrome/browser/chromeos/user_cros_settings_provider.h
@@ -9,6 +9,7 @@
#include <string>
#include "base/basictypes.h"
+#include "base/callback.h"
#include "chrome/browser/chromeos/cros_settings_provider.h"
#include "chrome/browser/chromeos/login/signed_settings_helper.h"
@@ -37,12 +38,12 @@ class UserCrosSettingsProvider : public CrosSettingsProvider {
// return trusted value.
// Return false if trusted values are unavailable at a moment.
// In latter case passed task will be posted when ready.
- bool RequestTrustedAllowGuest(Task* callback);
- bool RequestTrustedAllowNewUser(Task* callback);
- bool RequestTrustedDataRoamingEnabled(Task* callback);
- bool RequestTrustedShowUsersOnSignin(Task* callback);
- bool RequestTrustedOwner(Task* callback);
- bool RequestTrustedReportingEnabled(Task* callback);
+ bool RequestTrustedAllowGuest(const base::Closure& callback);
+ bool RequestTrustedAllowNewUser(const base::Closure& callback);
+ bool RequestTrustedDataRoamingEnabled(const base::Closure& callback);
+ bool RequestTrustedShowUsersOnSignin(const base::Closure& callback);
+ bool RequestTrustedOwner(const base::Closure& callback);
+ bool RequestTrustedReportingEnabled(const base::Closure& callback);
// Reloads values from device settings.
void Reload();