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.
5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_H_
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_H_
13 #include "base/basictypes.h"
14 #include "base/files/file_path.h"
15 #include "base/memory/ref_counted.h"
16 #include "base/strings/string16.h"
17 #include "content/browser/indexed_db/indexed_db_callbacks.h"
18 #include "content/browser/indexed_db/indexed_db_database.h"
19 #include "content/browser/indexed_db/indexed_db_database_callbacks.h"
20 #include "content/common/content_export.h"
24 class URLRequestContext
;
29 class IndexedDBBackingStore
;
30 struct IndexedDBPendingConnection
;
32 class CONTENT_EXPORT IndexedDBFactory
33 : NON_EXPORTED_BASE(public base::RefCountedThreadSafe
<IndexedDBFactory
>) {
35 typedef std::multimap
<GURL
, IndexedDBDatabase
*> OriginDBMap
;
36 typedef OriginDBMap::const_iterator OriginDBMapIterator
;
37 typedef std::pair
<OriginDBMapIterator
, OriginDBMapIterator
> OriginDBs
;
39 virtual void ReleaseDatabase(const IndexedDBDatabase::Identifier
& identifier
,
40 bool forcedClose
) = 0;
42 virtual void GetDatabaseNames(scoped_refptr
<IndexedDBCallbacks
> callbacks
,
43 const GURL
& origin_url
,
44 const base::FilePath
& data_directory
,
45 net::URLRequestContext
* request_context
) = 0;
46 virtual void Open(const base::string16
& name
,
47 const IndexedDBPendingConnection
& connection
,
48 net::URLRequestContext
* request_context
,
49 const GURL
& origin_url
,
50 const base::FilePath
& data_directory
) = 0;
52 virtual void DeleteDatabase(const base::string16
& name
,
53 net::URLRequestContext
* request_context
,
54 scoped_refptr
<IndexedDBCallbacks
> callbacks
,
55 const GURL
& origin_url
,
56 const base::FilePath
& data_directory
) = 0;
58 virtual void HandleBackingStoreFailure(const GURL
& origin_url
) = 0;
59 virtual void HandleBackingStoreCorruption(
60 const GURL
& origin_url
,
61 const IndexedDBDatabaseError
& error
) = 0;
63 virtual OriginDBs
GetOpenDatabasesForOrigin(const GURL
& origin_url
) const = 0;
65 virtual void ForceClose(const GURL
& origin_url
) = 0;
67 // Called by the IndexedDBContext destructor so the factory can do cleanup.
68 virtual void ContextDestroyed() = 0;
70 // Called by the IndexedDBActiveBlobRegistry.
71 virtual void ReportOutstandingBlobs(const GURL
& origin_url
,
72 bool blobs_outstanding
) = 0;
74 // Called by an IndexedDBDatabase when it is actually deleted.
75 virtual void DatabaseDeleted(
76 const IndexedDBDatabase::Identifier
& identifier
) = 0;
78 virtual size_t GetConnectionCount(const GURL
& origin_url
) const = 0;
81 friend class base::RefCountedThreadSafe
<IndexedDBFactory
>;
84 virtual ~IndexedDBFactory() {}
86 virtual scoped_refptr
<IndexedDBBackingStore
> OpenBackingStore(
87 const GURL
& origin_url
,
88 const base::FilePath
& data_directory
,
89 net::URLRequestContext
* request_context
,
90 blink::WebIDBDataLoss
* data_loss
,
91 std::string
* data_loss_reason
,
93 leveldb::Status
* status
) = 0;
95 virtual scoped_refptr
<IndexedDBBackingStore
> OpenBackingStoreHelper(
96 const GURL
& origin_url
,
97 const base::FilePath
& data_directory
,
98 net::URLRequestContext
* request_context
,
99 blink::WebIDBDataLoss
* data_loss
,
100 std::string
* data_loss_message
,
103 leveldb::Status
* status
) = 0;
106 DISALLOW_COPY_AND_ASSIGN(IndexedDBFactory
);
109 } // namespace content
111 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_H_