Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: content/browser/in_process_webkit/indexed_db_context.h

Issue 7692016: Delete indexedDBs from the cookie tree ui. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CONTEXT_H_ 5 #ifndef CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CONTEXT_H_
6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CONTEXT_H_ 6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CONTEXT_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <set>
11 #include <vector>
10 12
11 #include "base/basictypes.h" 13 #include "base/basictypes.h"
12 #include "base/file_path.h" 14 #include "base/file_path.h"
15 #include "base/gtest_prod_util.h"
13 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
15 #include "content/browser/browser_thread.h" 18 #include "content/browser/browser_thread.h"
19 #include "googleurl/src/gurl.h"
16 20
17 class GURL; 21 class GURL;
18 class FilePath; 22 class FilePath;
19 class WebKitContext; 23 class WebKitContext;
20 24
21 namespace WebKit { 25 namespace WebKit {
22 class WebIDBFactory; 26 class WebIDBFactory;
23 } 27 }
24 28
25 namespace base { 29 namespace base {
(...skipping 15 matching lines...) Expand all
41 ~IndexedDBContext(); 45 ~IndexedDBContext();
42 46
43 WebKit::WebIDBFactory* GetIDBFactory(); 47 WebKit::WebIDBFactory* GetIDBFactory();
44 48
45 // The indexed db directory. 49 // The indexed db directory.
46 static const FilePath::CharType kIndexedDBDirectory[]; 50 static const FilePath::CharType kIndexedDBDirectory[];
47 51
48 // The indexed db file extension. 52 // The indexed db file extension.
49 static const FilePath::CharType kIndexedDBExtension[]; 53 static const FilePath::CharType kIndexedDBExtension[];
50 54
51 // Get the file name of the indexed db file for the given origin.
52 FilePath GetIndexedDBFilePath(const string16& origin_id) const;
53
54 void set_clear_local_state_on_exit(bool clear_local_state) { 55 void set_clear_local_state_on_exit(bool clear_local_state) {
55 clear_local_state_on_exit_ = clear_local_state; 56 clear_local_state_on_exit_ = clear_local_state;
56 } 57 }
57 58
58 // Deletes all indexed db files for the given origin. 59 // Deletes all indexed db files for the given origin.
59 void DeleteIndexedDBForOrigin(const GURL& origin_url); 60 void DeleteIndexedDBForOrigin(const GURL& origin_url);
60 61
61 // Does a particular origin get unlimited storage? 62 // Does a particular origin get unlimited storage?
62 bool IsUnlimitedStorageGranted(const GURL& origin) const; 63 bool IsUnlimitedStorageGranted(const GURL& origin_url) const;
63 64
64 // Methods used in response to QuotaManager requests. 65 // Methods used in response to QuotaManager requests.
65 void GetAllOriginIdentifiers(std::vector<string16>* origin_ids); 66 void GetAllOrigins(std::vector<GURL>* origins);
66 int64 GetOriginDiskUsage(const GURL& origin_url); 67 int64 GetOriginDiskUsage(const GURL& origin_url);
68 base::Time GetOriginLastModified(const GURL& origin_url);
67 69
68 // Methods called by IndexedDBDispatcherHost for quota support. 70 // Methods called by IndexedDBDispatcherHost for quota support.
69 void ConnectionOpened(const GURL& origin_url); 71 void ConnectionOpened(const GURL& origin_url);
70 void ConnectionClosed(const GURL& origin_url); 72 void ConnectionClosed(const GURL& origin_url);
71 void TransactionComplete(const GURL& origin_url); 73 void TransactionComplete(const GURL& origin_url);
72 bool WouldBeOverQuota(const GURL& origin_url, int64 additional_bytes); 74 bool WouldBeOverQuota(const GURL& origin_url, int64 additional_bytes);
73 bool IsOverQuota(const GURL& origin_url); 75 bool IsOverQuota(const GURL& origin_url);
74 76
75 quota::QuotaManagerProxy* quota_manager_proxy(); 77 quota::QuotaManagerProxy* quota_manager_proxy();
76 78
77 #ifdef UNIT_TEST 79 #ifdef UNIT_TEST
78 // For unit tests allow to override the |data_path_|. 80 // For unit tests allow to override the |data_path_|.
79 void set_data_path(const FilePath& data_path) { data_path_ = data_path; } 81 void set_data_path(const FilePath& data_path) { data_path_ = data_path; }
80 #endif 82 #endif
81 83
82 private: 84 private:
85 FRIEND_TEST(ExtensionServiceTest, ClearExtensionData);
86 FRIEND_TEST(IndexedDBBrowserTest, ClearLocalState);
87 friend class IndexedDBQuotaClientTest;
88
83 typedef std::map<GURL, int64> OriginToSizeMap; 89 typedef std::map<GURL, int64> OriginToSizeMap;
84 class IndexedDBGetUsageAndQuotaCallback; 90 class IndexedDBGetUsageAndQuotaCallback;
85 91
92 FilePath GetIndexedDBFilePath(const string16& origin_id) const;
86 int64 ReadUsageFromDisk(const GURL& origin_url) const; 93 int64 ReadUsageFromDisk(const GURL& origin_url) const;
87 void EnsureDiskUsageCacheInitialized(const GURL& origin_url); 94 void EnsureDiskUsageCacheInitialized(const GURL& origin_url);
88 void QueryDiskAndUpdateQuotaUsage(const GURL& origin_url); 95 void QueryDiskAndUpdateQuotaUsage(const GURL& origin_url);
89 void GotUpdatedQuota(const GURL& origin_url, int64 usage, int64 quota); 96 void GotUpdatedQuota(const GURL& origin_url, int64 usage, int64 quota);
90 void QueryAvailableQuota(const GURL& origin_url); 97 void QueryAvailableQuota(const GURL& origin_url);
91 int64 ResetDiskUsageCache(const GURL& origin_url); 98
99 std::set<GURL>* GetOriginSet();
100 bool AddToOriginSet(const GURL& origin_url) {
101 return GetOriginSet()->insert(origin_url).second;
102 }
103 void RemoveFromOriginSet(const GURL& origin_url) {
104 GetOriginSet()->erase(origin_url);
105 }
106 bool IsInOriginSet(const GURL& origin_url) {
107 std::set<GURL>* set = GetOriginSet();
108 return set->find(origin_url) != set->end();
109 }
110
111 // Only for testing.
112 void ResetCaches();
92 113
93 scoped_ptr<WebKit::WebIDBFactory> idb_factory_; 114 scoped_ptr<WebKit::WebIDBFactory> idb_factory_;
94
95 // Path where the indexed db data is stored
96 FilePath data_path_; 115 FilePath data_path_;
97
98 // True if the destructor should delete its files.
99 bool clear_local_state_on_exit_; 116 bool clear_local_state_on_exit_;
100
101 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; 117 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_;
102
103 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; 118 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_;
104 119 scoped_ptr<std::set<GURL> > origin_set_;
105 OriginToSizeMap origin_size_map_; 120 OriginToSizeMap origin_size_map_;
106 OriginToSizeMap space_available_map_; 121 OriginToSizeMap space_available_map_;
107 std::map<GURL, unsigned int> connection_count_; 122 std::map<GURL, unsigned int> connection_count_;
108 123
109 DISALLOW_COPY_AND_ASSIGN(IndexedDBContext); 124 DISALLOW_COPY_AND_ASSIGN(IndexedDBContext);
110 }; 125 };
111 126
112 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CONTEXT_H_ 127 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CONTEXT_H_
OLDNEW
« no previous file with comments | « content/browser/in_process_webkit/indexed_db_browsertest.cc ('k') | content/browser/in_process_webkit/indexed_db_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698