Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(504)

Side by Side Diff: webkit/browser/fileapi/sandbox_origin_database.h

Issue 16150002: Implement special origin database handling for Isolated Apps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 WEBKIT_BROWSER_FILEAPI_SANDBOX_ORIGIN_DATABASE_H_ 5 #ifndef WEBKIT_BROWSER_FILEAPI_SANDBOX_ORIGIN_DATABASE_H_
6 #define WEBKIT_BROWSER_FILEAPI_SANDBOX_ORIGIN_DATABASE_H_ 6 #define WEBKIT_BROWSER_FILEAPI_SANDBOX_ORIGIN_DATABASE_H_
7 7
8 #include <string>
9 #include <utility>
10 #include <vector>
11
12 #include "base/files/file_path.h"
13 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
14 #include "base/time.h" 9 #include "base/time.h"
15 #include "webkit/storage/webkit_storage_export.h" 10 #include "webkit/browser/fileapi/sandbox_origin_database_interface.h"
16 11
17 namespace leveldb { 12 namespace leveldb {
18 class DB; 13 class DB;
19 class Status; 14 class Status;
20 } 15 }
21 16
22 namespace tracked_objects { 17 namespace tracked_objects {
23 class Location; 18 class Location;
24 } 19 }
25 20
26 namespace fileapi { 21 namespace fileapi {
27 22
28 // All methods of this class other than the constructor may be used only from 23 // All methods of this class other than the constructor may be used only from
29 // the browser's FILE thread. The constructor may be used on any thread. 24 // the browser's FILE thread. The constructor may be used on any thread.
30 class WEBKIT_STORAGE_EXPORT_PRIVATE SandboxOriginDatabase { 25 class WEBKIT_STORAGE_EXPORT_PRIVATE SandboxOriginDatabase
26 : public SandboxOriginDatabaseInterface {
31 public: 27 public:
32 struct WEBKIT_STORAGE_EXPORT_PRIVATE OriginRecord {
33 std::string origin;
34 base::FilePath path;
35
36 OriginRecord();
37 OriginRecord(const std::string& origin, const base::FilePath& path);
38 ~OriginRecord();
39 };
40
41 // Only one instance of SandboxOriginDatabase should exist for a given path 28 // Only one instance of SandboxOriginDatabase should exist for a given path
42 // at a given time. 29 // at a given time.
43 explicit SandboxOriginDatabase(const base::FilePath& file_system_directory); 30 explicit SandboxOriginDatabase(const base::FilePath& file_system_directory);
44 ~SandboxOriginDatabase(); 31 virtual ~SandboxOriginDatabase();
45 32
46 bool HasOriginPath(const std::string& origin); 33 // SandboxOriginDatabaseInterface overrides.
34 virtual bool HasOriginPath(const std::string& origin) OVERRIDE;
35 virtual bool GetPathForOrigin(const std::string& origin,
36 base::FilePath* directory) OVERRIDE;
37 virtual bool RemovePathForOrigin(const std::string& origin) OVERRIDE;
38 virtual bool ListAllOrigins(std::vector<OriginRecord>* origins) OVERRIDE;
39 virtual void DropDatabase() OVERRIDE;
47 40
48 // This will produce a unique path and add it to its database, if it's not 41 base::FilePath GetDatabasePath() const;
49 // already present. 42 void RemoveDatabase();
50 bool GetPathForOrigin(const std::string& origin, base::FilePath* directory);
51
52 // Also returns success if the origin is not found.
53 bool RemovePathForOrigin(const std::string& origin);
54
55 bool ListAllOrigins(std::vector<OriginRecord>* origins);
56
57 // This will release all database resources in use; call it to save memory.
58 void DropDatabase();
59 43
60 private: 44 private:
61 enum RecoveryOption { 45 enum RecoveryOption {
62 REPAIR_ON_CORRUPTION, 46 REPAIR_ON_CORRUPTION,
63 DELETE_ON_CORRUPTION, 47 DELETE_ON_CORRUPTION,
64 FAIL_ON_CORRUPTION, 48 FAIL_ON_CORRUPTION,
65 }; 49 };
66 50
67 bool Init(RecoveryOption recovery_option); 51 enum InitOption {
52 CREATE_IF_NONEXISTENT,
53 FAIL_IF_NONEXISTENT,
54 };
55
56 bool Init(InitOption init_option, RecoveryOption recovery_option);
68 bool RepairDatabase(const std::string& db_path); 57 bool RepairDatabase(const std::string& db_path);
69 void HandleError(const tracked_objects::Location& from_here, 58 void HandleError(const tracked_objects::Location& from_here,
70 const leveldb::Status& status); 59 const leveldb::Status& status);
71 void ReportInitStatus(const leveldb::Status& status); 60 void ReportInitStatus(const leveldb::Status& status);
72 bool GetLastPathNumber(int* number); 61 bool GetLastPathNumber(int* number);
73 62
74 base::FilePath file_system_directory_; 63 base::FilePath file_system_directory_;
75 scoped_ptr<leveldb::DB> db_; 64 scoped_ptr<leveldb::DB> db_;
76 base::Time last_reported_time_; 65 base::Time last_reported_time_;
77 DISALLOW_COPY_AND_ASSIGN(SandboxOriginDatabase); 66 DISALLOW_COPY_AND_ASSIGN(SandboxOriginDatabase);
78 }; 67 };
79 68
80 } // namespace fileapi 69 } // namespace fileapi
81 70
82 #endif // WEBKIT_BROWSER_FILEAPI_SANDBOX_ORIGIN_DATABASE_H_ 71 #endif // WEBKIT_BROWSER_FILEAPI_SANDBOX_ORIGIN_DATABASE_H_
OLDNEW
« no previous file with comments | « webkit/browser/fileapi/sandbox_mount_point_provider.cc ('k') | webkit/browser/fileapi/sandbox_origin_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698