indexed_db_factory.h revision 7dbb3d5cf0c15f500944d211057644d6a2f37371
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 IndexedDBFactory(); 30 31 // Notifications from weak pointers. 32 void RemoveIDBDatabaseBackend(const string16& unique_identifier); 33 34 void GetDatabaseNames(scoped_refptr<IndexedDBCallbacks> callbacks, 35 const std::string& origin_identifier, 36 const base::FilePath& data_directory); 37 void Open(const string16& name, 38 int64 version, 39 int64 transaction_id, 40 scoped_refptr<IndexedDBCallbacks> callbacks, 41 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, 42 const std::string& origin_identifier, 43 const base::FilePath& data_directory); 44 45 void DeleteDatabase(const string16& name, 46 scoped_refptr<IndexedDBCallbacks> callbacks, 47 const std::string& origin_identifier, 48 const base::FilePath& data_directory); 49 50 protected: 51 friend class base::RefCounted<IndexedDBFactory>; 52 53 virtual ~IndexedDBFactory(); 54 55 scoped_refptr<IndexedDBBackingStore> OpenBackingStore( 56 const std::string& origin_identifier, 57 const base::FilePath& data_directory, 58 WebKit::WebIDBCallbacks::DataLoss* data_loss); 59 60 private: 61 typedef std::map<string16, scoped_refptr<IndexedDBDatabase> > 62 IndexedDBDatabaseMap; 63 IndexedDBDatabaseMap database_backend_map_; 64 65 typedef std::map<std::string, base::WeakPtr<IndexedDBBackingStore> > 66 IndexedDBBackingStoreMap; 67 IndexedDBBackingStoreMap backing_store_map_; 68 69 std::set<scoped_refptr<IndexedDBBackingStore> > session_only_backing_stores_; 70}; 71 72} // namespace content 73 74#endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_H_ 75