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