| OLD | NEW | 
|---|
| 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/syncable_file_system_util.h" | 5 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" | 
| 6 | 6 | 
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" | 
| 8 #include "webkit/browser/fileapi/external_mount_points.h" | 8 #include "webkit/browser/fileapi/external_mount_points.h" | 
| 9 #include "webkit/browser/fileapi/file_observers.h" | 9 #include "webkit/browser/fileapi/file_observers.h" | 
| 10 #include "webkit/browser/fileapi/file_system_context.h" | 10 #include "webkit/browser/fileapi/file_system_context.h" | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 21 | 21 | 
| 22 // A command switch to enable syncing directory operations in Sync FileSystem | 22 // A command switch to enable syncing directory operations in Sync FileSystem | 
| 23 // API. (http://crbug.com/161442) | 23 // API. (http://crbug.com/161442) | 
| 24 // TODO(kinuko): this command-line switch should be temporary. | 24 // TODO(kinuko): this command-line switch should be temporary. | 
| 25 const char kEnableSyncFSDirectoryOperation[] = | 25 const char kEnableSyncFSDirectoryOperation[] = | 
| 26     "enable-syncfs-directory-operation"; | 26     "enable-syncfs-directory-operation"; | 
| 27 | 27 | 
| 28 const char kSyncableMountName[] = "syncfs"; | 28 const char kSyncableMountName[] = "syncfs"; | 
| 29 const char kSyncableMountNameForInternalSync[] = "syncfs-internal"; | 29 const char kSyncableMountNameForInternalSync[] = "syncfs-internal"; | 
| 30 | 30 | 
|  | 31 const base::FilePath::CharType kSyncFileSystemDir[] = | 
|  | 32     FILE_PATH_LITERAL("Sync FileSystem"); | 
|  | 33 const base::FilePath::CharType kSyncFileSystemDirDev[] = | 
|  | 34     FILE_PATH_LITERAL("Sync FileSystem Dev"); | 
|  | 35 | 
| 31 bool is_directory_operation_enabled = false; | 36 bool is_directory_operation_enabled = false; | 
| 32 | 37 | 
| 33 }  // namespace | 38 }  // namespace | 
| 34 | 39 | 
| 35 void RegisterSyncableFileSystem() { | 40 void RegisterSyncableFileSystem() { | 
| 36   ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( | 41   ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( | 
| 37       kSyncableMountName, | 42       kSyncableMountName, | 
| 38       fileapi::kFileSystemTypeSyncable, | 43       fileapi::kFileSystemTypeSyncable, | 
| 39       base::FilePath()); | 44       base::FilePath()); | 
| 40   ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( | 45   ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( | 
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 100 void SetEnableSyncFSDirectoryOperation(bool flag) { | 105 void SetEnableSyncFSDirectoryOperation(bool flag) { | 
| 101   is_directory_operation_enabled = flag; | 106   is_directory_operation_enabled = flag; | 
| 102 } | 107 } | 
| 103 | 108 | 
| 104 bool IsSyncFSDirectoryOperationEnabled() { | 109 bool IsSyncFSDirectoryOperationEnabled() { | 
| 105   return is_directory_operation_enabled || | 110   return is_directory_operation_enabled || | 
| 106       CommandLine::ForCurrentProcess()->HasSwitch( | 111       CommandLine::ForCurrentProcess()->HasSwitch( | 
| 107           kEnableSyncFSDirectoryOperation); | 112           kEnableSyncFSDirectoryOperation); | 
| 108 } | 113 } | 
| 109 | 114 | 
|  | 115 base::FilePath GetSyncFileSystemDir(const base::FilePath& profile_base_dir) { | 
|  | 116   return profile_base_dir.Append( | 
|  | 117       IsSyncFSDirectoryOperationEnabled() ? kSyncFileSystemDirDev | 
|  | 118                                           : kSyncFileSystemDir); | 
|  | 119 } | 
|  | 120 | 
| 110 ScopedEnableSyncFSDirectoryOperation::ScopedEnableSyncFSDirectoryOperation() { | 121 ScopedEnableSyncFSDirectoryOperation::ScopedEnableSyncFSDirectoryOperation() { | 
| 111   was_enabled_ = IsSyncFSDirectoryOperationEnabled(); | 122   was_enabled_ = IsSyncFSDirectoryOperationEnabled(); | 
| 112   SetEnableSyncFSDirectoryOperation(true); | 123   SetEnableSyncFSDirectoryOperation(true); | 
| 113 } | 124 } | 
| 114 | 125 | 
| 115 ScopedEnableSyncFSDirectoryOperation::~ScopedEnableSyncFSDirectoryOperation() { | 126 ScopedEnableSyncFSDirectoryOperation::~ScopedEnableSyncFSDirectoryOperation() { | 
| 116   DCHECK(IsSyncFSDirectoryOperationEnabled()); | 127   DCHECK(IsSyncFSDirectoryOperationEnabled()); | 
| 117   SetEnableSyncFSDirectoryOperation(was_enabled_); | 128   SetEnableSyncFSDirectoryOperation(was_enabled_); | 
| 118 } | 129 } | 
| 119 | 130 | 
| 120 }  // namespace sync_file_system | 131 }  // namespace sync_file_system | 
| OLD | NEW | 
|---|