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

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

Issue 313883003: Split IndexedDBFactory into virtual base + impl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed extraneous method proto's: ReleaseBackingStore & CloseBackingStore Created 6 years, 5 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
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_IMPL_H_
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_IMPL_H_
7
8 #include "content/browser/indexed_db/indexed_db_factory.h"
9
10 namespace content {
11
12 class IndexedDBContextImpl;
13
14 class CONTENT_EXPORT IndexedDBFactoryImpl : public IndexedDBFactory {
15 public:
16 explicit IndexedDBFactoryImpl(IndexedDBContextImpl* context);
17
18 // content::IndexedDBFactory overrides:
19 virtual void ReleaseDatabase(const IndexedDBDatabase::Identifier& identifier,
20 bool forcedClose) OVERRIDE;
21
22 virtual void GetDatabaseNames(
23 scoped_refptr<IndexedDBCallbacks> callbacks,
24 const GURL& origin_url,
25 const base::FilePath& data_directory,
26 net::URLRequestContext* request_context) OVERRIDE;
27 virtual void Open(const base::string16& name,
28 const IndexedDBPendingConnection& connection,
29 net::URLRequestContext* request_context,
30 const GURL& origin_url,
31 const base::FilePath& data_directory) OVERRIDE;
32
33 virtual void DeleteDatabase(const base::string16& name,
34 net::URLRequestContext* request_context,
35 scoped_refptr<IndexedDBCallbacks> callbacks,
36 const GURL& origin_url,
37 const base::FilePath& data_directory) OVERRIDE;
38
39 virtual void HandleBackingStoreFailure(const GURL& origin_url) OVERRIDE;
40 virtual void HandleBackingStoreCorruption(
41 const GURL& origin_url,
42 const IndexedDBDatabaseError& error) OVERRIDE;
43
44 virtual std::pair<OriginDBMapIterator, OriginDBMapIterator>
45 GetOpenDatabasesForOrigin(const GURL& origin_url) const OVERRIDE;
46
47 virtual void ForceClose(const GURL& origin_url) OVERRIDE;
48
49 // Called by the IndexedDBContext destructor so the factory can do cleanup.
50 virtual void ContextDestroyed() OVERRIDE;
51
52 // Called by the IndexedDBActiveBlobRegistry.
53 virtual void ReportOutstandingBlobs(const GURL& origin_url,
54 bool blobs_outstanding) OVERRIDE;
55
56 // Called by an IndexedDBDatabase when it is actually deleted.
57 virtual void DatabaseDeleted(
58 const IndexedDBDatabase::Identifier& identifier) OVERRIDE;
59
60 virtual size_t GetConnectionCount(const GURL& origin_url) const OVERRIDE;
61
62 protected:
63 virtual ~IndexedDBFactoryImpl();
64
65 virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStore(
66 const GURL& origin_url,
67 const base::FilePath& data_directory,
68 net::URLRequestContext* request_context,
69 blink::WebIDBDataLoss* data_loss,
70 std::string* data_loss_reason,
71 bool* disk_full,
72 leveldb::Status* s) OVERRIDE;
73
74 virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStoreHelper(
75 const GURL& origin_url,
76 const base::FilePath& data_directory,
77 net::URLRequestContext* request_context,
78 blink::WebIDBDataLoss* data_loss,
79 std::string* data_loss_message,
80 bool* disk_full,
81 bool first_time,
82 leveldb::Status* s) OVERRIDE;
83
84 void ReleaseBackingStore(const GURL& origin_url, bool immediate);
85 void CloseBackingStore(const GURL& origin_url);
86 IndexedDBContextImpl* context() const { return context_; }
87
88 private:
89 FRIEND_TEST_ALL_PREFIXES(IndexedDBFactoryTest,
90 BackingStoreReleasedOnForcedClose);
91 FRIEND_TEST_ALL_PREFIXES(IndexedDBFactoryTest,
92 BackingStoreReleaseDelayedOnClose);
93 FRIEND_TEST_ALL_PREFIXES(IndexedDBFactoryTest, DatabaseFailedOpen);
94 FRIEND_TEST_ALL_PREFIXES(IndexedDBFactoryTest,
95 DeleteDatabaseClosesBackingStore);
96 FRIEND_TEST_ALL_PREFIXES(IndexedDBFactoryTest,
97 ForceCloseReleasesBackingStore);
98 FRIEND_TEST_ALL_PREFIXES(IndexedDBFactoryTest,
99 GetDatabaseNamesClosesBackingStore);
100
101 // Called internally after a database is closed, with some delay. If this
102 // factory has the last reference, it will be released.
103 void MaybeCloseBackingStore(const GURL& origin_url);
104 bool HasLastBackingStoreReference(const GURL& origin_url) const;
105
106 // Testing helpers, so unit tests don't need to grovel through internal state.
107 bool IsDatabaseOpen(const GURL& origin_url, const base::string16& name) const;
108 virtual bool IsBackingStoreOpen(const GURL& origin_url) const OVERRIDE;
109 bool IsBackingStorePendingClose(const GURL& origin_url) const;
110 void RemoveDatabaseFromMaps(const IndexedDBDatabase::Identifier& identifier);
111
112 IndexedDBContextImpl* context_;
113
114 typedef std::map<IndexedDBDatabase::Identifier, IndexedDBDatabase*>
115 IndexedDBDatabaseMap;
116 IndexedDBDatabaseMap database_map_;
117 OriginDBMap origin_dbs_;
118
119 typedef std::map<GURL, scoped_refptr<IndexedDBBackingStore> >
120 IndexedDBBackingStoreMap;
121 IndexedDBBackingStoreMap backing_store_map_;
122
123 std::set<scoped_refptr<IndexedDBBackingStore> > session_only_backing_stores_;
124 IndexedDBBackingStoreMap backing_stores_with_active_blobs_;
125 std::set<GURL> backends_opened_since_boot_;
126
127 DISALLOW_COPY_AND_ASSIGN(IndexedDBFactoryImpl);
128 };
129
130 } // namespace content
131
132 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698