storage_partition.h revision bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3
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 CONTENT_PUBLIC_BROWSER_STORAGE_PARTITION_H_
6#define CONTENT_PUBLIC_BROWSER_STORAGE_PARTITION_H_
7
8#include <string>
9
10#include "base/basictypes.h"
11#include "base/files/file_path.h"
12
13class GURL;
14
15namespace appcache {
16class AppCacheService;
17}
18
19namespace fileapi {
20class FileSystemContext;
21}
22
23namespace net {
24class URLRequestContextGetter;
25}
26
27namespace quota {
28class QuotaManager;
29}
30
31namespace webkit_database {
32class DatabaseTracker;
33}
34
35namespace content {
36
37class BrowserContext;
38class IndexedDBContext;
39class DOMStorageContext;
40
41// Defines what persistent state a child process can access.
42//
43// The StoragePartition defines the view each child process has of the
44// persistent state inside the BrowserContext. This is used to implement
45// isolated storage where a renderer with isolated storage cannot see
46// the cookies, localStorage, etc., that normal web renderers have access to.
47class StoragePartition {
48 public:
49  virtual base::FilePath GetPath() = 0;
50  virtual net::URLRequestContextGetter* GetURLRequestContext() = 0;
51  virtual net::URLRequestContextGetter* GetMediaURLRequestContext() = 0;
52  virtual quota::QuotaManager* GetQuotaManager() = 0;
53  virtual appcache::AppCacheService* GetAppCacheService() = 0;
54  virtual fileapi::FileSystemContext* GetFileSystemContext() = 0;
55  virtual webkit_database::DatabaseTracker* GetDatabaseTracker() = 0;
56  virtual DOMStorageContext* GetDOMStorageContext() = 0;
57  virtual IndexedDBContext* GetIndexedDBContext() = 0;
58
59  enum RemoveDataMask {
60    REMOVE_DATA_MASK_APPCACHE = 1 << 0,
61    REMOVE_DATA_MASK_COOKIES = 1 << 1,
62    REMOVE_DATA_MASK_FILE_SYSTEMS = 1 << 2,
63    REMOVE_DATA_MASK_INDEXEDDB = 1 << 3,
64    REMOVE_DATA_MASK_LOCAL_STORAGE = 1 << 4,
65    REMOVE_DATA_MASK_SHADER_CACHE = 1 << 5,
66    REMOVE_DATA_MASK_WEBSQL = 1 << 6,
67
68    REMOVE_DATA_MASK_ALL = -1
69  };
70
71  // TODO(lazyboy): Value in the enum should start with the enum prefix
72  // (QUOTA_MANAGED_STORAGE_MASK_*).
73  enum QuotaManagedStorageMask {
74    // Corresponds to quota::kStorageTypeTemporary.
75    kQuotaManagedTemporaryStorage = 1 << 0,
76
77    // Corresponds to quota::kStorageTypePersistent.
78    kQuotaManagedPersistentStorage = 1 << 1,
79
80    // Corresponds to quota::kStorageTypeSyncable.
81    kQuotaManagedSyncableStorage = 1 << 2,
82
83    kAllStorage = -1
84  };
85
86  // Starts an asynchronous task that does a best-effort clear the data
87  // corresponding to the given |remove_mask| and |quota_storage_remove_mask|
88  // inside this StoragePartition for the given |storage_origin|.
89  // Note session dom storage is not cleared even if you specify
90  // REMOVE_DATA_MASK_LOCAL_STORAGE.
91  //
92  // TODO(ajwong): Right now, the embedder may have some
93  // URLRequestContextGetter objects that the StoragePartition does not know
94  // about.  This will no longer be the case when we resolve
95  // http://crbug.com/159193. Remove |request_context_getter| when that bug
96  // is fixed.
97  virtual void ClearDataForOrigin(uint32 remove_mask,
98                                  uint32 quota_storage_remove_mask,
99                                  const GURL& storage_origin,
100                                  net::URLRequestContextGetter* rq_context) = 0;
101
102  // Similar to ClearDataForOrigin(), but deletes all data out of the
103  // StoragePartition rather than just the data related to this origin.
104  virtual void ClearDataForUnboundedRange(uint32 remove_mask,
105                                          uint32 quota_storage_remove_mask) = 0;
106
107  // Similar to ClearDataForOrigin(), but deletes all the data out of the
108  // StoragePartion from between the given |begin| and |end| dates rather
109  // then just the data related to this origin.
110  virtual void ClearDataForRange(uint32 remove_mask,
111                                 uint32 quota_storage_remove_mask,
112                                 const base::Time& begin,
113                                 const base::Time& end,
114                                 const base::Closure& callback) = 0;
115
116 protected:
117  virtual ~StoragePartition() {}
118};
119
120}  // namespace content
121
122#endif  // CONTENT_PUBLIC_BROWSER_STORAGE_PARTITION_H_
123