OLD | NEW |
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> | 10 #include <set> |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // The indexed db directory. | 52 // The indexed db directory. |
53 static const FilePath::CharType kIndexedDBDirectory[]; | 53 static const FilePath::CharType kIndexedDBDirectory[]; |
54 | 54 |
55 // The indexed db file extension. | 55 // The indexed db file extension. |
56 static const FilePath::CharType kIndexedDBExtension[]; | 56 static const FilePath::CharType kIndexedDBExtension[]; |
57 | 57 |
58 void set_clear_local_state_on_exit(bool clear_local_state) { | 58 void set_clear_local_state_on_exit(bool clear_local_state) { |
59 clear_local_state_on_exit_ = clear_local_state; | 59 clear_local_state_on_exit_ = clear_local_state; |
60 } | 60 } |
61 | 61 |
| 62 // Disables the exit-time deletion for all data (also session-only data). |
| 63 void SaveSessionState() { |
| 64 save_session_state_ = true; |
| 65 } |
| 66 |
62 // Deletes all indexed db files for the given origin. | 67 // Deletes all indexed db files for the given origin. |
63 void DeleteIndexedDBForOrigin(const GURL& origin_url); | 68 void DeleteIndexedDBForOrigin(const GURL& origin_url); |
64 | 69 |
65 // Methods used in response to QuotaManager requests. | 70 // Methods used in response to QuotaManager requests. |
66 void GetAllOrigins(std::vector<GURL>* origins); | 71 void GetAllOrigins(std::vector<GURL>* origins); |
67 int64 GetOriginDiskUsage(const GURL& origin_url); | 72 int64 GetOriginDiskUsage(const GURL& origin_url); |
68 base::Time GetOriginLastModified(const GURL& origin_url); | 73 base::Time GetOriginLastModified(const GURL& origin_url); |
69 | 74 |
70 // Methods called by IndexedDBDispatcherHost for quota support. | 75 // Methods called by IndexedDBDispatcherHost for quota support. |
71 void ConnectionOpened(const GURL& origin_url); | 76 void ConnectionOpened(const GURL& origin_url); |
72 void ConnectionClosed(const GURL& origin_url); | 77 void ConnectionClosed(const GURL& origin_url); |
73 void TransactionComplete(const GURL& origin_url); | 78 void TransactionComplete(const GURL& origin_url); |
74 bool WouldBeOverQuota(const GURL& origin_url, int64 additional_bytes); | 79 bool WouldBeOverQuota(const GURL& origin_url, int64 additional_bytes); |
75 bool IsOverQuota(const GURL& origin_url); | 80 bool IsOverQuota(const GURL& origin_url); |
76 | 81 |
77 quota::QuotaManagerProxy* quota_manager_proxy(); | 82 quota::QuotaManagerProxy* quota_manager_proxy(); |
78 | 83 |
79 // For unit tests allow to override the |data_path_|. | 84 // For unit tests allow to override the |data_path_|. |
80 void set_data_path_for_testing(const FilePath& data_path) { | 85 void set_data_path_for_testing(const FilePath& data_path) { |
81 data_path_ = data_path; | 86 data_path_ = data_path; |
82 } | 87 } |
83 | 88 |
84 private: | 89 private: |
85 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, ClearExtensionData); | 90 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, ClearExtensionData); |
86 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, ClearAppData); | 91 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, ClearAppData); |
87 FRIEND_TEST_ALL_PREFIXES(IndexedDBBrowserTest, ClearLocalState); | 92 FRIEND_TEST_ALL_PREFIXES(IndexedDBBrowserTest, ClearLocalState); |
88 FRIEND_TEST_ALL_PREFIXES(IndexedDBBrowserTest, ClearSessionOnlyDatabases); | 93 FRIEND_TEST_ALL_PREFIXES(IndexedDBBrowserTest, ClearSessionOnlyDatabases); |
| 94 FRIEND_TEST_ALL_PREFIXES(IndexedDBBrowserTest, SaveSessionState); |
89 friend class IndexedDBQuotaClientTest; | 95 friend class IndexedDBQuotaClientTest; |
90 | 96 |
91 typedef std::map<GURL, int64> OriginToSizeMap; | 97 typedef std::map<GURL, int64> OriginToSizeMap; |
92 class IndexedDBGetUsageAndQuotaCallback; | 98 class IndexedDBGetUsageAndQuotaCallback; |
93 | 99 |
94 FilePath GetIndexedDBFilePath(const string16& origin_id) const; | 100 FilePath GetIndexedDBFilePath(const string16& origin_id) const; |
95 int64 ReadUsageFromDisk(const GURL& origin_url) const; | 101 int64 ReadUsageFromDisk(const GURL& origin_url) const; |
96 void EnsureDiskUsageCacheInitialized(const GURL& origin_url); | 102 void EnsureDiskUsageCacheInitialized(const GURL& origin_url); |
97 void QueryDiskAndUpdateQuotaUsage(const GURL& origin_url); | 103 void QueryDiskAndUpdateQuotaUsage(const GURL& origin_url); |
98 void GotUsageAndQuota(const GURL& origin_url, quota::QuotaStatusCode, | 104 void GotUsageAndQuota(const GURL& origin_url, quota::QuotaStatusCode, |
(...skipping 12 matching lines...) Expand all Loading... |
111 std::set<GURL>* set = GetOriginSet(); | 117 std::set<GURL>* set = GetOriginSet(); |
112 return set->find(origin_url) != set->end(); | 118 return set->find(origin_url) != set->end(); |
113 } | 119 } |
114 | 120 |
115 // Only for testing. | 121 // Only for testing. |
116 void ResetCaches(); | 122 void ResetCaches(); |
117 | 123 |
118 scoped_ptr<WebKit::WebIDBFactory> idb_factory_; | 124 scoped_ptr<WebKit::WebIDBFactory> idb_factory_; |
119 FilePath data_path_; | 125 FilePath data_path_; |
120 bool clear_local_state_on_exit_; | 126 bool clear_local_state_on_exit_; |
| 127 // If true, nothing (not even session-only data) should be deleted on exit. |
| 128 bool save_session_state_; |
121 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; | 129 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; |
122 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; | 130 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; |
123 scoped_ptr<std::set<GURL> > origin_set_; | 131 scoped_ptr<std::set<GURL> > origin_set_; |
124 OriginToSizeMap origin_size_map_; | 132 OriginToSizeMap origin_size_map_; |
125 OriginToSizeMap space_available_map_; | 133 OriginToSizeMap space_available_map_; |
126 std::map<GURL, unsigned int> connection_count_; | 134 std::map<GURL, unsigned int> connection_count_; |
127 | 135 |
128 DISALLOW_COPY_AND_ASSIGN(IndexedDBContext); | 136 DISALLOW_COPY_AND_ASSIGN(IndexedDBContext); |
129 }; | 137 }; |
130 | 138 |
131 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CONTEXT_H_ | 139 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CONTEXT_H_ |
OLD | NEW |