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