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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/sync_engine.cc

Issue 150003004: Replace PO2TS::GetPrimaryAccountId() with SMB::GetAuthenticatedAccountId. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/sync_file_system/drive_backend/sync_engine.h" 5 #include "chrome/browser/sync_file_system/drive_backend/sync_engine.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/threading/sequenced_worker_pool.h" 8 #include "base/threading/sequenced_worker_pool.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/drive/drive_api_service.h" 10 #include "chrome/browser/drive/drive_api_service.h"
11 #include "chrome/browser/drive/drive_notification_manager.h" 11 #include "chrome/browser/drive/drive_notification_manager.h"
12 #include "chrome/browser/drive/drive_notification_manager_factory.h" 12 #include "chrome/browser/drive/drive_notification_manager_factory.h"
13 #include "chrome/browser/drive/drive_service_interface.h" 13 #include "chrome/browser/drive/drive_service_interface.h"
14 #include "chrome/browser/drive/drive_uploader.h" 14 #include "chrome/browser/drive/drive_uploader.h"
15 #include "chrome/browser/drive/drive_uploader.h" 15 #include "chrome/browser/drive/drive_uploader.h"
16 #include "chrome/browser/extensions/extension_service.h" 16 #include "chrome/browser/extensions/extension_service.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/signin/profile_oauth2_token_service.h" 18 #include "chrome/browser/signin/profile_oauth2_token_service.h"
19 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 19 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
20 #include "chrome/browser/signin/signin_manager.h"
21 #include "chrome/browser/signin/signin_manager_factory.h"
20 #include "chrome/browser/sync_file_system/drive_backend/conflict_resolver.h" 22 #include "chrome/browser/sync_file_system/drive_backend/conflict_resolver.h"
21 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants. h" 23 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants. h"
22 #include "chrome/browser/sync_file_system/drive_backend/list_changes_task.h" 24 #include "chrome/browser/sync_file_system/drive_backend/list_changes_task.h"
23 #include "chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.h " 25 #include "chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.h "
24 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.h" 26 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.h"
25 #include "chrome/browser/sync_file_system/drive_backend/register_app_task.h" 27 #include "chrome/browser/sync_file_system/drive_backend/register_app_task.h"
26 #include "chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer.h " 28 #include "chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer.h "
27 #include "chrome/browser/sync_file_system/drive_backend/sync_engine_initializer. h" 29 #include "chrome/browser/sync_file_system/drive_backend/sync_engine_initializer. h"
28 #include "chrome/browser/sync_file_system/drive_backend/uninstall_app_task.h" 30 #include "chrome/browser/sync_file_system/drive_backend/uninstall_app_task.h"
29 #include "chrome/browser/sync_file_system/file_status_observer.h" 31 #include "chrome/browser/sync_file_system/file_status_observer.h"
(...skipping 28 matching lines...) Expand all
58 GURL wapi_base_url( 60 GURL wapi_base_url(
59 google_apis::GDataWapiUrlGenerator::kBaseUrlForProduction); 61 google_apis::GDataWapiUrlGenerator::kBaseUrlForProduction);
60 62
61 scoped_refptr<base::SequencedWorkerPool> worker_pool( 63 scoped_refptr<base::SequencedWorkerPool> worker_pool(
62 content::BrowserThread::GetBlockingPool()); 64 content::BrowserThread::GetBlockingPool());
63 scoped_refptr<base::SequencedTaskRunner> drive_task_runner( 65 scoped_refptr<base::SequencedTaskRunner> drive_task_runner(
64 worker_pool->GetSequencedTaskRunnerWithShutdownBehavior( 66 worker_pool->GetSequencedTaskRunnerWithShutdownBehavior(
65 worker_pool->GetSequenceToken(), 67 worker_pool->GetSequenceToken(),
66 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); 68 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
67 69
70 Profile* profile = Profile::FromBrowserContext(context);
68 ProfileOAuth2TokenService* token_service = 71 ProfileOAuth2TokenService* token_service =
69 ProfileOAuth2TokenServiceFactory::GetForProfile( 72 ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
70 Profile::FromBrowserContext(context)); 73 SigninManagerBase* signin_manager =
74 SigninManagerFactory::GetForProfile(profile);
71 scoped_ptr<drive::DriveServiceInterface> drive_service( 75 scoped_ptr<drive::DriveServiceInterface> drive_service(
72 new drive::DriveAPIService( 76 new drive::DriveAPIService(
73 token_service, 77 token_service,
74 context->GetRequestContext(), 78 context->GetRequestContext(),
75 drive_task_runner.get(), 79 drive_task_runner.get(),
76 base_drive_url, base_download_url, wapi_base_url, 80 base_drive_url, base_download_url, wapi_base_url,
77 std::string() /* custom_user_agent */)); 81 std::string() /* custom_user_agent */));
78 drive_service->Initialize(token_service->GetPrimaryAccountId()); 82 drive_service->Initialize(signin_manager->GetAuthenticatedAccountId());
79 83
80 scoped_ptr<drive::DriveUploaderInterface> drive_uploader( 84 scoped_ptr<drive::DriveUploaderInterface> drive_uploader(
81 new drive::DriveUploader(drive_service.get(), drive_task_runner.get())); 85 new drive::DriveUploader(drive_service.get(), drive_task_runner.get()));
82 86
83 drive::DriveNotificationManager* notification_manager = 87 drive::DriveNotificationManager* notification_manager =
84 drive::DriveNotificationManagerFactory::GetForBrowserContext(context); 88 drive::DriveNotificationManagerFactory::GetForBrowserContext(context);
85 ExtensionService* extension_service = 89 ExtensionService* extension_service =
86 extensions::ExtensionSystem::Get( 90 extensions::ExtensionSystem::Get(
87 context)->extension_service(); 91 context)->extension_service();
88 92
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 } 347 }
344 348
345 void SyncEngine::OnPushNotificationEnabled(bool enabled) {} 349 void SyncEngine::OnPushNotificationEnabled(bool enabled) {}
346 350
347 void SyncEngine::OnReadyToSendRequests() { 351 void SyncEngine::OnReadyToSendRequests() {
348 if (service_state_ == REMOTE_SERVICE_OK) 352 if (service_state_ == REMOTE_SERVICE_OK)
349 return; 353 return;
350 UpdateServiceState(REMOTE_SERVICE_OK, "Authenticated"); 354 UpdateServiceState(REMOTE_SERVICE_OK, "Authenticated");
351 355
352 if (!metadata_database_ && auth_token_service_) { 356 if (!metadata_database_ && auth_token_service_) {
353 drive_service_->Initialize(auth_token_service_->GetPrimaryAccountId()); 357 SigninManagerBase* signin_manager =
358 SigninManagerFactory::GetForProfile(auth_token_service_->profile());
359 drive_service_->Initialize(signin_manager->GetAuthenticatedAccountId());
354 PostInitializeTask(); 360 PostInitializeTask();
355 return; 361 return;
356 } 362 }
357 363
358 should_check_remote_change_ = true; 364 should_check_remote_change_ = true;
359 MaybeScheduleNextTask(); 365 MaybeScheduleNextTask();
360 } 366 }
361 367
362 void SyncEngine::OnRefreshTokenInvalid() { 368 void SyncEngine::OnRefreshTokenInvalid() {
363 UpdateServiceState( 369 UpdateServiceState(
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 tracker.tracker_kind() == TRACKER_KIND_APP_ROOT; 707 tracker.tracker_kind() == TRACKER_KIND_APP_ROOT;
702 if (is_app_enabled && !is_app_root_tracker_enabled) 708 if (is_app_enabled && !is_app_root_tracker_enabled)
703 EnableOrigin(origin, base::Bind(&EmptyStatusCallback)); 709 EnableOrigin(origin, base::Bind(&EmptyStatusCallback));
704 else if (!is_app_enabled && is_app_root_tracker_enabled) 710 else if (!is_app_enabled && is_app_root_tracker_enabled)
705 DisableOrigin(origin, base::Bind(&EmptyStatusCallback)); 711 DisableOrigin(origin, base::Bind(&EmptyStatusCallback));
706 } 712 }
707 } 713 }
708 714
709 } // namespace drive_backend 715 } // namespace drive_backend
710 } // namespace sync_file_system 716 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_downloader.cc ('k') | chrome/browser/sync_file_system/drive_backend_v1/api_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698