OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_FACTORY_H_ | 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_H_ |
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_H_ | 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
15 #include "content/browser/indexed_db/indexed_db_callbacks.h" | 15 #include "content/browser/indexed_db/indexed_db_callbacks.h" |
16 #include "content/browser/indexed_db/indexed_db_database.h" | 16 #include "content/browser/indexed_db/indexed_db_database.h" |
17 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" | 17 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" |
18 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
19 #include "url/gurl.h" | 19 #include "url/gurl.h" |
20 | 20 |
21 namespace base { | |
22 class TaskRunner; | |
23 } | |
24 | |
21 namespace content { | 25 namespace content { |
22 | 26 |
23 class IndexedDBBackingStore; | 27 class IndexedDBBackingStore; |
24 class IndexedDBContextImpl; | 28 class IndexedDBContextImpl; |
25 struct IndexedDBPendingConnection; | 29 struct IndexedDBPendingConnection; |
26 | 30 |
27 class CONTENT_EXPORT IndexedDBFactory | 31 class CONTENT_EXPORT IndexedDBFactory |
28 : NON_EXPORTED_BASE(public base::RefCountedThreadSafe<IndexedDBFactory>) { | 32 : NON_EXPORTED_BASE(public base::RefCountedThreadSafe<IndexedDBFactory>) { |
29 public: | 33 public: |
30 typedef std::multimap<GURL, IndexedDBDatabase*> OriginDBMap; | 34 typedef std::multimap<GURL, IndexedDBDatabase*> OriginDBMap; |
31 typedef OriginDBMap::const_iterator OriginDBMapIterator; | 35 typedef OriginDBMap::const_iterator OriginDBMapIterator; |
32 | 36 |
33 explicit IndexedDBFactory(IndexedDBContextImpl* context); | 37 explicit IndexedDBFactory(IndexedDBContextImpl* context); |
34 | 38 |
35 // Notifications from weak pointers. | 39 // Notifications from weak pointers. |
36 void ReleaseDatabase(const IndexedDBDatabase::Identifier& identifier, | 40 void ReleaseDatabase(const IndexedDBDatabase::Identifier& identifier, |
37 bool forcedClose); | 41 bool forcedClose); |
38 | 42 |
39 void GetDatabaseNames(scoped_refptr<IndexedDBCallbacks> callbacks, | 43 void GetDatabaseNames(scoped_refptr<IndexedDBCallbacks> callbacks, |
40 const GURL& origin_url, | 44 const GURL& origin_url, |
41 const base::FilePath& data_directory); | 45 const base::FilePath& data_directory, |
46 base::TaskRunner* task_runner); | |
42 void Open(const base::string16& name, | 47 void Open(const base::string16& name, |
43 const IndexedDBPendingConnection& connection, | 48 const IndexedDBPendingConnection& connection, |
44 const GURL& origin_url, | 49 const GURL& origin_url, |
45 const base::FilePath& data_directory); | 50 const base::FilePath& data_directory, |
51 base::TaskRunner* task_runner); | |
46 | 52 |
47 void DeleteDatabase(const base::string16& name, | 53 void DeleteDatabase(const base::string16& name, |
48 scoped_refptr<IndexedDBCallbacks> callbacks, | 54 scoped_refptr<IndexedDBCallbacks> callbacks, |
49 const GURL& origin_url, | 55 const GURL& origin_url, |
50 const base::FilePath& data_directory); | 56 const base::FilePath& data_directory, |
57 base::TaskRunner* task_runner); | |
51 | 58 |
52 void HandleBackingStoreFailure(const GURL& origin_url); | 59 void HandleBackingStoreFailure(const GURL& origin_url); |
53 | 60 |
54 std::pair<OriginDBMapIterator, OriginDBMapIterator> GetOpenDatabasesForOrigin( | 61 std::pair<OriginDBMapIterator, OriginDBMapIterator> GetOpenDatabasesForOrigin( |
55 const GURL& origin_url) const; | 62 const GURL& origin_url) const; |
56 | 63 |
57 // Called by IndexedDBContext after all connections are closed, to | 64 // Called by IndexedDBContext after all connections are closed, to |
58 // ensure the backing store closed immediately. | 65 // ensure the backing store closed immediately. |
59 void ForceClose(const GURL& origin_url); | 66 void ForceClose(const GURL& origin_url); |
60 | 67 |
61 // Called by the IndexedDBContext destructor so the factory can do cleanup. | 68 // Called by the IndexedDBContext destructor so the factory can do cleanup. |
62 void ContextDestroyed(); | 69 void ContextDestroyed(); |
63 | 70 |
71 // Called by the IndexedDBActiveBlobRegistry. | |
72 virtual void ReportOutstandingBlobs(const GURL& origin_url, | |
73 bool blobs_outstanding); | |
74 | |
64 // Called by an IndexedDBDatabase when it is actually deleted. | 75 // Called by an IndexedDBDatabase when it is actually deleted. |
65 void DatabaseDeleted(const IndexedDBDatabase::Identifier& identifier); | 76 void DatabaseDeleted(const IndexedDBDatabase::Identifier& identifier); |
66 | 77 |
67 size_t GetConnectionCount(const GURL& origin_url) const; | 78 size_t GetConnectionCount(const GURL& origin_url) const; |
68 | 79 |
69 protected: | 80 protected: |
70 friend class base::RefCountedThreadSafe<IndexedDBFactory>; | 81 friend class base::RefCountedThreadSafe<IndexedDBFactory>; |
71 | 82 |
72 virtual ~IndexedDBFactory(); | 83 virtual ~IndexedDBFactory(); |
73 | 84 |
74 virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStore( | 85 virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStore( |
75 const GURL& origin_url, | 86 const GURL& origin_url, |
76 const base::FilePath& data_directory, | 87 const base::FilePath& data_directory, |
77 blink::WebIDBDataLoss* data_loss, | 88 blink::WebIDBDataLoss* data_loss, |
78 std::string* data_loss_reason, | 89 std::string* data_loss_reason, |
79 bool* disk_full); | 90 bool* disk_full, |
91 base::TaskRunner* task_runner); | |
jsbell
2014/03/25 17:01:17
Since the factory has a context reference, do we n
ericu
2014/04/02 22:27:23
I pulled it out of the factory param lists. I did
jsbell
2014/04/02 22:32:42
That's cool. I hadn't considered injection/testabi
| |
80 | 92 |
81 void ReleaseBackingStore(const GURL& origin_url, bool immediate); | 93 void ReleaseBackingStore(const GURL& origin_url, bool immediate); |
82 void CloseBackingStore(const GURL& origin_url); | 94 void CloseBackingStore(const GURL& origin_url); |
83 | 95 |
84 private: | 96 private: |
85 FRIEND_TEST_ALL_PREFIXES(IndexedDBFactoryTest, | 97 FRIEND_TEST_ALL_PREFIXES(IndexedDBFactoryTest, |
86 BackingStoreReleasedOnForcedClose); | 98 BackingStoreReleasedOnForcedClose); |
87 FRIEND_TEST_ALL_PREFIXES(IndexedDBFactoryTest, | 99 FRIEND_TEST_ALL_PREFIXES(IndexedDBFactoryTest, |
88 BackingStoreReleaseDelayedOnClose); | 100 BackingStoreReleaseDelayedOnClose); |
89 FRIEND_TEST_ALL_PREFIXES(IndexedDBFactoryTest, DatabaseFailedOpen); | 101 FRIEND_TEST_ALL_PREFIXES(IndexedDBFactoryTest, DatabaseFailedOpen); |
(...skipping 23 matching lines...) Expand all Loading... | |
113 typedef std::map<IndexedDBDatabase::Identifier, | 125 typedef std::map<IndexedDBDatabase::Identifier, |
114 IndexedDBDatabase*> IndexedDBDatabaseMap; | 126 IndexedDBDatabase*> IndexedDBDatabaseMap; |
115 IndexedDBDatabaseMap database_map_; | 127 IndexedDBDatabaseMap database_map_; |
116 OriginDBMap origin_dbs_; | 128 OriginDBMap origin_dbs_; |
117 | 129 |
118 typedef std::map<GURL, scoped_refptr<IndexedDBBackingStore> > | 130 typedef std::map<GURL, scoped_refptr<IndexedDBBackingStore> > |
119 IndexedDBBackingStoreMap; | 131 IndexedDBBackingStoreMap; |
120 IndexedDBBackingStoreMap backing_store_map_; | 132 IndexedDBBackingStoreMap backing_store_map_; |
121 | 133 |
122 std::set<scoped_refptr<IndexedDBBackingStore> > session_only_backing_stores_; | 134 std::set<scoped_refptr<IndexedDBBackingStore> > session_only_backing_stores_; |
135 IndexedDBBackingStoreMap backing_stores_with_active_blobs_; | |
123 }; | 136 }; |
124 | 137 |
125 } // namespace content | 138 } // namespace content |
126 | 139 |
127 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_H_ | 140 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_H_ |
OLD | NEW |