1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DB_MIGRATION_UTIL_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DB_MIGRATION_UTIL_H_
10 #include "chrome/browser/sync_file_system/sync_file_system.pb.h"
11 #include "chrome/browser/sync_file_system/sync_status_code.h"
12 #include "third_party/leveldatabase/src/include/leveldb/db.h"
16 namespace sync_file_system
{
17 namespace drive_backend
{
19 // Parses a filesystem URL which contains 'drive' as a service name
20 // (a.k.a. V0-format filesystem URL).
22 // When you parse V0-format filesystem URL, you should use this function instead
23 // of DeserializeSyncableFileSystemURL() since 'drive' service name is no longer
24 // used and the deserializer cannot parse the unregistered service name.
27 // Assume following argument is given.
28 // url: 'filesystem:http://www.example.com/external/drive/foo/bar'
30 // origin: 'http://www.example.com/'
32 bool ParseV0FormatFileSystemURL(const GURL
& url
,
34 base::FilePath
* path
);
36 // Adds "file:" prefix to WAPI resource ID.
37 // EXAMPLE: "xxx" => "file:xxx"
38 std::string
AddWapiFilePrefix(const std::string
& resource_id
);
40 // Adds "folder:" prefix to WAPI resource ID.
41 // EXAMPLE: "xxx" => "folder:xxx"
42 std::string
AddWapiFolderPrefix(const std::string
& resource_id
);
44 // Adds a prefix corresponding to the given |type|.
45 std::string
AddWapiIdPrefix(const std::string
& resource_id
,
46 DriveMetadata_ResourceType type
);
48 // Removes a prefix from WAPI resource ID.
50 // "file:xxx" => "xxx"
51 // "folder:yyy" => "yyy"
53 std::string
RemoveWapiIdPrefix(const std::string
& resource_id
);
55 // Migrate |db| schema from version 0 to version 1.
56 SyncStatusCode
MigrateDatabaseFromV0ToV1(leveldb::DB
* db
);
58 // Migrate |db| schema from version 1 to version 2.
59 SyncStatusCode
MigrateDatabaseFromV1ToV2(leveldb::DB
* db
);
61 } // namespace drive_backend
62 } // namespace sync_file_system
64 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DB_MIGRATION_UTIL_H_