[Mac] Enable CrZombie for subprocesses in release builds.
[chromium-blink-merge.git] / webkit / fileapi / file_system_origin_database.h
blobac729dfbf50d9433fb64328a4409510987fd96ce
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_
8 #include <string>
9 #include <utility>
10 #include <vector>
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 {
17 class Location;
20 namespace fileapi {
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 {
25 public:
26 struct OriginRecord {
27 std::string origin;
28 FilePath path;
30 OriginRecord();
31 OriginRecord(const std::string& origin, const FilePath& path);
32 ~OriginRecord();
35 // Only one instance of FileSystemOriginDatabase should exist for a given path
36 // at a given time.
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
43 // already present.
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.
52 void DropDatabase();
54 private:
55 bool Init();
56 void HandleError(const tracked_objects::Location& from_here,
57 leveldb::Status status);
58 bool GetLastPathNumber(int* number);
60 std::string path_;
61 scoped_ptr<leveldb::DB> db_;
62 DISALLOW_COPY_AND_ASSIGN(FileSystemOriginDatabase);
65 } // namespace fileapi
67 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_ORIGIN_DATABASE_H_