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