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

Unified Diff: chrome/browser/sync/test_profile_sync_service.cc

Issue 15421011: Use OAuth2 token for sync (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 7 years, 6 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
Index: chrome/browser/sync/test_profile_sync_service.cc
diff --git a/chrome/browser/sync/test_profile_sync_service.cc b/chrome/browser/sync/test_profile_sync_service.cc
index 4606b4e9b32e588f230d8a29b6946652d8795dba..0937065ffae085d3bf270389022f1eb8a6130a33 100644
--- a/chrome/browser/sync/test_profile_sync_service.cc
+++ b/chrome/browser/sync/test_profile_sync_service.cc
@@ -85,7 +85,7 @@ void SyncBackendHostForProfileSyncTest::InitCore(
new TestInternalComponentsFactory(factory_switches, storage);
SyncBackendHost::InitCore(test_options);
- if (synchronous_init_) {
+ if (synchronous_init_ && !base::MessageLoop::current()->is_running()) {
// The SyncBackend posts a task to the current loop when
// initialization completes.
base::MessageLoop::current()->Run();
@@ -249,6 +249,23 @@ TestProfileSyncService::components_factory_mock() {
return static_cast<ProfileSyncComponentsFactoryMock*>(factory());
}
+void TestProfileSyncService::RequestAccessToken() {
+ ProfileSyncService::RequestAccessToken();
+ if (synchronous_backend_initialization_) {
+ base::MessageLoop::current()->Run();
+ }
+}
+
+void TestProfileSyncService::OnGetTokenFailure(
+ const OAuth2TokenService::Request* request,
+ const GoogleServiceAuthError& error) {
+ ProfileSyncService::OnGetTokenFailure(request, error);
+ if (synchronous_backend_initialization_) {
+ base::MessageLoop::current()->Quit();
+ }
+}
+
+
void TestProfileSyncService::OnBackendInitialized(
const syncer::WeakHandle<syncer::JsBackend>& backend,
const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&
@@ -301,3 +318,23 @@ void TestProfileSyncService::CreateBackend() {
fail_initial_download_,
storage_option_));
}
+
+scoped_ptr<OAuth2TokenService::Request> FakeOAuth2TokenService::StartRequest(
+ const OAuth2TokenService::ScopeSet& scopes,
+ OAuth2TokenService::Consumer* consumer) {
+ // Ensure token in question is cached and never expires. Request will succeed
+ // without network IO.
+ RegisterCacheEntry(GetRefreshToken(), scopes, "access_token",
+ base::Time::Max());
+ return ProfileOAuth2TokenService::StartRequest(scopes, consumer);
+}
+
+BrowserContextKeyedService* FakeOAuth2TokenService::BuildTokenService(
+ content::BrowserContext* context) {
+ Profile* profile = static_cast<Profile*>(context);
+
+ FakeOAuth2TokenService* service =
+ new FakeOAuth2TokenService(context->GetRequestContext());
+ service->Initialize(profile);
+ return service;
+}
« no previous file with comments | « chrome/browser/sync/test_profile_sync_service.h ('k') | chrome/browser/ui/webui/options/browser_options_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698