diff options
author | calvinlo@chromium.org <calvinlo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-27 10:59:13 +0000 |
---|---|---|
committer | calvinlo@chromium.org <calvinlo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-27 10:59:13 +0000 |
commit | 6cd128d23c9c576ce449fcc3022ce58876601f49 (patch) | |
tree | b785c7fa93e4c43588ba802a65673eb47d11b196 | |
parent | 933df47c743604207d9d0836dff94a20eddd24f6 (diff) | |
download | chromium_src-6cd128d23c9c576ce449fcc3022ce58876601f49.zip chromium_src-6cd128d23c9c576ce449fcc3022ce58876601f49.tar.gz chromium_src-6cd128d23c9c576ce449fcc3022ce58876601f49.tar.bz2 |
Final patch to migrate all files under webkit/fileapi/syncable from fileapi namespace to sync_file_system namespace.
BUG=174870
Review URL: https://codereview.chromium.org/12313144
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@184928 0039d316-1c4b-4281-b951-d872f2087c98
39 files changed, 517 insertions, 448 deletions
diff --git a/chrome/browser/extensions/api/sync_file_system/extension_sync_event_observer.cc b/chrome/browser/extensions/api/sync_file_system/extension_sync_event_observer.cc index 65a7207..e868fd1 100644 --- a/chrome/browser/extensions/api/sync_file_system/extension_sync_event_observer.cc +++ b/chrome/browser/extensions/api/sync_file_system/extension_sync_event_observer.cc @@ -143,8 +143,8 @@ void ExtensionSyncEventObserver::OnFileSynced( std::string mount_type = fileapi::GetFileSystemTypeString(url.mount_type()); std::string file_system_name = fileapi::GetFileSystemName(url.origin(), url.type()); - GURL root_url = fileapi::GetSyncableFileSystemRootURI(url.origin(), - url.filesystem_id()); + GURL root_url = sync_file_system::GetSyncableFileSystemRootURI( + url.origin(), url.filesystem_id()); base::FilePath file_path = url.path(); // Arguments must all be basic types. diff --git a/chrome/browser/extensions/api/sync_file_system/sync_file_system_apitest.cc b/chrome/browser/extensions/api/sync_file_system/sync_file_system_apitest.cc index c39ef78..0825198 100644 --- a/chrome/browser/extensions/api/sync_file_system/sync_file_system_apitest.cc +++ b/chrome/browser/extensions/api/sync_file_system/sync_file_system_apitest.cc @@ -23,6 +23,7 @@ using ::testing::_; using ::testing::Return; +using fileapi::FileSystemURL; using sync_file_system::MockRemoteFileSyncService; using sync_file_system::RemoteFileSyncService; using sync_file_system::SyncFileSystemServiceFactory; @@ -83,7 +84,7 @@ ACTION_P5(ReturnWithFakeFileAddedStatus, sync_direction, sync_file_status, sync_action_taken) { - fileapi::FileSystemURL mock_url = fileapi::CreateSyncableFileSystemURL( + FileSystemURL mock_url = sync_file_system::CreateSyncableFileSystemURL( *origin, "drive", base::FilePath(FILE_PATH_LITERAL("foo.txt"))); diff --git a/chrome/browser/sync_file_system/drive_file_sync_service.cc b/chrome/browser/sync_file_system/drive_file_sync_service.cc index d8a0749..3cff1df 100644 --- a/chrome/browser/sync_file_system/drive_file_sync_service.cc +++ b/chrome/browser/sync_file_system/drive_file_sync_service.cc @@ -1679,7 +1679,7 @@ bool DriveFileSyncService::AppendRemoteChangeInternal( const std::string& remote_file_md5, RemoteSyncType sync_type) { fileapi::FileSystemURL url( - fileapi::CreateSyncableFileSystemURL(origin, kServiceName, path)); + CreateSyncableFileSystemURL(origin, kServiceName, path)); std::string local_resource_id; std::string local_file_md5; diff --git a/chrome/browser/sync_file_system/drive_file_sync_service_unittest.cc b/chrome/browser/sync_file_system/drive_file_sync_service_unittest.cc index 2ec10ed..673a917 100644 --- a/chrome/browser/sync_file_system/drive_file_sync_service_unittest.cc +++ b/chrome/browser/sync_file_system/drive_file_sync_service_unittest.cc @@ -225,7 +225,7 @@ class DriveFileSyncServiceTest : public testing::Test { AddTestExtension(extension_service, FPL("example1")); AddTestExtension(extension_service, FPL("example2")); - ASSERT_TRUE(fileapi::RegisterSyncableFileSystem(kServiceName)); + ASSERT_TRUE(RegisterSyncableFileSystem(kServiceName)); mock_drive_service_ = new StrictMock<google_apis::MockDriveService>; @@ -270,7 +270,7 @@ class DriveFileSyncServiceTest : public testing::Test { sync_client_.reset(); mock_drive_service_ = NULL; - EXPECT_TRUE(fileapi::RevokeSyncableFileSystem(kServiceName)); + EXPECT_TRUE(RevokeSyncableFileSystem(kServiceName)); profile_.reset(); message_loop_.RunUntilIdle(); @@ -382,7 +382,7 @@ class DriveFileSyncServiceTest : public testing::Test { fileapi::FileSystemURL CreateURL(const GURL& origin, const base::FilePath::StringType& path) { - return fileapi::CreateSyncableFileSystemURL( + return CreateSyncableFileSystemURL( origin, kServiceName, base::FilePath(path)); } @@ -749,7 +749,7 @@ TEST_F(DriveFileSyncServiceTest, UnregisterOrigin) { } TEST_F(DriveFileSyncServiceTest, ResolveLocalSyncOperationType) { - const fileapi::FileSystemURL url = fileapi::CreateSyncableFileSystemURL( + const fileapi::FileSystemURL url = CreateSyncableFileSystemURL( GURL("chrome-extension://example/"), kServiceName, base::FilePath().AppendASCII("path/to/file")); diff --git a/chrome/browser/sync_file_system/drive_metadata_store.cc b/chrome/browser/sync_file_system/drive_metadata_store.cc index 5cfc563..9c5e7fa 100644 --- a/chrome/browser/sync_file_system/drive_metadata_store.cc +++ b/chrome/browser/sync_file_system/drive_metadata_store.cc @@ -454,7 +454,7 @@ SyncStatusCode DriveMetadataStore::GetConflictURLs( itr != origin_itr->second.end(); ++itr) { if (itr->second.conflicted()) { - urls->insert(fileapi::CreateSyncableFileSystemURL( + urls->insert(CreateSyncableFileSystemURL( origin_itr->first, kServiceName, itr->first)); } } @@ -475,7 +475,7 @@ SyncStatusCode DriveMetadataStore::GetToBeFetchedFiles( itr != origin_itr->second.end(); ++itr) { if (itr->second.to_be_fetched()) { - fileapi::FileSystemURL url = fileapi::CreateSyncableFileSystemURL( + FileSystemURL url = CreateSyncableFileSystemURL( origin_itr->first, kServiceName, itr->first); list->push_back(std::make_pair(url, itr->second.resource_id())); } @@ -557,8 +557,7 @@ SyncStatusCode DriveMetadataDB::ReadContents( std::string url_string( key.begin() + kDriveMetadataKeyPrefixLength - 1, key.end()); FileSystemURL url; - bool success = fileapi::DeserializeSyncableFileSystemURL( - url_string, &url); + bool success = DeserializeSyncableFileSystemURL(url_string, &url); DCHECK(success); DriveMetadata metadata; @@ -621,7 +620,7 @@ SyncStatusCode DriveMetadataDB::UpdateEntry(const FileSystemURL& url, DCHECK(db_.get()); std::string url_string; - bool success = fileapi::SerializeSyncableFileSystemURL(url, &url_string); + bool success = SerializeSyncableFileSystemURL(url, &url_string); DCHECK(success); std::string value; @@ -640,7 +639,7 @@ SyncStatusCode DriveMetadataDB::DeleteEntry(const FileSystemURL& url) { DCHECK(db_.get()); std::string url_string; - bool success = fileapi::SerializeSyncableFileSystemURL(url, &url_string); + bool success = SerializeSyncableFileSystemURL(url, &url_string); DCHECK(success); leveldb::Status status = db_->Delete( @@ -683,8 +682,8 @@ SyncStatusCode DriveMetadataDB::RemoveOrigin(const GURL& origin) { scoped_ptr<leveldb::Iterator> itr(db_->NewIterator(leveldb::ReadOptions())); std::string serialized_origin; - bool success = fileapi::SerializeSyncableFileSystemURL( - fileapi::CreateSyncableFileSystemURL( + bool success = SerializeSyncableFileSystemURL( + CreateSyncableFileSystemURL( origin, kServiceName, base::FilePath()), &serialized_origin); DCHECK(success); for (itr->Seek(kDriveMetadataKeyPrefix + serialized_origin); @@ -695,8 +694,7 @@ SyncStatusCode DriveMetadataDB::RemoveOrigin(const GURL& origin) { std::string serialized_url(key.begin() + kDriveMetadataKeyPrefixLength - 1, key.end()); FileSystemURL url; - bool success = fileapi::DeserializeSyncableFileSystemURL( - serialized_url, &url); + bool success = DeserializeSyncableFileSystemURL(serialized_url, &url); DCHECK(success); if (url.origin() != origin) break; diff --git a/chrome/browser/sync_file_system/drive_metadata_store_unittest.cc b/chrome/browser/sync_file_system/drive_metadata_store_unittest.cc index 23a0bae..039b69f 100644 --- a/chrome/browser/sync_file_system/drive_metadata_store_unittest.cc +++ b/chrome/browser/sync_file_system/drive_metadata_store_unittest.cc @@ -31,8 +31,7 @@ const char* const kServiceName = DriveFileSyncService::kServiceName; typedef DriveMetadataStore::ResourceIDMap ResourceIDMap; fileapi::FileSystemURL URL(const base::FilePath& path) { - return fileapi::CreateSyncableFileSystemURL( - GURL(kOrigin), kServiceName, path); + return CreateSyncableFileSystemURL(GURL(kOrigin), kServiceName, path); } std::string GetResourceID(const ResourceIDMap& sync_origins, @@ -72,11 +71,11 @@ class DriveMetadataStoreTest : public testing::Test { file_task_runner_ = file_thread_->message_loop_proxy(); ASSERT_TRUE(base_dir_.CreateUniqueTempDir()); - ASSERT_TRUE(fileapi::RegisterSyncableFileSystem(kServiceName)); + ASSERT_TRUE(RegisterSyncableFileSystem(kServiceName)); } virtual void TearDown() OVERRIDE { - EXPECT_TRUE(fileapi::RevokeSyncableFileSystem(kServiceName)); + EXPECT_TRUE(RevokeSyncableFileSystem(kServiceName)); DropDatabase(); file_thread_->Stop(); @@ -416,27 +415,27 @@ TEST_F(DriveMetadataStoreTest, RemoveOrigin) { EXPECT_EQ(SYNC_STATUS_OK, UpdateEntry( - fileapi::CreateSyncableFileSystemURL( + CreateSyncableFileSystemURL( kOrigin1, kServiceName, base::FilePath(FPL("guf"))), CreateMetadata("foo", "spam", false, false))); EXPECT_EQ(SYNC_STATUS_OK, UpdateEntry( - fileapi::CreateSyncableFileSystemURL( + CreateSyncableFileSystemURL( kOrigin2, kServiceName, base::FilePath(FPL("mof"))), CreateMetadata("bar", "ham", false, false))); EXPECT_EQ(SYNC_STATUS_OK, UpdateEntry( - fileapi::CreateSyncableFileSystemURL( + CreateSyncableFileSystemURL( kOrigin3, kServiceName, base::FilePath(FPL("waf"))), CreateMetadata("baz", "egg", false, false))); EXPECT_EQ(SYNC_STATUS_OK, UpdateEntry( - fileapi::CreateSyncableFileSystemURL( + CreateSyncableFileSystemURL( kOrigin4, kServiceName, base::FilePath(FPL("cue"))), CreateMetadata("lat", "fork", false, false))); EXPECT_EQ(SYNC_STATUS_OK, UpdateEntry( - fileapi::CreateSyncableFileSystemURL( + CreateSyncableFileSystemURL( kOrigin1, kServiceName, base::FilePath(FPL("tic"))), CreateMetadata("zav", "sause", false, false))); diff --git a/chrome/browser/sync_file_system/local_file_sync_service.cc b/chrome/browser/sync_file_system/local_file_sync_service.cc index 1aec476..4015815 100644 --- a/chrome/browser/sync_file_system/local_file_sync_service.cc +++ b/chrome/browser/sync_file_system/local_file_sync_service.cc @@ -23,7 +23,6 @@ using content::BrowserThread; using fileapi::FileSystemURL; -using fileapi::LocalFileSyncContext; namespace sync_file_system { diff --git a/chrome/browser/sync_file_system/local_file_sync_service.h b/chrome/browser/sync_file_system/local_file_sync_service.h index 3c941b0..9720c95 100644 --- a/chrome/browser/sync_file_system/local_file_sync_service.h +++ b/chrome/browser/sync_file_system/local_file_sync_service.h @@ -24,20 +24,20 @@ class Profile; namespace fileapi { class FileSystemContext; -class LocalFileSyncContext; } namespace sync_file_system { class FileChange; class LocalChangeProcessor; +class LocalFileSyncContext; struct LocalFileSyncInfo; // Maintains local file change tracker and sync status. // Owned by SyncFileSystemService (which is a per-profile object). class LocalFileSyncService : public RemoteChangeProcessor, - public fileapi::LocalOriginChangeObserver, + public LocalOriginChangeObserver, public base::SupportsWeakPtr<LocalFileSyncService> { public: class Observer { @@ -191,7 +191,7 @@ class LocalFileSyncService Profile* profile_; - scoped_refptr<fileapi::LocalFileSyncContext> sync_context_; + scoped_refptr<LocalFileSyncContext> sync_context_; // Origin to context map. (Assuming that as far as we're in the same // profile single origin wouldn't belong to multiple FileSystemContexts.) diff --git a/chrome/browser/sync_file_system/local_file_sync_service_unittest.cc b/chrome/browser/sync_file_system/local_file_sync_service_unittest.cc index b7a90b5..01b26f6bd 100644 --- a/chrome/browser/sync_file_system/local_file_sync_service_unittest.cc +++ b/chrome/browser/sync_file_system/local_file_sync_service_unittest.cc @@ -28,9 +28,6 @@ #include "webkit/fileapi/syncable/syncable_file_system_util.h" using fileapi::FileSystemURL; -using fileapi::LocalFileSyncStatus; -using fileapi::MockSyncStatusObserver; - using ::testing::_; using ::testing::AtLeast; using ::testing::InvokeWithoutArgs; @@ -108,7 +105,7 @@ class LocalFileSyncServiceTest thread_helper_.SetUp(); - file_system_.reset(new fileapi::CannedSyncableFileSystem( + file_system_.reset(new CannedSyncableFileSystem( GURL(kOrigin), kServiceName, thread_helper_.io_task_runner(), thread_helper_.file_task_runner())); @@ -135,7 +132,7 @@ class LocalFileSyncServiceTest virtual void TearDown() OVERRIDE { local_service_->Shutdown(); file_system_->TearDown(); - fileapi::RevokeSyncableFileSystem(kServiceName); + RevokeSyncableFileSystem(kServiceName); thread_helper_.TearDown(); } @@ -184,7 +181,7 @@ class LocalFileSyncServiceTest base::ScopedTempDir temp_dir_; - scoped_ptr<fileapi::CannedSyncableFileSystem> file_system_; + scoped_ptr<CannedSyncableFileSystem> file_system_; scoped_ptr<LocalFileSyncService> local_service_; int64 num_changes_; @@ -281,10 +278,10 @@ TEST_F(LocalFileSyncServiceTest, LocalChangeObserver) { TEST_F(LocalFileSyncServiceTest, MAYBE_LocalChangeObserverMultipleContexts) { const char kOrigin2[] = "http://foo"; - fileapi::CannedSyncableFileSystem file_system2( - GURL(kOrigin2), kServiceName, - thread_helper_.io_task_runner(), - thread_helper_.file_task_runner()); + CannedSyncableFileSystem file_system2(GURL(kOrigin2), + kServiceName, + thread_helper_.io_task_runner(), + thread_helper_.file_task_runner()); file_system2.SetUp(); base::RunLoop run_loop; diff --git a/chrome/browser/sync_file_system/sync_file_system_service_unittest.cc b/chrome/browser/sync_file_system/sync_file_system_service_unittest.cc index 97862fe..7d62e44 100644 --- a/chrome/browser/sync_file_system/sync_file_system_service_unittest.cc +++ b/chrome/browser/sync_file_system/sync_file_system_service_unittest.cc @@ -27,7 +27,6 @@ using fileapi::FileSystemURL; using fileapi::FileSystemURLSet; -using fileapi::MockSyncStatusObserver; using ::testing::AnyNumber; using ::testing::AtLeast; using ::testing::InSequence; @@ -120,7 +119,7 @@ class SyncFileSystemServiceTest : public testing::Test { virtual void SetUp() OVERRIDE { thread_helper_.SetUp(); - file_system_.reset(new fileapi::CannedSyncableFileSystem( + file_system_.reset(new CannedSyncableFileSystem( GURL(kOrigin), kServiceName, thread_helper_.io_task_runner(), thread_helper_.file_task_runner())); @@ -149,7 +148,7 @@ class SyncFileSystemServiceTest : public testing::Test { sync_service_->Shutdown(); file_system_->TearDown(); - fileapi::RevokeSyncableFileSystem(kServiceName); + RevokeSyncableFileSystem(kServiceName); thread_helper_.TearDown(); } @@ -237,7 +236,7 @@ class SyncFileSystemServiceTest : public testing::Test { MultiThreadTestHelper thread_helper_; TestingProfile profile_; - scoped_ptr<fileapi::CannedSyncableFileSystem> file_system_; + scoped_ptr<CannedSyncableFileSystem> file_system_; // Their ownerships are transferred to SyncFileSystemService. LocalFileSyncService* local_service_; @@ -399,7 +398,7 @@ TEST_F(SyncFileSystemServiceTest, SimpleSyncFlowWithFileBusy) { // Start a local operation on the same file (to make it BUSY). base::WaitableEvent event(false, false); thread_helper_.io_task_runner()->PostTask( - FROM_HERE, base::Bind(&fileapi::CannedSyncableFileSystem::DoCreateFile, + FROM_HERE, base::Bind(&CannedSyncableFileSystem::DoCreateFile, base::Unretained(file_system_.get()), kFile, base::Bind(&VerifyFileError, &event))); diff --git a/webkit/fileapi/file_system_context.cc b/webkit/fileapi/file_system_context.cc index ab8c929..017cf29 100644 --- a/webkit/fileapi/file_system_context.cc +++ b/webkit/fileapi/file_system_context.cc @@ -224,7 +224,8 @@ void FileSystemContext::OpenSyncableFileSystem( DCHECK(type == kFileSystemTypeSyncable); - GURL root_url = GetSyncableFileSystemRootURI(origin_url, mount_name); + GURL root_url = sync_file_system::GetSyncableFileSystemRootURI( + origin_url, mount_name); std::string name = GetFileSystemName(origin_url, kFileSystemTypeSyncable); FileSystemMountPointProvider* mount_point_provider = @@ -298,7 +299,7 @@ void FileSystemContext::RegisterMountPointProvider( } void FileSystemContext::SetLocalFileChangeTracker( - scoped_ptr<LocalFileChangeTracker> tracker) { + scoped_ptr<sync_file_system::LocalFileChangeTracker> tracker) { DCHECK(!change_tracker_.get()); DCHECK(tracker.get()); change_tracker_ = tracker.Pass(); @@ -311,7 +312,7 @@ void FileSystemContext::SetLocalFileChangeTracker( } void FileSystemContext::set_sync_context( - LocalFileSyncContext* sync_context) { + sync_file_system::LocalFileSyncContext* sync_context) { sync_context_ = sync_context; } diff --git a/webkit/fileapi/file_system_context.h b/webkit/fileapi/file_system_context.h index ec9fc6e..1a938e2 100644 --- a/webkit/fileapi/file_system_context.h +++ b/webkit/fileapi/file_system_context.h @@ -28,6 +28,11 @@ class QuotaManagerProxy; class SpecialStoragePolicy; } +namespace sync_file_system { +class LocalFileChangeTracker; +class LocalFileSyncContext; +} + namespace webkit_blob { class BlobURLRequestJobTest; class FileStreamReader; @@ -46,8 +51,6 @@ class FileSystemQuotaUtil; class FileSystemTaskRunners; class FileSystemURL; class IsolatedMountPointProvider; -class LocalFileChangeTracker; -class LocalFileSyncContext; class MountPoints; class SandboxMountPointProvider; @@ -182,11 +185,16 @@ class WEBKIT_STORAGE_EXPORT FileSystemContext FileSystemTaskRunners* task_runners() { return task_runners_.get(); } - LocalFileChangeTracker* change_tracker() { return change_tracker_.get(); } - void SetLocalFileChangeTracker(scoped_ptr<LocalFileChangeTracker> tracker); + sync_file_system::LocalFileChangeTracker* change_tracker() { + return change_tracker_.get(); + } + void SetLocalFileChangeTracker( + scoped_ptr<sync_file_system::LocalFileChangeTracker> tracker); - LocalFileSyncContext* sync_context() { return sync_context_.get(); } - void set_sync_context(LocalFileSyncContext* sync_context); + sync_file_system::LocalFileSyncContext* sync_context() { + return sync_context_.get(); + } + void set_sync_context(sync_file_system::LocalFileSyncContext* sync_context); const base::FilePath& partition_path() const { return partition_path_; } @@ -203,8 +211,8 @@ class WEBKIT_STORAGE_EXPORT FileSystemContext // These classes know the target filesystem (i.e. sandbox filesystem) // supports synchronous FileUtil. friend class LocalFileSystemOperation; - friend class LocalFileChangeTracker; - friend class LocalFileSyncContext; + friend class sync_file_system::LocalFileChangeTracker; + friend class sync_file_system::LocalFileSyncContext; // Friended for GetFileUtil. // Test classes that rely on synchronous FileUtils. @@ -262,8 +270,8 @@ class WEBKIT_STORAGE_EXPORT FileSystemContext const base::FilePath partition_path_; // For syncable file systems. - scoped_ptr<LocalFileChangeTracker> change_tracker_; - scoped_refptr<LocalFileSyncContext> sync_context_; + scoped_ptr<sync_file_system::LocalFileChangeTracker> change_tracker_; + scoped_refptr<sync_file_system::LocalFileSyncContext> sync_context_; DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemContext); }; diff --git a/webkit/fileapi/file_system_url_unittest.cc b/webkit/fileapi/file_system_url_unittest.cc index 06d3dbd..3869616 100644 --- a/webkit/fileapi/file_system_url_unittest.cc +++ b/webkit/fileapi/file_system_url_unittest.cc @@ -139,14 +139,16 @@ TEST(FileSystemURLTest, CompareURLs) { } TEST(FileSystemURLTest, IsParent) { - ScopedExternalFileSystem scoped1("foo", kFileSystemTypeSyncable, base::FilePath()); - ScopedExternalFileSystem scoped2("bar", kFileSystemTypeSyncable, base::FilePath()); + ScopedExternalFileSystem scoped1("foo", kFileSystemTypeSyncable, + base::FilePath()); + ScopedExternalFileSystem scoped2("bar", kFileSystemTypeSyncable, + base::FilePath()); const std::string root1 = GetFileSystemRootURI( GURL("http://example.com"), kFileSystemTypeTemporary).spec(); - const std::string root2 = GetSyncableFileSystemRootURI( + const std::string root2 = sync_file_system::GetSyncableFileSystemRootURI( GURL("http://example.com"), "foo").spec(); - const std::string root3 = GetSyncableFileSystemRootURI( + const std::string root3 = sync_file_system::GetSyncableFileSystemRootURI( GURL("http://example.com"), "bar").spec(); const std::string root4 = GetFileSystemRootURI( GURL("http://chromium.org"), kFileSystemTypeTemporary).spec(); diff --git a/webkit/fileapi/local_file_system_operation.h b/webkit/fileapi/local_file_system_operation.h index 73ee457..fd66acd 100644 --- a/webkit/fileapi/local_file_system_operation.h +++ b/webkit/fileapi/local_file_system_operation.h @@ -23,6 +23,10 @@ namespace chromeos { class CrosMountPointProvider; } +namespace sync_file_system { +class SyncableFileSystemOperation; +} + namespace fileapi { class AsyncFileUtil; @@ -176,7 +180,7 @@ class WEBKIT_STORAGE_EXPORT LocalFileSystemOperation friend class RecursiveOperationDelegate; friend class CrossOperationDelegate; - friend class SyncableFileSystemOperation; + friend class sync_file_system::SyncableFileSystemOperation; LocalFileSystemOperation( FileSystemContext* file_system_context, diff --git a/webkit/fileapi/sandbox_mount_point_provider.cc b/webkit/fileapi/sandbox_mount_point_provider.cc index d07fcad..bc005c6 100644 --- a/webkit/fileapi/sandbox_mount_point_provider.cc +++ b/webkit/fileapi/sandbox_mount_point_provider.cc @@ -280,7 +280,7 @@ FileSystemOperation* SandboxMountPointProvider::CreateFileSystemOperation( operation_context->set_update_observers(syncable_update_observers_); operation_context->set_change_observers(syncable_change_observers_); operation_context->set_access_observers(access_observers_); - return new SyncableFileSystemOperation( + return new sync_file_system::SyncableFileSystemOperation( context, new LocalFileSystemOperation(context, operation_context.Pass())); } diff --git a/webkit/fileapi/sandbox_mount_point_provider.h b/webkit/fileapi/sandbox_mount_point_provider.h index 22c7ec7..85cb4a0 100644 --- a/webkit/fileapi/sandbox_mount_point_provider.h +++ b/webkit/fileapi/sandbox_mount_point_provider.h @@ -29,6 +29,11 @@ namespace quota { class QuotaManagerProxy; } +namespace sync_file_system { +class CannedSyncableFileSystem; +class SyncableFileSystemOperation; +} + namespace fileapi { class AsyncFileUtilAdapter; @@ -167,9 +172,9 @@ class WEBKIT_STORAGE_EXPORT SandboxMountPointProvider friend class SandboxMountPointProviderOriginEnumeratorTest; // Temporarily allowing them to access enable_sync_directory_operation_ - friend class CannedSyncableFileSystem; friend class ObfuscatedFileUtil; - friend class SyncableFileSystemOperation; + friend class sync_file_system::CannedSyncableFileSystem; + friend class sync_file_system::SyncableFileSystemOperation; // Returns a path to the usage cache file. base::FilePath GetUsageCachePathForOriginAndType( diff --git a/webkit/fileapi/syncable/canned_syncable_file_system.cc b/webkit/fileapi/syncable/canned_syncable_file_system.cc index feb0327..954d6a5 100644 --- a/webkit/fileapi/syncable/canned_syncable_file_system.cc +++ b/webkit/fileapi/syncable/canned_syncable_file_system.cc @@ -26,12 +26,15 @@ #include "webkit/quota/quota_manager.h" using base::PlatformFileError; +using fileapi::FileSystemContext; +using fileapi::FileSystemOperation; +using fileapi::FileSystemURL; +using fileapi::FileSystemURLSet; using quota::QuotaManager; -using sync_file_system::SyncStatusCode; using webkit_blob::MockBlobURLRequestContext; using webkit_blob::ScopedTextBlob; -namespace fileapi { +namespace sync_file_system { namespace { @@ -175,7 +178,7 @@ CannedSyncableFileSystem::CannedSyncableFileSystem( base::SingleThreadTaskRunner* file_task_runner) : service_name_(service), origin_(origin), - type_(kFileSystemTypeSyncable), + type_(fileapi::kFileSystemTypeSyncable), result_(base::PLATFORM_FILE_OK), sync_status_(sync_file_system::SYNC_STATUS_OK), io_task_runner_(io_task_runner), @@ -202,15 +205,15 @@ void CannedSyncableFileSystem::SetUp() { storage_policy); file_system_context_ = new FileSystemContext( - make_scoped_ptr(new FileSystemTaskRunners( + make_scoped_ptr(new fileapi::FileSystemTaskRunners( io_task_runner_, file_task_runner_, file_task_runner_)), - ExternalMountPoints::CreateRefCounted().get(), + fileapi::ExternalMountPoints::CreateRefCounted().get(), storage_policy, quota_manager_->proxy(), data_dir_.path(), - CreateAllowFileAccessOptions()); + fileapi::CreateAllowFileAccessOptions()); // In testing we override this setting to support directory operations // by default. @@ -600,4 +603,4 @@ void CannedSyncableFileSystem::InitializeSyncStatusObserver() { file_system_context_->sync_context()->sync_status()->AddObserver(this); } -} // namespace fileapi +} // namespace sync_file_system diff --git a/webkit/fileapi/syncable/canned_syncable_file_system.h b/webkit/fileapi/syncable/canned_syncable_file_system.h index e89fba7..d1420d7 100644 --- a/webkit/fileapi/syncable/canned_syncable_file_system.h +++ b/webkit/fileapi/syncable/canned_syncable_file_system.h @@ -26,6 +26,12 @@ class SingleThreadTaskRunner; class Thread; } +namespace fileapi { +class FileSystemContext; +class FileSystemOperation; +class FileSystemURL; +} + namespace net { class URLRequestContext; } @@ -34,10 +40,8 @@ namespace quota { class QuotaManager; } -namespace fileapi { +namespace sync_file_system { -class FileSystemContext; -class FileSystemOperation; class LocalFileSyncContext; // A canned syncable filesystem for testing. @@ -62,7 +66,7 @@ class CannedSyncableFileSystem void TearDown(); // Creates a FileSystemURL for the given (utf8) path string. - FileSystemURL URL(const std::string& path) const; + fileapi::FileSystemURL URL(const std::string& path) const; // Initialize this with given |sync_context| if it hasn't // been initialized. @@ -79,12 +83,12 @@ class CannedSyncableFileSystem void RemoveSyncStatusObserver(LocalFileSyncStatus::Observer* observer); // Accessors. - FileSystemContext* file_system_context() { + fileapi::FileSystemContext* file_system_context() { return file_system_context_.get(); } quota::QuotaManager* quota_manager() { return quota_manager_.get(); } GURL origin() const { return origin_; } - FileSystemType type() const { return type_; } + fileapi::FileSystemType type() const { return type_; } quota::StorageType storage_type() const { return FileSystemTypeToQuotaStorageType(type_); } @@ -93,29 +97,31 @@ class CannedSyncableFileSystem // OpenFileSystem() must have been called before calling any of them. // They create an operation and run it on IO task runner, and the operation // posts a task on file runner. - base::PlatformFileError CreateDirectory(const FileSystemURL& url); - base::PlatformFileError CreateFile(const FileSystemURL& url); - base::PlatformFileError Copy(const FileSystemURL& src_url, - const FileSystemURL& dest_url); - base::PlatformFileError Move(const FileSystemURL& src_url, - const FileSystemURL& dest_url); - base::PlatformFileError TruncateFile(const FileSystemURL& url, int64 size); - base::PlatformFileError TouchFile(const FileSystemURL& url, + base::PlatformFileError CreateDirectory(const fileapi::FileSystemURL& url); + base::PlatformFileError CreateFile(const fileapi::FileSystemURL& url); + base::PlatformFileError Copy(const fileapi::FileSystemURL& src_url, + const fileapi::FileSystemURL& dest_url); + base::PlatformFileError Move(const fileapi::FileSystemURL& src_url, + const fileapi::FileSystemURL& dest_url); + base::PlatformFileError TruncateFile(const fileapi::FileSystemURL& url, + int64 size); + base::PlatformFileError TouchFile(const fileapi::FileSystemURL& url, const base::Time& last_access_time, const base::Time& last_modified_time); - base::PlatformFileError Remove(const FileSystemURL& url, bool recursive); - base::PlatformFileError FileExists(const FileSystemURL& url); - base::PlatformFileError DirectoryExists(const FileSystemURL& url); - base::PlatformFileError VerifyFile(const FileSystemURL& url, + base::PlatformFileError Remove(const fileapi::FileSystemURL& url, + bool recursive); + base::PlatformFileError FileExists(const fileapi::FileSystemURL& url); + base::PlatformFileError DirectoryExists(const fileapi::FileSystemURL& url); + base::PlatformFileError VerifyFile(const fileapi::FileSystemURL& url, const std::string& expected_data); - base::PlatformFileError GetMetadata(const FileSystemURL& url, + base::PlatformFileError GetMetadata(const fileapi::FileSystemURL& url, base::PlatformFileInfo* info, base::FilePath* platform_path); // Returns the # of bytes written (>=0) or an error code (<0). int64 Write(net::URLRequestContext* url_request_context, - const FileSystemURL& url, const GURL& blob_url); - int64 WriteString(const FileSystemURL& url, const std::string& data); + const fileapi::FileSystemURL& url, const GURL& blob_url); + int64 WriteString(const fileapi::FileSystemURL& url, const std::string& data); // Purges the file system local storage. base::PlatformFileError DeleteFileSystem(); @@ -124,15 +130,15 @@ class CannedSyncableFileSystem quota::QuotaStatusCode GetUsageAndQuota(int64* usage, int64* quota); // ChangeTracker related methods. They run on file task runner. - void GetChangedURLsInTracker(FileSystemURLSet* urls); - void ClearChangeForURLInTracker(const FileSystemURL& url); + void GetChangedURLsInTracker(fileapi::FileSystemURLSet* urls); + void ClearChangeForURLInTracker(const fileapi::FileSystemURL& url); // Returns new FileSystemOperation. - FileSystemOperation* NewOperation(); + fileapi::FileSystemOperation* NewOperation(); // LocalFileSyncStatus::Observer overrides. - virtual void OnSyncEnabled(const FileSystemURL& url) OVERRIDE; - virtual void OnWriteEnabled(const FileSystemURL& url) OVERRIDE; + virtual void OnSyncEnabled(const fileapi::FileSystemURL& url) OVERRIDE; + virtual void OnWriteEnabled(const fileapi::FileSystemURL& url) OVERRIDE; // Overrides --enable-sync-directory-operation setting which is disabled // by default in production code but enabled in (and only in) an instance @@ -143,42 +149,42 @@ class CannedSyncableFileSystem // Operation methods body. // They can be also called directly if the caller is already on IO thread. - void DoCreateDirectory(const FileSystemURL& url, + void DoCreateDirectory(const fileapi::FileSystemURL& url, const StatusCallback& callback); - void DoCreateFile(const FileSystemURL& url, + void DoCreateFile(const fileapi::FileSystemURL& url, const StatusCallback& callback); - void DoCopy(const FileSystemURL& src_url, - const FileSystemURL& dest_url, + void DoCopy(const fileapi::FileSystemURL& src_url, + const fileapi::FileSystemURL& dest_url, const StatusCallback& callback); - void DoMove(const FileSystemURL& src_url, - const FileSystemURL& dest_url, + void DoMove(const fileapi::FileSystemURL& src_url, + const fileapi::FileSystemURL& dest_url, const StatusCallback& callback); - void DoTruncateFile(const FileSystemURL& url, + void DoTruncateFile(const fileapi::FileSystemURL& url, int64 size, const StatusCallback& callback); - void DoTouchFile(const FileSystemURL& url, + void DoTouchFile(const fileapi::FileSystemURL& url, const base::Time& last_access_time, const base::Time& last_modified_time, const StatusCallback& callback); - void DoRemove(const FileSystemURL& url, + void DoRemove(const fileapi::FileSystemURL& url, bool recursive, const StatusCallback& callback); - void DoFileExists(const FileSystemURL& url, + void DoFileExists(const fileapi::FileSystemURL& url, const StatusCallback& callback); - void DoDirectoryExists(const FileSystemURL& url, + void DoDirectoryExists(const fileapi::FileSystemURL& url, const StatusCallback& callback); - void DoVerifyFile(const FileSystemURL& url, + void DoVerifyFile(const fileapi::FileSystemURL& url, const std::string& expected_data, const StatusCallback& callback); - void DoGetMetadata(const FileSystemURL& url, + void DoGetMetadata(const fileapi::FileSystemURL& url, base::PlatformFileInfo* info, base::FilePath* platform_path, const StatusCallback& callback); void DoWrite(net::URLRequestContext* url_request_context, - const FileSystemURL& url, + const fileapi::FileSystemURL& url, const GURL& blob_url, const WriteCallback& callback); - void DoWriteString(const FileSystemURL& url, + void DoWriteString(const fileapi::FileSystemURL& url, const std::string& data, const WriteCallback& callback); void DoGetUsageAndQuota(int64* usage, @@ -200,9 +206,9 @@ class CannedSyncableFileSystem const std::string service_name_; scoped_refptr<quota::QuotaManager> quota_manager_; - scoped_refptr<FileSystemContext> file_system_context_; + scoped_refptr<fileapi::FileSystemContext> file_system_context_; const GURL origin_; - const FileSystemType type_; + const fileapi::FileSystemType type_; GURL root_url_; base::PlatformFileError result_; sync_file_system::SyncStatusCode sync_status_; @@ -219,6 +225,6 @@ class CannedSyncableFileSystem DISALLOW_COPY_AND_ASSIGN(CannedSyncableFileSystem); }; -} // namespace fileapi +} // namespace sync_file_system #endif // WEBKIT_FILEAPI_SYNCABLE_CANNED_SYNCABLE_FILE_SYSTEM_H_ diff --git a/webkit/fileapi/syncable/local_file_change_tracker.cc b/webkit/fileapi/syncable/local_file_change_tracker.cc index ea32c7f..189a2a4 100644 --- a/webkit/fileapi/syncable/local_file_change_tracker.cc +++ b/webkit/fileapi/syncable/local_file_change_tracker.cc @@ -18,11 +18,13 @@ #include "webkit/fileapi/syncable/local_file_sync_status.h" #include "webkit/fileapi/syncable/syncable_file_system_util.h" -using sync_file_system::FileChange; -using sync_file_system::FileChangeList; -using sync_file_system::SyncStatusCode; +using fileapi::FileSystemContext; +using fileapi::FileSystemFileUtil; +using fileapi::FileSystemOperationContext; +using fileapi::FileSystemURL; +using fileapi::FileSystemURLSet; -namespace fileapi { +namespace sync_file_system { namespace { const base::FilePath::CharType kDatabaseName[] = @@ -38,7 +40,8 @@ class LocalFileChangeTracker::TrackerDB { SyncStatusCode MarkDirty(const std::string& url); SyncStatusCode ClearDirty(const std::string& url); - SyncStatusCode GetDirtyEntries(std::queue<FileSystemURL>* dirty_files); + SyncStatusCode GetDirtyEntries( + std::queue<FileSystemURL>* dirty_files); private: enum RecoveryOption { @@ -90,33 +93,33 @@ void LocalFileChangeTracker::OnEndUpdate(const FileSystemURL& url) {} void LocalFileChangeTracker::OnCreateFile(const FileSystemURL& url) { RecordChange(url, FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, - sync_file_system::SYNC_FILE_TYPE_FILE)); + SYNC_FILE_TYPE_FILE)); } void LocalFileChangeTracker::OnCreateFileFrom(const FileSystemURL& url, const FileSystemURL& src) { RecordChange(url, FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, - sync_file_system::SYNC_FILE_TYPE_FILE)); + SYNC_FILE_TYPE_FILE)); } void LocalFileChangeTracker::OnRemoveFile(const FileSystemURL& url) { RecordChange(url, FileChange(FileChange::FILE_CHANGE_DELETE, - sync_file_system::SYNC_FILE_TYPE_FILE)); + SYNC_FILE_TYPE_FILE)); } void LocalFileChangeTracker::OnModifyFile(const FileSystemURL& url) { RecordChange(url, FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, - sync_file_system::SYNC_FILE_TYPE_FILE)); + SYNC_FILE_TYPE_FILE)); } void LocalFileChangeTracker::OnCreateDirectory(const FileSystemURL& url) { RecordChange(url, FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, - sync_file_system::SYNC_FILE_TYPE_DIRECTORY)); + SYNC_FILE_TYPE_DIRECTORY)); } void LocalFileChangeTracker::OnRemoveDirectory(const FileSystemURL& url) { RecordChange(url, FileChange(FileChange::FILE_CHANGE_DELETE, - sync_file_system::SYNC_FILE_TYPE_DIRECTORY)); + SYNC_FILE_TYPE_DIRECTORY)); } void LocalFileChangeTracker::GetNextChangedURLs( @@ -165,7 +168,7 @@ SyncStatusCode LocalFileChangeTracker::Initialize( DCHECK(file_system_context); SyncStatusCode status = CollectLastDirtyChanges(file_system_context); - if (status == sync_file_system::SYNC_STATUS_OK) + if (status == SYNC_STATUS_OK) initialized_ = true; return status; } @@ -191,7 +194,7 @@ SyncStatusCode LocalFileChangeTracker::MarkDirtyOnDatabase( const FileSystemURL& url) { std::string serialized_url; if (!SerializeSyncableFileSystemURL(url, &serialized_url)) - return sync_file_system::SYNC_FILE_ERROR_INVALID_URL; + return SYNC_FILE_ERROR_INVALID_URL; return tracker_db_->MarkDirty(serialized_url); } @@ -200,7 +203,7 @@ SyncStatusCode LocalFileChangeTracker::ClearDirtyOnDatabase( const FileSystemURL& url) { std::string serialized_url; if (!SerializeSyncableFileSystemURL(url, &serialized_url)) - return sync_file_system::SYNC_FILE_ERROR_INVALID_URL; + return SYNC_FILE_ERROR_INVALID_URL; return tracker_db_->ClearDirty(serialized_url); } @@ -211,11 +214,11 @@ SyncStatusCode LocalFileChangeTracker::CollectLastDirtyChanges( std::queue<FileSystemURL> dirty_files; const SyncStatusCode status = tracker_db_->GetDirtyEntries(&dirty_files); - if (status != sync_file_system::SYNC_STATUS_OK) + if (status != SYNC_STATUS_OK) return status; FileSystemFileUtil* file_util = - file_system_context->GetFileUtil(kFileSystemTypeSyncable); + file_system_context->GetFileUtil(fileapi::kFileSystemTypeSyncable); DCHECK(file_util); scoped_ptr<FileSystemOperationContext> context( new FileSystemOperationContext(file_system_context)); @@ -226,20 +229,20 @@ SyncStatusCode LocalFileChangeTracker::CollectLastDirtyChanges( while (!dirty_files.empty()) { const FileSystemURL url = dirty_files.front(); dirty_files.pop(); - DCHECK_EQ(url.type(), kFileSystemTypeSyncable); + DCHECK_EQ(url.type(), fileapi::kFileSystemTypeSyncable); switch (file_util->GetFileInfo(context.get(), url, &file_info, &platform_path)) { case base::PLATFORM_FILE_OK: { if (!file_info.is_directory) { RecordChange(url, FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, - sync_file_system::SYNC_FILE_TYPE_FILE)); + SYNC_FILE_TYPE_FILE)); break; } RecordChange(url, FileChange( FileChange::FILE_CHANGE_ADD_OR_UPDATE, - sync_file_system::SYNC_FILE_TYPE_DIRECTORY)); + SYNC_FILE_TYPE_DIRECTORY)); // Push files and directories in this directory into |dirty_files|. scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> enumerator( @@ -256,12 +259,12 @@ SyncStatusCode LocalFileChangeTracker::CollectLastDirtyChanges( case base::PLATFORM_FILE_ERROR_NOT_FOUND: { // File represented by |url| has already been deleted. Since we cannot // figure out if this file was directory or not from the URL, file - // type is treated as sync_file_system::SYNC_FILE_TYPE_UNKNOWN. + // type is treated as SYNC_FILE_TYPE_UNKNOWN. // // NOTE: Directory to have been reverted (that is, ADD -> DELETE) is // also treated as FILE_CHANGE_DELETE. RecordChange(url, FileChange(FileChange::FILE_CHANGE_DELETE, - sync_file_system::SYNC_FILE_TYPE_UNKNOWN)); + SYNC_FILE_TYPE_UNKNOWN)); break; } case base::PLATFORM_FILE_ERROR_FAILED: @@ -271,7 +274,7 @@ SyncStatusCode LocalFileChangeTracker::CollectLastDirtyChanges( break; } } - return sync_file_system::SYNC_STATUS_OK; + return SYNC_STATUS_OK; } void LocalFileChangeTracker::RecordChange( @@ -295,36 +298,37 @@ void LocalFileChangeTracker::RecordChange( LocalFileChangeTracker::TrackerDB::TrackerDB(const base::FilePath& base_path) : base_path_(base_path), - db_status_(sync_file_system::SYNC_STATUS_OK) {} + db_status_(SYNC_STATUS_OK) {} SyncStatusCode LocalFileChangeTracker::TrackerDB::Init( RecoveryOption recovery_option) { - if (db_.get() && db_status_ == sync_file_system::SYNC_STATUS_OK) - return sync_file_system::SYNC_STATUS_OK; + if (db_.get() && db_status_ == SYNC_STATUS_OK) + return SYNC_STATUS_OK; - std::string path = FilePathToString(base_path_.Append(kDatabaseName)); + std::string path = fileapi::FilePathToString( + base_path_.Append(kDatabaseName)); leveldb::Options options; options.create_if_missing = true; leveldb::DB* db; leveldb::Status status = leveldb::DB::Open(options, path, &db); if (status.ok()) { db_.reset(db); - return sync_file_system::SYNC_STATUS_OK; + return SYNC_STATUS_OK; } HandleError(FROM_HERE, status); if (!status.IsCorruption()) - return sync_file_system::LevelDBStatusToSyncStatusCode(status); + return LevelDBStatusToSyncStatusCode(status); // Try to repair the corrupted DB. switch (recovery_option) { case FAIL_ON_CORRUPTION: - return sync_file_system::SYNC_DATABASE_ERROR_CORRUPTION; + return SYNC_DATABASE_ERROR_CORRUPTION; case REPAIR_ON_CORRUPTION: return Repair(path); } NOTREACHED(); - return sync_file_system::SYNC_DATABASE_ERROR_FAILED; + return SYNC_DATABASE_ERROR_FAILED; } SyncStatusCode LocalFileChangeTracker::TrackerDB::Repair( @@ -333,15 +337,15 @@ SyncStatusCode LocalFileChangeTracker::TrackerDB::Repair( LOG(WARNING) << "Attempting to repair TrackerDB."; if (leveldb::RepairDB(db_path, leveldb::Options()).ok() && - Init(FAIL_ON_CORRUPTION) == sync_file_system::SYNC_STATUS_OK) { + Init(FAIL_ON_CORRUPTION) == SYNC_STATUS_OK) { // TODO(nhiroki): perform some consistency checks between TrackerDB and // syncable file system. LOG(WARNING) << "Repairing TrackerDB completed."; - return sync_file_system::SYNC_STATUS_OK; + return SYNC_STATUS_OK; } LOG(WARNING) << "Failed to repair TrackerDB."; - return sync_file_system::SYNC_DATABASE_ERROR_CORRUPTION; + return SYNC_DATABASE_ERROR_CORRUPTION; } // TODO(nhiroki): factor out the common methods into somewhere else. @@ -354,11 +358,11 @@ void LocalFileChangeTracker::TrackerDB::HandleError( SyncStatusCode LocalFileChangeTracker::TrackerDB::MarkDirty( const std::string& url) { - if (db_status_ != sync_file_system::SYNC_STATUS_OK) + if (db_status_ != SYNC_STATUS_OK) return db_status_; db_status_ = Init(REPAIR_ON_CORRUPTION); - if (db_status_ != sync_file_system::SYNC_STATUS_OK) { + if (db_status_ != SYNC_STATUS_OK) { db_.reset(); return db_status_; } @@ -366,16 +370,16 @@ SyncStatusCode LocalFileChangeTracker::TrackerDB::MarkDirty( leveldb::Status status = db_->Put(leveldb::WriteOptions(), url, kMark); if (!status.ok()) { HandleError(FROM_HERE, status); - db_status_ = sync_file_system::LevelDBStatusToSyncStatusCode(status); + db_status_ = LevelDBStatusToSyncStatusCode(status); db_.reset(); return db_status_; } - return sync_file_system::SYNC_STATUS_OK; + return SYNC_STATUS_OK; } SyncStatusCode LocalFileChangeTracker::TrackerDB::ClearDirty( const std::string& url) { - if (db_status_ != sync_file_system::SYNC_STATUS_OK) + if (db_status_ != SYNC_STATUS_OK) return db_status_; // Should not reach here before initializing the database. The database should @@ -386,20 +390,20 @@ SyncStatusCode LocalFileChangeTracker::TrackerDB::ClearDirty( leveldb::Status status = db_->Delete(leveldb::WriteOptions(), url); if (!status.ok() && !status.IsNotFound()) { HandleError(FROM_HERE, status); - db_status_ = sync_file_system::LevelDBStatusToSyncStatusCode(status); + db_status_ = LevelDBStatusToSyncStatusCode(status); db_.reset(); return db_status_; } - return sync_file_system::SYNC_STATUS_OK; + return SYNC_STATUS_OK; } SyncStatusCode LocalFileChangeTracker::TrackerDB::GetDirtyEntries( std::queue<FileSystemURL>* dirty_files) { - if (db_status_ != sync_file_system::SYNC_STATUS_OK) + if (db_status_ != SYNC_STATUS_OK) return db_status_; db_status_ = Init(REPAIR_ON_CORRUPTION); - if (db_status_ != sync_file_system::SYNC_STATUS_OK) { + if (db_status_ != SYNC_STATUS_OK) { db_.reset(); return db_status_; } @@ -411,14 +415,14 @@ SyncStatusCode LocalFileChangeTracker::TrackerDB::GetDirtyEntries( if (!DeserializeSyncableFileSystemURL(iter->key().ToString(), &url)) { LOG(WARNING) << "Failed to deserialize an URL. " << "TrackerDB might be corrupted."; - db_status_ = sync_file_system::SYNC_DATABASE_ERROR_CORRUPTION; + db_status_ = SYNC_DATABASE_ERROR_CORRUPTION; db_.reset(); return db_status_; } dirty_files->push(url); iter->Next(); } - return sync_file_system::SYNC_STATUS_OK; + return SYNC_STATUS_OK; } -} // namespace fileapi +} // namespace sync_file_system diff --git a/webkit/fileapi/syncable/local_file_change_tracker.h b/webkit/fileapi/syncable/local_file_change_tracker.h index 341770e..5a79f40 100644 --- a/webkit/fileapi/syncable/local_file_change_tracker.h +++ b/webkit/fileapi/syncable/local_file_change_tracker.h @@ -26,15 +26,18 @@ class SequencedTaskRunner; } namespace fileapi { - class FileSystemContext; +class FileSystemURL; +} + +namespace sync_file_system { // Tracks local file changes for cloud-backed file systems. // All methods must be called on the file_task_runner given to the constructor. // Owned by FileSystemContext. class WEBKIT_STORAGE_EXPORT LocalFileChangeTracker - : public FileUpdateObserver, - public FileChangeObserver { + : public fileapi::FileUpdateObserver, + public fileapi::FileChangeObserver { public: // |file_task_runner| must be the one where the observee file operations run. // (So that we can make sure DB operations are done before actual update @@ -44,37 +47,38 @@ class WEBKIT_STORAGE_EXPORT LocalFileChangeTracker virtual ~LocalFileChangeTracker(); // FileUpdateObserver overrides. - virtual void OnStartUpdate(const FileSystemURL& url) OVERRIDE; - virtual void OnUpdate(const FileSystemURL& url, int64 delta) OVERRIDE {} - virtual void OnEndUpdate(const FileSystemURL& url) OVERRIDE; + virtual void OnStartUpdate(const fileapi::FileSystemURL& url) OVERRIDE; + virtual void OnUpdate( + const fileapi::FileSystemURL& url, int64 delta) OVERRIDE {} + virtual void OnEndUpdate(const fileapi::FileSystemURL& url) OVERRIDE; // FileChangeObserver overrides. - virtual void OnCreateFile(const FileSystemURL& url) OVERRIDE; - virtual void OnCreateFileFrom(const FileSystemURL& url, - const FileSystemURL& src) OVERRIDE; - virtual void OnRemoveFile(const FileSystemURL& url) OVERRIDE; - virtual void OnModifyFile(const FileSystemURL& url) OVERRIDE; - virtual void OnCreateDirectory(const FileSystemURL& url) OVERRIDE; - virtual void OnRemoveDirectory(const FileSystemURL& url) OVERRIDE; + virtual void OnCreateFile(const fileapi::FileSystemURL& url) OVERRIDE; + virtual void OnCreateFileFrom(const fileapi::FileSystemURL& url, + const fileapi::FileSystemURL& src) OVERRIDE; + virtual void OnRemoveFile(const fileapi::FileSystemURL& url) OVERRIDE; + virtual void OnModifyFile(const fileapi::FileSystemURL& url) OVERRIDE; + virtual void OnCreateDirectory(const fileapi::FileSystemURL& url) OVERRIDE; + virtual void OnRemoveDirectory(const fileapi::FileSystemURL& url) OVERRIDE; // Retrieves an array of |url| which have more than one pending changes. // If |max_urls| is non-zero (recommended in production code) this // returns URLs up to the number from the ones that have smallest // change_seq numbers (i.e. older changes). - void GetNextChangedURLs(std::deque<FileSystemURL>* urls, int max_urls); + void GetNextChangedURLs(std::deque<fileapi::FileSystemURL>* urls, + int max_urls); // Returns all changes recorded for the given |url|. // This should be called after writing is disabled. - void GetChangesForURL(const FileSystemURL& url, - sync_file_system::FileChangeList* changes); + void GetChangesForURL(const fileapi::FileSystemURL& url, + FileChangeList* changes); // Clears the pending changes recorded in this tracker for |url|. - void ClearChangesForURL(const FileSystemURL& url); + void ClearChangesForURL(const fileapi::FileSystemURL& url); // Called by FileSyncService at the startup time to restore last dirty changes // left after the last shutdown (if any). - sync_file_system::SyncStatusCode Initialize( - FileSystemContext* file_system_context); + SyncStatusCode Initialize(fileapi::FileSystemContext* file_system_context); // This method is (exceptionally) thread-safe. int64 num_changes() const { @@ -94,32 +98,31 @@ class WEBKIT_STORAGE_EXPORT LocalFileChangeTracker struct ChangeInfo { ChangeInfo(); ~ChangeInfo(); - sync_file_system::FileChangeList change_list; + FileChangeList change_list; int64 change_seq; }; - typedef std::map<FileSystemURL, ChangeInfo, FileSystemURL::Comparator> - FileChangeMap; - typedef std::map<int64, FileSystemURL> ChangeSeqMap; + typedef std::map<fileapi::FileSystemURL, ChangeInfo, + fileapi::FileSystemURL::Comparator> + FileChangeMap; + typedef std::map<int64, fileapi::FileSystemURL> ChangeSeqMap; // This does mostly same as calling GetNextChangedURLs with max_url=0 // except that it returns urls in set rather than in deque. // Used only in testings. - void GetAllChangedURLs(FileSystemURLSet* urls); + void GetAllChangedURLs(fileapi::FileSystemURLSet* urls); // Used only in testings. void DropAllChanges(); // Database related methods. - sync_file_system::SyncStatusCode MarkDirtyOnDatabase( - const FileSystemURL& url); - sync_file_system::SyncStatusCode ClearDirtyOnDatabase( - const FileSystemURL& url); + SyncStatusCode MarkDirtyOnDatabase(const fileapi::FileSystemURL& url); + SyncStatusCode ClearDirtyOnDatabase(const fileapi::FileSystemURL& url); - sync_file_system::SyncStatusCode CollectLastDirtyChanges( - FileSystemContext* file_system_context); - void RecordChange(const FileSystemURL& url, - const sync_file_system::FileChange& change); + SyncStatusCode CollectLastDirtyChanges( + fileapi::FileSystemContext* file_system_context); + void RecordChange(const fileapi::FileSystemURL& url, + const FileChange& change); bool initialized_; @@ -142,6 +145,6 @@ class WEBKIT_STORAGE_EXPORT LocalFileChangeTracker DISALLOW_COPY_AND_ASSIGN(LocalFileChangeTracker); }; -} // namespace fileapi +} // namespace sync_file_system #endif // WEBKIT_FILEAPI_SYNCABLE_LOCAL_FILE_CHANGE_TRACKER_H_ diff --git a/webkit/fileapi/syncable/local_file_change_tracker_unittest.cc b/webkit/fileapi/syncable/local_file_change_tracker_unittest.cc index 6748645..618b129 100644 --- a/webkit/fileapi/syncable/local_file_change_tracker_unittest.cc +++ b/webkit/fileapi/syncable/local_file_change_tracker_unittest.cc @@ -23,12 +23,13 @@ #include "webkit/fileapi/syncable/syncable_file_system_util.h" #include "webkit/quota/quota_manager.h" -using sync_file_system::FileChange; -using sync_file_system::FileChangeList; +using fileapi::FileSystemContext; +using fileapi::FileSystemURL; +using fileapi::FileSystemURLSet; using webkit_blob::MockBlobURLRequestContext; using webkit_blob::ScopedTextBlob; -namespace fileapi { +namespace sync_file_system { class LocalFileChangeTrackerTest : public testing::Test { public: @@ -536,4 +537,4 @@ TEST_F(LocalFileChangeTrackerTest, NextChangedURLsWithRecursiveRemove) { URL(kPath2) == urls_to_process[1]); } -} // namespace fileapi +} // namespace sync_file_system diff --git a/webkit/fileapi/syncable/local_file_sync_context.cc b/webkit/fileapi/syncable/local_file_sync_context.cc index e846ed6..10e33cd 100644 --- a/webkit/fileapi/syncable/local_file_sync_context.cc +++ b/webkit/fileapi/syncable/local_file_sync_context.cc @@ -22,14 +22,14 @@ #include "webkit/fileapi/syncable/syncable_file_operation_runner.h" #include "webkit/fileapi/syncable/syncable_file_system_util.h" -using sync_file_system::FileChangeList; -using sync_file_system::LocalFileSyncInfo; -using sync_file_system::SyncFileMetadata; -using sync_file_system::SyncFileMetadataCallback; -using sync_file_system::SyncFileType; -using sync_file_system::SyncStatusCode; +using fileapi::FileSystemContext; +using fileapi::FileSystemFileUtil; +using fileapi::FileSystemOperation; +using fileapi::FileSystemOperationContext; +using fileapi::FileSystemURL; +using fileapi::LocalFileSystemOperation; -namespace fileapi { +namespace sync_file_system { namespace { const int kMaxConcurrentSyncableOperation = 3; @@ -51,14 +51,14 @@ void LocalFileSyncContext::MaybeInitializeFileSystemContext( const GURL& source_url, const std::string& service_name, FileSystemContext* file_system_context, - const sync_file_system::SyncStatusCallback& callback) { + const SyncStatusCallback& callback) { DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); if (ContainsKey(file_system_contexts_, file_system_context)) { // The context has been already initialized. Just dispatch the callback - // with sync_file_system::SYNC_STATUS_OK. + // with SYNC_STATUS_OK. ui_task_runner_->PostTask(FROM_HERE, base::Bind(callback, - sync_file_system::SYNC_STATUS_OK)); + SYNC_STATUS_OK)); return; } @@ -154,8 +154,8 @@ void LocalFileSyncContext::PrepareForSync( FROM_HERE, base::Bind(&LocalFileSyncContext::DidGetWritingStatusForSync, this, make_scoped_refptr(file_system_context), - syncable ? sync_file_system::SYNC_STATUS_OK : - sync_file_system::SYNC_STATUS_FILE_BUSY, + syncable ? SYNC_STATUS_OK : + SYNC_STATUS_FILE_BUSY, url, callback)); } @@ -183,10 +183,10 @@ void LocalFileSyncContext::RegisterURLForWaitingSync( void LocalFileSyncContext::ApplyRemoteChange( FileSystemContext* file_system_context, - const sync_file_system::FileChange& change, + const FileChange& change, const base::FilePath& local_path, const FileSystemURL& url, - const sync_file_system::SyncStatusCallback& callback) { + const SyncStatusCallback& callback) { if (!io_task_runner_->RunsTasksOnCurrentThread()) { DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); io_task_runner_->PostTask( @@ -206,22 +206,22 @@ void LocalFileSyncContext::ApplyRemoteChange( base::Bind(&LocalFileSyncContext::DidApplyRemoteChange, this, url, callback); switch (change.change()) { - case sync_file_system::FileChange::FILE_CHANGE_ADD_OR_UPDATE: + case FileChange::FILE_CHANGE_ADD_OR_UPDATE: switch (change.file_type()) { - case sync_file_system::SYNC_FILE_TYPE_FILE: + case SYNC_FILE_TYPE_FILE: DCHECK(!local_path.empty()); operation->CopyInForeignFile(local_path, url, operation_callback); break; - case sync_file_system::SYNC_FILE_TYPE_DIRECTORY: + case SYNC_FILE_TYPE_DIRECTORY: operation->CreateDirectory( url, false /* exclusive */, true /* recursive */, operation_callback); break; - case sync_file_system::SYNC_FILE_TYPE_UNKNOWN: + case SYNC_FILE_TYPE_UNKNOWN: NOTREACHED() << "File type unknown for ADD_OR_UPDATE change"; } break; - case sync_file_system::FileChange::FILE_CHANGE_DELETE: + case FileChange::FILE_CHANGE_DELETE: operation->Remove(url, true /* recursive */, operation_callback); break; } @@ -229,9 +229,9 @@ void LocalFileSyncContext::ApplyRemoteChange( void LocalFileSyncContext::RecordFakeLocalChange( FileSystemContext* file_system_context, - const fileapi::FileSystemURL& url, - const sync_file_system::FileChange& change, - const sync_file_system::SyncStatusCallback& callback) { + const FileSystemURL& url, + const FileChange& change, + const SyncStatusCallback& callback) { // This is called on UI thread and to be relayed to FILE thread. DCHECK(file_system_context); if (!file_system_context->task_runners()->file_task_runner()-> @@ -252,7 +252,7 @@ void LocalFileSyncContext::RecordFakeLocalChange( // Fire the callback on UI thread. ui_task_runner_->PostTask(FROM_HERE, base::Bind(callback, - sync_file_system::SYNC_STATUS_OK)); + SYNC_STATUS_OK)); } void LocalFileSyncContext::GetFileMetadata( @@ -301,7 +301,7 @@ void LocalFileSyncContext::HasPendingLocalChanges( // Fire the callback on UI thread. ui_task_runner_->PostTask(FROM_HERE, base::Bind(callback, - sync_file_system::SYNC_STATUS_OK, + SYNC_STATUS_OK, !changes.empty())); } @@ -424,7 +424,7 @@ void LocalFileSyncContext::InitializeFileSystemContextOnIOThread( } file_system_context->set_sync_context(this); DidInitialize(source_url, file_system_context, - sync_file_system::SYNC_STATUS_OK); + SYNC_STATUS_OK); } SyncStatusCode LocalFileSyncContext::InitializeChangeTrackerOnFileThread( @@ -438,7 +438,7 @@ SyncStatusCode LocalFileSyncContext::InitializeChangeTrackerOnFileThread( file_system_context->partition_path(), file_system_context->task_runners()->file_task_runner())); const SyncStatusCode status = (*tracker_ptr)->Initialize(file_system_context); - if (status != sync_file_system::SYNC_STATUS_OK) + if (status != SYNC_STATUS_OK) return status; // Get all origins that have pending changes. @@ -461,7 +461,7 @@ void LocalFileSyncContext::DidInitializeChangeTrackerOnIOThread( DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); DCHECK(file_system_context); DCHECK(origins_with_changes); - if (status != sync_file_system::SYNC_STATUS_OK) { + if (status != SYNC_STATUS_OK) { DidInitialize(source_url, file_system_context, status); return; } @@ -522,7 +522,7 @@ void LocalFileSyncContext::TryPrepareForLocalSync( DCHECK(urls); if (urls->empty()) { - callback.Run(sync_file_system::SYNC_STATUS_NO_CHANGE_TO_SYNC, + callback.Run(SYNC_STATUS_NO_CHANGE_TO_SYNC, LocalFileSyncInfo()); return; } @@ -546,7 +546,7 @@ void LocalFileSyncContext::DidTryPrepareForLocalSync( SyncStatusCode status, const LocalFileSyncInfo& sync_file_info) { DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); - if (status != sync_file_system::SYNC_STATUS_FILE_BUSY) { + if (status != SYNC_STATUS_FILE_BUSY) { callback.Run(status, sync_file_info); return; } @@ -565,7 +565,7 @@ void LocalFileSyncContext::DidGetWritingStatusForSync( RunsTasksOnCurrentThread()) { DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); if (shutdown_on_ui_) { - callback.Run(sync_file_system::SYNC_STATUS_ABORT, LocalFileSyncInfo()); + callback.Run(SYNC_STATUS_ABORT, LocalFileSyncInfo()); return; } file_system_context->task_runners()->file_task_runner()->PostTask( @@ -590,18 +590,18 @@ void LocalFileSyncContext::DidGetWritingStatusForSync( url, &file_info, &platform_path); - if (status == sync_file_system::SYNC_STATUS_OK && + if (status == SYNC_STATUS_OK && file_error != base::PLATFORM_FILE_OK && file_error != base::PLATFORM_FILE_ERROR_NOT_FOUND) - status = sync_file_system::PlatformFileErrorToSyncStatusCode(file_error); + status = PlatformFileErrorToSyncStatusCode(file_error); DCHECK(!file_info.is_symbolic_link); - SyncFileType file_type = sync_file_system::SYNC_FILE_TYPE_FILE; + SyncFileType file_type = SYNC_FILE_TYPE_FILE; if (file_error == base::PLATFORM_FILE_ERROR_NOT_FOUND) - file_type = sync_file_system::SYNC_FILE_TYPE_UNKNOWN; + file_type = SYNC_FILE_TYPE_UNKNOWN; else if (file_info.is_directory) - file_type = sync_file_system::SYNC_FILE_TYPE_DIRECTORY; + file_type = SYNC_FILE_TYPE_DIRECTORY; LocalFileSyncInfo sync_file_info; sync_file_info.url = url; @@ -626,14 +626,13 @@ void LocalFileSyncContext::EnableWritingOnIOThread( void LocalFileSyncContext::DidApplyRemoteChange( const FileSystemURL& url, - const sync_file_system::SyncStatusCallback& callback_on_ui, + const SyncStatusCallback& callback_on_ui, base::PlatformFileError file_error) { DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); ui_task_runner_->PostTask( FROM_HERE, base::Bind(callback_on_ui, - sync_file_system::PlatformFileErrorToSyncStatusCode( - file_error))); + PlatformFileErrorToSyncStatusCode(file_error))); EnableWritingOnIOThread(url); } @@ -646,16 +645,14 @@ void LocalFileSyncContext::DidGetFileMetadata( SyncFileMetadata metadata; if (file_error == base::PLATFORM_FILE_OK) { metadata.file_type = file_info.is_directory ? - sync_file_system::SYNC_FILE_TYPE_DIRECTORY : - sync_file_system::SYNC_FILE_TYPE_FILE; + SYNC_FILE_TYPE_DIRECTORY : SYNC_FILE_TYPE_FILE; metadata.size = file_info.size; metadata.last_modified = file_info.last_modified; } ui_task_runner_->PostTask( FROM_HERE, base::Bind(callback, - sync_file_system::PlatformFileErrorToSyncStatusCode( - file_error), + PlatformFileErrorToSyncStatusCode(file_error), metadata)); } @@ -665,4 +662,4 @@ base::TimeDelta LocalFileSyncContext::NotifyChangesDuration() { return base::TimeDelta::FromSeconds(kNotifyChangesDurationInSec); } -} // namespace fileapi +} // namespace sync_file_system diff --git a/webkit/fileapi/syncable/local_file_sync_context.h b/webkit/fileapi/syncable/local_file_sync_context.h index 075f326..e492932 100644 --- a/webkit/fileapi/syncable/local_file_sync_context.h +++ b/webkit/fileapi/syncable/local_file_sync_context.h @@ -29,15 +29,16 @@ namespace base { class SingleThreadTaskRunner; } -namespace sync_file_system { -class FileChange; -struct LocalFileSyncInfo; +namespace fileapi { +class FileSystemContext; +class FileSystemURL; } -namespace fileapi { +namespace sync_file_system { -class FileSystemContext; +class FileChange; class LocalFileChangeTracker; +struct LocalFileSyncInfo; class LocalOriginChangeObserver; class SyncableFileOperationRunner; @@ -51,11 +52,10 @@ class WEBKIT_STORAGE_EXPORT LocalFileSyncContext public LocalFileSyncStatus::Observer { public: typedef base::Callback<void( - sync_file_system::SyncStatusCode status, - const sync_file_system::LocalFileSyncInfo& sync_file_info)> + SyncStatusCode status, const LocalFileSyncInfo& sync_file_info)> LocalFileSyncInfoCallback; - typedef base::Callback<void(sync_file_system::SyncStatusCode status, + typedef base::Callback<void(SyncStatusCode status, bool has_pending_changes)> HasPendingLocalChangeCallback; @@ -69,8 +69,8 @@ class WEBKIT_STORAGE_EXPORT LocalFileSyncContext void MaybeInitializeFileSystemContext( const GURL& source_url, const std::string& service_name, - FileSystemContext* file_system_context, - const sync_file_system::SyncStatusCallback& callback); + fileapi::FileSystemContext* file_system_context, + const SyncStatusCallback& callback); // Called when the corresponding LocalFileSyncService exits. // This method must be called on UI thread. @@ -79,20 +79,20 @@ class WEBKIT_STORAGE_EXPORT LocalFileSyncContext // Picks a file for next local sync and returns it after disabling writes // for the file. // This method must be called on UI thread. - void GetFileForLocalSync(FileSystemContext* file_system_context, + void GetFileForLocalSync(fileapi::FileSystemContext* file_system_context, const LocalFileSyncInfoCallback& callback); // Clears all pending local changes for |url|. |done_callback| is called // when the changes are cleared. // This method must be called on UI thread. - void ClearChangesForURL(FileSystemContext* file_system_context, - const FileSystemURL& url, + void ClearChangesForURL(fileapi::FileSystemContext* file_system_context, + const fileapi::FileSystemURL& url, const base::Closure& done_callback); // A local or remote sync has been finished (either successfully or // with an error). Clears the internal sync flag and enable writing for |url|. // This method must be called on UI thread. - void ClearSyncFlagForURL(const FileSystemURL& url); + void ClearSyncFlagForURL(const fileapi::FileSystemURL& url); // Prepares for sync |url| by disabling writes on |url|. // If the target |url| is being written and cannot start sync it @@ -100,8 +100,8 @@ class WEBKIT_STORAGE_EXPORT LocalFileSyncContext // Otherwise it disables writes, marks the |url| syncing and returns // the current change set made on |url|. // This method must be called on UI thread. - void PrepareForSync(FileSystemContext* file_system_context, - const FileSystemURL& url, + void PrepareForSync(fileapi::FileSystemContext* file_system_context, + const fileapi::FileSystemURL& url, const LocalFileSyncInfoCallback& callback); // Registers |url| to wait until sync is enabled for |url|. @@ -113,36 +113,36 @@ class WEBKIT_STORAGE_EXPORT LocalFileSyncContext // for sync will overwrite the previously registered URL. // // This method must be called on UI thread. - void RegisterURLForWaitingSync(const FileSystemURL& url, + void RegisterURLForWaitingSync(const fileapi::FileSystemURL& url, const base::Closure& on_syncable_callback); // Applies a remote change. // This method must be called on UI thread. void ApplyRemoteChange( - FileSystemContext* file_system_context, - const sync_file_system::FileChange& change, + fileapi::FileSystemContext* file_system_context, + const FileChange& change, const base::FilePath& local_path, - const FileSystemURL& url, - const sync_file_system::SyncStatusCallback& callback); + const fileapi::FileSystemURL& url, + const SyncStatusCallback& callback); // Records a fake local change in the local change tracker. void RecordFakeLocalChange( - FileSystemContext* file_system_context, + fileapi::FileSystemContext* file_system_context, const fileapi::FileSystemURL& url, - const sync_file_system::FileChange& change, - const sync_file_system::SyncStatusCallback& callback); + const FileChange& change, + const SyncStatusCallback& callback); // This must be called on UI thread. void GetFileMetadata( - FileSystemContext* file_system_context, - const FileSystemURL& url, - const sync_file_system::SyncFileMetadataCallback& callback); + fileapi::FileSystemContext* file_system_context, + const fileapi::FileSystemURL& url, + const SyncFileMetadataCallback& callback); // Returns true via |callback| if the given file |url| has local pending // changes. void HasPendingLocalChanges( - FileSystemContext* file_system_context, - const FileSystemURL& url, + fileapi::FileSystemContext* file_system_context, + const fileapi::FileSystemURL& url, const HasPendingLocalChangeCallback& callback); // They must be called on UI thread. @@ -163,11 +163,11 @@ class WEBKIT_STORAGE_EXPORT LocalFileSyncContext protected: // LocalFileSyncStatus::Observer overrides. They are called on IO thread. - virtual void OnSyncEnabled(const FileSystemURL& url) OVERRIDE; - virtual void OnWriteEnabled(const FileSystemURL& url) OVERRIDE; + virtual void OnSyncEnabled(const fileapi::FileSystemURL& url) OVERRIDE; + virtual void OnWriteEnabled(const fileapi::FileSystemURL& url) OVERRIDE; private: - typedef std::deque<sync_file_system::SyncStatusCallback> StatusCallbackQueue; + typedef std::deque<SyncStatusCallback> StatusCallbackQueue; friend class base::RefCountedThreadSafe<LocalFileSyncContext>; friend class CannedSyncableFileSystem; @@ -190,56 +190,56 @@ class WEBKIT_STORAGE_EXPORT LocalFileSyncContext void InitializeFileSystemContextOnIOThread( const GURL& source_url, const std::string& service_name, - FileSystemContext* file_system_context); - sync_file_system::SyncStatusCode InitializeChangeTrackerOnFileThread( + fileapi::FileSystemContext* file_system_context); + SyncStatusCode InitializeChangeTrackerOnFileThread( scoped_ptr<LocalFileChangeTracker>* tracker_ptr, - FileSystemContext* file_system_context, + fileapi::FileSystemContext* file_system_context, std::set<GURL>* origins_with_changes); void DidInitializeChangeTrackerOnIOThread( scoped_ptr<LocalFileChangeTracker>* tracker_ptr, const GURL& source_url, const std::string& service_name, - FileSystemContext* file_system_context, + fileapi::FileSystemContext* file_system_context, std::set<GURL>* origins_with_changes, - sync_file_system::SyncStatusCode status); + SyncStatusCode status); void DidInitialize( const GURL& source_url, - FileSystemContext* file_system_context, - sync_file_system::SyncStatusCode status); + fileapi::FileSystemContext* file_system_context, + SyncStatusCode status); // Helper routines for GetFileForLocalSync. void GetNextURLsForSyncOnFileThread( - FileSystemContext* file_system_context, - std::deque<FileSystemURL>* urls); + fileapi::FileSystemContext* file_system_context, + std::deque<fileapi::FileSystemURL>* urls); void TryPrepareForLocalSync( - FileSystemContext* file_system_context, - std::deque<FileSystemURL>* urls, + fileapi::FileSystemContext* file_system_context, + std::deque<fileapi::FileSystemURL>* urls, const LocalFileSyncInfoCallback& callback); void DidTryPrepareForLocalSync( - FileSystemContext* file_system_context, - std::deque<FileSystemURL>* remaining_urls, + fileapi::FileSystemContext* file_system_context, + std::deque<fileapi::FileSystemURL>* remaining_urls, const LocalFileSyncInfoCallback& callback, - sync_file_system::SyncStatusCode status, - const sync_file_system::LocalFileSyncInfo& sync_file_info); + SyncStatusCode status, + const LocalFileSyncInfo& sync_file_info); // Callback routine for PrepareForSync and GetFileForLocalSync. void DidGetWritingStatusForSync( - FileSystemContext* file_system_context, - sync_file_system::SyncStatusCode status, - const FileSystemURL& url, + fileapi::FileSystemContext* file_system_context, + SyncStatusCode status, + const fileapi::FileSystemURL& url, const LocalFileSyncInfoCallback& callback); // Helper routine for ClearSyncFlagForURL. - void EnableWritingOnIOThread(const FileSystemURL& url); + void EnableWritingOnIOThread(const fileapi::FileSystemURL& url); // Callback routine for ApplyRemoteChange. void DidApplyRemoteChange( - const FileSystemURL& url, - const sync_file_system::SyncStatusCallback& callback_on_ui, + const fileapi::FileSystemURL& url, + const SyncStatusCallback& callback_on_ui, base::PlatformFileError file_error); void DidGetFileMetadata( - const sync_file_system::SyncFileMetadataCallback& callback, + const SyncFileMetadataCallback& callback, base::PlatformFileError file_error, const base::PlatformFileInfo& file_info, const base::FilePath& platform_path); @@ -262,15 +262,15 @@ class WEBKIT_STORAGE_EXPORT LocalFileSyncContext // Pointers to file system contexts that have been initialized for // synchronization (i.e. that own this instance). // This must be accessed only on UI thread. - std::set<FileSystemContext*> file_system_contexts_; + std::set<fileapi::FileSystemContext*> file_system_contexts_; // Accessed only on UI thread. - std::map<FileSystemContext*, StatusCallbackQueue> + std::map<fileapi::FileSystemContext*, StatusCallbackQueue> pending_initialize_callbacks_; // A URL and associated callback waiting for sync is enabled. // Accessed only on IO thread. - FileSystemURL url_waiting_sync_on_io_; + fileapi::FileSystemURL url_waiting_sync_on_io_; base::Closure url_syncable_callback_; // Used only on IO thread for available changes notifications. @@ -285,6 +285,6 @@ class WEBKIT_STORAGE_EXPORT LocalFileSyncContext DISALLOW_COPY_AND_ASSIGN(LocalFileSyncContext); }; -} // namespace fileapi +} // namespace sync_file_system #endif // WEBKIT_FILEAPI_SYNCABLE_LOCAL_FILE_SYNC_CONTEXT_H_ diff --git a/webkit/fileapi/syncable/local_file_sync_context_unittest.cc b/webkit/fileapi/syncable/local_file_sync_context_unittest.cc index cf62cbf..9273a7b 100644 --- a/webkit/fileapi/syncable/local_file_sync_context_unittest.cc +++ b/webkit/fileapi/syncable/local_file_sync_context_unittest.cc @@ -28,20 +28,17 @@ #define FPL FILE_PATH_LITERAL +using fileapi::FileSystemContext; +using fileapi::FileSystemURL; +using fileapi::FileSystemURLSet; + // This tests LocalFileSyncContext behavior in multi-thread / // multi-file-system-context environment. // Basic combined tests (single-thread / single-file-system-context) // that involve LocalFileSyncContext are also in // syncable_file_system_unittests.cc. -using sync_file_system::FileChange; -using sync_file_system::FileChangeList; -using sync_file_system::LocalFileSyncInfo; -using sync_file_system::SyncFileMetadata; -using sync_file_system::SyncFileType; -using sync_file_system::SyncStatusCode; - -namespace fileapi { +namespace sync_file_system { namespace { const char kOrigin1[] = "http://example.com"; @@ -52,13 +49,13 @@ const char kServiceName[] = "test"; class LocalFileSyncContextTest : public testing::Test { protected: LocalFileSyncContextTest() - : status_(sync_file_system::SYNC_FILE_ERROR_FAILED), + : status_(SYNC_FILE_ERROR_FAILED), file_error_(base::PLATFORM_FILE_ERROR_FAILED), async_modify_finished_(false), has_inflight_prepare_for_sync_(false) {} virtual void SetUp() OVERRIDE { - EXPECT_TRUE(fileapi::RegisterSyncableFileSystem(kServiceName)); + EXPECT_TRUE(RegisterSyncableFileSystem(kServiceName)); io_thread_.reset(new base::Thread("Thread_IO")); io_thread_->StartWithOptions( @@ -73,7 +70,7 @@ class LocalFileSyncContextTest : public testing::Test { } virtual void TearDown() OVERRIDE { - EXPECT_TRUE(fileapi::RevokeSyncableFileSystem(kServiceName)); + EXPECT_TRUE(RevokeSyncableFileSystem(kServiceName)); io_thread_->Stop(); file_thread_->Stop(); } @@ -84,7 +81,7 @@ class LocalFileSyncContextTest : public testing::Test { FileChangeList* changes) { ASSERT_TRUE(changes != NULL); ASSERT_FALSE(has_inflight_prepare_for_sync_); - status_ = sync_file_system::SYNC_STATUS_UNKNOWN; + status_ = SYNC_STATUS_UNKNOWN; has_inflight_prepare_for_sync_ = true; sync_context_->PrepareForSync( file_system_context, @@ -135,11 +132,11 @@ class LocalFileSyncContextTest : public testing::Test { // First we should call PrepareForSync to disable writing. SyncFileMetadata metadata; FileChangeList changes; - EXPECT_EQ(sync_file_system::SYNC_STATUS_OK, + EXPECT_EQ(SYNC_STATUS_OK, PrepareForSync(file_system_context, url, &metadata, &changes)); EXPECT_EQ(expected_file_type, metadata.file_type); - status_ = sync_file_system::SYNC_STATUS_UNKNOWN; + status_ = SYNC_STATUS_UNKNOWN; sync_context_->ApplyRemoteChange( file_system_context, change, local_path, url, base::Bind(&LocalFileSyncContextTest::DidApplyRemoteChange, @@ -223,7 +220,7 @@ TEST_F(LocalFileSyncContextTest, InitializeFileSystemContext) { sync_context_ = new LocalFileSyncContext(ui_task_runner_, io_task_runner_); // Initializes file_system using |sync_context_|. - EXPECT_EQ(sync_file_system::SYNC_STATUS_OK, + EXPECT_EQ(SYNC_STATUS_OK, file_system.MaybeInitializeFileSystemContext(sync_context_)); // Make sure everything's set up for file_system to be able to handle @@ -234,7 +231,7 @@ TEST_F(LocalFileSyncContextTest, InitializeFileSystemContext) { file_system.file_system_context()->sync_context()); // Calling MaybeInitialize for the same context multiple times must be ok. - EXPECT_EQ(sync_file_system::SYNC_STATUS_OK, + EXPECT_EQ(SYNC_STATUS_OK, file_system.MaybeInitializeFileSystemContext(sync_context_)); EXPECT_EQ(sync_context_.get(), file_system.file_system_context()->sync_context()); @@ -267,9 +264,9 @@ TEST_F(LocalFileSyncContextTest, MultipleFileSystemContexts) { sync_context_ = new LocalFileSyncContext(ui_task_runner_, io_task_runner_); // Initializes file_system1 and file_system2. - EXPECT_EQ(sync_file_system::SYNC_STATUS_OK, + EXPECT_EQ(SYNC_STATUS_OK, file_system1.MaybeInitializeFileSystemContext(sync_context_)); - EXPECT_EQ(sync_file_system::SYNC_STATUS_OK, + EXPECT_EQ(SYNC_STATUS_OK, file_system2.MaybeInitializeFileSystemContext(sync_context_)); EXPECT_EQ(base::PLATFORM_FILE_OK, file_system1.OpenFileSystem()); @@ -309,23 +306,23 @@ TEST_F(LocalFileSyncContextTest, MultipleFileSystemContexts) { SyncFileMetadata metadata; FileChangeList changes; - EXPECT_EQ(sync_file_system::SYNC_STATUS_OK, + EXPECT_EQ(SYNC_STATUS_OK, PrepareForSync(file_system1.file_system_context(), kURL1, &metadata, &changes)); EXPECT_EQ(1U, changes.size()); EXPECT_TRUE(changes.list().back().IsFile()); EXPECT_TRUE(changes.list().back().IsAddOrUpdate()); - EXPECT_EQ(sync_file_system::SYNC_FILE_TYPE_FILE, metadata.file_type); + EXPECT_EQ(SYNC_FILE_TYPE_FILE, metadata.file_type); EXPECT_EQ(0, metadata.size); changes.clear(); - EXPECT_EQ(sync_file_system::SYNC_STATUS_OK, + EXPECT_EQ(SYNC_STATUS_OK, PrepareForSync(file_system2.file_system_context(), kURL2, &metadata, &changes)); EXPECT_EQ(1U, changes.size()); EXPECT_FALSE(changes.list().back().IsFile()); EXPECT_TRUE(changes.list().back().IsAddOrUpdate()); - EXPECT_EQ(sync_file_system::SYNC_FILE_TYPE_DIRECTORY, metadata.file_type); + EXPECT_EQ(SYNC_FILE_TYPE_DIRECTORY, metadata.file_type); EXPECT_EQ(0, metadata.size); sync_context_->ShutdownOnUIThread(); @@ -340,7 +337,7 @@ TEST_F(LocalFileSyncContextTest, PrepareSyncWhileWriting) { io_task_runner_, file_task_runner_); file_system.SetUp(); sync_context_ = new LocalFileSyncContext(ui_task_runner_, io_task_runner_); - EXPECT_EQ(sync_file_system::SYNC_STATUS_OK, + EXPECT_EQ(SYNC_STATUS_OK, file_system.MaybeInitializeFileSystemContext(sync_context_)); EXPECT_EQ(base::PLATFORM_FILE_OK, file_system.OpenFileSystem()); @@ -355,17 +352,17 @@ TEST_F(LocalFileSyncContextTest, PrepareSyncWhileWriting) { // Until the operation finishes PrepareForSync should return BUSY error. SyncFileMetadata metadata; - metadata.file_type = sync_file_system::SYNC_FILE_TYPE_UNKNOWN; + metadata.file_type = SYNC_FILE_TYPE_UNKNOWN; FileChangeList changes; - EXPECT_EQ(sync_file_system::SYNC_STATUS_FILE_BUSY, + EXPECT_EQ(SYNC_STATUS_FILE_BUSY, PrepareForSync(file_system.file_system_context(), kURL1, &metadata, &changes)); - EXPECT_EQ(sync_file_system::SYNC_FILE_TYPE_FILE, metadata.file_type); + EXPECT_EQ(SYNC_FILE_TYPE_FILE, metadata.file_type); // Register PrepareForSync method to be invoked when kURL1 becomes // syncable. (Actually this may be done after all operations are done // on IO thread in this test.) - metadata.file_type = sync_file_system::SYNC_FILE_TYPE_UNKNOWN; + metadata.file_type = SYNC_FILE_TYPE_UNKNOWN; changes.clear(); sync_context_->RegisterURLForWaitingSync( kURL1, GetPrepareForSyncClosure(file_system.file_system_context(), @@ -380,11 +377,11 @@ TEST_F(LocalFileSyncContextTest, PrepareSyncWhileWriting) { ASSERT_FALSE(has_inflight_prepare_for_sync_); // Now PrepareForSync should have run and returned OK. - EXPECT_EQ(sync_file_system::SYNC_STATUS_OK, status_); + EXPECT_EQ(SYNC_STATUS_OK, status_); EXPECT_EQ(1U, changes.size()); EXPECT_TRUE(changes.list().back().IsFile()); EXPECT_TRUE(changes.list().back().IsAddOrUpdate()); - EXPECT_EQ(sync_file_system::SYNC_FILE_TYPE_FILE, metadata.file_type); + EXPECT_EQ(SYNC_FILE_TYPE_FILE, metadata.file_type); EXPECT_EQ(1, metadata.size); sync_context_->ShutdownOnUIThread(); @@ -398,7 +395,7 @@ TEST_F(LocalFileSyncContextTest, ApplyRemoteChangeForDeletion) { file_system.SetUp(); sync_context_ = new LocalFileSyncContext(ui_task_runner_, io_task_runner_); - ASSERT_EQ(sync_file_system::SYNC_STATUS_OK, + ASSERT_EQ(SYNC_STATUS_OK, file_system.MaybeInitializeFileSystemContext(sync_context_)); ASSERT_EQ(base::PLATFORM_FILE_OK, file_system.OpenFileSystem()); @@ -437,20 +434,20 @@ TEST_F(LocalFileSyncContextTest, ApplyRemoteChangeForDeletion) { // Now let's apply remote deletion changes. FileChange change(FileChange::FILE_CHANGE_DELETE, - sync_file_system::SYNC_FILE_TYPE_FILE); - EXPECT_EQ(sync_file_system::SYNC_STATUS_OK, + SYNC_FILE_TYPE_FILE); + EXPECT_EQ(SYNC_STATUS_OK, ApplyRemoteChange(file_system.file_system_context(), change, base::FilePath(), kFile, - sync_file_system::SYNC_FILE_TYPE_FILE)); + SYNC_FILE_TYPE_FILE)); // The implementation doesn't check file type for deletion, and it must be ok // even if we don't know if the deletion change was for a file or a directory. change = FileChange(FileChange::FILE_CHANGE_DELETE, - sync_file_system::SYNC_FILE_TYPE_UNKNOWN); - EXPECT_EQ(sync_file_system::SYNC_STATUS_OK, + SYNC_FILE_TYPE_UNKNOWN); + EXPECT_EQ(SYNC_STATUS_OK, ApplyRemoteChange(file_system.file_system_context(), change, base::FilePath(), kDir, - sync_file_system::SYNC_FILE_TYPE_DIRECTORY)); + SYNC_FILE_TYPE_DIRECTORY)); // Check the directory/files are deleted successfully. EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, @@ -485,7 +482,7 @@ TEST_F(LocalFileSyncContextTest, ApplyRemoteChangeForAddOrUpdate) { file_system.SetUp(); sync_context_ = new LocalFileSyncContext(ui_task_runner_, io_task_runner_); - ASSERT_EQ(sync_file_system::SYNC_STATUS_OK, + ASSERT_EQ(SYNC_STATUS_OK, file_system.MaybeInitializeFileSystemContext(sync_context_)); ASSERT_EQ(base::PLATFORM_FILE_OK, file_system.OpenFileSystem()); @@ -547,11 +544,11 @@ TEST_F(LocalFileSyncContextTest, ApplyRemoteChangeForAddOrUpdate) { // Apply the remote change to kFile1 (which will update the file). FileChange change(FileChange::FILE_CHANGE_ADD_OR_UPDATE, - sync_file_system::SYNC_FILE_TYPE_FILE); - EXPECT_EQ(sync_file_system::SYNC_STATUS_OK, + SYNC_FILE_TYPE_FILE); + EXPECT_EQ(SYNC_STATUS_OK, ApplyRemoteChange(file_system.file_system_context(), change, kFilePath1, kFile1, - sync_file_system::SYNC_FILE_TYPE_FILE)); + SYNC_FILE_TYPE_FILE)); // Check if the usage has been increased by (kTestFileData1 - kTestFileData0). const int updated_size = @@ -564,29 +561,29 @@ TEST_F(LocalFileSyncContextTest, ApplyRemoteChangeForAddOrUpdate) { // directory respectively). // They are non-existent yet so their expected file type (the last // parameter of ApplyRemoteChange) are - // sync_file_system::SYNC_FILE_TYPE_UNKNOWN. + // SYNC_FILE_TYPE_UNKNOWN. change = FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, - sync_file_system::SYNC_FILE_TYPE_FILE); - EXPECT_EQ(sync_file_system::SYNC_STATUS_OK, + SYNC_FILE_TYPE_FILE); + EXPECT_EQ(SYNC_STATUS_OK, ApplyRemoteChange(file_system.file_system_context(), change, kFilePath2, kFile2, - sync_file_system::SYNC_FILE_TYPE_UNKNOWN)); + SYNC_FILE_TYPE_UNKNOWN)); change = FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, - sync_file_system::SYNC_FILE_TYPE_DIRECTORY); - EXPECT_EQ(sync_file_system::SYNC_STATUS_OK, + SYNC_FILE_TYPE_DIRECTORY); + EXPECT_EQ(SYNC_STATUS_OK, ApplyRemoteChange(file_system.file_system_context(), change, base::FilePath(), kDir, - sync_file_system::SYNC_FILE_TYPE_UNKNOWN)); + SYNC_FILE_TYPE_UNKNOWN)); // This should not happen, but calling ApplyRemoteChange // with wrong file type will result in error. change = FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, - sync_file_system::SYNC_FILE_TYPE_FILE); - EXPECT_NE(sync_file_system::SYNC_STATUS_OK, + SYNC_FILE_TYPE_FILE); + EXPECT_NE(SYNC_STATUS_OK, ApplyRemoteChange(file_system.file_system_context(), change, kFilePath1, kDir, - sync_file_system::SYNC_FILE_TYPE_DIRECTORY)); + SYNC_FILE_TYPE_DIRECTORY)); // Creating a file/directory must have increased the usage more than // the size of kTestFileData2. @@ -611,4 +608,4 @@ TEST_F(LocalFileSyncContextTest, ApplyRemoteChangeForAddOrUpdate) { file_system.TearDown(); } -} // namespace fileapi +} // namespace sync_file_system diff --git a/webkit/fileapi/syncable/local_file_sync_status.cc b/webkit/fileapi/syncable/local_file_sync_status.cc index 4966fe6..b043650 100644 --- a/webkit/fileapi/syncable/local_file_sync_status.cc +++ b/webkit/fileapi/syncable/local_file_sync_status.cc @@ -6,7 +6,10 @@ #include "base/logging.h" -namespace fileapi { +using fileapi::FileSystemURL; +using fileapi::FileSystemURLSet; + +namespace sync_file_system { LocalFileSyncStatus::LocalFileSyncStatus() {} @@ -91,4 +94,4 @@ bool LocalFileSyncStatus::IsChildOrParentSyncing( return false; } -} // namespace fileapi +} // namespace sync_file_system diff --git a/webkit/fileapi/syncable/local_file_sync_status.h b/webkit/fileapi/syncable/local_file_sync_status.h index cf48cbe..0654064 100644 --- a/webkit/fileapi/syncable/local_file_sync_status.h +++ b/webkit/fileapi/syncable/local_file_sync_status.h @@ -15,6 +15,10 @@ #include "webkit/fileapi/file_system_url.h" namespace fileapi { +class FileSystemURL; +} + +namespace sync_file_system { // Represents local file sync status. // This class is supposed to run only on IO thread. @@ -31,8 +35,8 @@ class WEBKIT_STORAGE_EXPORT LocalFileSyncStatus : public base::NonThreadSafe { public: Observer() {} virtual ~Observer() {} - virtual void OnSyncEnabled(const FileSystemURL& url) = 0; - virtual void OnWriteEnabled(const FileSystemURL& url) = 0; + virtual void OnSyncEnabled(const fileapi::FileSystemURL& url) = 0; + virtual void OnWriteEnabled(const fileapi::FileSystemURL& url) = 0; private: DISALLOW_COPY_AND_ASSIGN(Observer); }; @@ -42,48 +46,49 @@ class WEBKIT_STORAGE_EXPORT LocalFileSyncStatus : public base::NonThreadSafe { // Increment writing counter for |url|. // This should not be called if the |url| is not writable. - void StartWriting(const FileSystemURL& url); + void StartWriting(const fileapi::FileSystemURL& url); // Decrement writing counter for |url|. - void EndWriting(const FileSystemURL& url); + void EndWriting(const fileapi::FileSystemURL& url); // Start syncing for |url| and disable writing. // This should not be called if |url| is in syncing or in writing. - void StartSyncing(const FileSystemURL& url); + void StartSyncing(const fileapi::FileSystemURL& url); // Clears the syncing flag for |url| and enable writing. - void EndSyncing(const FileSystemURL& url); + void EndSyncing(const fileapi::FileSystemURL& url); // Returns true if the |url| or its parent or child is in writing. - bool IsWriting(const FileSystemURL& url) const; + bool IsWriting(const fileapi::FileSystemURL& url) const; // Returns true if the |url| is enabled for writing (i.e. not in syncing). - bool IsWritable(const FileSystemURL& url) const; + bool IsWritable(const fileapi::FileSystemURL& url) const; // Returns true if the |url| is enabled for syncing (i.e. neither in // syncing nor writing). - bool IsSyncable(const FileSystemURL& url) const; + bool IsSyncable(const fileapi::FileSystemURL& url) const; void AddObserver(Observer* observer); void RemoveObserver(Observer* observer); private: - typedef std::map<FileSystemURL, int64, FileSystemURL::Comparator> URLCountMap; + typedef std::map<fileapi::FileSystemURL,int64, + fileapi::FileSystemURL::Comparator> URLCountMap; - bool IsChildOrParentWriting(const FileSystemURL& url) const; - bool IsChildOrParentSyncing(const FileSystemURL& url) const; + bool IsChildOrParentWriting(const fileapi::FileSystemURL& url) const; + bool IsChildOrParentSyncing(const fileapi::FileSystemURL& url) const; // If this count is non-zero positive there're ongoing write operations. URLCountMap writing_; // If this flag is set sync process is running on the file. - FileSystemURLSet syncing_; + fileapi::FileSystemURLSet syncing_; ObserverList<Observer> observer_list_; DISALLOW_COPY_AND_ASSIGN(LocalFileSyncStatus); }; -} // namespace fileapi +} // namespace sync_file_system #endif // WEBKIT_FILEAPI_SYNCABLE_LOCAL_FILE_SYNC_STATUS_H_ diff --git a/webkit/fileapi/syncable/local_file_sync_status_unittest.cc b/webkit/fileapi/syncable/local_file_sync_status_unittest.cc index c78237f..8a5d401 100644 --- a/webkit/fileapi/syncable/local_file_sync_status_unittest.cc +++ b/webkit/fileapi/syncable/local_file_sync_status_unittest.cc @@ -8,7 +8,9 @@ #include "googleurl/src/gurl.h" #include "testing/gtest/include/gtest/gtest.h" -namespace fileapi { +using fileapi::FileSystemURL; + +namespace sync_file_system { namespace { @@ -84,4 +86,4 @@ TEST(LocalFileSyncStatusTest, SyncingSimple) { EXPECT_TRUE(status.IsWritable(URL(kChild))); } -} // namespace fileapi +} // namespace sync_file_system diff --git a/webkit/fileapi/syncable/local_origin_change_observer.h b/webkit/fileapi/syncable/local_origin_change_observer.h index a932917..84ed65d 100644 --- a/webkit/fileapi/syncable/local_origin_change_observer.h +++ b/webkit/fileapi/syncable/local_origin_change_observer.h @@ -10,7 +10,7 @@ #include "base/basictypes.h" #include "googleurl/src/gurl.h" -namespace fileapi { +namespace sync_file_system { class LocalOriginChangeObserver { public: @@ -23,6 +23,6 @@ class LocalOriginChangeObserver { DISALLOW_COPY_AND_ASSIGN(LocalOriginChangeObserver); }; -} // namespace fileapi +} // namespace sync_file_system #endif // WEBKIT_FILEAPI_SYNCABLE_LOCAL_ORIGIN_CHANGE_OBSERVER_H_ diff --git a/webkit/fileapi/syncable/mock_sync_status_observer.cc b/webkit/fileapi/syncable/mock_sync_status_observer.cc index 80ae893..4a1a4c0a 100644 --- a/webkit/fileapi/syncable/mock_sync_status_observer.cc +++ b/webkit/fileapi/syncable/mock_sync_status_observer.cc @@ -4,7 +4,7 @@ #include "webkit/fileapi/syncable/mock_sync_status_observer.h" -namespace fileapi { +namespace sync_file_system { MockSyncStatusObserver::MockSyncStatusObserver() { } @@ -12,4 +12,4 @@ MockSyncStatusObserver::MockSyncStatusObserver() { MockSyncStatusObserver::~MockSyncStatusObserver() { } -} // namespace fileapi +} // namespace sync_file_system diff --git a/webkit/fileapi/syncable/mock_sync_status_observer.h b/webkit/fileapi/syncable/mock_sync_status_observer.h index 59c89b3..6483f1d 100644 --- a/webkit/fileapi/syncable/mock_sync_status_observer.h +++ b/webkit/fileapi/syncable/mock_sync_status_observer.h @@ -8,7 +8,7 @@ #include "testing/gmock/include/gmock/gmock.h" #include "webkit/fileapi/syncable/local_file_sync_status.h" -namespace fileapi { +namespace sync_file_system { class MockSyncStatusObserver : public LocalFileSyncStatus::Observer { public: @@ -16,13 +16,13 @@ class MockSyncStatusObserver : public LocalFileSyncStatus::Observer { virtual ~MockSyncStatusObserver(); // LocalFileSyncStatus::Observer overrides. - MOCK_METHOD1(OnSyncEnabled, void(const FileSystemURL& url)); - MOCK_METHOD1(OnWriteEnabled, void(const FileSystemURL& url)); + MOCK_METHOD1(OnSyncEnabled, void(const fileapi::FileSystemURL& url)); + MOCK_METHOD1(OnWriteEnabled, void(const fileapi::FileSystemURL& url)); private: DISALLOW_COPY_AND_ASSIGN(MockSyncStatusObserver); }; -} // namespace fileapi +} // namespace sync_file_system #endif // WEBKIT_FILEAPI_SYNCABLE_MOCK_SYNC_STATUS_OBSERVER_H_ diff --git a/webkit/fileapi/syncable/syncable_file_operation_runner.cc b/webkit/fileapi/syncable/syncable_file_operation_runner.cc index 4389a4d..91fca3e 100644 --- a/webkit/fileapi/syncable/syncable_file_operation_runner.cc +++ b/webkit/fileapi/syncable/syncable_file_operation_runner.cc @@ -11,7 +11,9 @@ #include "base/stl_util.h" #include "webkit/fileapi/syncable/local_file_sync_status.h" -namespace fileapi { +using fileapi::FileSystemURL; + +namespace sync_file_system { // SyncableFileOperationRunner::Task ------------------------------------------- @@ -102,4 +104,4 @@ bool SyncableFileOperationRunner::ShouldStartMoreTasks() const { return num_inflight_tasks_ < max_inflight_tasks_; } -} // namespace fileapi +} // namespace sync_file_system diff --git a/webkit/fileapi/syncable/syncable_file_operation_runner.h b/webkit/fileapi/syncable/syncable_file_operation_runner.h index cd63138..9f15e21 100644 --- a/webkit/fileapi/syncable/syncable_file_operation_runner.h +++ b/webkit/fileapi/syncable/syncable_file_operation_runner.h @@ -18,8 +18,10 @@ #include "webkit/storage/webkit_storage_export.h" namespace fileapi { - class FileSystemURL; +} + +namespace sync_file_system { // This class must run only on IO thread. // Owned by LocalFileSyncContext. @@ -40,7 +42,7 @@ class WEBKIT_STORAGE_EXPORT SyncableFileOperationRunner protected: // This is never called after Run() or Cancel() is called. - virtual const std::vector<FileSystemURL>& target_paths() const = 0; + virtual const std::vector<fileapi::FileSystemURL>& target_paths() const = 0; private: friend class SyncableFileOperationRunner; @@ -56,8 +58,8 @@ class WEBKIT_STORAGE_EXPORT SyncableFileOperationRunner virtual ~SyncableFileOperationRunner(); // LocalFileSyncStatus::Observer overrides. - virtual void OnSyncEnabled(const FileSystemURL& url) OVERRIDE; - virtual void OnWriteEnabled(const FileSystemURL& url) OVERRIDE; + virtual void OnSyncEnabled(const fileapi::FileSystemURL& url) OVERRIDE; + virtual void OnWriteEnabled(const fileapi::FileSystemURL& url) OVERRIDE; // Runs the given |task| if no sync operation is running on any of // its target_paths(). This also runs pending tasks that have become @@ -72,7 +74,8 @@ class WEBKIT_STORAGE_EXPORT SyncableFileOperationRunner // Called when an operation is completed. This will make |target_paths| // writable and may start a next runnable task. - void OnOperationCompleted(const std::vector<FileSystemURL>& target_paths); + void OnOperationCompleted( + const std::vector<fileapi::FileSystemURL>& target_paths); LocalFileSyncStatus* sync_status() const { return sync_status_; } @@ -97,6 +100,6 @@ class WEBKIT_STORAGE_EXPORT SyncableFileOperationRunner DISALLOW_COPY_AND_ASSIGN(SyncableFileOperationRunner); }; -} // namespace fileapi +} // namespace sync_file_system #endif // WEBKIT_FILEAPI_SYNCABLE_SYNCABLE_FILE_OPERATION_RUNNER_H_ diff --git a/webkit/fileapi/syncable/syncable_file_operation_runner_unittest.cc b/webkit/fileapi/syncable/syncable_file_operation_runner_unittest.cc index a36c620..284943a 100644 --- a/webkit/fileapi/syncable/syncable_file_operation_runner_unittest.cc +++ b/webkit/fileapi/syncable/syncable_file_operation_runner_unittest.cc @@ -19,11 +19,13 @@ #include "webkit/fileapi/syncable/syncable_file_system_operation.h" #include "webkit/fileapi/syncable/syncable_file_system_util.h" +using fileapi::FileSystemOperation; +using fileapi::FileSystemURL; using webkit_blob::MockBlobURLRequestContext; using webkit_blob::ScopedTextBlob; using base::PlatformFileError; -namespace fileapi { +namespace sync_file_system { namespace { const std::string kServiceName = "test"; @@ -56,7 +58,7 @@ class SyncableFileOperationRunnerTest : public testing::Test { file_system_.SetUp(); sync_context_ = new LocalFileSyncContext(base::MessageLoopProxy::current(), base::MessageLoopProxy::current()); - ASSERT_EQ(sync_file_system::SYNC_STATUS_OK, + ASSERT_EQ(SYNC_STATUS_OK, file_system_.MaybeInitializeFileSystemContext(sync_context_)); ASSERT_EQ(base::PLATFORM_FILE_OK, file_system_.OpenFileSystem()); @@ -319,4 +321,4 @@ TEST_F(SyncableFileOperationRunnerTest, QueueAndCancel) { EXPECT_EQ(2, callback_count_); } -} // namespace fileapi +} // namespace sync_file_system diff --git a/webkit/fileapi/syncable/syncable_file_system_operation.cc b/webkit/fileapi/syncable/syncable_file_system_operation.cc index e2145b5..3d90af7 100644 --- a/webkit/fileapi/syncable/syncable_file_system_operation.cc +++ b/webkit/fileapi/syncable/syncable_file_system_operation.cc @@ -13,7 +13,10 @@ #include "webkit/fileapi/syncable/local_file_sync_context.h" #include "webkit/fileapi/syncable/syncable_file_operation_runner.h" -namespace fileapi { +using fileapi::FileSystemURL; +using fileapi::LocalFileSystemOperation; + +namespace sync_file_system { namespace { @@ -340,8 +343,8 @@ void SyncableFileSystemOperation::CreateSnapshotFile( } SyncableFileSystemOperation::SyncableFileSystemOperation( - FileSystemContext* file_system_context, - FileSystemOperation* file_system_operation) { + fileapi::FileSystemContext* file_system_context, + fileapi::FileSystemOperation* file_system_operation) { DCHECK(file_system_context); DCHECK(file_system_operation); file_system_operation_ = file_system_operation->AsLocalFileSystemOperation(); @@ -398,4 +401,4 @@ void SyncableFileSystemOperation::Destruct() { delete this; } -} // namespace fileapi +} // namespace sync_file_system diff --git a/webkit/fileapi/syncable/syncable_file_system_operation.h b/webkit/fileapi/syncable/syncable_file_system_operation.h index 2a87192..9631c72 100644 --- a/webkit/fileapi/syncable/syncable_file_system_operation.h +++ b/webkit/fileapi/syncable/syncable_file_system_operation.h @@ -16,61 +16,68 @@ #include "webkit/storage/webkit_storage_export.h" namespace fileapi { +class FileSystemContext; +class FileSystemOperation; +class SandboxMountPointProvider; +} + +namespace sync_file_system { class FileSystemContext; class SyncableFileOperationRunner; // A wrapper class of LocalFileSystemOperation for syncable file system. class WEBKIT_STORAGE_EXPORT SyncableFileSystemOperation - : public NON_EXPORTED_BASE(FileSystemOperation), + : public NON_EXPORTED_BASE(fileapi::FileSystemOperation), public base::NonThreadSafe { public: virtual ~SyncableFileSystemOperation(); - // FileSystemOperation overrides. - virtual void CreateFile(const FileSystemURL& url, + // fileapi::FileSystemOperation overrides. + virtual void CreateFile(const fileapi::FileSystemURL& url, bool exclusive, const StatusCallback& callback) OVERRIDE; - virtual void CreateDirectory(const FileSystemURL& url, + virtual void CreateDirectory(const fileapi::FileSystemURL& url, bool exclusive, bool recursive, const StatusCallback& callback) OVERRIDE; - virtual void Copy(const FileSystemURL& src_url, - const FileSystemURL& dest_url, + virtual void Copy(const fileapi::FileSystemURL& src_url, + const fileapi::FileSystemURL& dest_url, const StatusCallback& callback) OVERRIDE; - virtual void Move(const FileSystemURL& src_url, - const FileSystemURL& dest_url, + virtual void Move(const fileapi::FileSystemURL& src_url, + const fileapi::FileSystemURL& dest_url, const StatusCallback& callback) OVERRIDE; - virtual void DirectoryExists(const FileSystemURL& url, + virtual void DirectoryExists(const fileapi::FileSystemURL& url, const StatusCallback& callback) OVERRIDE; - virtual void FileExists(const FileSystemURL& url, + virtual void FileExists(const fileapi::FileSystemURL& url, const StatusCallback& callback) OVERRIDE; - virtual void GetMetadata(const FileSystemURL& url, + virtual void GetMetadata(const fileapi::FileSystemURL& url, const GetMetadataCallback& callback) OVERRIDE; - virtual void ReadDirectory(const FileSystemURL& url, + virtual void ReadDirectory(const fileapi::FileSystemURL& url, const ReadDirectoryCallback& callback) OVERRIDE; - virtual void Remove(const FileSystemURL& url, bool recursive, + virtual void Remove(const fileapi::FileSystemURL& url, bool recursive, const StatusCallback& callback) OVERRIDE; virtual void Write(const net::URLRequestContext* url_request_context, - const FileSystemURL& url, + const fileapi::FileSystemURL& url, const GURL& blob_url, int64 offset, const WriteCallback& callback) OVERRIDE; - virtual void Truncate(const FileSystemURL& url, int64 length, + virtual void Truncate(const fileapi::FileSystemURL& url, int64 length, const StatusCallback& callback) OVERRIDE; - virtual void TouchFile(const FileSystemURL& url, + virtual void TouchFile(const fileapi::FileSystemURL& url, const base::Time& last_access_time, const base::Time& last_modified_time, const StatusCallback& callback) OVERRIDE; - virtual void OpenFile(const FileSystemURL& url, + virtual void OpenFile(const fileapi::FileSystemURL& url, int file_flags, base::ProcessHandle peer_handle, const OpenFileCallback& callback) OVERRIDE; - virtual void NotifyCloseFile(const FileSystemURL& url) OVERRIDE; + virtual void NotifyCloseFile(const fileapi::FileSystemURL& url) OVERRIDE; virtual void Cancel(const StatusCallback& cancel_callback) OVERRIDE; - virtual LocalFileSystemOperation* AsLocalFileSystemOperation() OVERRIDE; + virtual fileapi::LocalFileSystemOperation* + AsLocalFileSystemOperation() OVERRIDE; virtual void CreateSnapshotFile( - const FileSystemURL& path, + const fileapi::FileSystemURL& path, const SnapshotFileCallback& callback) OVERRIDE; private: @@ -78,9 +85,10 @@ class WEBKIT_STORAGE_EXPORT SyncableFileSystemOperation class QueueableTask; // Only MountPointProviders can create a new operation directly. - friend class SandboxMountPointProvider; - SyncableFileSystemOperation(FileSystemContext* file_system_context, - FileSystemOperation* file_system_operation); + friend class fileapi::SandboxMountPointProvider; + SyncableFileSystemOperation( + fileapi::FileSystemContext* file_system_context, + fileapi::FileSystemOperation* file_system_operation); void DidFinish(base::PlatformFileError status); void DidWrite(const WriteCallback& callback, @@ -98,8 +106,8 @@ class WEBKIT_STORAGE_EXPORT SyncableFileSystemOperation void Destruct(); base::WeakPtr<SyncableFileOperationRunner> operation_runner_; - LocalFileSystemOperation* file_system_operation_; - std::vector<FileSystemURL> target_paths_; + fileapi::LocalFileSystemOperation* file_system_operation_; + std::vector<fileapi::FileSystemURL> target_paths_; StatusCallback completion_callback_; @@ -108,6 +116,6 @@ class WEBKIT_STORAGE_EXPORT SyncableFileSystemOperation DISALLOW_COPY_AND_ASSIGN(SyncableFileSystemOperation); }; -} // namespace fileapi +} // namespace sync_file_system #endif // WEBKIT_FILEAPI_SYNCABLE_SYNCABLE_FILE_SYSTEM_OPERATION_H_ diff --git a/webkit/fileapi/syncable/syncable_file_system_unittest.cc b/webkit/fileapi/syncable/syncable_file_system_unittest.cc index ac4e001..991c04a 100644 --- a/webkit/fileapi/syncable/syncable_file_system_unittest.cc +++ b/webkit/fileapi/syncable/syncable_file_system_unittest.cc @@ -18,12 +18,15 @@ #include "webkit/quota/quota_types.h" using base::PlatformFileError; +using fileapi::FileSystemContext; +using fileapi::FileSystemOperationContext; +using fileapi::FileSystemURL; +using fileapi::FileSystemURLSet; +using fileapi::LocalFileSystemTestOriginHelper; using quota::QuotaManager; using quota::QuotaStatusCode; -using sync_file_system::FileChange; -using sync_file_system::FileChangeList; -namespace fileapi { +namespace sync_file_system { class SyncableFileSystemTest : public testing::Test { public: @@ -243,8 +246,8 @@ TEST_F(SyncableFileSystemTest, DisableDirectoryOperations) { file_system_.CreateDirectory(URL("dir"))); // Set up another (non-syncable) local file system. - LocalFileSystemTestOriginHelper other_file_system_(GURL("http://foo.com/"), - kFileSystemTypeTemporary); + LocalFileSystemTestOriginHelper other_file_system_( + GURL("http://foo.com/"), fileapi::kFileSystemTypeTemporary); other_file_system_.SetUp(file_system_.file_system_context()); // Create directory '/a' and file '/a/b' in the other file system. @@ -276,4 +279,4 @@ TEST_F(SyncableFileSystemTest, DisableDirectoryOperations) { other_file_system_.TearDown(); } -} // namespace fileapi +} // namespace sync_file_system diff --git a/webkit/fileapi/syncable/syncable_file_system_util.cc b/webkit/fileapi/syncable/syncable_file_system_util.cc index efb9122..bceb096 100644 --- a/webkit/fileapi/syncable/syncable_file_system_util.cc +++ b/webkit/fileapi/syncable/syncable_file_system_util.cc @@ -10,11 +10,16 @@ #include "webkit/fileapi/file_system_util.h" #include "webkit/fileapi/sandbox_mount_point_provider.h" -namespace fileapi { +using fileapi::ExternalMountPoints; +using fileapi::FileSystemContext; +using fileapi::FileSystemURL; +using fileapi::LocalFileSystemOperation; + +namespace sync_file_system { bool RegisterSyncableFileSystem(const std::string& service_name) { return ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( - service_name, kFileSystemTypeSyncable, base::FilePath()); + service_name, fileapi::kFileSystemTypeSyncable, base::FilePath()); } bool RevokeSyncableFileSystem(const std::string& service_name) { @@ -24,7 +29,8 @@ bool RevokeSyncableFileSystem(const std::string& service_name) { GURL GetSyncableFileSystemRootURI(const GURL& origin, const std::string& service_name) { - const GURL url = GetFileSystemRootURI(origin, kFileSystemTypeExternal); + const GURL url = GetFileSystemRootURI(origin, + fileapi::kFileSystemTypeExternal); const std::string path = service_name + "/"; url_canon::Replacements<char> replacements; replacements.SetPath(path.c_str(), url_parse::Component(0, path.length())); @@ -36,13 +42,13 @@ FileSystemURL CreateSyncableFileSystemURL(const GURL& origin, const base::FilePath& path) { return ExternalMountPoints::GetSystemInstance()->CreateCrackedFileSystemURL( origin, - kFileSystemTypeExternal, + fileapi::kFileSystemTypeExternal, base::FilePath::FromUTF8Unsafe(service_name).Append(path)); } bool SerializeSyncableFileSystemURL(const FileSystemURL& url, std::string* serialized_url) { - if (!url.is_valid() || url.type() != kFileSystemTypeSyncable) + if (!url.is_valid() || url.type() != fileapi::kFileSystemTypeSyncable) return false; *serialized_url = GetSyncableFileSystemRootURI(url.origin(), url.filesystem_id()).spec() + @@ -59,7 +65,7 @@ bool DeserializeSyncableFileSystemURL( FileSystemURL deserialized = ExternalMountPoints::GetSystemInstance()->CrackURL(GURL(serialized_url)); if (!deserialized.is_valid() || - deserialized.type() != kFileSystemTypeSyncable) { + deserialized.type() != fileapi::kFileSystemTypeSyncable) { return false; } @@ -67,11 +73,11 @@ bool DeserializeSyncableFileSystemURL( return true; } -LocalFileSystemOperation* -CreateFileSystemOperationForSync(FileSystemContext* file_system_context) { +LocalFileSystemOperation* CreateFileSystemOperationForSync( + FileSystemContext* file_system_context) { DCHECK(file_system_context); return file_system_context->sandbox_provider()-> CreateFileSystemOperationForSync(file_system_context); } -} // namespace fileapi +} // namespace sync_file_system diff --git a/webkit/fileapi/syncable/syncable_file_system_util.h b/webkit/fileapi/syncable/syncable_file_system_util.h index 26e446d..14a8ab2 100644 --- a/webkit/fileapi/syncable/syncable_file_system_util.h +++ b/webkit/fileapi/syncable/syncable_file_system_util.h @@ -12,9 +12,12 @@ #include "webkit/storage/webkit_storage_export.h" namespace fileapi { - class FileSystemContext; +class FileSystemURL; class LocalFileSystemOperation; +} + +namespace sync_file_system { // Registers a syncable filesystem with the given |service_name|. WEBKIT_STORAGE_EXPORT bool RegisterSyncableFileSystem( @@ -37,7 +40,7 @@ WEBKIT_STORAGE_EXPORT GURL GetSyncableFileSystemRootURI( // service_name: 'service_name', // path: '/foo/bar', // returns 'filesystem:http://www.example.com/external/service_name/foo/bar' -WEBKIT_STORAGE_EXPORT FileSystemURL CreateSyncableFileSystemURL( +WEBKIT_STORAGE_EXPORT fileapi::FileSystemURL CreateSyncableFileSystemURL( const GURL& origin, const std::string& service_name, const base::FilePath& path); @@ -57,7 +60,7 @@ WEBKIT_STORAGE_EXPORT FileSystemURL CreateSyncableFileSystemURL( // (on others) // 'filesystem:http://www.example.com/external/service_name/foo/bar' WEBKIT_STORAGE_EXPORT bool SerializeSyncableFileSystemURL( - const FileSystemURL& url, std::string* serialized_url); + const fileapi::FileSystemURL& url, std::string* serialized_url); // Deserializes a serialized FileSystem URL string |serialized_url| and sets the // deserialized value to |url|. If the reconstructed object is invalid or does @@ -70,7 +73,7 @@ WEBKIT_STORAGE_EXPORT bool SerializeSyncableFileSystemURL( // // See the comment of SerializeSyncableFileSystemURL() for more details. WEBKIT_STORAGE_EXPORT bool DeserializeSyncableFileSystemURL( - const std::string& serialized_url, FileSystemURL* url); + const std::string& serialized_url, fileapi::FileSystemURL* url); // Returns a new FileSystemOperation that can be used to apply changes @@ -79,9 +82,10 @@ WEBKIT_STORAGE_EXPORT bool DeserializeSyncableFileSystemURL( // * notifies the regular sandboxed quota observer // therefore quota will be updated appropriately without bothering the // change tracker. -WEBKIT_STORAGE_EXPORT LocalFileSystemOperation* -CreateFileSystemOperationForSync(FileSystemContext* file_system_context); +WEBKIT_STORAGE_EXPORT fileapi::LocalFileSystemOperation* + CreateFileSystemOperationForSync( + fileapi::FileSystemContext* file_system_context); -} // namespace fileapi +} // namespace sync_file_system #endif // WEBKIT_FILEAPI_SYNCABLE_SYNCABLE_FILE_SYSTEM_UTIL_H_ diff --git a/webkit/fileapi/syncable/syncable_file_system_util_unittest.cc b/webkit/fileapi/syncable/syncable_file_system_util_unittest.cc index e097afb..0302cf4 100644 --- a/webkit/fileapi/syncable/syncable_file_system_util_unittest.cc +++ b/webkit/fileapi/syncable/syncable_file_system_util_unittest.cc @@ -12,7 +12,11 @@ #include "webkit/fileapi/syncable/canned_syncable_file_system.h" #include "webkit/fileapi/syncable/local_file_sync_context.h" -namespace fileapi { +using fileapi::ExternalMountPoints; +using fileapi::FileSystemURL; +using fileapi::ScopedExternalFileSystem; + +namespace sync_file_system { namespace { @@ -45,7 +49,7 @@ TEST(SyncableFileSystemUtilTest, GetSyncableFileSystemRootURI) { TEST(SyncableFileSystemUtilTest, CreateSyncableFileSystemURL) { ScopedExternalFileSystem scoped_fs( - kServiceName, kFileSystemTypeSyncable, base::FilePath()); + kServiceName, fileapi::kFileSystemTypeSyncable, base::FilePath()); const base::FilePath path(kPath); const FileSystemURL expected_url = @@ -60,13 +64,13 @@ TEST(SyncableFileSystemUtilTest, CreateSyncableFileSystemURL) { TEST(SyncableFileSystemUtilTest, SerializeAndDesirializeSyncableFileSystemURL) { ScopedExternalFileSystem scoped_fs( - kServiceName, kFileSystemTypeSyncable, base::FilePath()); + kServiceName, fileapi::kFileSystemTypeSyncable, base::FilePath()); const std::string expected_url_str = kSyncableFileSystemRootURI + CreateNormalizedFilePath(kPath).AsUTF8Unsafe(); const FileSystemURL expected_url = CreateFileSystemURL(expected_url_str); - const FileSystemURL url = - CreateSyncableFileSystemURL(GURL(kOrigin), kServiceName, base::FilePath(kPath)); + const FileSystemURL url = CreateSyncableFileSystemURL( + GURL(kOrigin), kServiceName, base::FilePath(kPath)); std::string serialized; EXPECT_TRUE(SerializeSyncableFileSystemURL(url, &serialized)); @@ -81,7 +85,7 @@ TEST(SyncableFileSystemUtilTest, TEST(SyncableFileSystemUtilTest, FailInSerializingAndDeserializingSyncableFileSystemURL) { ScopedExternalFileSystem scoped_fs( - kServiceName, kFileSystemTypeSyncable, base::FilePath()); + kServiceName, fileapi::kFileSystemTypeSyncable, base::FilePath()); const base::FilePath normalized_path = CreateNormalizedFilePath(kPath); const std::string non_registered_url = @@ -142,4 +146,4 @@ TEST(SyncableFileSystemUtilTest, SerializeBeforeOpenFileSystem) { MessageLoop::current()->RunUntilIdle(); } -} // namespace fileapi +} // namespace sync_file_system |