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> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "content/browser/browser_main_loop.h" |
16 #include "content/browser/indexed_db/webidbfactory_impl.h" | 17 #include "content/browser/indexed_db/webidbfactory_impl.h" |
17 #include "content/public/browser/indexed_db_context.h" | 18 #include "content/public/browser/indexed_db_context.h" |
18 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
19 #include "webkit/common/quota/quota_types.h" | 20 #include "webkit/common/quota/quota_types.h" |
20 | 21 |
21 class GURL; | 22 class GURL; |
22 | 23 |
23 namespace base { | 24 namespace base { |
24 class FilePath; | 25 class FilePath; |
25 class MessageLoopProxy; | 26 class SequencedTaskRunner; |
26 } | 27 } |
27 | 28 |
28 namespace quota { | 29 namespace quota { |
29 class QuotaManagerProxy; | 30 class QuotaManagerProxy; |
30 class SpecialStoragePolicy; | 31 class SpecialStoragePolicy; |
31 } | 32 } |
32 | 33 |
33 namespace content { | 34 namespace content { |
34 | 35 |
35 class WebIDBDatabaseImpl; | 36 class WebIDBDatabaseImpl; |
36 | 37 |
37 class CONTENT_EXPORT IndexedDBContextImpl | 38 class CONTENT_EXPORT IndexedDBContextImpl |
38 : NON_EXPORTED_BASE(public IndexedDBContext) { | 39 : NON_EXPORTED_BASE(public IndexedDBContext) { |
39 public: | 40 public: |
40 // If |data_path| is empty, nothing will be saved to disk. | 41 // If |data_path| is empty, nothing will be saved to disk. |
41 IndexedDBContextImpl(const base::FilePath& data_path, | 42 IndexedDBContextImpl(const base::FilePath& data_path, |
42 quota::SpecialStoragePolicy* special_storage_policy, | 43 quota::SpecialStoragePolicy* special_storage_policy, |
43 quota::QuotaManagerProxy* quota_manager_proxy, | 44 quota::QuotaManagerProxy* quota_manager_proxy, |
44 base::MessageLoopProxy* webkit_thread_loop); | 45 base::SequencedTaskRunner* task_runner); |
45 | 46 |
46 WebIDBFactoryImpl* GetIDBFactory(); | 47 WebIDBFactoryImpl* GetIDBFactory(); |
47 | 48 |
48 // The indexed db directory. | 49 // The indexed db directory. |
49 static const base::FilePath::CharType kIndexedDBDirectory[]; | 50 static const base::FilePath::CharType kIndexedDBDirectory[]; |
50 | 51 |
51 // Disables the exit-time deletion of session-only data. | 52 // Disables the exit-time deletion of session-only data. |
52 void SetForceKeepSessionState() { force_keep_session_state_ = true; } | 53 void SetForceKeepSessionState() { force_keep_session_state_ = true; } |
53 | 54 |
54 // IndexedDBContext implementation: | 55 // IndexedDBContext implementation: |
| 56 virtual base::TaskRunner* TaskRunner() const OVERRIDE; |
55 virtual std::vector<GURL> GetAllOrigins() OVERRIDE; | 57 virtual std::vector<GURL> GetAllOrigins() OVERRIDE; |
56 virtual std::vector<IndexedDBInfo> GetAllOriginsInfo() OVERRIDE; | 58 virtual std::vector<IndexedDBInfo> GetAllOriginsInfo() OVERRIDE; |
57 virtual int64 GetOriginDiskUsage(const GURL& origin_url) OVERRIDE; | 59 virtual int64 GetOriginDiskUsage(const GURL& origin_url) OVERRIDE; |
58 virtual base::Time GetOriginLastModified(const GURL& origin_url) OVERRIDE; | 60 virtual base::Time GetOriginLastModified(const GURL& origin_url) OVERRIDE; |
59 virtual void DeleteForOrigin(const GURL& origin_url) OVERRIDE; | 61 virtual void DeleteForOrigin(const GURL& origin_url) OVERRIDE; |
60 virtual base::FilePath GetFilePathForTesting( | 62 virtual base::FilePath GetFilePathForTesting( |
61 const std::string& origin_id) const OVERRIDE; | 63 const std::string& origin_id) const OVERRIDE; |
| 64 virtual void SetTaskRunnerForTesting( |
| 65 base::SequencedTaskRunner* task_runner) OVERRIDE; |
62 | 66 |
63 // Methods called by IndexedDBDispatcherHost for quota support. | 67 // Methods called by IndexedDBDispatcherHost for quota support. |
64 void ConnectionOpened(const GURL& origin_url, WebIDBDatabaseImpl* db); | 68 void ConnectionOpened(const GURL& origin_url, WebIDBDatabaseImpl* db); |
65 void ConnectionClosed(const GURL& origin_url, WebIDBDatabaseImpl* db); | 69 void ConnectionClosed(const GURL& origin_url, WebIDBDatabaseImpl* db); |
66 void TransactionComplete(const GURL& origin_url); | 70 void TransactionComplete(const GURL& origin_url); |
67 bool WouldBeOverQuota(const GURL& origin_url, int64 additional_bytes); | 71 bool WouldBeOverQuota(const GURL& origin_url, int64 additional_bytes); |
68 bool IsOverQuota(const GURL& origin_url); | 72 bool IsOverQuota(const GURL& origin_url); |
69 | 73 |
70 quota::QuotaManagerProxy* quota_manager_proxy(); | 74 quota::QuotaManagerProxy* quota_manager_proxy(); |
71 | 75 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 void GotUpdatedQuota(const GURL& origin_url, int64 usage, int64 quota); | 110 void GotUpdatedQuota(const GURL& origin_url, int64 usage, int64 quota); |
107 void QueryAvailableQuota(const GURL& origin_url); | 111 void QueryAvailableQuota(const GURL& origin_url); |
108 | 112 |
109 std::set<GURL>* GetOriginSet(); | 113 std::set<GURL>* GetOriginSet(); |
110 bool AddToOriginSet(const GURL& origin_url) { | 114 bool AddToOriginSet(const GURL& origin_url) { |
111 return GetOriginSet()->insert(origin_url).second; | 115 return GetOriginSet()->insert(origin_url).second; |
112 } | 116 } |
113 void RemoveFromOriginSet(const GURL& origin_url) { | 117 void RemoveFromOriginSet(const GURL& origin_url) { |
114 GetOriginSet()->erase(origin_url); | 118 GetOriginSet()->erase(origin_url); |
115 } | 119 } |
| 120 |
116 // Only for testing. | 121 // Only for testing. |
117 void ResetCaches(); | 122 void ResetCaches(); |
118 | 123 |
119 scoped_ptr<WebIDBFactoryImpl> idb_factory_; | 124 scoped_ptr<WebIDBFactoryImpl> idb_factory_; |
120 base::FilePath data_path_; | 125 base::FilePath data_path_; |
121 // If true, nothing (not even session-only data) should be deleted on exit. | 126 // If true, nothing (not even session-only data) should be deleted on exit. |
122 bool force_keep_session_state_; | 127 bool force_keep_session_state_; |
123 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; | 128 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; |
124 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; | 129 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; |
| 130 base::SequencedTaskRunner* task_runner_; |
125 scoped_ptr<std::set<GURL> > origin_set_; | 131 scoped_ptr<std::set<GURL> > origin_set_; |
126 OriginToSizeMap origin_size_map_; | 132 OriginToSizeMap origin_size_map_; |
127 OriginToSizeMap space_available_map_; | 133 OriginToSizeMap space_available_map_; |
128 typedef std::set<WebIDBDatabaseImpl*> ConnectionSet; | 134 typedef std::set<WebIDBDatabaseImpl*> ConnectionSet; |
129 std::map<GURL, ConnectionSet> connections_; | 135 std::map<GURL, ConnectionSet> connections_; |
130 | 136 |
131 DISALLOW_COPY_AND_ASSIGN(IndexedDBContextImpl); | 137 DISALLOW_COPY_AND_ASSIGN(IndexedDBContextImpl); |
132 }; | 138 }; |
133 | 139 |
134 } // namespace content | 140 } // namespace content |
135 | 141 |
136 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONTEXT_IMPL_H_ | 142 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONTEXT_IMPL_H_ |
OLD | NEW |