summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-28 23:33:27 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-28 23:33:27 +0000
commit0b8caade234fad8523bee24e84aad4c2a9428b3d (patch)
tree3a7927cd8001f7c1bc441b56380d4545bacf5b92 /chrome/browser/chromeos
parent453f57f0becc1da334668adb0ab9a42c032f85c4 (diff)
downloadchromium_src-0b8caade234fad8523bee24e84aad4c2a9428b3d.zip
chromium_src-0b8caade234fad8523bee24e84aad4c2a9428b3d.tar.gz
chromium_src-0b8caade234fad8523bee24e84aad4c2a9428b3d.tar.bz2
base::Bind: A few Task conversions.
BUG=none TEST=none R=groby@chromium.org Review URL: http://codereview.chromium.org/8719001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111814 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos')
-rw-r--r--chrome/browser/chromeos/login/login_utils.cc113
1 files changed, 52 insertions, 61 deletions
diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc
index 1f80bae..304e73b 100644
--- a/chrome/browser/chromeos/login/login_utils.cc
+++ b/chrome/browser/chromeos/login/login_utils.cc
@@ -103,74 +103,63 @@ const char kServiceScopeChromeOS[] =
const char kServiceScopeChromeOSDeviceManagement[] =
"https://www.googleapis.com/auth/chromeosdevicemanagement";
-} // namespace
-// Transfers initial set of Profile cookies from the default profile.
-class TransferDefaultCookiesOnIOThreadTask : public Task {
+class InitializeCookieMonsterHelper {
public:
- TransferDefaultCookiesOnIOThreadTask(
- net::URLRequestContextGetter* auth_context,
+ explicit InitializeCookieMonsterHelper(
net::URLRequestContextGetter* new_context)
- : auth_context_(auth_context),
- new_context_(new_context) {}
- virtual ~TransferDefaultCookiesOnIOThreadTask() {}
+ : ALLOW_THIS_IN_INITIALIZER_LIST(callback_(base::Bind(
+ &InitializeCookieMonsterHelper::InitializeCookieMonster,
+ base::Unretained(this)))),
+ new_context_(new_context) {
+ }
- // Task override.
- virtual void Run() OVERRIDE {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- net::CookieStore* default_store =
- auth_context_->GetURLRequestContext()->cookie_store();
- net::CookieMonster* default_monster = default_store->GetCookieMonster();
- default_monster->SetKeepExpiredCookies();
- default_monster->GetAllCookiesAsync(
- base::Bind(
- &TransferDefaultCookiesOnIOThreadTask::InitializeCookieMonster,
- base::Unretained(this)));
+ const net::CookieMonster::GetCookieListCallback& callback() const {
+ return callback_;
}
+ private:
void InitializeCookieMonster(const net::CookieList& cookies) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- net::CookieStore* new_store =
- new_context_->GetURLRequestContext()->cookie_store();
- net::CookieMonster* new_monster = new_store->GetCookieMonster();
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ net::CookieStore* new_store =
+ new_context_->GetURLRequestContext()->cookie_store();
+ net::CookieMonster* new_monster = new_store->GetCookieMonster();
- if (!new_monster->InitializeFrom(cookies)) {
+ if (!new_monster->InitializeFrom(cookies))
LOG(WARNING) << "Failed initial cookie transfer.";
- }
}
- private:
- net::URLRequestContextGetter* auth_context_;
- net::URLRequestContextGetter* new_context_;
+ net::CookieMonster::GetCookieListCallback callback_;
+ scoped_refptr<net::URLRequestContextGetter> new_context_;
- DISALLOW_COPY_AND_ASSIGN(TransferDefaultCookiesOnIOThreadTask);
+ DISALLOW_COPY_AND_ASSIGN(InitializeCookieMonsterHelper);
};
-// Transfers initial HTTP proxy authentication from the default profile.
-class TransferDefaultAuthCacheOnIOThreadTask : public Task {
- public:
- TransferDefaultAuthCacheOnIOThreadTask(
- net::URLRequestContextGetter* auth_context,
- net::URLRequestContextGetter* new_context)
- : auth_context_(auth_context),
- new_context_(new_context) {}
- virtual ~TransferDefaultAuthCacheOnIOThreadTask() {}
-
- // Task override.
- virtual void Run() OVERRIDE {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- net::HttpAuthCache* new_cache = new_context_->GetURLRequestContext()->
- http_transaction_factory()->GetSession()->http_auth_cache();
- new_cache->UpdateAllFrom(*auth_context_->GetURLRequestContext()->
- http_transaction_factory()->GetSession()->http_auth_cache());
- }
+// Transfers initial set of Profile cookies from the default profile.
+void TransferDefaultCookiesOnIOThread(
+ net::URLRequestContextGetter* auth_context,
+ net::URLRequestContextGetter* new_context) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ net::CookieStore* default_store =
+ auth_context->GetURLRequestContext()->cookie_store();
+
+ InitializeCookieMonsterHelper helper(new_context);
+ net::CookieMonster* default_monster = default_store->GetCookieMonster();
+ default_monster->SetKeepExpiredCookies();
+ default_monster->GetAllCookiesAsync(helper.callback());
+}
- private:
- net::URLRequestContextGetter* auth_context_;
- net::URLRequestContextGetter* new_context_;
+void TransferDefaultAuthCacheOnIOThread(
+ net::URLRequestContextGetter* auth_context,
+ net::URLRequestContextGetter* new_context) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ net::HttpAuthCache* new_cache = new_context->GetURLRequestContext()->
+ http_transaction_factory()->GetSession()->http_auth_cache();
+ new_cache->UpdateAllFrom(*auth_context->GetURLRequestContext()->
+ http_transaction_factory()->GetSession()->http_auth_cache());
+}
- DISALLOW_COPY_AND_ASSIGN(TransferDefaultAuthCacheOnIOThreadTask);
-};
+} // namespace
// Verifies OAuth1 access token by performing OAuthLogin. Fetches user cookies
// on successful OAuth authentication.
@@ -514,7 +503,7 @@ class JobRestartRequest
// constructor.
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this, &JobRestartRequest::RestartJob));
+ base::Bind(&JobRestartRequest::RestartJob, this));
MessageLoop::current()->AssertIdle();
}
}
@@ -1142,18 +1131,20 @@ BackgroundView* LoginUtilsImpl::GetBackgroundView() {
void LoginUtilsImpl::TransferDefaultCookies(Profile* default_profile,
Profile* profile) {
- BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
- new TransferDefaultCookiesOnIOThreadTask(
- default_profile->GetRequestContext(),
- profile->GetRequestContext()));
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&TransferDefaultCookiesOnIOThread,
+ make_scoped_refptr(default_profile->GetRequestContext()),
+ make_scoped_refptr(profile->GetRequestContext())));
}
void LoginUtilsImpl::TransferDefaultAuthCache(Profile* default_profile,
Profile* profile) {
- BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
- new TransferDefaultAuthCacheOnIOThreadTask(
- default_profile->GetRequestContext(),
- profile->GetRequestContext()));
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&TransferDefaultAuthCacheOnIOThread,
+ make_scoped_refptr(default_profile->GetRequestContext()),
+ make_scoped_refptr(profile->GetRequestContext())));
}
void LoginUtilsImpl::OnGetOAuthTokenSuccess(const std::string& oauth_token) {