1 // Copyright (c) 2011 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_FILEAPI_FILE_SYSTEM_ORIGIN_DATABASE_H_
6 #define WEBKIT_FILEAPI_FILE_SYSTEM_ORIGIN_DATABASE_H_
12 #include "base/file_path.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "third_party/leveldatabase/src/include/leveldb/db.h"
16 namespace tracked_objects
{
22 // All methods of this class other than the constructor may be used only from
23 // the browser's FILE thread. The constructor may be used on any thread.
24 class FileSystemOriginDatabase
{
31 OriginRecord(const std::string
& origin
, const FilePath
& path
);
35 // Only one instance of FileSystemOriginDatabase should exist for a given path
37 explicit FileSystemOriginDatabase(const FilePath
& path
);
38 ~FileSystemOriginDatabase();
40 bool HasOriginPath(const std::string
& origin
);
42 // This will produce a unique path and add it to its database, if it's not
44 bool GetPathForOrigin(const std::string
& origin
, FilePath
* directory
);
46 // Also returns success if the origin is not found.
47 bool RemovePathForOrigin(const std::string
& origin
);
49 bool ListAllOrigins(std::vector
<OriginRecord
>* origins
);
51 // This will release all database resources in use; call it to save memory.
56 void HandleError(const tracked_objects::Location
& from_here
,
57 leveldb::Status status
);
58 bool GetLastPathNumber(int* number
);
61 scoped_ptr
<leveldb::DB
> db_
;
62 DISALLOW_COPY_AND_ASSIGN(FileSystemOriginDatabase
);
65 } // namespace fileapi
67 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_ORIGIN_DATABASE_H_