1// Copyright 2013 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 STORAGE_BROWSER_FILEAPI_SANDBOX_ORIGIN_DATABASE_INTERFACE_H_
6#define STORAGE_BROWSER_FILEAPI_SANDBOX_ORIGIN_DATABASE_INTERFACE_H_
7
8#include <string>
9#include <vector>
10
11#include "base/files/file_path.h"
12#include "storage/browser/storage_browser_export.h"
13
14namespace storage {
15
16class STORAGE_EXPORT_PRIVATE SandboxOriginDatabaseInterface {
17 public:
18  struct STORAGE_EXPORT_PRIVATE OriginRecord {
19    std::string origin;
20    base::FilePath path;
21
22    OriginRecord();
23    OriginRecord(const std::string& origin, const base::FilePath& path);
24    ~OriginRecord();
25  };
26
27  virtual ~SandboxOriginDatabaseInterface() {}
28
29  // Returns true if the origin's path is included in this database.
30  virtual bool HasOriginPath(const std::string& origin) = 0;
31
32  // This will produce a unique path and add it to its database, if it's not
33  // already present.
34  virtual bool GetPathForOrigin(const std::string& origin,
35                                base::FilePath* directory) = 0;
36
37  // Removes the origin's path from the database.
38  // Returns success if the origin has been successfully removed, or
39  // the origin is not found.
40  // (This doesn't remove the actual path).
41  virtual bool RemovePathForOrigin(const std::string& origin) = 0;
42
43  // Lists all origins in this database.
44  virtual bool ListAllOrigins(std::vector<OriginRecord>* origins) = 0;
45
46  // This will release all database resources in use; call it to save memory.
47  virtual void DropDatabase() = 0;
48
49 protected:
50  SandboxOriginDatabaseInterface() {}
51};
52
53}  // namespace storage
54
55#endif  // STORAGE_BROWSER_FILEAPI_SANDBOX_ORIGIN_DATABASE_INTERFACE_H_
56