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 <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
8 #include <map> | 11 #include <map> |
9 #include <set> | 12 #include <set> |
10 #include <string> | 13 #include <string> |
11 #include <vector> | 14 #include <vector> |
12 | 15 |
13 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
14 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
15 #include "base/gtest_prod_util.h" | 18 #include "base/gtest_prod_util.h" |
| 19 #include "base/macros.h" |
16 #include "base/memory/scoped_ptr.h" | 20 #include "base/memory/scoped_ptr.h" |
17 #include "content/browser/browser_main_loop.h" | 21 #include "content/browser/browser_main_loop.h" |
18 #include "content/browser/indexed_db/indexed_db_factory.h" | 22 #include "content/browser/indexed_db/indexed_db_factory.h" |
19 #include "content/public/browser/indexed_db_context.h" | 23 #include "content/public/browser/indexed_db_context.h" |
20 #include "storage/common/quota/quota_types.h" | 24 #include "storage/common/quota/quota_types.h" |
21 #include "url/gurl.h" | 25 #include "url/gurl.h" |
22 | 26 |
23 class GURL; | 27 class GURL; |
24 | 28 |
25 namespace base { | 29 namespace base { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 base::SequencedTaskRunner* task_runner); | 63 base::SequencedTaskRunner* task_runner); |
60 | 64 |
61 IndexedDBFactory* GetIDBFactory(); | 65 IndexedDBFactory* GetIDBFactory(); |
62 | 66 |
63 // Disables the exit-time deletion of session-only data. | 67 // Disables the exit-time deletion of session-only data. |
64 void SetForceKeepSessionState() { force_keep_session_state_ = true; } | 68 void SetForceKeepSessionState() { force_keep_session_state_ = true; } |
65 | 69 |
66 // IndexedDBContext implementation: | 70 // IndexedDBContext implementation: |
67 base::SequencedTaskRunner* TaskRunner() const override; | 71 base::SequencedTaskRunner* TaskRunner() const override; |
68 std::vector<IndexedDBInfo> GetAllOriginsInfo() override; | 72 std::vector<IndexedDBInfo> GetAllOriginsInfo() override; |
69 int64 GetOriginDiskUsage(const GURL& origin_url) override; | 73 int64_t GetOriginDiskUsage(const GURL& origin_url) override; |
70 void DeleteForOrigin(const GURL& origin_url) override; | 74 void DeleteForOrigin(const GURL& origin_url) override; |
71 void CopyOriginData(const GURL& origin_url, | 75 void CopyOriginData(const GURL& origin_url, |
72 IndexedDBContext* dest_context) override; | 76 IndexedDBContext* dest_context) override; |
73 base::FilePath GetFilePathForTesting( | 77 base::FilePath GetFilePathForTesting( |
74 const std::string& origin_id) const override; | 78 const std::string& origin_id) const override; |
75 void SetTaskRunnerForTesting(base::SequencedTaskRunner* task_runner) override; | 79 void SetTaskRunnerForTesting(base::SequencedTaskRunner* task_runner) override; |
76 | 80 |
77 // Methods called by IndexedDBDispatcherHost for quota support. | 81 // Methods called by IndexedDBDispatcherHost for quota support. |
78 void ConnectionOpened(const GURL& origin_url, IndexedDBConnection* db); | 82 void ConnectionOpened(const GURL& origin_url, IndexedDBConnection* db); |
79 void ConnectionClosed(const GURL& origin_url, IndexedDBConnection* db); | 83 void ConnectionClosed(const GURL& origin_url, IndexedDBConnection* db); |
80 void TransactionComplete(const GURL& origin_url); | 84 void TransactionComplete(const GURL& origin_url); |
81 void DatabaseDeleted(const GURL& origin_url); | 85 void DatabaseDeleted(const GURL& origin_url); |
82 bool WouldBeOverQuota(const GURL& origin_url, int64 additional_bytes); | 86 bool WouldBeOverQuota(const GURL& origin_url, int64_t additional_bytes); |
83 bool IsOverQuota(const GURL& origin_url); | 87 bool IsOverQuota(const GURL& origin_url); |
84 | 88 |
85 storage::QuotaManagerProxy* quota_manager_proxy(); | 89 storage::QuotaManagerProxy* quota_manager_proxy(); |
86 | 90 |
87 std::vector<GURL> GetAllOrigins(); | 91 std::vector<GURL> GetAllOrigins(); |
88 base::Time GetOriginLastModified(const GURL& origin_url); | 92 base::Time GetOriginLastModified(const GURL& origin_url); |
89 base::ListValue* GetAllOriginsDetails(); | 93 base::ListValue* GetAllOriginsDetails(); |
90 | 94 |
91 // ForceClose takes a value rather than a reference since it may release the | 95 // ForceClose takes a value rather than a reference since it may release the |
92 // owning object. | 96 // owning object. |
(...skipping 20 matching lines...) Expand all Loading... |
113 protected: | 117 protected: |
114 ~IndexedDBContextImpl() override; | 118 ~IndexedDBContextImpl() override; |
115 | 119 |
116 private: | 120 private: |
117 FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, ClearLocalState); | 121 FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, ClearLocalState); |
118 FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, ClearSessionOnlyDatabases); | 122 FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, ClearSessionOnlyDatabases); |
119 FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, SetForceKeepSessionState); | 123 FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, SetForceKeepSessionState); |
120 FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, ForceCloseOpenDatabasesOnDelete); | 124 FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, ForceCloseOpenDatabasesOnDelete); |
121 friend class IndexedDBQuotaClientTest; | 125 friend class IndexedDBQuotaClientTest; |
122 | 126 |
123 typedef std::map<GURL, int64> OriginToSizeMap; | 127 typedef std::map<GURL, int64_t> OriginToSizeMap; |
124 class IndexedDBGetUsageAndQuotaCallback; | 128 class IndexedDBGetUsageAndQuotaCallback; |
125 | 129 |
126 base::FilePath GetBlobPath(const std::string& origin_id) const; | 130 base::FilePath GetBlobPath(const std::string& origin_id) const; |
127 base::FilePath GetLevelDBPath(const GURL& origin_url) const; | 131 base::FilePath GetLevelDBPath(const GURL& origin_url) const; |
128 base::FilePath GetLevelDBPath(const std::string& origin_id) const; | 132 base::FilePath GetLevelDBPath(const std::string& origin_id) const; |
129 int64 ReadUsageFromDisk(const GURL& origin_url) const; | 133 int64_t ReadUsageFromDisk(const GURL& origin_url) const; |
130 void EnsureDiskUsageCacheInitialized(const GURL& origin_url); | 134 void EnsureDiskUsageCacheInitialized(const GURL& origin_url); |
131 void QueryDiskAndUpdateQuotaUsage(const GURL& origin_url); | 135 void QueryDiskAndUpdateQuotaUsage(const GURL& origin_url); |
132 void GotUsageAndQuota(const GURL& origin_url, | 136 void GotUsageAndQuota(const GURL& origin_url, |
133 storage::QuotaStatusCode, | 137 storage::QuotaStatusCode, |
134 int64 usage, | 138 int64_t usage, |
135 int64 quota); | 139 int64_t quota); |
136 void GotUpdatedQuota(const GURL& origin_url, int64 usage, int64 quota); | 140 void GotUpdatedQuota(const GURL& origin_url, int64_t usage, int64_t quota); |
137 void QueryAvailableQuota(const GURL& origin_url); | 141 void QueryAvailableQuota(const GURL& origin_url); |
138 | 142 |
139 std::set<GURL>* GetOriginSet(); | 143 std::set<GURL>* GetOriginSet(); |
140 bool AddToOriginSet(const GURL& origin_url) { | 144 bool AddToOriginSet(const GURL& origin_url) { |
141 return GetOriginSet()->insert(origin_url).second; | 145 return GetOriginSet()->insert(origin_url).second; |
142 } | 146 } |
143 void RemoveFromOriginSet(const GURL& origin_url) { | 147 void RemoveFromOriginSet(const GURL& origin_url) { |
144 GetOriginSet()->erase(origin_url); | 148 GetOriginSet()->erase(origin_url); |
145 } | 149 } |
146 | 150 |
(...skipping 10 matching lines...) Expand all Loading... |
157 scoped_ptr<std::set<GURL> > origin_set_; | 161 scoped_ptr<std::set<GURL> > origin_set_; |
158 OriginToSizeMap origin_size_map_; | 162 OriginToSizeMap origin_size_map_; |
159 OriginToSizeMap space_available_map_; | 163 OriginToSizeMap space_available_map_; |
160 | 164 |
161 DISALLOW_COPY_AND_ASSIGN(IndexedDBContextImpl); | 165 DISALLOW_COPY_AND_ASSIGN(IndexedDBContextImpl); |
162 }; | 166 }; |
163 | 167 |
164 } // namespace content | 168 } // namespace content |
165 | 169 |
166 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONTEXT_IMPL_H_ | 170 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONTEXT_IMPL_H_ |
OLD | NEW |