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

Side by Side Diff: chrome/browser/sync_file_system/sync_file_system_service_factory.cc

Issue 23618029: [SyncFS] Implement Database initialization part of SyncEngineInitializer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: +DriveAPIService dependency Created 7 years, 3 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/sync_file_system_service_factory.h" 5 #include "chrome/browser/sync_file_system/sync_file_system_service_factory.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/threading/sequenced_worker_pool.h" 8 #include "base/threading/sequenced_worker_pool.h"
9 #include "chrome/browser/drive/drive_api_service.h" 9 #include "chrome/browser/drive/drive_api_service.h"
10 #include "chrome/browser/drive/drive_notification_manager_factory.h" 10 #include "chrome/browser/drive/drive_notification_manager_factory.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 kEnableSyncFileSystemV2)) { 73 kEnableSyncFileSystemV2)) {
74 RegisterSyncableFileSystem(); 74 RegisterSyncableFileSystem();
75 75
76 GURL base_drive_url( 76 GURL base_drive_url(
77 google_apis::DriveApiUrlGenerator::kBaseUrlForProduction); 77 google_apis::DriveApiUrlGenerator::kBaseUrlForProduction);
78 GURL base_download_url( 78 GURL base_download_url(
79 google_apis::DriveApiUrlGenerator::kBaseDownloadUrlForProduction); 79 google_apis::DriveApiUrlGenerator::kBaseDownloadUrlForProduction);
80 GURL wapi_base_url( 80 GURL wapi_base_url(
81 google_apis::GDataWapiUrlGenerator::kBaseUrlForProduction); 81 google_apis::GDataWapiUrlGenerator::kBaseUrlForProduction);
82 82
83 scoped_refptr<base::SequencedWorkerPool> worker_pool(
84 content::BrowserThread::GetBlockingPool());
85
83 scoped_ptr<drive::DriveAPIService> drive_api_service( 86 scoped_ptr<drive::DriveAPIService> drive_api_service(
84 new drive::DriveAPIService( 87 new drive::DriveAPIService(
85 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), 88 ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
86 context->GetRequestContext(), 89 context->GetRequestContext(),
87 content::BrowserThread::GetBlockingPool(), 90 worker_pool.get(),
88 base_drive_url, base_download_url, wapi_base_url, 91 base_drive_url, base_download_url, wapi_base_url,
89 std::string() /* custom_user_agent */)); 92 std::string() /* custom_user_agent */));
90 93
91 drive::DriveNotificationManager* notification_manager = 94 drive::DriveNotificationManager* notification_manager =
92 drive::DriveNotificationManagerFactory::GetForProfile(profile); 95 drive::DriveNotificationManagerFactory::GetForProfile(profile);
93 ExtensionService* extension_service = 96 ExtensionService* extension_service =
94 extensions::ExtensionSystem::Get(profile)->extension_service(); 97 extensions::ExtensionSystem::Get(profile)->extension_service();
95 98
99 scoped_refptr<base::SequencedTaskRunner> task_runner(
100 worker_pool->GetSequencedTaskRunnerWithShutdownBehavior(
101 worker_pool->GetSequenceToken(),
102 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
103
96 scoped_ptr<drive_backend::SyncEngine> sync_engine( 104 scoped_ptr<drive_backend::SyncEngine> sync_engine(
97 new drive_backend::SyncEngine( 105 new drive_backend::SyncEngine(
98 context->GetPath(), 106 context->GetPath(),
107 task_runner.get(),
99 drive_api_service.Pass(), 108 drive_api_service.Pass(),
100 notification_manager, 109 notification_manager,
101 extension_service)); 110 extension_service));
102 111
103 sync_engine->Initialize(); 112 sync_engine->Initialize();
104 remote_file_service = sync_engine.PassAs<RemoteFileSyncService>(); 113 remote_file_service = sync_engine.PassAs<RemoteFileSyncService>();
105 } else { 114 } else {
106 // FileSystem needs to be registered before DriveFileSyncService runs 115 // FileSystem needs to be registered before DriveFileSyncService runs
107 // its initialization code. 116 // its initialization code.
108 RegisterSyncableFileSystem(); 117 RegisterSyncableFileSystem();
109 remote_file_service = 118 remote_file_service =
110 DriveFileSyncService::Create(profile).PassAs<RemoteFileSyncService>(); 119 DriveFileSyncService::Create(profile).PassAs<RemoteFileSyncService>();
111 } 120 }
112 121
113 if (CommandLine::ForCurrentProcess()->HasSwitch(kDisableLastWriteWin)) { 122 if (CommandLine::ForCurrentProcess()->HasSwitch(kDisableLastWriteWin)) {
114 remote_file_service->SetConflictResolutionPolicy( 123 remote_file_service->SetConflictResolutionPolicy(
115 CONFLICT_RESOLUTION_POLICY_MANUAL); 124 CONFLICT_RESOLUTION_POLICY_MANUAL);
116 } 125 }
117 126
118 service->Initialize(local_file_service.Pass(), 127 service->Initialize(local_file_service.Pass(),
119 remote_file_service.Pass()); 128 remote_file_service.Pass());
120 return service; 129 return service;
121 } 130 }
122 131
123 } // namespace sync_file_system 132 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698