storage_partition.h revision f2477e01787aa58f445919b809d89e252beef54f
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; 29class SpecialStoragePolicy; 30} 31 32namespace webkit_database { 33class DatabaseTracker; 34} 35 36namespace content { 37 38class BrowserContext; 39class IndexedDBContext; 40class DOMStorageContext; 41 42// Defines what persistent state a child process can access. 43// 44// The StoragePartition defines the view each child process has of the 45// persistent state inside the BrowserContext. This is used to implement 46// isolated storage where a renderer with isolated storage cannot see 47// the cookies, localStorage, etc., that normal web renderers have access to. 48class StoragePartition { 49 public: 50 virtual base::FilePath GetPath() = 0; 51 virtual net::URLRequestContextGetter* GetURLRequestContext() = 0; 52 virtual net::URLRequestContextGetter* GetMediaURLRequestContext() = 0; 53 virtual quota::QuotaManager* GetQuotaManager() = 0; 54 virtual appcache::AppCacheService* GetAppCacheService() = 0; 55 virtual fileapi::FileSystemContext* GetFileSystemContext() = 0; 56 virtual webkit_database::DatabaseTracker* GetDatabaseTracker() = 0; 57 virtual DOMStorageContext* GetDOMStorageContext() = 0; 58 virtual IndexedDBContext* GetIndexedDBContext() = 0; 59 60 enum RemoveDataMask { 61 REMOVE_DATA_MASK_APPCACHE = 1 << 0, 62 REMOVE_DATA_MASK_COOKIES = 1 << 1, 63 REMOVE_DATA_MASK_FILE_SYSTEMS = 1 << 2, 64 REMOVE_DATA_MASK_INDEXEDDB = 1 << 3, 65 REMOVE_DATA_MASK_LOCAL_STORAGE = 1 << 4, 66 REMOVE_DATA_MASK_SHADER_CACHE = 1 << 5, 67 REMOVE_DATA_MASK_WEBSQL = 1 << 6, 68 REMOVE_DATA_MASK_WEBRTC_IDENTITY = 1 << 7, 69 REMOVE_DATA_MASK_ALL = -1 70 }; 71 72 enum QuotaManagedStorageMask { 73 // Corresponds to quota::kStorageTypeTemporary. 74 QUOTA_MANAGED_STORAGE_MASK_TEMPORARY = 1 << 0, 75 76 // Corresponds to quota::kStorageTypePersistent. 77 QUOTA_MANAGED_STORAGE_MASK_PERSISTENT = 1 << 1, 78 79 // Corresponds to quota::kStorageTypeSyncable. 80 QUOTA_MANAGED_STORAGE_MASK_SYNCABLE = 1 << 2, 81 82 QUOTA_MANAGED_STORAGE_MASK_ALL = -1 83 }; 84 85 // Starts an asynchronous task that does a best-effort clear the data 86 // corresponding to the given |remove_mask| and |quota_storage_remove_mask| 87 // inside this StoragePartition for the given |storage_origin|. 88 // Note session dom storage is not cleared even if you specify 89 // REMOVE_DATA_MASK_LOCAL_STORAGE. 90 // 91 // TODO(ajwong): Right now, the embedder may have some 92 // URLRequestContextGetter objects that the StoragePartition does not know 93 // about. This will no longer be the case when we resolve 94 // http://crbug.com/159193. Remove |request_context_getter| when that bug 95 // is fixed. 96 virtual void ClearDataForOrigin(uint32 remove_mask, 97 uint32 quota_storage_remove_mask, 98 const GURL& storage_origin, 99 net::URLRequestContextGetter* rq_context) = 0; 100 101 // A callback type to check if a given origin matches a storage policy. 102 // Can be passed empty/null where used, which means the origin will always 103 // match. 104 typedef base::Callback<bool(const GURL&, 105 quota::SpecialStoragePolicy*)> 106 OriginMatcherFunction; 107 108 // Similar to ClearDataForOrigin(). 109 // Deletes all data out fo the StoragePartition if |storage_origin| is NULL. 110 // |origin_matcher| is present if special storage policy is to be handled, 111 // otherwise the callback can be null (base::Callback::is_null() == true). 112 // |callback| is called when data deletion is done or at least the deletion is 113 // scheduled. 114 virtual void ClearData(uint32 remove_mask, 115 uint32 quota_storage_remove_mask, 116 const GURL* storage_origin, 117 const OriginMatcherFunction& origin_matcher, 118 const base::Time begin, 119 const base::Time end, 120 const base::Closure& callback) = 0; 121 122 protected: 123 virtual ~StoragePartition() {} 124}; 125 126} // namespace content 127 128#endif // CONTENT_PUBLIC_BROWSER_STORAGE_PARTITION_H_ 129