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

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

Issue 130913013: [SyncFS] Add ScopedEnableSyncFSV2 for testing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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
« no previous file with comments | « chrome/browser/sync_file_system/syncable_file_system_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/syncable_file_system_util.h" 5 #include "chrome/browser/sync_file_system/syncable_file_system_util.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 25 matching lines...) Expand all
36 const char kSyncFileSystemV2Whitelist[] = "syncfs-v2-whitelist"; 36 const char kSyncFileSystemV2Whitelist[] = "syncfs-v2-whitelist";
37 37
38 const char kSyncableMountName[] = "syncfs"; 38 const char kSyncableMountName[] = "syncfs";
39 const char kSyncableMountNameForInternalSync[] = "syncfs-internal"; 39 const char kSyncableMountNameForInternalSync[] = "syncfs-internal";
40 40
41 const base::FilePath::CharType kSyncFileSystemDir[] = 41 const base::FilePath::CharType kSyncFileSystemDir[] =
42 FILE_PATH_LITERAL("Sync FileSystem"); 42 FILE_PATH_LITERAL("Sync FileSystem");
43 const base::FilePath::CharType kSyncFileSystemDirDev[] = 43 const base::FilePath::CharType kSyncFileSystemDirDev[] =
44 FILE_PATH_LITERAL("Sync FileSystem Dev"); 44 FILE_PATH_LITERAL("Sync FileSystem Dev");
45 45
46 bool is_directory_operation_enabled = false; 46 // Flags to enable features for testing.
47 bool g_is_directory_operation_enabled = false;
48 bool g_is_syncfs_v2_enabled = false;
47 49
48 } // namespace 50 } // namespace
49 51
50 void RegisterSyncableFileSystem() { 52 void RegisterSyncableFileSystem() {
51 ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( 53 ExternalMountPoints::GetSystemInstance()->RegisterFileSystem(
52 kSyncableMountName, 54 kSyncableMountName,
53 fileapi::kFileSystemTypeSyncable, 55 fileapi::kFileSystemTypeSyncable,
54 fileapi::FileSystemMountOption(), 56 fileapi::FileSystemMountOption(),
55 base::FilePath()); 57 base::FilePath());
56 ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( 58 ExternalMountPoints::GetSystemInstance()->RegisterFileSystem(
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 if (!deserialized.is_valid() || 114 if (!deserialized.is_valid() ||
113 deserialized.type() != fileapi::kFileSystemTypeSyncable) { 115 deserialized.type() != fileapi::kFileSystemTypeSyncable) {
114 return false; 116 return false;
115 } 117 }
116 118
117 *url = deserialized; 119 *url = deserialized;
118 return true; 120 return true;
119 } 121 }
120 122
121 void SetEnableSyncFSDirectoryOperation(bool flag) { 123 void SetEnableSyncFSDirectoryOperation(bool flag) {
122 is_directory_operation_enabled = flag; 124 g_is_directory_operation_enabled = flag;
123 } 125 }
124 126
125 bool IsSyncFSDirectoryOperationEnabled() { 127 bool IsSyncFSDirectoryOperationEnabled() {
126 return IsSyncFSDirectoryOperationEnabled(GURL()); 128 return IsSyncFSDirectoryOperationEnabled(GURL());
127 } 129 }
128 130
129 bool IsSyncFSDirectoryOperationEnabled(const GURL& origin) { 131 bool IsSyncFSDirectoryOperationEnabled(const GURL& origin) {
130 return is_directory_operation_enabled || 132 return g_is_directory_operation_enabled ||
131 CommandLine::ForCurrentProcess()->HasSwitch( 133 CommandLine::ForCurrentProcess()->HasSwitch(
132 kEnableSyncFSDirectoryOperation) || 134 kEnableSyncFSDirectoryOperation) ||
133 IsV2EnabledForOrigin(origin); 135 IsV2EnabledForOrigin(origin);
134 } 136 }
135 137
136 bool IsV2Enabled() { 138 bool IsV2Enabled() {
137 return CommandLine::ForCurrentProcess()->HasSwitch(kEnableSyncFileSystemV2); 139 return g_is_syncfs_v2_enabled ||
140 CommandLine::ForCurrentProcess()->HasSwitch(kEnableSyncFileSystemV2);
138 } 141 }
139 142
140 bool IsV2EnabledForOrigin(const GURL& origin) { 143 bool IsV2EnabledForOrigin(const GURL& origin) {
141 if (IsV2Enabled()) 144 if (IsV2Enabled())
142 return true; 145 return true;
143 146
144 // Spark release channel. 147 // Spark release channel.
145 if (origin.host() == "kcjgcakhgelcejampmijgkjkadfcncjl") 148 if (origin.host() == "kcjgcakhgelcejampmijgkjkadfcncjl")
146 return true; 149 return true;
147 // Spark dev channel. 150 // Spark dev channel.
(...skipping 28 matching lines...) Expand all
176 ScopedEnableSyncFSDirectoryOperation::ScopedEnableSyncFSDirectoryOperation() { 179 ScopedEnableSyncFSDirectoryOperation::ScopedEnableSyncFSDirectoryOperation() {
177 was_enabled_ = IsSyncFSDirectoryOperationEnabled(GURL()); 180 was_enabled_ = IsSyncFSDirectoryOperationEnabled(GURL());
178 SetEnableSyncFSDirectoryOperation(true); 181 SetEnableSyncFSDirectoryOperation(true);
179 } 182 }
180 183
181 ScopedEnableSyncFSDirectoryOperation::~ScopedEnableSyncFSDirectoryOperation() { 184 ScopedEnableSyncFSDirectoryOperation::~ScopedEnableSyncFSDirectoryOperation() {
182 DCHECK(IsSyncFSDirectoryOperationEnabled(GURL())); 185 DCHECK(IsSyncFSDirectoryOperationEnabled(GURL()));
183 SetEnableSyncFSDirectoryOperation(was_enabled_); 186 SetEnableSyncFSDirectoryOperation(was_enabled_);
184 } 187 }
185 188
189 ScopedEnableSyncFSV2::ScopedEnableSyncFSV2() {
190 was_enabled_ = IsV2Enabled();
191 g_is_syncfs_v2_enabled = true;
192 }
193
194 ScopedEnableSyncFSV2::~ScopedEnableSyncFSV2() {
195 DCHECK(IsV2Enabled());
196 g_is_syncfs_v2_enabled = was_enabled_;
197 }
198
186 void RunSoon(const tracked_objects::Location& from_here, 199 void RunSoon(const tracked_objects::Location& from_here,
187 const base::Closure& callback) { 200 const base::Closure& callback) {
188 base::MessageLoop::current()->PostTask(from_here, callback); 201 base::MessageLoop::current()->PostTask(from_here, callback);
189 } 202 }
190 203
191 } // namespace sync_file_system 204 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « chrome/browser/sync_file_system/syncable_file_system_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698