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> |
| 9 #include <set> |
| 10 |
8 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
9 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
10 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/weak_ptr.h" |
11 #include "base/string16.h" | 15 #include "base/string16.h" |
| 16 #include "content/browser/indexed_db/indexed_db_callbacks_wrapper.h" |
| 17 #include "content/browser/indexed_db/indexed_db_database_callbacks_wrapper.h" |
| 18 #include "content/browser/indexed_db/indexed_db_factory.h" |
| 19 #include "content/common/content_export.h" |
12 | 20 |
13 namespace content { | 21 namespace content { |
14 | 22 |
15 class IndexedDBCallbacksWrapper; | 23 class IndexedDBBackingStore; |
16 class IndexedDBDatabase; | 24 class IndexedDBDatabase; |
17 class IndexedDBDatabaseCallbacksWrapper; | |
18 | 25 |
19 class IndexedDBFactory : public base::RefCounted<IndexedDBFactory> { | 26 class CONTENT_EXPORT IndexedDBFactory |
| 27 : NON_EXPORTED_BASE(public base::RefCounted<IndexedDBFactory>) { |
20 public: | 28 public: |
21 static scoped_refptr<IndexedDBFactory> Create(); | 29 static scoped_refptr<IndexedDBFactory> Create() { |
| 30 return make_scoped_refptr(new IndexedDBFactory()); |
| 31 } |
22 | 32 |
23 virtual void GetDatabaseNames( | 33 // Notifications from weak pointers. |
24 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, | 34 void RemoveIDBDatabaseBackend(const string16& unique_identifier); |
25 const string16& database_identifier, | 35 |
26 const base::FilePath& data_directory) = 0; | 36 void GetDatabaseNames(scoped_refptr<IndexedDBCallbacksWrapper> callbacks, |
27 virtual void Open( | 37 const string16& database_identifier, |
28 const string16& name, | 38 const base::FilePath& data_directory); |
29 int64 version, | 39 void Open(const string16& name, |
30 int64 transaction_id, | 40 int64 version, |
31 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, | 41 int64 transaction_id, |
32 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks, | 42 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, |
33 const string16& database_identifier, | 43 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks, |
34 const base::FilePath& data_directory) = 0; | 44 const string16& database_identifier, |
35 virtual void DeleteDatabase( | 45 const base::FilePath& data_directory); |
36 const string16& name, | 46 |
37 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, | 47 void DeleteDatabase(const string16& name, |
38 const string16& database_identifier, | 48 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, |
39 const base::FilePath& data_directory) = 0; | 49 const string16& database_identifier, |
| 50 const base::FilePath& data_directory); |
40 | 51 |
41 protected: | 52 protected: |
42 virtual ~IndexedDBFactory() {} | |
43 friend class base::RefCounted<IndexedDBFactory>; | 53 friend class base::RefCounted<IndexedDBFactory>; |
| 54 |
| 55 IndexedDBFactory(); |
| 56 virtual ~IndexedDBFactory(); |
| 57 |
| 58 scoped_refptr<IndexedDBBackingStore> OpenBackingStore( |
| 59 const string16& database_identifier, |
| 60 const base::FilePath& data_directory); |
| 61 |
| 62 private: |
| 63 typedef std::map<string16, scoped_refptr<IndexedDBDatabase> > |
| 64 IndexedDBDatabaseMap; |
| 65 IndexedDBDatabaseMap database_backend_map_; |
| 66 |
| 67 typedef std::map<string16, base::WeakPtr<IndexedDBBackingStore> > |
| 68 IndexedDBBackingStoreMap; |
| 69 IndexedDBBackingStoreMap backing_store_map_; |
| 70 |
| 71 std::set<scoped_refptr<IndexedDBBackingStore> > session_only_backing_stores_; |
44 }; | 72 }; |
45 | 73 |
46 } // namespace content | 74 } // namespace content |
47 | 75 |
48 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_H_ | 76 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_H_ |
OLD | NEW |