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

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

Issue 18023022: Blob support for IDB [Chromium] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: small cleanup Created 7 years 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 | Annotate | Revision Log
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
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
25 namespace net {
26 class URLRequestContext;
27 }
28
21 namespace content { 29 namespace content {
22 30
23 class IndexedDBBackingStore; 31 class IndexedDBBackingStore;
24 class IndexedDBContextImpl; 32 class IndexedDBContextImpl;
25 33
26 class CONTENT_EXPORT IndexedDBFactory 34 class CONTENT_EXPORT IndexedDBFactory
27 : NON_EXPORTED_BASE(public base::RefCountedThreadSafe<IndexedDBFactory>) { 35 : NON_EXPORTED_BASE(public base::RefCountedThreadSafe<IndexedDBFactory>) {
28 public: 36 public:
29 explicit IndexedDBFactory(IndexedDBContextImpl* context); 37 explicit IndexedDBFactory(IndexedDBContextImpl* context);
30 38
31 // Notifications from weak pointers.
32 void ReleaseDatabase(const IndexedDBDatabase::Identifier& identifier, 39 void ReleaseDatabase(const IndexedDBDatabase::Identifier& identifier,
33 const GURL& origin_url, 40 const GURL& origin_url,
34 bool forcedClose); 41 bool forcedClose);
35 42
36 void GetDatabaseNames(scoped_refptr<IndexedDBCallbacks> callbacks, 43 void GetDatabaseNames(scoped_refptr<IndexedDBCallbacks> callbacks,
37 const GURL& origin_url, 44 const GURL& origin_url,
38 const base::FilePath& data_directory); 45 const base::FilePath& data_directory,
46 base::TaskRunner* task_runner);
39 void Open(const string16& name, 47 void Open(const string16& name,
40 int64 version, 48 int64 version,
49 net::URLRequestContext* request_context,
41 int64 transaction_id, 50 int64 transaction_id,
42 scoped_refptr<IndexedDBCallbacks> callbacks, 51 scoped_refptr<IndexedDBCallbacks> callbacks,
43 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, 52 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks,
44 const GURL& origin_url, 53 const GURL& origin_url,
45 const base::FilePath& data_directory); 54 const base::FilePath& data_directory,
55 int child_process_id,
56 base::TaskRunner* task_runner);
46 57
47 void DeleteDatabase(const string16& name, 58 void DeleteDatabase(const string16& name,
59 net::URLRequestContext* request_context,
48 scoped_refptr<IndexedDBCallbacks> callbacks, 60 scoped_refptr<IndexedDBCallbacks> callbacks,
49 const GURL& origin_url, 61 const GURL& origin_url,
50 const base::FilePath& data_directory); 62 const base::FilePath& data_directory,
63 base::TaskRunner* task_runner);
51 64
52 void HandleBackingStoreFailure(const GURL& origin_url); 65 void HandleBackingStoreFailure(const GURL& origin_url);
53 66
54 // Iterates over all databases; for diagnostics only. 67 // Iterates over all databases; for diagnostics only.
55 std::vector<IndexedDBDatabase*> GetOpenDatabasesForOrigin( 68 std::vector<IndexedDBDatabase*> GetOpenDatabasesForOrigin(
56 const GURL& origin_url) const; 69 const GURL& origin_url) const;
57 70
58 bool IsBackingStoreOpenForTesting(const GURL& origin_url) const; 71 bool IsBackingStoreOpenForTesting(const GURL& origin_url) const;
59 72
60 // Called by the IndexedDBContext destructor so the factory can do cleanup. 73 // Called by the IndexedDBContext destructor so the factory can do cleanup.
61 void ContextDestroyed(); 74 void ContextDestroyed();
62 75
76 // Called by the IndexedDBActiveBlobRegistry.
77 void ReportOutstandingBlobs(const GURL& origin_url, bool blobs_outstanding);
78
63 protected: 79 protected:
64 friend class base::RefCountedThreadSafe<IndexedDBFactory>; 80 friend class base::RefCountedThreadSafe<IndexedDBFactory>;
65 81
66 virtual ~IndexedDBFactory(); 82 virtual ~IndexedDBFactory();
67 83
68 virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStore( 84 virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStore(
69 const GURL& origin_url, 85 const GURL& origin_url,
70 const base::FilePath& data_directory, 86 const base::FilePath& data_directory,
87 net::URLRequestContext* request_context,
71 blink::WebIDBDataLoss* data_loss, 88 blink::WebIDBDataLoss* data_loss,
72 std::string* data_loss_reason, 89 std::string* data_loss_reason,
73 bool* disk_full); 90 bool* disk_full,
91 base::TaskRunner* task_runner);
92
93 virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStoreHelper(
94 const GURL& origin_url,
95 const base::FilePath& data_directory,
96 net::URLRequestContext* request_context,
97 blink::WebIDBDataLoss* data_loss,
98 std::string* data_loss_message,
99 bool* disk_full,
100 base::TaskRunner* task_runner,
101 bool first_time);
74 102
75 void ReleaseBackingStore(const GURL& origin_url, bool immediate); 103 void ReleaseBackingStore(const GURL& origin_url, bool immediate);
76 void CloseBackingStore(const GURL& origin_url); 104 void CloseBackingStore(const GURL& origin_url);
105 IndexedDBContextImpl* context() const { return context_; }
77 106
78 private: 107 private:
79 // Called internally after a database is closed, with some delay. If this 108 // Called internally after a database is closed, with some delay. If this
80 // factory has the last reference, it will be released. 109 // factory has the last reference, it will be released.
81 void MaybeCloseBackingStore(const GURL& origin_url); 110 void MaybeCloseBackingStore(const GURL& origin_url);
82 bool HasLastBackingStoreReference(const GURL& origin_url) const; 111 bool HasLastBackingStoreReference(const GURL& origin_url) const;
83 112
84 IndexedDBContextImpl* context_; 113 IndexedDBContextImpl* context_;
85 114
86 typedef std::map<IndexedDBDatabase::Identifier, 115 typedef std::map<IndexedDBDatabase::Identifier,
87 scoped_refptr<IndexedDBDatabase> > IndexedDBDatabaseMap; 116 scoped_refptr<IndexedDBDatabase> > IndexedDBDatabaseMap;
88 IndexedDBDatabaseMap database_map_; 117 IndexedDBDatabaseMap database_map_;
89 118
90 typedef std::map<GURL, scoped_refptr<IndexedDBBackingStore> > 119 typedef std::map<GURL, scoped_refptr<IndexedDBBackingStore> >
91 IndexedDBBackingStoreMap; 120 IndexedDBBackingStoreMap;
92 IndexedDBBackingStoreMap backing_store_map_; 121 IndexedDBBackingStoreMap backing_store_map_;
93 122
94 std::set<scoped_refptr<IndexedDBBackingStore> > session_only_backing_stores_; 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_;
95 }; 126 };
96 127
97 } // namespace content 128 } // namespace content
98 129
99 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_H_ 130 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698