Fix build break
[chromium-blink-merge.git] / chrome / browser / sync_file_system / sync_file_system_service_factory.cc
blob5a4f5ae7f326127e72bd7014f167ffd4be553d23
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
3 // found in the LICENSE file.
5 #include "chrome/browser/sync_file_system/sync_file_system_service_factory.h"
7 #include "base/command_line.h"
8 #include "chrome/browser/google_apis/drive_notification_manager_factory.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/profiles/profile_dependency_manager.h"
11 #include "chrome/browser/sync/profile_sync_service.h"
12 #include "chrome/browser/sync_file_system/drive_file_sync_service.h"
13 #include "chrome/browser/sync_file_system/sync_file_system_service.h"
14 #include "webkit/fileapi/syncable/syncable_file_system_util.h"
16 namespace sync_file_system {
18 namespace {
19 const char kDisableLastWriteWin[] = "disable-syncfs-last-write-win";
22 // static
23 SyncFileSystemService* SyncFileSystemServiceFactory::GetForProfile(
24 Profile* profile) {
25 return static_cast<SyncFileSystemService*>(
26 GetInstance()->GetServiceForProfile(profile, true));
29 // static
30 SyncFileSystemServiceFactory* SyncFileSystemServiceFactory::GetInstance() {
31 return Singleton<SyncFileSystemServiceFactory>::get();
34 void SyncFileSystemServiceFactory::set_mock_remote_file_service(
35 scoped_ptr<RemoteFileSyncService> mock_remote_service) {
36 mock_remote_file_service_ = mock_remote_service.Pass();
39 SyncFileSystemServiceFactory::SyncFileSystemServiceFactory()
40 : ProfileKeyedServiceFactory("SyncFileSystemService",
41 ProfileDependencyManager::GetInstance()) {
42 DependsOn(google_apis::DriveNotificationManagerFactory::GetInstance());
45 SyncFileSystemServiceFactory::~SyncFileSystemServiceFactory() {}
47 ProfileKeyedService* SyncFileSystemServiceFactory::BuildServiceInstanceFor(
48 Profile* profile) const {
49 SyncFileSystemService* service = new SyncFileSystemService(profile);
51 scoped_ptr<LocalFileSyncService> local_file_service(
52 new LocalFileSyncService(profile));
54 scoped_ptr<RemoteFileSyncService> remote_file_service;
55 if (mock_remote_file_service_) {
56 remote_file_service = mock_remote_file_service_.Pass();
57 } else {
58 // FileSystem needs to be registered before DriveFileSyncService runs
59 // its initialization code.
60 // TODO(kinuko): Clean up RegisterSyncableFileSystem in
61 // local_file_sync_context.cc, which is still there for testing.
62 RegisterSyncableFileSystem(DriveFileSyncService::kServiceName);
63 remote_file_service.reset(new DriveFileSyncService(profile));
66 if (CommandLine::ForCurrentProcess()->HasSwitch(kDisableLastWriteWin)) {
67 remote_file_service->SetConflictResolutionPolicy(
68 CONFLICT_RESOLUTION_MANUAL);
71 service->Initialize(local_file_service.Pass(),
72 remote_file_service.Pass());
73 return service;
76 } // namespace sync_file_system