Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: content/browser/indexed_db/indexed_db_factory.h

Issue 93873017: IndexedDBFactory now ForceCloses databases. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added multimap for more efficient origin->db mapping. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 const GURL& origin_url, 43 const GURL& origin_url,
44 const base::FilePath& data_directory); 44 const base::FilePath& data_directory);
45 45
46 void DeleteDatabase(const base::string16& name, 46 void DeleteDatabase(const base::string16& name,
47 scoped_refptr<IndexedDBCallbacks> callbacks, 47 scoped_refptr<IndexedDBCallbacks> callbacks,
48 const GURL& origin_url, 48 const GURL& origin_url,
49 const base::FilePath& data_directory); 49 const base::FilePath& data_directory);
50 50
51 void HandleBackingStoreFailure(const GURL& origin_url); 51 void HandleBackingStoreFailure(const GURL& origin_url);
52 52
53 // Iterates over all databases; for diagnostics only. 53 typedef std::multimap<GURL, IndexedDBDatabase*> OriginDbMap;
jsbell 2014/01/03 00:34:25 Nit: capitalize 'DB' or spell it out (i.e. 'Databa
cmumford 2014/01/03 21:34:01 Done.
54 std::vector<IndexedDBDatabase*> GetOpenDatabasesForOrigin( 54 typedef OriginDbMap::const_iterator OriginDbMapIterator;
55 const GURL& origin_url) const; 55 std::pair<OriginDbMapIterator, OriginDbMapIterator>
56 GetOpenDatabasesForOrigin(const GURL& origin_url) const;
56 57
57 // Called by IndexedDBContext after all connections are closed, to 58 // Called by IndexedDBContext after all connections are closed, to
58 // ensure the backing store closed immediately. 59 // ensure the backing store closed immediately.
59 void ForceClose(const GURL& origin_url); 60 void ForceClose(const GURL& origin_url);
60 61
61 // Called by the IndexedDBContext destructor so the factory can do cleanup. 62 // Called by the IndexedDBContext destructor so the factory can do cleanup.
62 void ContextDestroyed(); 63 void ContextDestroyed();
63 64
64 // Called by an IndexedDBDatabase when it is actually deleted. 65 // Called by an IndexedDBDatabase when it is actually deleted.
65 void DatabaseDeleted(const IndexedDBDatabase::Identifier& identifier); 66 void DatabaseDeleted(const IndexedDBDatabase::Identifier& identifier);
66 67
68 size_t GetConnectionCount(const GURL& origin_url) const;
69
67 protected: 70 protected:
68 friend class base::RefCountedThreadSafe<IndexedDBFactory>; 71 friend class base::RefCountedThreadSafe<IndexedDBFactory>;
69 72
70 virtual ~IndexedDBFactory(); 73 virtual ~IndexedDBFactory();
71 74
72 virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStore( 75 virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStore(
73 const GURL& origin_url, 76 const GURL& origin_url,
74 const base::FilePath& data_directory, 77 const base::FilePath& data_directory,
75 blink::WebIDBDataLoss* data_loss, 78 blink::WebIDBDataLoss* data_loss,
76 std::string* data_loss_reason, 79 std::string* data_loss_reason,
(...skipping 20 matching lines...) Expand all
97 // Called internally after a database is closed, with some delay. If this 100 // Called internally after a database is closed, with some delay. If this
98 // factory has the last reference, it will be released. 101 // factory has the last reference, it will be released.
99 void MaybeCloseBackingStore(const GURL& origin_url); 102 void MaybeCloseBackingStore(const GURL& origin_url);
100 bool HasLastBackingStoreReference(const GURL& origin_url) const; 103 bool HasLastBackingStoreReference(const GURL& origin_url) const;
101 104
102 // Testing helpers, so unit tests don't need to grovel through internal state. 105 // Testing helpers, so unit tests don't need to grovel through internal state.
103 bool IsDatabaseOpen(const GURL& origin_url, 106 bool IsDatabaseOpen(const GURL& origin_url,
104 const base::string16& name) const; 107 const base::string16& name) const;
105 bool IsBackingStoreOpen(const GURL& origin_url) const; 108 bool IsBackingStoreOpen(const GURL& origin_url) const;
106 bool IsBackingStorePendingClose(const GURL& origin_url) const; 109 bool IsBackingStorePendingClose(const GURL& origin_url) const;
110 void RemoveDatabaseFromMaps(const IndexedDBDatabase::Identifier& identifier);
107 111
108 IndexedDBContextImpl* context_; 112 IndexedDBContextImpl* context_;
109 113
110 typedef std::map<IndexedDBDatabase::Identifier, 114 typedef std::map<IndexedDBDatabase::Identifier,
111 IndexedDBDatabase*> IndexedDBDatabaseMap; 115 IndexedDBDatabase*> IndexedDBDatabaseMap;
112 IndexedDBDatabaseMap database_map_; 116 IndexedDBDatabaseMap database_map_;
117 OriginDbMap origin_dbs_;
113 118
114 typedef std::map<GURL, scoped_refptr<IndexedDBBackingStore> > 119 typedef std::map<GURL, scoped_refptr<IndexedDBBackingStore> >
115 IndexedDBBackingStoreMap; 120 IndexedDBBackingStoreMap;
116 IndexedDBBackingStoreMap backing_store_map_; 121 IndexedDBBackingStoreMap backing_store_map_;
117 122
118 std::set<scoped_refptr<IndexedDBBackingStore> > session_only_backing_stores_; 123 std::set<scoped_refptr<IndexedDBBackingStore> > session_only_backing_stores_;
119 }; 124 };
120 125
121 } // namespace content 126 } // namespace content
122 127
123 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_H_ 128 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698