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

Unified Diff: chromeos/login/auth/online_attempt.cc

Issue 402403004: Refactoring : Move OnlineAttempt to chromeos/login (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Yet another merge with ToT Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/login/auth/online_attempt.h ('k') | chromeos/login/auth/online_attempt_host.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/login/auth/online_attempt.cc
diff --git a/chrome/browser/chromeos/login/auth/online_attempt.cc b/chromeos/login/auth/online_attempt.cc
similarity index 82%
rename from chrome/browser/chromeos/login/auth/online_attempt.cc
rename to chromeos/login/auth/online_attempt.cc
index 5dfed04fdff55fdbc10f493ed251778a257be38d..fc728f674c20eee37a8127da839804bfe6326f37 100644
--- a/chrome/browser/chromeos/login/auth/online_attempt.cc
+++ b/chromeos/login/auth/online_attempt.cc
@@ -2,21 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/chromeos/login/auth/online_attempt.h"
+#include "chromeos/login/auth/online_attempt.h"
#include <string>
#include "base/bind.h"
+#include "base/location.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/message_loop/message_loop_proxy.h"
#include "chromeos/login/auth/auth_attempt_state.h"
#include "chromeos/login/auth/auth_attempt_state_resolver.h"
#include "chromeos/login/auth/key.h"
#include "chromeos/login/auth/user_context.h"
#include "components/user_manager/user_type.h"
-#include "content/public/browser/browser_context.h"
-#include "content/public/browser/browser_thread.h"
#include "google_apis/gaia/gaia_auth_consumer.h"
#include "google_apis/gaia/gaia_auth_fetcher.h"
#include "google_apis/gaia/gaia_constants.h"
@@ -24,8 +24,6 @@
#include "net/base/net_errors.h"
#include "net/url_request/url_request_status.h"
-using content::BrowserThread;
-
namespace chromeos {
// static
@@ -33,7 +31,8 @@ const int OnlineAttempt::kClientLoginTimeoutMs = 10000;
OnlineAttempt::OnlineAttempt(AuthAttemptState* current_attempt,
AuthAttemptStateResolver* callback)
- : attempt_(current_attempt),
+ : message_loop_(base::MessageLoopProxy::current()),
+ attempt_(current_attempt),
resolver_(callback),
weak_factory_(this),
try_again_(true) {
@@ -46,19 +45,16 @@ OnlineAttempt::~OnlineAttempt() {
client_fetcher_->CancelRequest();
}
-void OnlineAttempt::Initiate(content::BrowserContext* auth_context) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- client_fetcher_.reset(
- new GaiaAuthFetcher(this, GaiaConstants::kChromeOSSource,
- auth_context->GetRequestContext()));
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
+void OnlineAttempt::Initiate(net::URLRequestContextGetter* request_context) {
+ client_fetcher_.reset(new GaiaAuthFetcher(
+ this, GaiaConstants::kChromeOSSource, request_context));
+ message_loop_->PostTask(
+ FROM_HERE,
base::Bind(&OnlineAttempt::TryClientLogin, weak_factory_.GetWeakPtr()));
}
void OnlineAttempt::OnClientLoginSuccess(
const GaiaAuthConsumer::ClientLoginResult& unused) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
VLOG(1) << "Online login successful!";
weak_factory_.InvalidateWeakPtrs();
@@ -79,10 +75,7 @@ void OnlineAttempt::OnClientLoginSuccess(
TriggerResolve(AuthFailure::AuthFailureNone());
}
-void OnlineAttempt::OnClientLoginFailure(
- const GoogleServiceAuthError& error) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
+void OnlineAttempt::OnClientLoginFailure(const GoogleServiceAuthError& error) {
weak_factory_.InvalidateWeakPtrs();
if (error.state() == GoogleServiceAuthError::REQUEST_CANCELED) {
@@ -119,10 +112,8 @@ void OnlineAttempt::OnClientLoginFailure(
}
void OnlineAttempt::TryClientLogin() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
- BrowserThread::PostDelayedTask(
- BrowserThread::UI, FROM_HERE,
+ message_loop_->PostDelayedTask(
+ FROM_HERE,
base::Bind(&OnlineAttempt::CancelClientLogin, weak_factory_.GetWeakPtr()),
base::TimeDelta::FromMilliseconds(kClientLoginTimeoutMs));
@@ -144,7 +135,6 @@ void OnlineAttempt::CancelRequest() {
}
void OnlineAttempt::CancelClientLogin() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (HasPendingFetch()) {
LOG(WARNING) << "Canceling ClientLogin attempt.";
CancelRequest();
« no previous file with comments | « chromeos/login/auth/online_attempt.h ('k') | chromeos/login/auth/online_attempt_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698