indexed_db_factory.h revision 868fa2fe829687343ffae624259930155e16dbd8
1868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved. 2868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// found in the LICENSE file. 4868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 5868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_H_ 6868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_H_ 7868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 8868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include <map> 9868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include <set> 10868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 11868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/basictypes.h" 12868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/files/file_path.h" 13868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/memory/ref_counted.h" 14868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/memory/weak_ptr.h" 15868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/string16.h" 16868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "content/browser/indexed_db/indexed_db_callbacks_wrapper.h" 17868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "content/browser/indexed_db/indexed_db_database_callbacks_wrapper.h" 18868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "content/browser/indexed_db/indexed_db_factory.h" 19868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "content/common/content_export.h" 20868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 21868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)namespace content { 22868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 23868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class IndexedDBBackingStore; 24868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class IndexedDBDatabase; 25868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 26868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class CONTENT_EXPORT IndexedDBFactory 27868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) : NON_EXPORTED_BASE(public base::RefCounted<IndexedDBFactory>) { 28868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) public: 29868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) static scoped_refptr<IndexedDBFactory> Create() { 30868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) return make_scoped_refptr(new IndexedDBFactory()); 31868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) } 32868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 33868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Notifications from weak pointers. 34868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void RemoveIDBDatabaseBackend(const string16& unique_identifier); 35868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 36868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void GetDatabaseNames(scoped_refptr<IndexedDBCallbacksWrapper> callbacks, 37868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const string16& database_identifier, 38868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const base::FilePath& data_directory); 39868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void Open(const string16& name, 40868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int64 version, 41868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int64 transaction_id, 42868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) scoped_refptr<IndexedDBCallbacksWrapper> callbacks, 43868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks, 44868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const string16& database_identifier, 45868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const base::FilePath& data_directory); 46868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 47868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void DeleteDatabase(const string16& name, 48868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) scoped_refptr<IndexedDBCallbacksWrapper> callbacks, 49868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const string16& database_identifier, 50868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const base::FilePath& data_directory); 51868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 52868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) protected: 53868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) friend class base::RefCounted<IndexedDBFactory>; 54868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 55868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) IndexedDBFactory(); 56868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual ~IndexedDBFactory(); 57868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 58868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) scoped_refptr<IndexedDBBackingStore> OpenBackingStore( 59868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const string16& database_identifier, 60868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const base::FilePath& data_directory); 61868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 62868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) private: 63868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) typedef std::map<string16, scoped_refptr<IndexedDBDatabase> > 64868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) IndexedDBDatabaseMap; 65868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) IndexedDBDatabaseMap database_backend_map_; 66868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 67868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) typedef std::map<string16, base::WeakPtr<IndexedDBBackingStore> > 68868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) IndexedDBBackingStoreMap; 69868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) IndexedDBBackingStoreMap backing_store_map_; 70868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 71868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) std::set<scoped_refptr<IndexedDBBackingStore> > session_only_backing_stores_; 72868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}; 73868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 74868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} // namespace content 75868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 76868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_H_ 77