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/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
16 #include "content/browser/indexed_db/indexed_db_callbacks.h" | 16 #include "content/browser/indexed_db/indexed_db_callbacks.h" |
17 #include "content/browser/indexed_db/indexed_db_database.h" | 17 #include "content/browser/indexed_db/indexed_db_database.h" |
18 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" | 18 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" |
19 #include "content/browser/indexed_db/indexed_db_factory.h" | 19 #include "content/browser/indexed_db/indexed_db_factory.h" |
20 #include "content/common/content_export.h" | 20 #include "content/common/content_export.h" |
21 | 21 |
| 22 namespace base { |
| 23 class TaskRunner; |
| 24 } |
| 25 |
| 26 namespace net { |
| 27 class URLRequestContext; |
| 28 } |
| 29 |
22 namespace content { | 30 namespace content { |
23 | 31 |
24 class IndexedDBBackingStore; | 32 class IndexedDBBackingStore; |
25 | 33 |
26 class CONTENT_EXPORT IndexedDBFactory | 34 class CONTENT_EXPORT IndexedDBFactory |
27 : NON_EXPORTED_BASE(public base::RefCounted<IndexedDBFactory>) { | 35 : NON_EXPORTED_BASE(public base::RefCounted<IndexedDBFactory>) { |
28 public: | 36 public: |
29 IndexedDBFactory(); | 37 IndexedDBFactory(); |
30 | 38 |
31 // Notifications from weak pointers. | 39 // Notifications from weak pointers. |
32 void RemoveIDBDatabaseBackend( | 40 void RemoveIDBDatabaseBackend( |
33 const IndexedDBDatabase::Identifier& unique_identifier); | 41 const IndexedDBDatabase::Identifier& unique_identifier); |
34 | 42 |
35 void GetDatabaseNames(scoped_refptr<IndexedDBCallbacks> callbacks, | 43 void GetDatabaseNames(scoped_refptr<IndexedDBCallbacks> callbacks, |
36 const std::string& origin_identifier, | 44 const std::string& origin_identifier, |
37 const base::FilePath& data_directory); | 45 const base::FilePath& data_directory, |
| 46 base::TaskRunner* task_runner); |
38 void Open(const string16& name, | 47 void Open(const string16& name, |
39 int64 version, | 48 int64 version, |
| 49 net::URLRequestContext* request_context, |
40 int64 transaction_id, | 50 int64 transaction_id, |
41 scoped_refptr<IndexedDBCallbacks> callbacks, | 51 scoped_refptr<IndexedDBCallbacks> callbacks, |
42 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, | 52 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, |
43 const std::string& origin_identifier, | 53 const std::string& origin_identifier, |
44 const base::FilePath& data_directory); | 54 const base::FilePath& data_directory, |
| 55 int child_process_id, |
| 56 base::TaskRunner* task_runner); |
45 | 57 |
46 void DeleteDatabase(const string16& name, | 58 void DeleteDatabase(const string16& name, |
| 59 net::URLRequestContext* request_context, |
47 scoped_refptr<IndexedDBCallbacks> callbacks, | 60 scoped_refptr<IndexedDBCallbacks> callbacks, |
48 const std::string& origin_identifier, | 61 const std::string& origin_identifier, |
49 const base::FilePath& data_directory); | 62 const base::FilePath& data_directory, |
| 63 base::TaskRunner* task_runner); |
50 | 64 |
51 // Iterates over all databases; for diagnostics only. | 65 // Iterates over all databases; for diagnostics only. |
52 std::vector<IndexedDBDatabase*> GetOpenDatabasesForOrigin( | 66 std::vector<IndexedDBDatabase*> GetOpenDatabasesForOrigin( |
53 const std::string& origin_identifier) const; | 67 const std::string& origin_identifier) const; |
54 | 68 |
55 protected: | 69 protected: |
56 friend class base::RefCounted<IndexedDBFactory>; | 70 friend class base::RefCounted<IndexedDBFactory>; |
57 | 71 |
58 virtual ~IndexedDBFactory(); | 72 virtual ~IndexedDBFactory(); |
59 | 73 |
60 scoped_refptr<IndexedDBBackingStore> OpenBackingStore( | 74 scoped_refptr<IndexedDBBackingStore> OpenBackingStore( |
61 const std::string& origin_identifier, | 75 const std::string& origin_identifier, |
62 const base::FilePath& data_directory, | 76 const base::FilePath& data_directory, |
63 WebKit::WebIDBCallbacks::DataLoss* data_loss); | 77 net::URLRequestContext* request_context, |
| 78 WebKit::WebIDBCallbacks::DataLoss* data_loss, |
| 79 base::TaskRunner* task_runner); |
64 | 80 |
65 private: | 81 private: |
66 typedef std::map<IndexedDBDatabase::Identifier, | 82 typedef std::map<IndexedDBDatabase::Identifier, |
67 scoped_refptr<IndexedDBDatabase> > IndexedDBDatabaseMap; | 83 scoped_refptr<IndexedDBDatabase> > IndexedDBDatabaseMap; |
68 IndexedDBDatabaseMap database_map_; | 84 IndexedDBDatabaseMap database_map_; |
69 | 85 |
70 typedef std::map<std::string, base::WeakPtr<IndexedDBBackingStore> > | 86 typedef std::map<std::string, base::WeakPtr<IndexedDBBackingStore> > |
71 IndexedDBBackingStoreMap; | 87 IndexedDBBackingStoreMap; |
72 IndexedDBBackingStoreMap backing_store_map_; | 88 IndexedDBBackingStoreMap backing_store_map_; |
73 | 89 |
74 std::set<scoped_refptr<IndexedDBBackingStore> > session_only_backing_stores_; | 90 std::set<scoped_refptr<IndexedDBBackingStore> > session_only_backing_stores_; |
| 91 std::set<std::string> backends_opened_since_boot_; |
75 }; | 92 }; |
76 | 93 |
77 } // namespace content | 94 } // namespace content |
78 | 95 |
79 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_H_ | 96 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_H_ |
OLD | NEW |