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 STORAGE_BROWSER_FILEAPI_SANDBOX_ISOLATED_ORIGIN_DATABASE_H_
6 #define STORAGE_BROWSER_FILEAPI_SANDBOX_ISOLATED_ORIGIN_DATABASE_H_
11 #include "storage/browser/fileapi/sandbox_origin_database_interface.h"
15 class SandboxOriginDatabase
;
17 // This origin database implementation supports only one origin
18 // (therefore is expected to run very fast).
19 class STORAGE_EXPORT_PRIVATE SandboxIsolatedOriginDatabase
20 : public SandboxOriginDatabaseInterface
{
22 static const base::FilePath::CharType kObsoleteOriginDirectory
[];
24 // Initialize this database for |origin| which makes GetPathForOrigin return
25 // |origin_directory| (in |file_system_directory|).
26 SandboxIsolatedOriginDatabase(
27 const std::string
& origin
,
28 const base::FilePath
& file_system_directory
,
29 const base::FilePath
& origin_directory
);
30 ~SandboxIsolatedOriginDatabase() override
;
32 // SandboxOriginDatabaseInterface overrides.
33 bool HasOriginPath(const std::string
& origin
) override
;
34 bool GetPathForOrigin(const std::string
& origin
,
35 base::FilePath
* directory
) override
;
36 bool RemovePathForOrigin(const std::string
& origin
) override
;
37 bool ListAllOrigins(std::vector
<OriginRecord
>* origins
) override
;
38 void DropDatabase() override
;
40 // TODO(kinuko): Deprecate this after a few release cycles, e.g. around M33.
41 static void MigrateBackFromObsoleteOriginDatabase(
42 const std::string
& origin
,
43 const base::FilePath
& file_system_directory
,
44 SandboxOriginDatabase
* origin_database
);
46 const std::string
& origin() const { return origin_
; }
49 void MigrateDatabaseIfNeeded();
51 bool migration_checked_
;
52 const std::string origin_
;
53 const base::FilePath file_system_directory_
;
54 const base::FilePath origin_directory_
;
56 DISALLOW_COPY_AND_ASSIGN(SandboxIsolatedOriginDatabase
);
59 } // namespace storage
61 #endif // STORAGE_BROWSER_FILEAPI_SANDBOX_ISOLATED_ORIGIN_DATABASE_H_