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

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

Issue 15442002: Move FileAPI sandboxed filesystem related code from webkit/fileapi to webkit/browser/fileapi (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 years, 7 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef WEBKIT_FILEAPI_SANDBOX_ORIGIN_DATABASE_H_
6 #define WEBKIT_FILEAPI_SANDBOX_ORIGIN_DATABASE_H_
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"
14 #include "base/time.h"
15 #include "webkit/storage/webkit_storage_export.h"
16
17 namespace leveldb {
18 class DB;
19 class Status;
20 }
21
22 namespace tracked_objects {
23 class Location;
24 }
25
26 namespace fileapi {
27
28 // 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.
30 class WEBKIT_STORAGE_EXPORT_PRIVATE SandboxOriginDatabase {
31 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
42 // at a given time.
43 explicit SandboxOriginDatabase(const base::FilePath& file_system_directory);
44 ~SandboxOriginDatabase();
45
46 bool HasOriginPath(const std::string& origin);
47
48 // This will produce a unique path and add it to its database, if it's not
49 // already present.
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
60 private:
61 enum RecoveryOption {
62 REPAIR_ON_CORRUPTION,
63 DELETE_ON_CORRUPTION,
64 FAIL_ON_CORRUPTION,
65 };
66
67 bool Init(RecoveryOption recovery_option);
68 bool RepairDatabase(const std::string& db_path);
69 void HandleError(const tracked_objects::Location& from_here,
70 const leveldb::Status& status);
71 void ReportInitStatus(const leveldb::Status& status);
72 bool GetLastPathNumber(int* number);
73
74 base::FilePath file_system_directory_;
75 scoped_ptr<leveldb::DB> db_;
76 base::Time last_reported_time_;
77 DISALLOW_COPY_AND_ASSIGN(SandboxOriginDatabase);
78 };
79
80 } // namespace fileapi
81
82 #endif // WEBKIT_FILEAPI_SANDBOX_ORIGIN_DATABASE_H_
OLDNEW
« no previous file with comments | « webkit/fileapi/sandbox_mount_point_provider_unittest.cc ('k') | webkit/fileapi/sandbox_origin_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698