Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / content / public / browser / storage_partition.h
blobdd5a78984e70dd68f7620603e76319b7a1a811f2
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 CONTENT_PUBLIC_BROWSER_STORAGE_PARTITION_H_
6 #define CONTENT_PUBLIC_BROWSER_STORAGE_PARTITION_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/callback_forward.h"
12 #include "base/files/file_path.h"
13 #include "base/time/time.h"
14 #include "content/common/content_export.h"
16 class GURL;
18 namespace base {
19 class Time;
22 namespace storage {
23 class FileSystemContext;
26 namespace net {
27 class URLRequestContextGetter;
30 namespace storage {
31 class QuotaManager;
32 class SpecialStoragePolicy;
35 namespace storage {
36 class DatabaseTracker;
39 namespace content {
41 class AppCacheService;
42 class BackgroundSyncContext;
43 class BrowserContext;
44 class HostZoomLevelContext;
45 class HostZoomMap;
46 class DOMStorageContext;
47 class GeofencingManager;
48 class IndexedDBContext;
49 class NavigatorConnectContext;
50 class PlatformNotificationContext;
51 class ServiceWorkerContext;
52 class ZoomLevelDelegate;
54 // Defines what persistent state a child process can access.
56 // The StoragePartition defines the view each child process has of the
57 // persistent state inside the BrowserContext. This is used to implement
58 // isolated storage where a renderer with isolated storage cannot see
59 // the cookies, localStorage, etc., that normal web renderers have access to.
60 class CONTENT_EXPORT StoragePartition {
61 public:
62 virtual base::FilePath GetPath() = 0;
63 virtual net::URLRequestContextGetter* GetURLRequestContext() = 0;
64 virtual net::URLRequestContextGetter* GetMediaURLRequestContext() = 0;
65 virtual storage::QuotaManager* GetQuotaManager() = 0;
66 virtual AppCacheService* GetAppCacheService() = 0;
67 virtual storage::FileSystemContext* GetFileSystemContext() = 0;
68 virtual storage::DatabaseTracker* GetDatabaseTracker() = 0;
69 virtual DOMStorageContext* GetDOMStorageContext() = 0;
70 virtual IndexedDBContext* GetIndexedDBContext() = 0;
71 virtual ServiceWorkerContext* GetServiceWorkerContext() = 0;
72 virtual GeofencingManager* GetGeofencingManager() = 0;
73 virtual HostZoomMap* GetHostZoomMap() = 0;
74 virtual HostZoomLevelContext* GetHostZoomLevelContext() = 0;
75 virtual ZoomLevelDelegate* GetZoomLevelDelegate() = 0;
76 virtual NavigatorConnectContext* GetNavigatorConnectContext() = 0;
77 virtual PlatformNotificationContext* GetPlatformNotificationContext() = 0;
78 virtual BackgroundSyncContext* GetBackgroundSyncContext() = 0;
80 static const uint32 REMOVE_DATA_MASK_APPCACHE = 1 << 0;
81 static const uint32 REMOVE_DATA_MASK_COOKIES = 1 << 1;
82 static const uint32 REMOVE_DATA_MASK_FILE_SYSTEMS = 1 << 2;
83 static const uint32 REMOVE_DATA_MASK_INDEXEDDB = 1 << 3;
84 static const uint32 REMOVE_DATA_MASK_LOCAL_STORAGE = 1 << 4;
85 static const uint32 REMOVE_DATA_MASK_SHADER_CACHE = 1 << 5;
86 static const uint32 REMOVE_DATA_MASK_WEBSQL = 1 << 6;
87 static const uint32 REMOVE_DATA_MASK_WEBRTC_IDENTITY = 1 << 7;
88 static const uint32 REMOVE_DATA_MASK_SERVICE_WORKERS = 1 << 8;
89 static const uint32 REMOVE_DATA_MASK_ALL = 0xFFFFFFFF;
91 // Corresponds to storage::kStorageTypeTemporary.
92 static const uint32 QUOTA_MANAGED_STORAGE_MASK_TEMPORARY = 1 << 0;
93 // Corresponds to storage::kStorageTypePersistent.
94 static const uint32 QUOTA_MANAGED_STORAGE_MASK_PERSISTENT = 1 << 1;
95 // Corresponds to storage::kStorageTypeSyncable.
96 static const uint32 QUOTA_MANAGED_STORAGE_MASK_SYNCABLE = 1 << 2;
97 static const uint32 QUOTA_MANAGED_STORAGE_MASK_ALL = 0xFFFFFFFF;
99 // Starts an asynchronous task that does a best-effort clear the data
100 // corresponding to the given |remove_mask| and |quota_storage_remove_mask|
101 // inside this StoragePartition for the given |storage_origin|.
102 // Note session dom storage is not cleared even if you specify
103 // REMOVE_DATA_MASK_LOCAL_STORAGE.
104 // |callback| is called when data deletion is done or at least the deletion is
105 // scheduled.
107 // TODO(ajwong): Right now, the embedder may have some
108 // URLRequestContextGetter objects that the StoragePartition does not know
109 // about. This will no longer be the case when we resolve
110 // http://crbug.com/159193. Remove |request_context_getter| when that bug
111 // is fixed.
112 virtual void ClearDataForOrigin(uint32 remove_mask,
113 uint32 quota_storage_remove_mask,
114 const GURL& storage_origin,
115 net::URLRequestContextGetter* rq_context,
116 const base::Closure& callback) = 0;
118 // A callback type to check if a given origin matches a storage policy.
119 // Can be passed empty/null where used, which means the origin will always
120 // match.
121 typedef base::Callback<bool(const GURL&, storage::SpecialStoragePolicy*)>
122 OriginMatcherFunction;
124 // Similar to ClearDataForOrigin().
125 // Deletes all data out fo the StoragePartition if |storage_origin| is
126 // nullptr.
127 // |origin_matcher| is present if special storage policy is to be handled,
128 // otherwise the callback can be null (base::Callback::is_null() == true).
129 // |callback| is called when data deletion is done or at least the deletion is
130 // scheduled.
131 virtual void ClearData(uint32 remove_mask,
132 uint32 quota_storage_remove_mask,
133 const GURL& storage_origin,
134 const OriginMatcherFunction& origin_matcher,
135 const base::Time begin,
136 const base::Time end,
137 const base::Closure& callback) = 0;
139 // Write any unwritten data to disk.
140 // Note: this method does not sync the data - it only ensures that any
141 // unwritten data has been written out to the filesystem.
142 virtual void Flush() = 0;
144 protected:
145 virtual ~StoragePartition() {}
148 } // namespace content
150 #endif // CONTENT_PUBLIC_BROWSER_STORAGE_PARTITION_H_