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_
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"
23 class FileSystemContext
;
27 class URLRequestContextGetter
;
32 class SpecialStoragePolicy
;
36 class DatabaseTracker
;
41 class AppCacheService
;
43 class HostZoomLevelContext
;
45 class DOMStorageContext
;
46 class GeofencingManager
;
47 class IndexedDBContext
;
48 class NavigatorConnectContext
;
49 class PlatformNotificationContext
;
50 class ServiceWorkerContext
;
51 class ZoomLevelDelegate
;
53 // Defines what persistent state a child process can access.
55 // The StoragePartition defines the view each child process has of the
56 // persistent state inside the BrowserContext. This is used to implement
57 // isolated storage where a renderer with isolated storage cannot see
58 // the cookies, localStorage, etc., that normal web renderers have access to.
59 class CONTENT_EXPORT StoragePartition
{
61 virtual base::FilePath
GetPath() = 0;
62 virtual net::URLRequestContextGetter
* GetURLRequestContext() = 0;
63 virtual net::URLRequestContextGetter
* GetMediaURLRequestContext() = 0;
64 virtual storage::QuotaManager
* GetQuotaManager() = 0;
65 virtual AppCacheService
* GetAppCacheService() = 0;
66 virtual storage::FileSystemContext
* GetFileSystemContext() = 0;
67 virtual storage::DatabaseTracker
* GetDatabaseTracker() = 0;
68 virtual DOMStorageContext
* GetDOMStorageContext() = 0;
69 virtual IndexedDBContext
* GetIndexedDBContext() = 0;
70 virtual ServiceWorkerContext
* GetServiceWorkerContext() = 0;
71 virtual GeofencingManager
* GetGeofencingManager() = 0;
72 virtual HostZoomMap
* GetHostZoomMap() = 0;
73 virtual HostZoomLevelContext
* GetHostZoomLevelContext() = 0;
74 virtual ZoomLevelDelegate
* GetZoomLevelDelegate() = 0;
75 virtual NavigatorConnectContext
* GetNavigatorConnectContext() = 0;
76 virtual PlatformNotificationContext
* GetPlatformNotificationContext() = 0;
78 static const uint32 REMOVE_DATA_MASK_APPCACHE
= 1 << 0;
79 static const uint32 REMOVE_DATA_MASK_COOKIES
= 1 << 1;
80 static const uint32 REMOVE_DATA_MASK_FILE_SYSTEMS
= 1 << 2;
81 static const uint32 REMOVE_DATA_MASK_INDEXEDDB
= 1 << 3;
82 static const uint32 REMOVE_DATA_MASK_LOCAL_STORAGE
= 1 << 4;
83 static const uint32 REMOVE_DATA_MASK_SHADER_CACHE
= 1 << 5;
84 static const uint32 REMOVE_DATA_MASK_WEBSQL
= 1 << 6;
85 static const uint32 REMOVE_DATA_MASK_WEBRTC_IDENTITY
= 1 << 7;
86 static const uint32 REMOVE_DATA_MASK_SERVICE_WORKERS
= 1 << 8;
87 static const uint32 REMOVE_DATA_MASK_ALL
= 0xFFFFFFFF;
89 // Corresponds to storage::kStorageTypeTemporary.
90 static const uint32 QUOTA_MANAGED_STORAGE_MASK_TEMPORARY
= 1 << 0;
91 // Corresponds to storage::kStorageTypePersistent.
92 static const uint32 QUOTA_MANAGED_STORAGE_MASK_PERSISTENT
= 1 << 1;
93 // Corresponds to storage::kStorageTypeSyncable.
94 static const uint32 QUOTA_MANAGED_STORAGE_MASK_SYNCABLE
= 1 << 2;
95 static const uint32 QUOTA_MANAGED_STORAGE_MASK_ALL
= 0xFFFFFFFF;
97 // Starts an asynchronous task that does a best-effort clear the data
98 // corresponding to the given |remove_mask| and |quota_storage_remove_mask|
99 // inside this StoragePartition for the given |storage_origin|.
100 // Note session dom storage is not cleared even if you specify
101 // REMOVE_DATA_MASK_LOCAL_STORAGE.
102 // |callback| is called when data deletion is done or at least the deletion is
105 // TODO(ajwong): Right now, the embedder may have some
106 // URLRequestContextGetter objects that the StoragePartition does not know
107 // about. This will no longer be the case when we resolve
108 // http://crbug.com/159193. Remove |request_context_getter| when that bug
110 virtual void ClearDataForOrigin(uint32 remove_mask
,
111 uint32 quota_storage_remove_mask
,
112 const GURL
& storage_origin
,
113 net::URLRequestContextGetter
* rq_context
,
114 const base::Closure
& callback
) = 0;
116 // A callback type to check if a given origin matches a storage policy.
117 // Can be passed empty/null where used, which means the origin will always
119 typedef base::Callback
<bool(const GURL
&, storage::SpecialStoragePolicy
*)>
120 OriginMatcherFunction
;
122 // Similar to ClearDataForOrigin().
123 // Deletes all data out fo the StoragePartition if |storage_origin| is
125 // |origin_matcher| is present if special storage policy is to be handled,
126 // otherwise the callback can be null (base::Callback::is_null() == true).
127 // |callback| is called when data deletion is done or at least the deletion is
129 virtual void ClearData(uint32 remove_mask
,
130 uint32 quota_storage_remove_mask
,
131 const GURL
& storage_origin
,
132 const OriginMatcherFunction
& origin_matcher
,
133 const base::Time begin
,
134 const base::Time end
,
135 const base::Closure
& callback
) = 0;
137 // Write any unwritten data to disk.
138 // Note: this method does not sync the data - it only ensures that any
139 // unwritten data has been written out to the filesystem.
140 virtual void Flush() = 0;
143 virtual ~StoragePartition() {}
146 } // namespace content
148 #endif // CONTENT_PUBLIC_BROWSER_STORAGE_PARTITION_H_