OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef STORAGE_BROWSER_FILEAPI_SANDBOX_PRIORITIZED_ORIGIN_DATABASE_H_ | 5 #ifndef STORAGE_BROWSER_FILEAPI_SANDBOX_PRIORITIZED_ORIGIN_DATABASE_H_ |
6 #define STORAGE_BROWSER_FILEAPI_SANDBOX_PRIORITIZED_ORIGIN_DATABASE_H_ | 6 #define STORAGE_BROWSER_FILEAPI_SANDBOX_PRIORITIZED_ORIGIN_DATABASE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 class SandboxOriginDatabase; | 23 class SandboxOriginDatabase; |
24 | 24 |
25 class STORAGE_EXPORT_PRIVATE SandboxPrioritizedOriginDatabase | 25 class STORAGE_EXPORT_PRIVATE SandboxPrioritizedOriginDatabase |
26 : public SandboxOriginDatabaseInterface { | 26 : public SandboxOriginDatabaseInterface { |
27 public: | 27 public: |
28 static const base::FilePath::CharType* kPrimaryDirectory; | 28 static const base::FilePath::CharType* kPrimaryDirectory; |
29 static const base::FilePath::CharType* kPrimaryOriginFile; | 29 static const base::FilePath::CharType* kPrimaryOriginFile; |
30 | 30 |
31 SandboxPrioritizedOriginDatabase(const base::FilePath& file_system_directory, | 31 SandboxPrioritizedOriginDatabase(const base::FilePath& file_system_directory, |
32 leveldb::Env* env_override); | 32 leveldb::Env* env_override); |
33 virtual ~SandboxPrioritizedOriginDatabase(); | 33 ~SandboxPrioritizedOriginDatabase() override; |
34 | 34 |
35 // Sets |origin| as primary origin in this database (e.g. may | 35 // Sets |origin| as primary origin in this database (e.g. may |
36 // allow faster access). | 36 // allow faster access). |
37 // Returns false if this database already has a primary origin | 37 // Returns false if this database already has a primary origin |
38 // which is different from |origin|. | 38 // which is different from |origin|. |
39 bool InitializePrimaryOrigin(const std::string& origin); | 39 bool InitializePrimaryOrigin(const std::string& origin); |
40 std::string GetPrimaryOrigin(); | 40 std::string GetPrimaryOrigin(); |
41 | 41 |
42 // SandboxOriginDatabaseInterface overrides. | 42 // SandboxOriginDatabaseInterface overrides. |
43 virtual bool HasOriginPath(const std::string& origin) override; | 43 bool HasOriginPath(const std::string& origin) override; |
44 virtual bool GetPathForOrigin(const std::string& origin, | 44 bool GetPathForOrigin(const std::string& origin, |
45 base::FilePath* directory) override; | 45 base::FilePath* directory) override; |
46 virtual bool RemovePathForOrigin(const std::string& origin) override; | 46 bool RemovePathForOrigin(const std::string& origin) override; |
47 virtual bool ListAllOrigins(std::vector<OriginRecord>* origins) override; | 47 bool ListAllOrigins(std::vector<OriginRecord>* origins) override; |
48 virtual void DropDatabase() override; | 48 void DropDatabase() override; |
49 | 49 |
50 const base::FilePath& primary_origin_file() const { | 50 const base::FilePath& primary_origin_file() const { |
51 return primary_origin_file_; | 51 return primary_origin_file_; |
52 } | 52 } |
53 | 53 |
54 private: | 54 private: |
55 bool MaybeLoadPrimaryOrigin(); | 55 bool MaybeLoadPrimaryOrigin(); |
56 bool ResetPrimaryOrigin(const std::string& origin); | 56 bool ResetPrimaryOrigin(const std::string& origin); |
57 void MaybeMigrateDatabase(const std::string& origin); | 57 void MaybeMigrateDatabase(const std::string& origin); |
58 void MaybeInitializeDatabases(bool create); | 58 void MaybeInitializeDatabases(bool create); |
59 void MaybeInitializeNonPrimaryDatabase(bool create); | 59 void MaybeInitializeNonPrimaryDatabase(bool create); |
60 | 60 |
61 // For migration. | 61 // For migration. |
62 friend class ObfuscatedFileUtil; | 62 friend class ObfuscatedFileUtil; |
63 SandboxOriginDatabase* GetSandboxOriginDatabase(); | 63 SandboxOriginDatabase* GetSandboxOriginDatabase(); |
64 | 64 |
65 const base::FilePath file_system_directory_; | 65 const base::FilePath file_system_directory_; |
66 leveldb::Env* env_override_; | 66 leveldb::Env* env_override_; |
67 const base::FilePath primary_origin_file_; | 67 const base::FilePath primary_origin_file_; |
68 scoped_ptr<SandboxOriginDatabase> origin_database_; | 68 scoped_ptr<SandboxOriginDatabase> origin_database_; |
69 scoped_ptr<SandboxIsolatedOriginDatabase> primary_origin_database_; | 69 scoped_ptr<SandboxIsolatedOriginDatabase> primary_origin_database_; |
70 | 70 |
71 DISALLOW_COPY_AND_ASSIGN(SandboxPrioritizedOriginDatabase); | 71 DISALLOW_COPY_AND_ASSIGN(SandboxPrioritizedOriginDatabase); |
72 }; | 72 }; |
73 | 73 |
74 } // namespace storage | 74 } // namespace storage |
75 | 75 |
76 #endif // STORAGE_BROWSER_FILEAPI_SANDBOX_PRIORITIZED_ORIGIN_DATABASE_H_ | 76 #endif // STORAGE_BROWSER_FILEAPI_SANDBOX_PRIORITIZED_ORIGIN_DATABASE_H_ |
OLD | NEW |