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.
5 #ifndef WEBKIT_BROWSER_FILEAPI_SANDBOX_ORIGIN_DATABASE_H_
6 #define WEBKIT_BROWSER_FILEAPI_SANDBOX_ORIGIN_DATABASE_H_
11 #include "base/memory/scoped_ptr.h"
12 #include "base/time/time.h"
13 #include "webkit/browser/fileapi/sandbox_origin_database_interface.h"
20 namespace tracked_objects {
26 // All methods of this class other than the constructor may be used only from
27 // the browser's FILE thread. The constructor may be used on any thread.
28 class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE SandboxOriginDatabase
29 : public SandboxOriginDatabaseInterface {
31 // Only one instance of SandboxOriginDatabase should exist for a given path
33 explicit SandboxOriginDatabase(const base::FilePath& file_system_directory);
34 virtual ~SandboxOriginDatabase();
36 // SandboxOriginDatabaseInterface overrides.
37 virtual bool HasOriginPath(const std::string& origin) OVERRIDE;
38 virtual bool GetPathForOrigin(const std::string& origin,
39 base::FilePath* directory) OVERRIDE;
40 virtual bool RemovePathForOrigin(const std::string& origin) OVERRIDE;
41 virtual bool ListAllOrigins(std::vector<OriginRecord>* origins) OVERRIDE;
42 virtual void DropDatabase() OVERRIDE;
44 base::FilePath GetDatabasePath() const;
45 void RemoveDatabase();
55 CREATE_IF_NONEXISTENT,
59 bool Init(InitOption init_option, RecoveryOption recovery_option);
60 bool RepairDatabase(const std::string& db_path);
61 void HandleError(const tracked_objects::Location& from_here,
62 const leveldb::Status& status);
63 void ReportInitStatus(const leveldb::Status& status);
64 bool GetLastPathNumber(int* number);
66 base::FilePath file_system_directory_;
67 scoped_ptr<leveldb::DB> db_;
68 base::Time last_reported_time_;
69 DISALLOW_COPY_AND_ASSIGN(SandboxOriginDatabase);
72 } // namespace fileapi
74 #endif // WEBKIT_BROWSER_FILEAPI_SANDBOX_ORIGIN_DATABASE_H_