OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_INDEXED_DB_INDEXED_DB_CONTEXT_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONTEXT_IMPL_H_ |
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONTEXT_IMPL_H_ | 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONTEXT_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 | 47 |
48 WebKit::WebIDBFactory* GetIDBFactory(); | 48 WebKit::WebIDBFactory* GetIDBFactory(); |
49 | 49 |
50 // The indexed db directory. | 50 // The indexed db directory. |
51 static const base::FilePath::CharType kIndexedDBDirectory[]; | 51 static const base::FilePath::CharType kIndexedDBDirectory[]; |
52 | 52 |
53 // The indexed db file extension. | 53 // The indexed db file extension. |
54 static const base::FilePath::CharType kIndexedDBExtension[]; | 54 static const base::FilePath::CharType kIndexedDBExtension[]; |
55 | 55 |
56 // Disables the exit-time deletion of session-only data. | 56 // Disables the exit-time deletion of session-only data. |
57 void SetForceKeepSessionState() { | 57 void SetForceKeepSessionState() { force_keep_session_state_ = true; } |
jsbell
2013/04/29 19:16:14
Looks like you ran clang-format over this?
alecflett
2013/04/29 22:28:16
yes.
| |
58 force_keep_session_state_ = true; | |
59 } | |
60 | 58 |
61 // IndexedDBContext implementation: | 59 // IndexedDBContext implementation: |
62 virtual std::vector<GURL> GetAllOrigins() OVERRIDE; | 60 virtual std::vector<GURL> GetAllOrigins() OVERRIDE; |
63 virtual std::vector<IndexedDBInfo> GetAllOriginsInfo() OVERRIDE; | 61 virtual std::vector<IndexedDBInfo> GetAllOriginsInfo() OVERRIDE; |
64 virtual int64 GetOriginDiskUsage(const GURL& origin_url) OVERRIDE; | 62 virtual int64 GetOriginDiskUsage(const GURL& origin_url) OVERRIDE; |
65 virtual base::Time GetOriginLastModified(const GURL& origin_url) OVERRIDE; | 63 virtual base::Time GetOriginLastModified(const GURL& origin_url) OVERRIDE; |
66 virtual void DeleteForOrigin(const GURL& origin_url) OVERRIDE; | 64 virtual void DeleteForOrigin(const GURL& origin_url) OVERRIDE; |
67 virtual base::FilePath GetFilePathForTesting( | 65 virtual base::FilePath GetFilePathForTesting(const string16& origin_id) const |
68 const string16& origin_id) const OVERRIDE; | 66 OVERRIDE; |
69 | 67 |
70 // Methods called by IndexedDBDispatcherHost for quota support. | 68 // Methods called by IndexedDBDispatcherHost for quota support. |
71 void ConnectionOpened(const GURL& origin_url, WebKit::WebIDBDatabase*); | 69 void ConnectionOpened(const GURL& origin_url, WebKit::WebIDBDatabase*); |
72 void ConnectionClosed(const GURL& origin_url, WebKit::WebIDBDatabase*); | 70 void ConnectionClosed(const GURL& origin_url, WebKit::WebIDBDatabase*); |
73 void TransactionComplete(const GURL& origin_url); | 71 void TransactionComplete(const GURL& origin_url); |
74 bool WouldBeOverQuota(const GURL& origin_url, int64 additional_bytes); | 72 bool WouldBeOverQuota(const GURL& origin_url, int64 additional_bytes); |
75 bool IsOverQuota(const GURL& origin_url); | 73 bool IsOverQuota(const GURL& origin_url); |
76 | 74 |
77 quota::QuotaManagerProxy* quota_manager_proxy(); | 75 quota::QuotaManagerProxy* quota_manager_proxy(); |
78 | 76 |
77 void ForceClose(const GURL& origin_url); | |
78 base::FilePath GetFilePath(const GURL& origin_url); | |
79 bool HasOrigin(const GURL& origin_url); | |
79 base::FilePath data_path() const { return data_path_; } | 80 base::FilePath data_path() const { return data_path_; } |
80 | 81 |
81 // For unit tests allow to override the |data_path_|. | 82 // For unit tests allow to override the |data_path_|. |
82 void set_data_path_for_testing(const base::FilePath& data_path) { | 83 void set_data_path_for_testing(const base::FilePath& data_path) { |
83 data_path_ = data_path; | 84 data_path_ = data_path; |
84 } | 85 } |
85 | 86 |
86 protected: | 87 protected: |
87 virtual ~IndexedDBContextImpl(); | 88 virtual ~IndexedDBContextImpl(); |
88 | 89 |
89 private: | 90 private: |
90 FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, ClearLocalState); | 91 FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, ClearLocalState); |
91 FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, ClearSessionOnlyDatabases); | 92 FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, ClearSessionOnlyDatabases); |
92 FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, SetForceKeepSessionState); | 93 FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, SetForceKeepSessionState); |
93 FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, ForceCloseOpenDatabasesOnDelete); | 94 FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, ForceCloseOpenDatabasesOnDelete); |
94 friend class IndexedDBQuotaClientTest; | 95 friend class IndexedDBQuotaClientTest; |
95 | 96 |
96 typedef std::map<GURL, int64> OriginToSizeMap; | 97 typedef std::map<GURL, int64> OriginToSizeMap; |
97 class IndexedDBGetUsageAndQuotaCallback; | 98 class IndexedDBGetUsageAndQuotaCallback; |
98 | 99 |
99 base::FilePath GetIndexedDBFilePath(const string16& origin_id) const; | 100 base::FilePath GetIndexedDBFilePath(const string16& origin_id) const; |
100 int64 ReadUsageFromDisk(const GURL& origin_url) const; | 101 int64 ReadUsageFromDisk(const GURL& origin_url) const; |
101 void EnsureDiskUsageCacheInitialized(const GURL& origin_url); | 102 void EnsureDiskUsageCacheInitialized(const GURL& origin_url); |
102 void QueryDiskAndUpdateQuotaUsage(const GURL& origin_url); | 103 void QueryDiskAndUpdateQuotaUsage(const GURL& origin_url); |
103 void GotUsageAndQuota(const GURL& origin_url, quota::QuotaStatusCode, | 104 void GotUsageAndQuota(const GURL& origin_url, |
104 int64 usage, int64 quota); | 105 quota::QuotaStatusCode, |
106 int64 usage, | |
107 int64 quota); | |
105 void GotUpdatedQuota(const GURL& origin_url, int64 usage, int64 quota); | 108 void GotUpdatedQuota(const GURL& origin_url, int64 usage, int64 quota); |
106 void QueryAvailableQuota(const GURL& origin_url); | 109 void QueryAvailableQuota(const GURL& origin_url); |
107 | 110 |
108 std::set<GURL>* GetOriginSet(); | 111 std::set<GURL>* GetOriginSet(); |
109 bool AddToOriginSet(const GURL& origin_url) { | 112 bool AddToOriginSet(const GURL& origin_url) { |
110 return GetOriginSet()->insert(origin_url).second; | 113 return GetOriginSet()->insert(origin_url).second; |
111 } | 114 } |
112 void RemoveFromOriginSet(const GURL& origin_url) { | 115 void RemoveFromOriginSet(const GURL& origin_url) { |
113 GetOriginSet()->erase(origin_url); | 116 GetOriginSet()->erase(origin_url); |
114 } | 117 } |
115 bool IsInOriginSet(const GURL& origin_url) { | |
jsbell
2013/04/29 19:16:14
Just a minor note about the name change here (IsIn
alecflett
2013/04/29 22:28:16
oops this is somewhat leftover from an earlier ver
| |
116 std::set<GURL>* set = GetOriginSet(); | |
117 return set->find(origin_url) != set->end(); | |
118 } | |
119 | 118 |
120 // Only for testing. | 119 // Only for testing. |
121 void ResetCaches(); | 120 void ResetCaches(); |
122 | 121 |
123 scoped_ptr<WebKit::WebIDBFactory> idb_factory_; | 122 scoped_ptr<WebKit::WebIDBFactory> idb_factory_; |
124 base::FilePath data_path_; | 123 base::FilePath data_path_; |
125 // If true, nothing (not even session-only data) should be deleted on exit. | 124 // If true, nothing (not even session-only data) should be deleted on exit. |
126 bool force_keep_session_state_; | 125 bool force_keep_session_state_; |
127 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; | 126 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; |
128 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; | 127 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; |
129 scoped_ptr<std::set<GURL> > origin_set_; | 128 scoped_ptr<std::set<GURL> > origin_set_; |
130 OriginToSizeMap origin_size_map_; | 129 OriginToSizeMap origin_size_map_; |
131 OriginToSizeMap space_available_map_; | 130 OriginToSizeMap space_available_map_; |
132 typedef std::set<WebKit::WebIDBDatabase*> ConnectionSet; | 131 typedef std::set<WebKit::WebIDBDatabase*> ConnectionSet; |
133 std::map<GURL, ConnectionSet> connections_; | 132 std::map<GURL, ConnectionSet> connections_; |
134 | 133 |
135 DISALLOW_COPY_AND_ASSIGN(IndexedDBContextImpl); | 134 DISALLOW_COPY_AND_ASSIGN(IndexedDBContextImpl); |
136 }; | 135 }; |
137 | 136 |
138 } // namespace content | 137 } // namespace content |
139 | 138 |
140 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONTEXT_IMPL_H_ | 139 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONTEXT_IMPL_H_ |
OLD | NEW |