diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-04 07:23:56 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-04 07:23:56 +0000 |
commit | 3899be4f08ba835bdf1c6af501a64eb438cc304c (patch) | |
tree | 3d0c1ce7d31fe301bbab5f7e871adbe7865af12e | |
parent | dedd0a9e00390f585c41f065d1bff0731bd4a2d8 (diff) | |
download | chromium_src-3899be4f08ba835bdf1c6af501a64eb438cc304c.zip chromium_src-3899be4f08ba835bdf1c6af501a64eb438cc304c.tar.gz chromium_src-3899be4f08ba835bdf1c6af501a64eb438cc304c.tar.bz2 |
Cleanup: Deprecate DriveFileSyncService::kServiceName
Also deprecate service_name parameters everywhere in SyncFileSystem.
BUG=246123
TEST=unit_tests:Drive\*, content_unittests:SyncableFileSystemUtilTest
TBR=nhiroki@chromium.org, tzik@chromium.org
Review URL: https://codereview.chromium.org/16109008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203893 0039d316-1c4b-4281-b951-d872f2087c98
47 files changed, 175 insertions, 237 deletions
diff --git a/chrome/browser/extensions/api/developer_private/developer_private_api.cc b/chrome/browser/extensions/api/developer_private/developer_private_api.cc index 992c041..dc3ac18 100644 --- a/chrome/browser/extensions/api/developer_private/developer_private_api.cc +++ b/chrome/browser/extensions/api/developer_private/developer_private_api.cc @@ -864,7 +864,6 @@ void DeveloperPrivateExportSyncfsFolderToLocalfsFunction:: Extension::GetBaseURLFromExtensionId(extension_id()).spec()); fileapi::FileSystemURL url(sync_file_system::CreateSyncableFileSystemURL( GURL(origin_url), - sync_file_system::DriveFileSyncService::kServiceName, project_path.BaseName())); base::PlatformFileError error_code; @@ -907,7 +906,6 @@ void DeveloperPrivateExportSyncfsFolderToLocalfsFunction:: Extension::GetBaseURLFromExtensionId(extension_id()).spec()); fileapi::FileSystemURL url(sync_file_system::CreateSyncableFileSystemURL( GURL(origin_url), - sync_file_system::DriveFileSyncService::kServiceName, project_path.BaseName().Append(file_list[i].name))); base::FilePath target_path = project_path; target_path = target_path.Append(file_list[i].name); 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 3d2b82b..e856033 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 @@ -26,15 +26,13 @@ ExtensionSyncEventObserver::ExtensionSyncEventObserver( sync_service_(NULL) {} void ExtensionSyncEventObserver::InitializeForService( - sync_file_system::SyncFileSystemService* sync_service, - const std::string& service_name) { + sync_file_system::SyncFileSystemService* sync_service) { DCHECK(sync_service); if (sync_service_ != NULL) { DCHECK_EQ(sync_service_, sync_service); return; } sync_service_ = sync_service; - service_name_ = service_name; sync_service_->AddSyncEventObserver(this); } diff --git a/chrome/browser/extensions/api/sync_file_system/extension_sync_event_observer.h b/chrome/browser/extensions/api/sync_file_system/extension_sync_event_observer.h index 25aadf8..78055eb 100644 --- a/chrome/browser/extensions/api/sync_file_system/extension_sync_event_observer.h +++ b/chrome/browser/extensions/api/sync_file_system/extension_sync_event_observer.h @@ -29,8 +29,7 @@ class ExtensionSyncEventObserver virtual ~ExtensionSyncEventObserver(); void InitializeForService( - sync_file_system::SyncFileSystemService* sync_service, - const std::string& service_name); + sync_file_system::SyncFileSystemService* sync_service); // BrowserContextKeyedService override. virtual void Shutdown() OVERRIDE; @@ -56,7 +55,6 @@ class ExtensionSyncEventObserver // Not owned. If not null, then this is registered to SyncFileSystemService. sync_file_system::SyncFileSystemService* sync_service_; - std::string service_name_; void BroadcastOrDispatchEvent(const GURL& app_origin, const std::string& event_name, diff --git a/chrome/browser/extensions/api/sync_file_system/sync_file_system_api.cc b/chrome/browser/extensions/api/sync_file_system/sync_file_system_api.cc index 4d7c2a0..598d255 100644 --- a/chrome/browser/extensions/api/sync_file_system/sync_file_system_api.cc +++ b/chrome/browser/extensions/api/sync_file_system/sync_file_system_api.cc @@ -40,10 +40,6 @@ namespace extensions { namespace { -// This is the only supported cloud backend service for now. -const char* const kDriveCloudService = - sync_file_system::DriveFileSyncService::kServiceName; - // Error messages. const char kFileError[] = "File error %d."; const char kQuotaError[] = "Quota error %d."; @@ -58,7 +54,7 @@ sync_file_system::SyncFileSystemService* GetSyncFileSystemService( ExtensionSyncEventObserver* observer = ExtensionSyncEventObserverFactory::GetForProfile(profile); DCHECK(observer); - observer->InitializeForService(service, kDriveCloudService); + observer->InitializeForService(service); return service; } @@ -113,21 +109,13 @@ void SyncFileSystemDeleteFileSystemFunction::DidDeleteFileSystem( } bool SyncFileSystemRequestFileSystemFunction::RunImpl() { - // Please note that Google Drive is the only supported cloud backend at this - // time. However other functions which have already been written to - // accommodate different service names are being left as is to allow easier - // future support for other backend services. (http://crbug.com/172562). - const std::string service_name = sync_file_system::DriveFileSyncService:: - kServiceName; // Initializes sync context for this extension and continue to open // a new file system. GetSyncFileSystemService(profile())-> InitializeForApp( GetFileSystemContext(), - service_name, source_url().GetOrigin(), - base::Bind(&self::DidInitializeFileSystemContext, this, - service_name)); + base::Bind(&self::DidInitializeFileSystemContext, this)); return true; } @@ -140,7 +128,6 @@ SyncFileSystemRequestFileSystemFunction::GetFileSystemContext() { } void SyncFileSystemRequestFileSystemFunction::DidInitializeFileSystemContext( - const std::string& service_name, SyncStatusCode status) { if (status != sync_file_system::SYNC_STATUS_OK) { error_ = sync_file_system::SyncStatusCodeToString(status); @@ -157,7 +144,6 @@ void SyncFileSystemRequestFileSystemFunction::DidInitializeFileSystemContext( BrowserThread::IO, FROM_HERE, Bind(&fileapi::FileSystemContext::OpenSyncableFileSystem, GetFileSystemContext(), - service_name, source_url().GetOrigin(), fileapi::kFileSystemTypeSyncable, fileapi::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, diff --git a/chrome/browser/extensions/api/sync_file_system/sync_file_system_api.h b/chrome/browser/extensions/api/sync_file_system/sync_file_system_api.h index e41dd54..fa3e1f9 100644 --- a/chrome/browser/extensions/api/sync_file_system/sync_file_system_api.h +++ b/chrome/browser/extensions/api/sync_file_system/sync_file_system_api.h @@ -114,8 +114,7 @@ class SyncFileSystemRequestFileSystemFunction // Returns the file system context for this extension. fileapi::FileSystemContext* GetFileSystemContext(); - void DidInitializeFileSystemContext(const std::string& service_name, - sync_file_system::SyncStatusCode status); + void DidInitializeFileSystemContext(sync_file_system::SyncStatusCode status); void DidOpenFileSystem(base::PlatformFileError error, const std::string& file_system_name, const GURL& root_url); 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 fe896a2..f226979 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 @@ -85,7 +85,6 @@ ACTION_P5(ReturnWithFakeFileAddedStatus, sync_action_taken) { FileSystemURL mock_url = sync_file_system::CreateSyncableFileSystemURL( *origin, - sync_file_system::DriveFileSyncService::kServiceName, base::FilePath(FILE_PATH_LITERAL("foo.txt"))); mock_remote_service->NotifyRemoteChangeQueueUpdated(0); base::MessageLoopProxy::current()->PostTask( diff --git a/chrome/browser/sync_file_system/drive/metadata_db_migration_util.cc b/chrome/browser/sync_file_system/drive/metadata_db_migration_util.cc index ff37333..1c9a4f3 100644 --- a/chrome/browser/sync_file_system/drive/metadata_db_migration_util.cc +++ b/chrome/browser/sync_file_system/drive/metadata_db_migration_util.cc @@ -39,7 +39,7 @@ bool ParseV0FormatFileSystemURL(const GURL& url, if (!fileapi::FileSystemURL::ParseFileSystemSchemeURL( url, origin, &mount_type, &virtual_path) || mount_type != fileapi::kFileSystemTypeExternal) { - NOTREACHED() << "Failed to parse filesystem scheme URL"; + NOTREACHED() << "Failed to parse filesystem scheme URL " << url.spec(); return false; } diff --git a/chrome/browser/sync_file_system/drive/metadata_db_migration_util_unittest.cc b/chrome/browser/sync_file_system/drive/metadata_db_migration_util_unittest.cc index 3c7daf4..8a75f86 100644 --- a/chrome/browser/sync_file_system/drive/metadata_db_migration_util_unittest.cc +++ b/chrome/browser/sync_file_system/drive/metadata_db_migration_util_unittest.cc @@ -12,6 +12,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/leveldatabase/src/include/leveldb/db.h" #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" +#include "webkit/browser/fileapi/external_mount_points.h" #include "webkit/browser/fileapi/syncable/syncable_file_system_util.h" #include "webkit/common/fileapi/file_system_util.h" @@ -21,28 +22,41 @@ namespace sync_file_system { namespace drive { namespace { + const char kV0ServiceName[] = "drive"; + +bool CreateV0SerializedSyncableFileSystemURL( + const GURL& origin, + const base::FilePath& path, + std::string* serialized_url) { + fileapi::ScopedExternalFileSystem scoped_fs( + kV0ServiceName, fileapi::kFileSystemTypeSyncable, base::FilePath()); + + fileapi::FileSystemURL url = + fileapi::ExternalMountPoints::GetSystemInstance()-> + CreateExternalFileSystemURL(origin, kV0ServiceName, path); + if (!url.is_valid()) + return false; + *serialized_url = fileapi::GetExternalFileSystemRootURIString( + origin, kV0ServiceName) + url.path().AsUTF8Unsafe(); + return true; } +} // namespace + TEST(DriveMetadataDBMigrationUtilTest, ParseV0FormatFileSystemURL) { const GURL kOrigin("chrome-extension://example"); const base::FilePath kFile(FPL("foo bar")); - ASSERT_TRUE(RegisterSyncableFileSystem(kV0ServiceName)); - - fileapi::FileSystemURL url = - CreateSyncableFileSystemURL(kOrigin, kV0ServiceName, kFile); - std::string serialized_url; - SerializeSyncableFileSystemURL(url, &serialized_url); + ASSERT_TRUE(CreateV0SerializedSyncableFileSystemURL( + kOrigin, kFile, &serialized_url)); GURL origin; base::FilePath path; EXPECT_TRUE(ParseV0FormatFileSystemURL(GURL(serialized_url), &origin, &path)); EXPECT_EQ(kOrigin, origin); EXPECT_EQ(kFile, path); - - EXPECT_TRUE(RevokeSyncableFileSystem(kV0ServiceName)); } TEST(DriveMetadataDBMigrationUtilTest, AddWapiIdPrefix) { @@ -88,8 +102,6 @@ TEST(DriveMetadataDBMigrationUtilTest, MigrationFromV0) { const base::FilePath kFile(FPL("foo bar")); const std::string kFileMD5("file_md5"); - ASSERT_TRUE(RegisterSyncableFileSystem(kV0ServiceName)); - base::ScopedTempDir base_dir; ASSERT_TRUE(base_dir.CreateUniqueTempDir()); @@ -108,9 +120,6 @@ TEST(DriveMetadataDBMigrationUtilTest, MigrationFromV0) { batch.Put(kChangeStampKey, "1"); batch.Put(kSyncRootDirectoryKey, kSyncRootResourceId); - fileapi::FileSystemURL url = - CreateSyncableFileSystemURL(kOrigin1, kV0ServiceName, kFile); - // Setup drive metadata. DriveMetadata drive_metadata; drive_metadata.set_resource_id(kFileResourceId); @@ -119,7 +128,8 @@ TEST(DriveMetadataDBMigrationUtilTest, MigrationFromV0) { drive_metadata.set_to_be_fetched(false); std::string serialized_url; - SerializeSyncableFileSystemURL(url, &serialized_url); + ASSERT_TRUE(CreateV0SerializedSyncableFileSystemURL( + kOrigin1, kFile, &serialized_url)); std::string metadata_string; drive_metadata.SerializeToString(&metadata_string); batch.Put(kDriveMetadataKeyPrefix + serialized_url, metadata_string); @@ -131,7 +141,6 @@ TEST(DriveMetadataDBMigrationUtilTest, MigrationFromV0) { status = db->Write(leveldb::WriteOptions(), &batch); EXPECT_EQ(SYNC_STATUS_OK, LevelDBStatusToSyncStatusCode(status)); - EXPECT_TRUE(RevokeSyncableFileSystem(kV0ServiceName)); // Migrate the database. drive::MigrateDatabaseFromV0ToV1(db.get()); @@ -200,8 +209,7 @@ TEST(DriveMetadataDBMigrationUtilTest, MigrationFromV1) { const base::FilePath kFile(FPL("foo bar")); const std::string kFileMD5("file_md5"); - const char kV1ServiceName[] = "syncfs"; - ASSERT_TRUE(RegisterSyncableFileSystem(kV1ServiceName)); + RegisterSyncableFileSystem(); base::ScopedTempDir base_dir; ASSERT_TRUE(base_dir.CreateUniqueTempDir()); @@ -222,8 +230,7 @@ TEST(DriveMetadataDBMigrationUtilTest, MigrationFromV1) { batch.Put(kChangeStampKey, "1"); batch.Put(kSyncRootDirectoryKey, kSyncRootResourceId); - fileapi::FileSystemURL url = - CreateSyncableFileSystemURL(kOrigin1, kV1ServiceName, kFile); + fileapi::FileSystemURL url = CreateSyncableFileSystemURL(kOrigin1, kFile); // Setup drive metadata. DriveMetadata drive_metadata; @@ -245,7 +252,8 @@ TEST(DriveMetadataDBMigrationUtilTest, MigrationFromV1) { status = db->Write(leveldb::WriteOptions(), &batch); EXPECT_EQ(SYNC_STATUS_OK, LevelDBStatusToSyncStatusCode(status)); - EXPECT_TRUE(RevokeSyncableFileSystem(kV1ServiceName)); + + RevokeSyncableFileSystem(); // Migrate the database. drive::MigrateDatabaseFromV1ToV2(db.get()); 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 b26eaa1..336c14a 100644 --- a/chrome/browser/sync_file_system/drive_file_sync_service.cc +++ b/chrome/browser/sync_file_system/drive_file_sync_service.cc @@ -89,7 +89,6 @@ void SyncFileCallbackAdapter( } // namespace -const char DriveFileSyncService::kServiceName[] = "syncfs"; ConflictResolutionPolicy DriveFileSyncService::kDefaultPolicy = CONFLICT_RESOLUTION_LAST_WRITE_WIN; @@ -249,10 +248,6 @@ RemoteServiceState DriveFileSyncService::GetCurrentState() const { return state_; } -const char* DriveFileSyncService::GetServiceName() const { - return kServiceName; -} - void DriveFileSyncService::SetSyncEnabled(bool enabled) { if (sync_enabled_ == enabled) return; @@ -586,7 +581,6 @@ void DriveFileSyncService::DoProcessRemoteChange( remote_change, callback)); remote_change_processor_->PrepareForProcessRemoteChange( remote_change.url, - kServiceName, base::Bind(&DriveFileSyncService::DidPrepareForProcessRemoteChange, AsWeakPtr(), base::Passed(¶m))); } @@ -776,7 +770,7 @@ void DriveFileSyncService::DidGetDirectoryContentForBatchSync( base::FilePath path = TitleToPath(entry.title()); fileapi::FileSystemURL url(CreateSyncableFileSystemURL( - origin, kServiceName, path)); + origin, path)); // TODO(calvinlo): Write metadata and origin data as single batch command // so it's not possible for the DB to contain a DriveMetadata with an // unknown origin. @@ -1291,8 +1285,7 @@ bool DriveFileSyncService::AppendRemoteChangeInternal( const base::Time& updated_time, SyncFileType file_type, RemoteChangeHandler::RemoteSyncType sync_type) { - fileapi::FileSystemURL url( - CreateSyncableFileSystemURL(origin, kServiceName, path)); + fileapi::FileSystemURL url(CreateSyncableFileSystemURL(origin, path)); DCHECK(url.is_valid()); // Note that we create a normalized path from url.path() rather than diff --git a/chrome/browser/sync_file_system/drive_file_sync_service.h b/chrome/browser/sync_file_system/drive_file_sync_service.h index 74b5064..96729e6 100644 --- a/chrome/browser/sync_file_system/drive_file_sync_service.h +++ b/chrome/browser/sync_file_system/drive_file_sync_service.h @@ -65,7 +65,6 @@ class DriveFileSyncService : public RemoteFileSyncService, typedef base::Callback<void(const SyncStatusCallback& callback)> Task; - static const char kServiceName[]; static ConflictResolutionPolicy kDefaultPolicy; virtual ~DriveFileSyncService(); @@ -110,7 +109,6 @@ class DriveFileSyncService : public RemoteFileSyncService, virtual LocalChangeProcessor* GetLocalChangeProcessor() OVERRIDE; virtual bool IsConflicting(const fileapi::FileSystemURL& url) OVERRIDE; virtual RemoteServiceState GetCurrentState() const OVERRIDE; - virtual const char* GetServiceName() const OVERRIDE; virtual void SetSyncEnabled(bool enabled) OVERRIDE; virtual SyncStatusCode SetConflictResolutionPolicy( ConflictResolutionPolicy resolution) OVERRIDE; diff --git a/chrome/browser/sync_file_system/drive_file_sync_service_mock_unittest.cc b/chrome/browser/sync_file_system/drive_file_sync_service_mock_unittest.cc index acbde2d..6608383 100644 --- a/chrome/browser/sync_file_system/drive_file_sync_service_mock_unittest.cc +++ b/chrome/browser/sync_file_system/drive_file_sync_service_mock_unittest.cc @@ -67,7 +67,6 @@ namespace sync_file_system { namespace { const char kRootResourceId[] = "folder:root"; -const char* kServiceName = DriveFileSyncService::kServiceName; base::FilePath::StringType ASCIIToFilePathString(const std::string& path) { return base::FilePath().AppendASCII(path).value(); @@ -177,7 +176,7 @@ ACTION_P2(InvokeGetResourceListCallback2, error, result) { ACTION(PrepareForRemoteChange_Busy) { base::MessageLoopProxy::current()->PostTask( FROM_HERE, - base::Bind(arg2, + base::Bind(arg1, SYNC_STATUS_FILE_BUSY, SyncFileMetadata(), FileChangeList())); @@ -186,7 +185,7 @@ ACTION(PrepareForRemoteChange_Busy) { ACTION(PrepareForRemoteChange_NotFound) { base::MessageLoopProxy::current()->PostTask( FROM_HERE, - base::Bind(arg2, + base::Bind(arg1, SYNC_STATUS_OK, SyncFileMetadata(SYNC_FILE_TYPE_UNKNOWN, 0, base::Time()), FileChangeList())); @@ -195,7 +194,7 @@ ACTION(PrepareForRemoteChange_NotFound) { ACTION(PrepareForRemoteChange_NotModified) { base::MessageLoopProxy::current()->PostTask( FROM_HERE, - base::Bind(arg2, + base::Bind(arg1, SYNC_STATUS_OK, SyncFileMetadata(SYNC_FILE_TYPE_FILE, 0, base::Time()), FileChangeList())); @@ -261,7 +260,7 @@ class DriveFileSyncServiceMockTest : public testing::Test { AddTestExtension(extension_service_, FPL("example1")); AddTestExtension(extension_service_, FPL("example2")); - ASSERT_TRUE(RegisterSyncableFileSystem(kServiceName)); + RegisterSyncableFileSystem(); mock_drive_service_ = new NiceMock<google_apis::MockDriveService>; @@ -316,7 +315,7 @@ class DriveFileSyncServiceMockTest : public testing::Test { api_util_.reset(); mock_drive_service_ = NULL; - EXPECT_TRUE(RevokeSyncableFileSystem(kServiceName)); + RevokeSyncableFileSystem(); extension_service_ = NULL; profile_.reset(); @@ -398,8 +397,7 @@ class DriveFileSyncServiceMockTest : public testing::Test { fileapi::FileSystemURL CreateURL(const GURL& origin, const base::FilePath::StringType& path) { - return CreateSyncableFileSystemURL( - origin, kServiceName, base::FilePath(path)); + return CreateSyncableFileSystemURL(origin, base::FilePath(path)); } void ProcessRemoteChange(SyncStatusCode expected_status, @@ -807,8 +805,7 @@ TEST_F(DriveFileSyncServiceMockTest, RemoteChange_Busy) { .Times(AnyNumber()); EXPECT_CALL(*mock_remote_processor(), - PrepareForProcessRemoteChange(CreateURL(kOrigin, kFileName), - kServiceName, _)) + PrepareForProcessRemoteChange(CreateURL(kOrigin, kFileName), _)) .WillOnce(PrepareForRemoteChange_Busy()); EXPECT_CALL(*mock_remote_processor(), ClearLocalChanges(CreateURL(kOrigin, kFileName), _)) @@ -843,8 +840,7 @@ TEST_F(DriveFileSyncServiceMockTest, RemoteChange_NewFile) { .Times(AnyNumber()); EXPECT_CALL(*mock_remote_processor(), - PrepareForProcessRemoteChange(CreateURL(kOrigin, kFileName), - kServiceName, _)) + PrepareForProcessRemoteChange(CreateURL(kOrigin, kFileName), _)) .WillOnce(PrepareForRemoteChange_NotFound()); EXPECT_CALL(*mock_remote_processor(), ClearLocalChanges(CreateURL(kOrigin, kFileName), _)) @@ -885,8 +881,7 @@ TEST_F(DriveFileSyncServiceMockTest, RemoteChange_UpdateFile) { .Times(AnyNumber()); EXPECT_CALL(*mock_remote_processor(), - PrepareForProcessRemoteChange(CreateURL(kOrigin, kFileName), - kServiceName, _)) + PrepareForProcessRemoteChange(CreateURL(kOrigin, kFileName), _)) .WillOnce(PrepareForRemoteChange_NotModified()); EXPECT_CALL(*mock_remote_processor(), ClearLocalChanges(CreateURL(kOrigin, kFileName), _)) diff --git a/chrome/browser/sync_file_system/drive_file_sync_service_sync_unittest.cc b/chrome/browser/sync_file_system/drive_file_sync_service_sync_unittest.cc index 445b46f..c3680ef 100644 --- a/chrome/browser/sync_file_system/drive_file_sync_service_sync_unittest.cc +++ b/chrome/browser/sync_file_system/drive_file_sync_service_sync_unittest.cc @@ -59,11 +59,11 @@ class DriveFileSyncServiceSyncTest : public testing::Test { virtual void SetUp() OVERRIDE { SetEnableSyncFSDirectoryOperation(true); - RegisterSyncableFileSystem(DriveFileSyncService::kServiceName); + RegisterSyncableFileSystem(); } virtual void TearDown() OVERRIDE { - RevokeSyncableFileSystem(DriveFileSyncService::kServiceName); + RevokeSyncableFileSystem(); SetEnableSyncFSDirectoryOperation(false); } 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 3c44599..6b35230 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 @@ -17,7 +17,6 @@ namespace sync_file_system { namespace { -const char* kServiceName = DriveFileSyncService::kServiceName; const char kSyncRootResourceId[] = "folder:sync_root_resource_id"; void DidInitialize(bool* done, SyncStatusCode status, bool created) { @@ -45,7 +44,7 @@ class DriveFileSyncServiceTest : public testing::Test { sync_service_(NULL) {} virtual void SetUp() OVERRIDE { - ASSERT_TRUE(RegisterSyncableFileSystem(kServiceName)); + RegisterSyncableFileSystem(); fake_api_util_ = new drive::FakeAPIUtil; ASSERT_TRUE(scoped_base_dir_.CreateUniqueTempDir()); @@ -73,7 +72,7 @@ class DriveFileSyncServiceTest : public testing::Test { message_loop_.RunUntilIdle(); base_dir_ = base::FilePath(); - ASSERT_TRUE(RevokeSyncableFileSystem(kServiceName)); + RevokeSyncableFileSystem(); } virtual ~DriveFileSyncServiceTest() { diff --git a/chrome/browser/sync_file_system/drive_metadata_store.cc b/chrome/browser/sync_file_system/drive_metadata_store.cc index 89eb3aa..6b217fc 100644 --- a/chrome/browser/sync_file_system/drive_metadata_store.cc +++ b/chrome/browser/sync_file_system/drive_metadata_store.cc @@ -41,7 +41,6 @@ const base::FilePath::CharType DriveMetadataStore::kDatabaseName[] = namespace { -const char* const kServiceName = DriveFileSyncService::kServiceName; const char kDatabaseVersionKey[] = "VERSION"; const int64 kCurrentDatabaseVersion = 2; const char kChangeStampKey[] = "CHANGE_STAMP"; @@ -670,7 +669,7 @@ SyncStatusCode DriveMetadataStore::GetConflictURLs( ++itr) { if (itr->second.conflicted()) { urls->insert(CreateSyncableFileSystemURL( - origin_itr->first, kServiceName, itr->first)); + origin_itr->first, itr->first)); } } } @@ -691,7 +690,7 @@ SyncStatusCode DriveMetadataStore::GetToBeFetchedFiles( ++itr) { if (itr->second.to_be_fetched()) { FileSystemURL url = CreateSyncableFileSystemURL( - origin_itr->first, kServiceName, itr->first); + origin_itr->first, itr->first); list->push_back(std::make_pair(url, itr->second)); } } 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 996ac0f..29ec9f5 100644 --- a/chrome/browser/sync_file_system/drive_metadata_store_unittest.cc +++ b/chrome/browser/sync_file_system/drive_metadata_store_unittest.cc @@ -33,13 +33,12 @@ namespace sync_file_system { namespace { const char kOrigin[] = "chrome-extension://example"; -const char* const kServiceName = DriveFileSyncService::kServiceName; typedef DriveMetadataStore::ResourceIdByOrigin ResourceIdByOrigin; typedef DriveMetadataStore::OriginByResourceId OriginByResourceId; fileapi::FileSystemURL URL(const base::FilePath& path) { - return CreateSyncableFileSystemURL(GURL(kOrigin), kServiceName, path); + return CreateSyncableFileSystemURL(GURL(kOrigin), path); } std::string GetResourceID(const ResourceIdByOrigin& sync_origins, @@ -79,11 +78,11 @@ class DriveMetadataStoreTest : public testing::Test { file_task_runner_ = file_thread_->message_loop_proxy(); ASSERT_TRUE(base_dir_.CreateUniqueTempDir()); - ASSERT_TRUE(RegisterSyncableFileSystem(kServiceName)); + RegisterSyncableFileSystem(); } virtual void TearDown() OVERRIDE { - EXPECT_TRUE(RevokeSyncableFileSystem(kServiceName)); + RevokeSyncableFileSystem(); DropDatabase(); file_thread_->Stop(); @@ -515,17 +514,17 @@ TEST_F(DriveMetadataStoreTest, RemoveOrigin) { EXPECT_EQ(SYNC_STATUS_OK, UpdateEntry( CreateSyncableFileSystemURL( - kOrigin1, kServiceName, base::FilePath(FPL("guf"))), + kOrigin1, base::FilePath(FPL("guf"))), CreateMetadata("foo", "spam", false, false))); EXPECT_EQ(SYNC_STATUS_OK, UpdateEntry( CreateSyncableFileSystemURL( - kOrigin2, kServiceName, base::FilePath(FPL("mof"))), + kOrigin2, base::FilePath(FPL("mof"))), CreateMetadata("bar", "ham", false, false))); EXPECT_EQ(SYNC_STATUS_OK, UpdateEntry( CreateSyncableFileSystemURL( - kOrigin3, kServiceName, base::FilePath(FPL("waf"))), + kOrigin3, base::FilePath(FPL("waf"))), CreateMetadata("baz", "egg", false, false))); EXPECT_EQ(SYNC_STATUS_OK, RemoveOrigin(kOrigin2)); diff --git a/chrome/browser/sync_file_system/fake_remote_change_processor.cc b/chrome/browser/sync_file_system/fake_remote_change_processor.cc index 82e83db..14ae8c4 100644 --- a/chrome/browser/sync_file_system/fake_remote_change_processor.cc +++ b/chrome/browser/sync_file_system/fake_remote_change_processor.cc @@ -22,7 +22,6 @@ FakeRemoteChangeProcessor::~FakeRemoteChangeProcessor() { void FakeRemoteChangeProcessor::PrepareForProcessRemoteChange( const fileapi::FileSystemURL& url, - const std::string& service_name, const PrepareChangeCallback& callback) { SyncFileMetadata local_metadata; diff --git a/chrome/browser/sync_file_system/fake_remote_change_processor.h b/chrome/browser/sync_file_system/fake_remote_change_processor.h index d59941f..f5a4365 100644 --- a/chrome/browser/sync_file_system/fake_remote_change_processor.h +++ b/chrome/browser/sync_file_system/fake_remote_change_processor.h @@ -36,7 +36,6 @@ class FakeRemoteChangeProcessor : public RemoteChangeProcessor { // RemoteChangeProcessor overrides. virtual void PrepareForProcessRemoteChange( const fileapi::FileSystemURL& url, - const std::string& service_name, const PrepareChangeCallback& callback) OVERRIDE; virtual void ApplyRemoteChange( const FileChange& change, 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 c67f1cc..7b70865 100644 --- a/chrome/browser/sync_file_system/local_file_sync_service.cc +++ b/chrome/browser/sync_file_system/local_file_sync_service.cc @@ -115,11 +115,10 @@ void LocalFileSyncService::Shutdown() { void LocalFileSyncService::MaybeInitializeFileSystemContext( const GURL& app_origin, - const std::string& service_name, fileapi::FileSystemContext* file_system_context, const SyncStatusCallback& callback) { sync_context_->MaybeInitializeFileSystemContext( - app_origin, service_name, file_system_context, + app_origin, file_system_context, base::Bind(&LocalFileSyncService::DidInitializeFileSystemContext, AsWeakPtr(), app_origin, make_scoped_refptr(file_system_context), callback)); @@ -189,7 +188,6 @@ void LocalFileSyncService::GetLocalFileMetadata( void LocalFileSyncService::PrepareForProcessRemoteChange( const FileSystemURL& url, - const std::string& service_name, const PrepareChangeCallback& callback) { if (!ContainsKey(origin_to_contexts_, url.origin())) { // This could happen if a remote sync is triggered for the app that hasn't @@ -220,12 +218,10 @@ void LocalFileSyncService::PrepareForProcessRemoteChange( profile_, site_url)->GetFileSystemContext(); MaybeInitializeFileSystemContext( url.origin(), - service_name, file_system_context.get(), base::Bind(&LocalFileSyncService::DidInitializeForRemoteSync, AsWeakPtr(), url, - service_name, file_system_context, callback)); return; @@ -327,7 +323,6 @@ void LocalFileSyncService::DidInitializeFileSystemContext( void LocalFileSyncService::DidInitializeForRemoteSync( const FileSystemURL& url, - const std::string& service_name, fileapi::FileSystemContext* file_system_context, const PrepareChangeCallback& callback, SyncStatusCode status) { @@ -339,7 +334,7 @@ void LocalFileSyncService::DidInitializeForRemoteSync( return; } origin_to_contexts_[url.origin()] = file_system_context; - PrepareForProcessRemoteChange(url, service_name, callback); + PrepareForProcessRemoteChange(url, callback); } void LocalFileSyncService::RunLocalSyncCallback( 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 cb5fb8a..63d12c1 100644 --- a/chrome/browser/sync_file_system/local_file_sync_service.h +++ b/chrome/browser/sync_file_system/local_file_sync_service.h @@ -66,7 +66,6 @@ class LocalFileSyncService void MaybeInitializeFileSystemContext( const GURL& app_origin, - const std::string& service_name, fileapi::FileSystemContext* file_system_context, const SyncStatusCallback& callback); @@ -109,7 +108,6 @@ class LocalFileSyncService // RemoteChangeProcessor overrides. virtual void PrepareForProcessRemoteChange( const fileapi::FileSystemURL& url, - const std::string& service_name, const PrepareChangeCallback& callback) OVERRIDE; virtual void ApplyRemoteChange( const FileChange& change, @@ -171,7 +169,6 @@ class LocalFileSyncService SyncStatusCode status); void DidInitializeForRemoteSync( const fileapi::FileSystemURL& url, - const std::string& service_name, fileapi::FileSystemContext* file_system_context, const PrepareChangeCallback& callback, SyncStatusCode status); 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 8180312..ec1c631 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 @@ -38,7 +38,6 @@ namespace sync_file_system { namespace { const char kOrigin[] = "http://example.com"; -const char kServiceName[] = "test"; void DidPrepareForProcessRemoteChange(const tracked_objects::Location& where, const base::Closure& oncompleted, @@ -106,7 +105,7 @@ class LocalFileSyncServiceTest thread_helper_.SetUp(); file_system_.reset(new CannedSyncableFileSystem( - GURL(kOrigin), kServiceName, + GURL(kOrigin), thread_helper_.io_task_runner(), thread_helper_.file_task_runner())); @@ -117,7 +116,7 @@ class LocalFileSyncServiceTest base::RunLoop run_loop; SyncStatusCode status = SYNC_STATUS_UNKNOWN; local_service_->MaybeInitializeFileSystemContext( - GURL(kOrigin), kServiceName, file_system_->file_system_context(), + GURL(kOrigin), file_system_->file_system_context(), AssignAndQuitCallback(&run_loop, &status)); run_loop.Run(); @@ -132,7 +131,7 @@ class LocalFileSyncServiceTest virtual void TearDown() OVERRIDE { local_service_->Shutdown(); file_system_->TearDown(); - RevokeSyncableFileSystem(kServiceName); + RevokeSyncableFileSystem(); thread_helper_.TearDown(); } @@ -150,7 +149,6 @@ class LocalFileSyncServiceTest base::RunLoop run_loop; local_service_->PrepareForProcessRemoteChange( url, - kServiceName, base::Bind(&DidPrepareForProcessRemoteChange, where, run_loop.QuitClosure(), @@ -279,7 +277,6 @@ TEST_F(LocalFileSyncServiceTest, LocalChangeObserver) { TEST_F(LocalFileSyncServiceTest, MAYBE_LocalChangeObserverMultipleContexts) { const char kOrigin2[] = "http://foo"; CannedSyncableFileSystem file_system2(GURL(kOrigin2), - kServiceName, thread_helper_.io_task_runner(), thread_helper_.file_task_runner()); file_system2.SetUp(); @@ -287,7 +284,7 @@ TEST_F(LocalFileSyncServiceTest, MAYBE_LocalChangeObserverMultipleContexts) { base::RunLoop run_loop; SyncStatusCode status = SYNC_STATUS_UNKNOWN; local_service_->MaybeInitializeFileSystemContext( - GURL(kOrigin2), kServiceName, file_system2.file_system_context(), + GURL(kOrigin2), file_system2.file_system_context(), AssignAndQuitCallback(&run_loop, &status)); run_loop.Run(); diff --git a/chrome/browser/sync_file_system/mock_remote_change_processor.h b/chrome/browser/sync_file_system/mock_remote_change_processor.h index 8466151..50116af 100644 --- a/chrome/browser/sync_file_system/mock_remote_change_processor.h +++ b/chrome/browser/sync_file_system/mock_remote_change_processor.h @@ -27,9 +27,8 @@ class MockRemoteChangeProcessor : public RemoteChangeProcessor { virtual ~MockRemoteChangeProcessor(); // RemoteChangeProcessor overrides. - MOCK_METHOD3(PrepareForProcessRemoteChange, + MOCK_METHOD2(PrepareForProcessRemoteChange, void(const fileapi::FileSystemURL& url, - const std::string& service_name, const PrepareChangeCallback& callback)); MOCK_METHOD4(ApplyRemoteChange, void(const FileChange& change, diff --git a/chrome/browser/sync_file_system/mock_remote_file_sync_service.cc b/chrome/browser/sync_file_system/mock_remote_file_sync_service.cc index 165205d..f274dfe 100644 --- a/chrome/browser/sync_file_system/mock_remote_file_sync_service.cc +++ b/chrome/browser/sync_file_system/mock_remote_file_sync_service.cc @@ -18,8 +18,6 @@ using ::testing::Return; namespace sync_file_system { -const char MockRemoteFileSyncService::kServiceName[] = "mock_sync_service"; - MockRemoteFileSyncService::MockRemoteFileSyncService() : conflict_resolution_policy_(CONFLICT_RESOLUTION_MANUAL) { typedef MockRemoteFileSyncService self; @@ -43,8 +41,6 @@ MockRemoteFileSyncService::MockRemoteFileSyncService() .WillByDefault(Return(false)); ON_CALL(*this, GetCurrentState()) .WillByDefault(Return(REMOTE_SERVICE_OK)); - ON_CALL(*this, GetServiceName()) - .WillByDefault(Return(kServiceName)); ON_CALL(*this, SetConflictResolutionPolicy(_)) .WillByDefault(Invoke(this, &self::SetConflictResolutionPolicyStub)); ON_CALL(*this, GetConflictResolutionPolicy()) diff --git a/chrome/browser/sync_file_system/mock_remote_file_sync_service.h b/chrome/browser/sync_file_system/mock_remote_file_sync_service.h index dbadf9d..8ab1650 100644 --- a/chrome/browser/sync_file_system/mock_remote_file_sync_service.h +++ b/chrome/browser/sync_file_system/mock_remote_file_sync_service.h @@ -23,8 +23,6 @@ namespace sync_file_system { class MockRemoteFileSyncService : public RemoteFileSyncService { public: - static const char kServiceName[]; - MockRemoteFileSyncService(); virtual ~MockRemoteFileSyncService(); @@ -51,7 +49,6 @@ class MockRemoteFileSyncService : public RemoteFileSyncService { MOCK_METHOD1(IsConflicting, bool(const fileapi::FileSystemURL& url)); MOCK_CONST_METHOD0(GetCurrentState, RemoteServiceState()); - MOCK_CONST_METHOD0(GetServiceName, const char*()); MOCK_METHOD1(SetSyncEnabled, void(bool)); MOCK_METHOD1(SetConflictResolutionPolicy, SyncStatusCode(ConflictResolutionPolicy)); diff --git a/chrome/browser/sync_file_system/remote_change_processor.h b/chrome/browser/sync_file_system/remote_change_processor.h index ab71914..3a3d105 100644 --- a/chrome/browser/sync_file_system/remote_change_processor.h +++ b/chrome/browser/sync_file_system/remote_change_processor.h @@ -42,15 +42,13 @@ class RemoteChangeProcessor { RemoteChangeProcessor() {} virtual ~RemoteChangeProcessor() {} - // This must be called before processing the change for the |url| - // for sync service |service_name|. + // This must be called before processing the change for the |url|. // This tries to lock the target |url| and returns the local changes // if any. (The change returned by the callback is to make a decision // on conflict resolution, but NOT for applying local changes to the remote, // which is supposed to be done by LocalChangeProcessor) virtual void PrepareForProcessRemoteChange( const fileapi::FileSystemURL& url, - const std::string& service_name, const PrepareChangeCallback& callback) = 0; // This is called to apply the remote |change|. If the change type is diff --git a/chrome/browser/sync_file_system/remote_file_sync_service.h b/chrome/browser/sync_file_system/remote_file_sync_service.h index 0deb9c4..62b86c7 100644 --- a/chrome/browser/sync_file_system/remote_file_sync_service.h +++ b/chrome/browser/sync_file_system/remote_file_sync_service.h @@ -136,9 +136,6 @@ class RemoteFileSyncService { // returned by the last OnRemoteServiceStateUpdated notification. virtual RemoteServiceState GetCurrentState() const = 0; - // Returns the service name that backs this remote_file_sync_service. - virtual const char* GetServiceName() const = 0; - // Enables or disables the background sync. // Setting this to false should disable the synchronization (and make // the service state to REMOTE_SERVICE_DISABLED), while setting this to diff --git a/chrome/browser/sync_file_system/sync_file_system_service.cc b/chrome/browser/sync_file_system/sync_file_system_service.cc index ca85aa3..346e269 100644 --- a/chrome/browser/sync_file_system/sync_file_system_service.cc +++ b/chrome/browser/sync_file_system/sync_file_system_service.cc @@ -122,7 +122,6 @@ SyncFileSystemService::~SyncFileSystemService() { void SyncFileSystemService::InitializeForApp( fileapi::FileSystemContext* file_system_context, - const std::string& service_name, const GURL& app_origin, const SyncStatusCallback& callback) { DCHECK(local_file_service_); @@ -132,7 +131,7 @@ void SyncFileSystemService::InitializeForApp( DVLOG(1) << "InitializeForApp: " << app_origin.spec(); local_file_service_->MaybeInitializeFileSystemContext( - app_origin, service_name, file_system_context, + app_origin, file_system_context, base::Bind(&SyncFileSystemService::DidInitializeFileSystem, AsWeakPtr(), app_origin, callback)); } diff --git a/chrome/browser/sync_file_system/sync_file_system_service.h b/chrome/browser/sync_file_system/sync_file_system_service.h index df7a85d..70470ed 100644 --- a/chrome/browser/sync_file_system/sync_file_system_service.h +++ b/chrome/browser/sync_file_system/sync_file_system_service.h @@ -50,7 +50,6 @@ class SyncFileSystemService void InitializeForApp( fileapi::FileSystemContext* file_system_context, - const std::string& service_name, const GURL& app_origin, const SyncStatusCallback& callback); diff --git a/chrome/browser/sync_file_system/sync_file_system_service_factory.cc b/chrome/browser/sync_file_system/sync_file_system_service_factory.cc index 4f5040b..a0c628f 100644 --- a/chrome/browser/sync_file_system/sync_file_system_service_factory.cc +++ b/chrome/browser/sync_file_system/sync_file_system_service_factory.cc @@ -61,7 +61,7 @@ SyncFileSystemServiceFactory::BuildServiceInstanceFor( } else { // FileSystem needs to be registered before DriveFileSyncService runs // its initialization code. - RegisterSyncableFileSystem(DriveFileSyncService::kServiceName); + RegisterSyncableFileSystem(); remote_file_service = DriveFileSyncService::Create(profile).PassAs<RemoteFileSyncService>(); } 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 481b0fa..18222e2 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 @@ -40,7 +40,6 @@ namespace sync_file_system { namespace { const char kOrigin[] = "http://example.com"; -const char kServiceName[] = "test"; template <typename R> struct AssignTrait { typedef const R& ArgumentType; @@ -120,7 +119,7 @@ class SyncFileSystemServiceTest : public testing::Test { thread_helper_.SetUp(); file_system_.reset(new CannedSyncableFileSystem( - GURL(kOrigin), kServiceName, + GURL(kOrigin), thread_helper_.io_task_runner(), thread_helper_.file_task_runner())); @@ -153,7 +152,7 @@ class SyncFileSystemServiceTest : public testing::Test { sync_service_->Shutdown(); file_system_->TearDown(); - RevokeSyncableFileSystem(kServiceName); + RevokeSyncableFileSystem(); thread_helper_.TearDown(); } @@ -166,7 +165,7 @@ class SyncFileSystemServiceTest : public testing::Test { sync_service_->InitializeForApp( file_system_->file_system_context(), - kServiceName, GURL(kOrigin), + GURL(kOrigin), AssignAndQuitCallback(&run_loop, &status)); run_loop.Run(); @@ -209,7 +208,7 @@ class SyncFileSystemServiceTest : public testing::Test { base::RunLoop run_loop; sync_service_->InitializeForApp( file_system_->file_system_context(), - kServiceName, GURL(kOrigin), + GURL(kOrigin), AssignAndQuitCallback(&run_loop, &actual_status)); run_loop.Run(); diff --git a/webkit/browser/fileapi/external_mount_points.cc b/webkit/browser/fileapi/external_mount_points.cc index 269c09e..2b6d967 100644 --- a/webkit/browser/fileapi/external_mount_points.cc +++ b/webkit/browser/fileapi/external_mount_points.cc @@ -257,6 +257,19 @@ base::FilePath ExternalMountPoints::CreateVirtualRootPath( return base::FilePath().AppendASCII(mount_name); } +FileSystemURL ExternalMountPoints::CreateExternalFileSystemURL( + const GURL& origin, + const std::string& mount_name, + const base::FilePath& path) const { + return CreateCrackedFileSystemURL( + origin, + fileapi::kFileSystemTypeExternal, + // Avoid using FilePath::Append as path may be an absolute path. + base::FilePath( + CreateVirtualRootPath(mount_name).value() + + base::FilePath::kSeparators[0] + path.value())); +} + ExternalMountPoints::ExternalMountPoints() {} ExternalMountPoints::~ExternalMountPoints() { diff --git a/webkit/browser/fileapi/external_mount_points.h b/webkit/browser/fileapi/external_mount_points.h index 25294a9..5a045c1 100644 --- a/webkit/browser/fileapi/external_mount_points.h +++ b/webkit/browser/fileapi/external_mount_points.h @@ -110,6 +110,11 @@ class WEBKIT_STORAGE_EXPORT ExternalMountPoints // Returns the virtual root path that looks like /<mount_name>. base::FilePath CreateVirtualRootPath(const std::string& mount_name) const; + FileSystemURL CreateExternalFileSystemURL( + const GURL& origin, + const std::string& mount_name, + const base::FilePath& path) const; + private: friend class base::RefCountedThreadSafe<ExternalMountPoints>; diff --git a/webkit/browser/fileapi/file_system_context.cc b/webkit/browser/fileapi/file_system_context.cc index c8bb838..881a334 100644 --- a/webkit/browser/fileapi/file_system_context.cc +++ b/webkit/browser/fileapi/file_system_context.cc @@ -233,7 +233,6 @@ void FileSystemContext::OpenFileSystem( } void FileSystemContext::OpenSyncableFileSystem( - const std::string& mount_name, const GURL& origin_url, FileSystemType type, OpenFileSystemMode mode, @@ -242,8 +241,7 @@ void FileSystemContext::OpenSyncableFileSystem( DCHECK(type == kFileSystemTypeSyncable); - GURL root_url = sync_file_system::GetSyncableFileSystemRootURI( - origin_url, mount_name); + GURL root_url = sync_file_system::GetSyncableFileSystemRootURI(origin_url); std::string name = GetFileSystemName(origin_url, kFileSystemTypeSyncable); FileSystemMountPointProvider* mount_point_provider = diff --git a/webkit/browser/fileapi/file_system_context.h b/webkit/browser/fileapi/file_system_context.h index 64104dc..102a7d2 100644 --- a/webkit/browser/fileapi/file_system_context.h +++ b/webkit/browser/fileapi/file_system_context.h @@ -167,7 +167,6 @@ class WEBKIT_STORAGE_EXPORT FileSystemContext // Currently only kFileSystemTypeSyncable type is supported. // TODO(kinuko): Deprecate this method. (http://crbug.com/177137) void OpenSyncableFileSystem( - const std::string& mount_name, const GURL& origin_url, FileSystemType type, OpenFileSystemMode mode, diff --git a/webkit/browser/fileapi/syncable/canned_syncable_file_system.cc b/webkit/browser/fileapi/syncable/canned_syncable_file_system.cc index 2913d69..5268100 100644 --- a/webkit/browser/fileapi/syncable/canned_syncable_file_system.cc +++ b/webkit/browser/fileapi/syncable/canned_syncable_file_system.cc @@ -177,11 +177,10 @@ void EnsureLastTaskRuns(base::SingleThreadTaskRunner* runner) { } // namespace CannedSyncableFileSystem::CannedSyncableFileSystem( - const GURL& origin, const std::string& service, + const GURL& origin, base::SingleThreadTaskRunner* io_task_runner, base::SingleThreadTaskRunner* file_task_runner) - : service_name_(service), - origin_(origin), + : origin_(origin), type_(fileapi::kFileSystemTypeSyncable), result_(base::PLATFORM_FILE_OK), sync_status_(sync_file_system::SYNC_STATUS_OK), @@ -248,7 +247,7 @@ PlatformFileError CannedSyncableFileSystem::OpenFileSystem() { EXPECT_TRUE(is_filesystem_set_up_); EXPECT_FALSE(is_filesystem_opened_); file_system_context_->OpenSyncableFileSystem( - service_name_, origin_, type_, + origin_, type_, fileapi::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, base::Bind(&CannedSyncableFileSystem::DidOpenFileSystem, base::Unretained(this))); @@ -282,7 +281,6 @@ SyncStatusCode CannedSyncableFileSystem::MaybeInitializeFileSystemContext( sync_context->io_task_runner_.get()); sync_context->MaybeInitializeFileSystemContext( origin_, - service_name_, file_system_context_.get(), base::Bind(&CannedSyncableFileSystem::DidInitializeFileSystemContext, base::Unretained(this))); diff --git a/webkit/browser/fileapi/syncable/canned_syncable_file_system.h b/webkit/browser/fileapi/syncable/canned_syncable_file_system.h index 7d0b52e..2242ff4 100644 --- a/webkit/browser/fileapi/syncable/canned_syncable_file_system.h +++ b/webkit/browser/fileapi/syncable/canned_syncable_file_system.h @@ -55,7 +55,6 @@ class CannedSyncableFileSystem typedef base::Callback<void(int64)> WriteCallback; CannedSyncableFileSystem(const GURL& origin, - const std::string& service, base::SingleThreadTaskRunner* io_task_runner, base::SingleThreadTaskRunner* file_task_runner); virtual ~CannedSyncableFileSystem(); diff --git a/webkit/browser/fileapi/syncable/local_file_change_tracker.cc b/webkit/browser/fileapi/syncable/local_file_change_tracker.cc index 7e189a1..01d99c0 100644 --- a/webkit/browser/fileapi/syncable/local_file_change_tracker.cc +++ b/webkit/browser/fileapi/syncable/local_file_change_tracker.cc @@ -250,7 +250,7 @@ SyncStatusCode LocalFileChangeTracker::CollectLastDirtyChanges( base::FilePath path_each; while (!(path_each = enumerator->Next()).empty()) { dirty_files.push(CreateSyncableFileSystemURL( - url.origin(), url.filesystem_id(), path_each)); + url.origin(), path_each)); } break; } diff --git a/webkit/browser/fileapi/syncable/local_file_change_tracker_unittest.cc b/webkit/browser/fileapi/syncable/local_file_change_tracker_unittest.cc index a454b8d..7abd54c 100644 --- a/webkit/browser/fileapi/syncable/local_file_change_tracker_unittest.cc +++ b/webkit/browser/fileapi/syncable/local_file_change_tracker_unittest.cc @@ -36,7 +36,6 @@ class LocalFileChangeTrackerTest : public testing::Test { LocalFileChangeTrackerTest() : message_loop_(base::MessageLoop::TYPE_IO), file_system_(GURL("http://example.com"), - "test", base::MessageLoopProxy::current(), base::MessageLoopProxy::current()) {} @@ -60,7 +59,7 @@ class LocalFileChangeTrackerTest : public testing::Test { // Make sure we don't leave the external filesystem. // (CannedSyncableFileSystem::TearDown does not do this as there may be // multiple syncable file systems registered for the name) - RevokeSyncableFileSystem("test"); + RevokeSyncableFileSystem(); } protected: diff --git a/webkit/browser/fileapi/syncable/local_file_sync_context.cc b/webkit/browser/fileapi/syncable/local_file_sync_context.cc index 9aa434e..c0a656a 100644 --- a/webkit/browser/fileapi/syncable/local_file_sync_context.cc +++ b/webkit/browser/fileapi/syncable/local_file_sync_context.cc @@ -50,7 +50,6 @@ LocalFileSyncContext::LocalFileSyncContext( void LocalFileSyncContext::MaybeInitializeFileSystemContext( const GURL& source_url, - const std::string& service_name, FileSystemContext* file_system_context, const SyncStatusCallback& callback) { DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); @@ -72,7 +71,7 @@ void LocalFileSyncContext::MaybeInitializeFileSystemContext( io_task_runner_->PostTask( FROM_HERE, base::Bind(&LocalFileSyncContext::InitializeFileSystemContextOnIOThread, - this, source_url, service_name, + this, source_url, make_scoped_refptr(file_system_context))); } @@ -440,13 +439,12 @@ void LocalFileSyncContext::ShutdownOnIOThread() { void LocalFileSyncContext::InitializeFileSystemContextOnIOThread( const GURL& source_url, - const std::string& service_name, FileSystemContext* file_system_context) { DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); DCHECK(file_system_context); if (!file_system_context->change_tracker()) { // First registers the service name. - RegisterSyncableFileSystem(service_name); + RegisterSyncableFileSystem(); // Create and initialize LocalFileChangeTracker and call back this method // later again. std::set<GURL>* origins_with_changes = new std::set<GURL>; @@ -461,7 +459,7 @@ void LocalFileSyncContext::InitializeFileSystemContextOnIOThread( origins_with_changes), base::Bind(&LocalFileSyncContext::DidInitializeChangeTrackerOnIOThread, this, base::Owned(tracker_ptr), - source_url, service_name, + source_url, make_scoped_refptr(file_system_context), base::Owned(origins_with_changes))); return; @@ -508,7 +506,6 @@ SyncStatusCode LocalFileSyncContext::InitializeChangeTrackerOnFileThread( void LocalFileSyncContext::DidInitializeChangeTrackerOnIOThread( scoped_ptr<LocalFileChangeTracker>* tracker_ptr, const GURL& source_url, - const std::string& service_name, FileSystemContext* file_system_context, std::set<GURL>* origins_with_changes, SyncStatusCode status) { @@ -525,8 +522,7 @@ void LocalFileSyncContext::DidInitializeChangeTrackerOnIOThread( origins_with_changes->end()); ScheduleNotifyChangesUpdatedOnIOThread(); - InitializeFileSystemContextOnIOThread(source_url, service_name, - file_system_context); + InitializeFileSystemContextOnIOThread(source_url, file_system_context); } void LocalFileSyncContext::DidInitialize( diff --git a/webkit/browser/fileapi/syncable/local_file_sync_context.h b/webkit/browser/fileapi/syncable/local_file_sync_context.h index 3ad650e..2f2b355 100644 --- a/webkit/browser/fileapi/syncable/local_file_sync_context.h +++ b/webkit/browser/fileapi/syncable/local_file_sync_context.h @@ -62,13 +62,12 @@ class WEBKIT_STORAGE_EXPORT LocalFileSyncContext LocalFileSyncContext(base::SingleThreadTaskRunner* ui_task_runner, base::SingleThreadTaskRunner* io_task_runner); - // Initializes |file_system_context| for syncable file operations for - // |service_name| and registers the it into the internal map. + // Initializes |file_system_context| for syncable file operations + // and registers the it into the internal map. // Calling this multiple times for the same file_system_context is valid. // This method must be called on UI thread. void MaybeInitializeFileSystemContext( const GURL& source_url, - const std::string& service_name, fileapi::FileSystemContext* file_system_context, const SyncStatusCallback& callback); @@ -190,7 +189,6 @@ class WEBKIT_STORAGE_EXPORT LocalFileSyncContext // Helper routines for MaybeInitializeFileSystemContext. void InitializeFileSystemContextOnIOThread( const GURL& source_url, - const std::string& service_name, fileapi::FileSystemContext* file_system_context); SyncStatusCode InitializeChangeTrackerOnFileThread( scoped_ptr<LocalFileChangeTracker>* tracker_ptr, @@ -199,7 +197,6 @@ class WEBKIT_STORAGE_EXPORT LocalFileSyncContext void DidInitializeChangeTrackerOnIOThread( scoped_ptr<LocalFileChangeTracker>* tracker_ptr, const GURL& source_url, - const std::string& service_name, fileapi::FileSystemContext* file_system_context, std::set<GURL>* origins_with_changes, SyncStatusCode status); diff --git a/webkit/browser/fileapi/syncable/local_file_sync_context_unittest.cc b/webkit/browser/fileapi/syncable/local_file_sync_context_unittest.cc index ad4beb2..1d9f4cd 100644 --- a/webkit/browser/fileapi/syncable/local_file_sync_context_unittest.cc +++ b/webkit/browser/fileapi/syncable/local_file_sync_context_unittest.cc @@ -43,7 +43,6 @@ namespace sync_file_system { namespace { const char kOrigin1[] = "http://example.com"; const char kOrigin2[] = "http://chromium.org"; -const char kServiceName[] = "test"; } class LocalFileSyncContextTest : public testing::Test { @@ -55,7 +54,7 @@ class LocalFileSyncContextTest : public testing::Test { has_inflight_prepare_for_sync_(false) {} virtual void SetUp() OVERRIDE { - EXPECT_TRUE(RegisterSyncableFileSystem(kServiceName)); + RegisterSyncableFileSystem(); io_thread_.reset(new base::Thread("Thread_IO")); io_thread_->StartWithOptions( @@ -70,7 +69,7 @@ class LocalFileSyncContextTest : public testing::Test { } virtual void TearDown() OVERRIDE { - EXPECT_TRUE(RevokeSyncableFileSystem(kServiceName)); + RevokeSyncableFileSystem(); io_thread_->Stop(); file_thread_->Stop(); } @@ -214,7 +213,6 @@ TEST_F(LocalFileSyncContextTest, ConstructAndDestruct) { TEST_F(LocalFileSyncContextTest, InitializeFileSystemContext) { CannedSyncableFileSystem file_system(GURL(kOrigin1), - kServiceName, io_task_runner_.get(), file_task_runner_.get()); file_system.SetUp(); @@ -258,11 +256,9 @@ TEST_F(LocalFileSyncContextTest, InitializeFileSystemContext) { TEST_F(LocalFileSyncContextTest, MultipleFileSystemContexts) { CannedSyncableFileSystem file_system1(GURL(kOrigin1), - kServiceName, io_task_runner_.get(), file_task_runner_.get()); CannedSyncableFileSystem file_system2(GURL(kOrigin2), - kServiceName, io_task_runner_.get(), file_task_runner_.get()); file_system1.SetUp(); @@ -349,7 +345,6 @@ TEST_F(LocalFileSyncContextTest, MultipleFileSystemContexts) { #endif TEST_F(LocalFileSyncContextTest, MAYBE_PrepareSyncWhileWriting) { CannedSyncableFileSystem file_system(GURL(kOrigin1), - kServiceName, io_task_runner_.get(), file_task_runner_.get()); file_system.SetUp(); @@ -409,7 +404,6 @@ TEST_F(LocalFileSyncContextTest, MAYBE_PrepareSyncWhileWriting) { TEST_F(LocalFileSyncContextTest, ApplyRemoteChangeForDeletion) { CannedSyncableFileSystem file_system(GURL(kOrigin1), - kServiceName, io_task_runner_.get(), file_task_runner_.get()); file_system.SetUp(); @@ -499,7 +493,6 @@ TEST_F(LocalFileSyncContextTest, ApplyRemoteChangeForAddOrUpdate) { ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); CannedSyncableFileSystem file_system(GURL(kOrigin1), - kServiceName, io_task_runner_.get(), file_task_runner_.get()); file_system.SetUp(); @@ -649,7 +642,6 @@ TEST_F(LocalFileSyncContextTest, ApplyRemoteChangeForAddOrUpdate_NoParent) { ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); CannedSyncableFileSystem file_system(GURL(kOrigin1), - kServiceName, io_task_runner_.get(), file_task_runner_.get()); file_system.SetUp(); diff --git a/webkit/browser/fileapi/syncable/syncable_file_operation_runner_unittest.cc b/webkit/browser/fileapi/syncable/syncable_file_operation_runner_unittest.cc index 03f1a3d..26567cc 100644 --- a/webkit/browser/fileapi/syncable/syncable_file_operation_runner_unittest.cc +++ b/webkit/browser/fileapi/syncable/syncable_file_operation_runner_unittest.cc @@ -29,7 +29,6 @@ using base::PlatformFileError; namespace sync_file_system { namespace { -const std::string kServiceName = "test"; const std::string kParent = "foo"; const std::string kFile = "foo/file"; const std::string kDir = "foo/dir"; @@ -45,7 +44,7 @@ class SyncableFileOperationRunnerTest : public testing::Test { // operations in the tests. SyncableFileOperationRunnerTest() : message_loop_(base::MessageLoop::TYPE_IO), - file_system_(GURL("http://example.com"), kServiceName, + file_system_(GURL("http://example.com"), base::MessageLoopProxy::current(), base::MessageLoopProxy::current()), callback_count_(0), @@ -76,7 +75,7 @@ class SyncableFileOperationRunnerTest : public testing::Test { file_system_.TearDown(); message_loop_.RunUntilIdle(); - RevokeSyncableFileSystem(kServiceName); + RevokeSyncableFileSystem(); } FileSystemURL URL(const std::string& path) { diff --git a/webkit/browser/fileapi/syncable/syncable_file_system_unittest.cc b/webkit/browser/fileapi/syncable/syncable_file_system_unittest.cc index f6bbd85..0db764a 100644 --- a/webkit/browser/fileapi/syncable/syncable_file_system_unittest.cc +++ b/webkit/browser/fileapi/syncable/syncable_file_system_unittest.cc @@ -33,7 +33,7 @@ namespace sync_file_system { class SyncableFileSystemTest : public testing::Test { public: SyncableFileSystemTest() - : file_system_(GURL("http://example.com/"), "test", + : file_system_(GURL("http://example.com/"), base::MessageLoopProxy::current(), base::MessageLoopProxy::current()), weak_factory_(this) {} @@ -58,7 +58,7 @@ class SyncableFileSystemTest : public testing::Test { // Make sure we don't leave the external filesystem. // (CannedSyncableFileSystem::TearDown does not do this as there may be // multiple syncable file systems registered for the name) - RevokeSyncableFileSystem("test"); + RevokeSyncableFileSystem(); } protected: diff --git a/webkit/browser/fileapi/syncable/syncable_file_system_util.cc b/webkit/browser/fileapi/syncable/syncable_file_system_util.cc index 84ae92f..6ad547e 100644 --- a/webkit/browser/fileapi/syncable/syncable_file_system_util.cc +++ b/webkit/browser/fileapi/syncable/syncable_file_system_util.cc @@ -26,41 +26,33 @@ namespace { const char kEnableSyncFSDirectoryOperation[] = "enable-syncfs-directory-operation"; +const char kSyncableMountName[] = "syncfs"; + bool is_directory_operation_enabled = false; } -bool RegisterSyncableFileSystem(const std::string& service_name) { - return ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( - service_name, fileapi::kFileSystemTypeSyncable, base::FilePath()); +void RegisterSyncableFileSystem() { + ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( + kSyncableMountName, + fileapi::kFileSystemTypeSyncable, + base::FilePath()); } -bool RevokeSyncableFileSystem(const std::string& service_name) { - return ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( - service_name); +void RevokeSyncableFileSystem() { + ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( + kSyncableMountName); } -GURL GetSyncableFileSystemRootURI(const GURL& origin, - const std::string& service_name) { - 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())); - return url.ReplaceComponents(replacements); +GURL GetSyncableFileSystemRootURI(const GURL& origin) { + return GURL(fileapi::GetExternalFileSystemRootURIString( + origin, kSyncableMountName)); } FileSystemURL CreateSyncableFileSystemURL(const GURL& origin, - const std::string& service_name, const base::FilePath& path) { - // Avoid using FilePath::Append as path may be an absolute path. - base::FilePath::StringType virtual_path = - base::FilePath::FromUTF8Unsafe(service_name + "/").value() + - path.value(); - return ExternalMountPoints::GetSystemInstance()->CreateCrackedFileSystemURL( - origin, - fileapi::kFileSystemTypeExternal, - base::FilePath(virtual_path)); + return ExternalMountPoints::GetSystemInstance()->CreateExternalFileSystemURL( + origin, kSyncableMountName, path); } bool SerializeSyncableFileSystemURL(const FileSystemURL& url, @@ -68,7 +60,7 @@ bool SerializeSyncableFileSystemURL(const FileSystemURL& url, if (!url.is_valid() || url.type() != fileapi::kFileSystemTypeSyncable) return false; *serialized_url = - GetSyncableFileSystemRootURI(url.origin(), url.filesystem_id()).spec() + + GetSyncableFileSystemRootURI(url.origin()).spec() + url.path().AsUTF8Unsafe(); return true; } diff --git a/webkit/browser/fileapi/syncable/syncable_file_system_util.h b/webkit/browser/fileapi/syncable/syncable_file_system_util.h index 3c296c0..e2750b0 100644 --- a/webkit/browser/fileapi/syncable/syncable_file_system_util.h +++ b/webkit/browser/fileapi/syncable/syncable_file_system_util.h @@ -19,30 +19,24 @@ class LocalFileSystemOperation; namespace sync_file_system { -// Registers a syncable filesystem with the given |service_name|. -WEBKIT_STORAGE_EXPORT bool RegisterSyncableFileSystem( - const std::string& service_name); +// Registers a syncable filesystem. +WEBKIT_STORAGE_EXPORT void RegisterSyncableFileSystem(); -// Revokes the syncable filesystem that was registered with |service_name|. -WEBKIT_STORAGE_EXPORT bool RevokeSyncableFileSystem( - const std::string& service_name); +// Revokes the syncable filesystem. +WEBKIT_STORAGE_EXPORT void RevokeSyncableFileSystem(); -// Returns the root URI of the syncable filesystem that can be specified by a -// pair of |origin| and |service_name|. -WEBKIT_STORAGE_EXPORT GURL GetSyncableFileSystemRootURI( - const GURL& origin, const std::string& service_name); +// Returns the root URI of the syncable filesystem for |origin|. +WEBKIT_STORAGE_EXPORT GURL GetSyncableFileSystemRootURI(const GURL& origin); -// Creates a FileSystem URL for the |path| in a syncable filesystem -// identifiable by a pair of |origin| and |service_name|. +// Creates a FileSystem URL for the |path| in a syncable filesystem for +// |origin|. // // Example: Assume following arguments are given: // origin: 'http://www.example.com/', -// service_name: 'service_name', // path: '/foo/bar', -// returns 'filesystem:http://www.example.com/external/service_name/foo/bar' +// returns 'filesystem:http://www.example.com/external/syncfs/foo/bar' WEBKIT_STORAGE_EXPORT fileapi::FileSystemURL CreateSyncableFileSystemURL( - const GURL& origin, const std::string& service_name, - const base::FilePath& path); + const GURL& origin, const base::FilePath& path); // Serializes a given FileSystemURL |url| and sets the serialized string to // |serialized_url|. If the URL does not represent a syncable filesystem, @@ -52,13 +46,13 @@ WEBKIT_STORAGE_EXPORT fileapi::FileSystemURL CreateSyncableFileSystemURL( // Example: Assume a following FileSystemURL object is given: // origin() returns 'http://www.example.com/', // type() returns the kFileSystemTypeSyncable, -// filesystem_id() returns 'service_name', +// filesystem_id() returns 'syncfs', // path() returns '/foo/bar', // this URL will be serialized to // (on Windows) -// 'filesystem:http://www.example.com/external/service_name/foo\\bar' +// 'filesystem:http://www.example.com/external/syncfs/foo\\bar' // (on others) -// 'filesystem:http://www.example.com/external/service_name/foo/bar' +// 'filesystem:http://www.example.com/external/syncfs/foo/bar' WEBKIT_STORAGE_EXPORT bool SerializeSyncableFileSystemURL( const fileapi::FileSystemURL& url, std::string* serialized_url); diff --git a/webkit/browser/fileapi/syncable/syncable_file_system_util_unittest.cc b/webkit/browser/fileapi/syncable/syncable_file_system_util_unittest.cc index ba35336..c7ed4a0 100644 --- a/webkit/browser/fileapi/syncable/syncable_file_system_util_unittest.cc +++ b/webkit/browser/fileapi/syncable/syncable_file_system_util_unittest.cc @@ -15,21 +15,19 @@ using fileapi::ExternalMountPoints; using fileapi::FileSystemURL; -using fileapi::ScopedExternalFileSystem; namespace sync_file_system { namespace { const char kSyncableFileSystemRootURI[] = - "filesystem:http://www.example.com/external/service/"; + "filesystem:http://www.example.com/external/syncfs/"; const char kNonRegisteredFileSystemRootURI[] = "filesystem:http://www.example.com/external/non_registered/"; const char kNonSyncableFileSystemRootURI[] = "filesystem:http://www.example.com/temporary/"; const char kOrigin[] = "http://www.example.com/"; -const char kServiceName[] = "service"; const base::FilePath::CharType kPath[] = FILE_PATH_LITERAL("dir/file"); FileSystemURL CreateFileSystemURL(const std::string& url) { @@ -43,35 +41,34 @@ base::FilePath CreateNormalizedFilePath(const base::FilePath::CharType* path) { } // namespace TEST(SyncableFileSystemUtilTest, GetSyncableFileSystemRootURI) { - const GURL root = GetSyncableFileSystemRootURI(GURL(kOrigin), kServiceName); + const GURL root = GetSyncableFileSystemRootURI(GURL(kOrigin)); EXPECT_TRUE(root.is_valid()); EXPECT_EQ(GURL(kSyncableFileSystemRootURI), root); } TEST(SyncableFileSystemUtilTest, CreateSyncableFileSystemURL) { - ScopedExternalFileSystem scoped_fs( - kServiceName, fileapi::kFileSystemTypeSyncable, base::FilePath()); + RegisterSyncableFileSystem(); const base::FilePath path(kPath); const FileSystemURL expected_url = CreateFileSystemURL(kSyncableFileSystemRootURI + path.AsUTF8Unsafe()); - const FileSystemURL url = - CreateSyncableFileSystemURL(GURL(kOrigin), kServiceName, path); + const FileSystemURL url = CreateSyncableFileSystemURL(GURL(kOrigin), path); EXPECT_TRUE(url.is_valid()); EXPECT_EQ(expected_url, url); + + RevokeSyncableFileSystem(); } TEST(SyncableFileSystemUtilTest, SerializeAndDesirializeSyncableFileSystemURL) { - ScopedExternalFileSystem scoped_fs( - kServiceName, fileapi::kFileSystemTypeSyncable, base::FilePath()); + RegisterSyncableFileSystem(); 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)); + GURL(kOrigin), base::FilePath(kPath)); std::string serialized; EXPECT_TRUE(SerializeSyncableFileSystemURL(url, &serialized)); @@ -81,12 +78,13 @@ TEST(SyncableFileSystemUtilTest, EXPECT_TRUE(DeserializeSyncableFileSystemURL(serialized, &deserialized)); EXPECT_TRUE(deserialized.is_valid()); EXPECT_EQ(expected_url, deserialized); + + RevokeSyncableFileSystem(); } TEST(SyncableFileSystemUtilTest, FailInSerializingAndDeserializingSyncableFileSystemURL) { - ScopedExternalFileSystem scoped_fs( - kServiceName, fileapi::kFileSystemTypeSyncable, base::FilePath()); + RegisterSyncableFileSystem(); const base::FilePath normalized_path = CreateNormalizedFilePath(kPath); const std::string non_registered_url = @@ -109,6 +107,8 @@ TEST(SyncableFileSystemUtilTest, non_registered_url, &deserialized)); EXPECT_FALSE(DeserializeSyncableFileSystemURL( non_syncable_url, &deserialized)); + + RevokeSyncableFileSystem(); } TEST(SyncableFileSystemUtilTest, SerializeBeforeOpenFileSystem) { @@ -118,7 +118,7 @@ TEST(SyncableFileSystemUtilTest, SerializeBeforeOpenFileSystem) { base::MessageLoop message_loop; // Setting up a full syncable filesystem environment. - CannedSyncableFileSystem file_system(GURL(kOrigin), kServiceName, + CannedSyncableFileSystem file_system(GURL(kOrigin), base::MessageLoopProxy::current(), base::MessageLoopProxy::current()); file_system.SetUp(); @@ -141,22 +141,19 @@ TEST(SyncableFileSystemUtilTest, SerializeBeforeOpenFileSystem) { // Shutting down. file_system.TearDown(); - RevokeSyncableFileSystem(kServiceName); + RevokeSyncableFileSystem(); sync_context->ShutdownOnUIThread(); sync_context = NULL; base::MessageLoop::current()->RunUntilIdle(); } TEST(SyncableFileSystemUtilTest, SyncableFileSystemURL_IsParent) { - ScopedExternalFileSystem scoped1("foo", fileapi::kFileSystemTypeSyncable, - base::FilePath()); - ScopedExternalFileSystem scoped2("bar", fileapi::kFileSystemTypeSyncable, - base::FilePath()); + RegisterSyncableFileSystem(); const std::string root1 = sync_file_system::GetSyncableFileSystemRootURI( - GURL("http://example.com"), "foo").spec(); + GURL("http://foo.com")).spec(); const std::string root2 = sync_file_system::GetSyncableFileSystemRootURI( - GURL("http://example.com"), "bar").spec(); + GURL("http://bar.com")).spec(); const std::string parent("dir"); const std::string child("dir/child"); @@ -167,11 +164,13 @@ TEST(SyncableFileSystemUtilTest, SyncableFileSystemURL_IsParent) { EXPECT_TRUE(CreateFileSystemURL(root2 + parent).IsParent( CreateFileSystemURL(root2 + child))); - // False case: different filesystem ID. + // False case: different origin. EXPECT_FALSE(CreateFileSystemURL(root1 + parent).IsParent( CreateFileSystemURL(root2 + child))); EXPECT_FALSE(CreateFileSystemURL(root2 + parent).IsParent( CreateFileSystemURL(root1 + child))); + + RevokeSyncableFileSystem(); } } // namespace sync_file_system diff --git a/webkit/common/fileapi/file_system_util.cc b/webkit/common/fileapi/file_system_util.cc index f7e80b2..ca656cc 100644 --- a/webkit/common/fileapi/file_system_util.cc +++ b/webkit/common/fileapi/file_system_util.cc @@ -355,4 +355,16 @@ std::string GetIsolatedFileSystemRootURIString( return root; } +std::string GetExternalFileSystemRootURIString( + const GURL& origin_url, + const std::string& mount_name) { + std::string root = GetFileSystemRootURI(origin_url, + kFileSystemTypeExternal).spec(); + if (base::FilePath::FromUTF8Unsafe(mount_name).ReferencesParent()) + return std::string(); + root.append(mount_name); + root.append("/"); + return root; +} + } // namespace fileapi diff --git a/webkit/common/fileapi/file_system_util.h b/webkit/common/fileapi/file_system_util.h index 6e09d22..aed0800 100644 --- a/webkit/common/fileapi/file_system_util.h +++ b/webkit/common/fileapi/file_system_util.h @@ -144,6 +144,12 @@ WEBKIT_STORAGE_EXPORT std::string GetIsolatedFileSystemRootURIString( const std::string& filesystem_id, const std::string& optional_root_name); +// Returns the root URI for an external filesystem for origin |origin_url| +// and |mount_name|. +WEBKIT_STORAGE_EXPORT std::string GetExternalFileSystemRootURIString( + const GURL& origin_url, + const std::string& mount_name); + } // namespace fileapi #endif // WEBKIT_COMMON_FILEAPI_FILE_SYSTEM_UTIL_H_ |