blob: 694251f2e319c15df26207a0a96d28f4c2513d0f [file] [log] [blame]
[email protected]72a4183d2013-05-31 18:33:101// 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
avib7348942015-12-25 20:57:108#include <stddef.h>
9
[email protected]907a8bc52013-06-07 16:32:3410#include <map>
cmumfordfbd8d172016-07-22 18:25:0111#include <memory>
[email protected]907a8bc52013-06-07 16:32:3412#include <set>
[email protected]4cfd02d2014-06-11 18:08:4013#include <utility>
[email protected]907a8bc52013-06-07 16:32:3414
[email protected]95b26022013-06-06 18:20:1915#include "base/files/file_path.h"
avib7348942015-12-25 20:57:1016#include "base/macros.h"
[email protected]72a4183d2013-05-31 18:33:1017#include "base/memory/ref_counted.h"
[email protected]10994d132013-06-11 07:16:1818#include "base/strings/string16.h"
[email protected]6abf88d2013-07-01 22:54:0719#include "content/browser/indexed_db/indexed_db_callbacks.h"
[email protected]8df07d22013-07-22 17:57:4320#include "content/browser/indexed_db/indexed_db_database.h"
[email protected]e67c0cc2013-07-01 20:21:1821#include "content/browser/indexed_db/indexed_db_database_callbacks.h"
[email protected]907a8bc52013-06-07 16:32:3422#include "content/common/content_export.h"
[email protected]97a34c22013-10-28 17:34:3423#include "url/gurl.h"
jsbelld77cea92016-04-13 22:58:5224#include "url/origin.h"
[email protected]72a4183d2013-05-31 18:33:1025
[email protected]e62fe0d2014-04-14 19:04:3526namespace net {
cmumford95032d52016-08-17 18:11:5227class URLRequestContextGetter;
[email protected]e62fe0d2014-04-14 19:04:3528}
29
[email protected]72a4183d2013-05-31 18:33:1030namespace content {
31
[email protected]907a8bc52013-06-07 16:32:3432class IndexedDBBackingStore;
[email protected]d29650c2014-03-18 01:20:5933struct IndexedDBPendingConnection;
cmumford2d8f8c912016-07-13 03:22:0334struct IndexedDBDataLossInfo;
[email protected]72a4183d2013-05-31 18:33:1035
[email protected]907a8bc52013-06-07 16:32:3436class CONTENT_EXPORT IndexedDBFactory
Nico Weber43ddd7a32017-08-15 19:19:2737 : public base::RefCountedThreadSafe<IndexedDBFactory> {
[email protected]72a4183d2013-05-31 18:33:1038 public:
jsbellbebef322016-04-15 16:46:2039 typedef std::multimap<url::Origin, IndexedDBDatabase*> OriginDBMap;
[email protected]7aba4d72014-01-11 22:38:2240 typedef OriginDBMap::const_iterator OriginDBMapIterator;
[email protected]1bdfff92014-07-31 00:04:0041 typedef std::pair<OriginDBMapIterator, OriginDBMapIterator> OriginDBs;
[email protected]7aba4d72014-01-11 22:38:2242
[email protected]8f4c9202014-07-18 18:21:3843 virtual void ReleaseDatabase(const IndexedDBDatabase::Identifier& identifier,
jsbelle5db46e2015-01-22 18:55:5344 bool forced_close) = 0;
[email protected]72a4183d2013-05-31 18:33:1045
cmumford95032d52016-08-17 18:11:5246 virtual void GetDatabaseNames(
47 scoped_refptr<IndexedDBCallbacks> callbacks,
48 const url::Origin& origin,
49 const base::FilePath& data_directory,
50 scoped_refptr<net::URLRequestContextGetter> request_context_getter) = 0;
51 virtual void Open(
52 const base::string16& name,
53 std::unique_ptr<IndexedDBPendingConnection> connection,
54 scoped_refptr<net::URLRequestContextGetter> request_context_getter,
55 const url::Origin& origin,
56 const base::FilePath& data_directory) = 0;
[email protected]907a8bc52013-06-07 16:32:3457
cmumford95032d52016-08-17 18:11:5258 virtual void DeleteDatabase(
59 const base::string16& name,
60 scoped_refptr<net::URLRequestContextGetter> request_context_getter,
61 scoped_refptr<IndexedDBCallbacks> callbacks,
62 const url::Origin& origin,
eostroukhov1470b1f2017-01-23 21:13:5363 const base::FilePath& data_directory,
64 bool force_close) = 0;
[email protected]907a8bc52013-06-07 16:32:3465
kristipark7603dc32017-07-06 22:28:2266 virtual void AbortTransactionsAndCompactDatabase(
67 base::OnceCallback<void(leveldb::Status)> callback,
68 const url::Origin& origin) = 0;
kristiparkffa79072017-07-12 01:15:3069 virtual void AbortTransactionsForDatabase(
70 base::OnceCallback<void(leveldb::Status)> callback,
71 const url::Origin& origin) = 0;
kristipark7603dc32017-07-06 22:28:2272
jsbellbebef322016-04-15 16:46:2073 virtual void HandleBackingStoreFailure(const url::Origin& origin) = 0;
[email protected]8f4c9202014-07-18 18:21:3874 virtual void HandleBackingStoreCorruption(
jsbellbebef322016-04-15 16:46:2075 const url::Origin& origin,
[email protected]8f4c9202014-07-18 18:21:3876 const IndexedDBDatabaseError& error) = 0;
[email protected]72a4183d2013-05-31 18:33:1077
jsbellbebef322016-04-15 16:46:2078 virtual OriginDBs GetOpenDatabasesForOrigin(
79 const url::Origin& origin) const = 0;
[email protected]2f626ee2013-10-31 01:36:5680
jsbellbebef322016-04-15 16:46:2081 virtual void ForceClose(const url::Origin& origin) = 0;
[email protected]72964572013-10-24 20:30:0182
83 // Called by the IndexedDBContext destructor so the factory can do cleanup.
[email protected]8f4c9202014-07-18 18:21:3884 virtual void ContextDestroyed() = 0;
[email protected]72964572013-10-24 20:30:0185
[email protected]3cf0cae2014-04-03 16:26:1986 // Called by the IndexedDBActiveBlobRegistry.
jsbellbebef322016-04-15 16:46:2087 virtual void ReportOutstandingBlobs(const url::Origin& origin,
[email protected]8f4c9202014-07-18 18:21:3888 bool blobs_outstanding) = 0;
[email protected]3cf0cae2014-04-03 16:26:1989
[email protected]4099d2542013-12-17 19:55:3090 // Called by an IndexedDBDatabase when it is actually deleted.
[email protected]8f4c9202014-07-18 18:21:3891 virtual void DatabaseDeleted(
92 const IndexedDBDatabase::Identifier& identifier) = 0;
[email protected]4099d2542013-12-17 19:55:3093
Daniel Murphyac35e5362017-10-03 01:28:1294 // Called by IndexedDBBackingStore when blob files have been cleaned.
95 virtual void BlobFilesCleaned(const url::Origin& origin) = 0;
96
jsbellbebef322016-04-15 16:46:2097 virtual size_t GetConnectionCount(const url::Origin& origin) const = 0;
[email protected]7aba4d72014-01-11 22:38:2298
kristipark5e4cbe02017-09-29 00:24:5399 virtual void NotifyIndexedDBContentChanged(
100 const url::Origin& origin,
101 const base::string16& database_name,
102 const base::string16& object_store_name) = 0;
103
[email protected]72a4183d2013-05-31 18:33:10104 protected:
[email protected]c4f03aa2013-11-22 22:21:09105 friend class base::RefCountedThreadSafe<IndexedDBFactory>;
[email protected]907a8bc52013-06-07 16:32:34106
[email protected]8f4c9202014-07-18 18:21:38107 IndexedDBFactory() {}
108 virtual ~IndexedDBFactory() {}
[email protected]907a8bc52013-06-07 16:32:34109
[email protected]bc882ddd2013-09-23 22:23:03110 virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStore(
jsbellbebef322016-04-15 16:46:20111 const url::Origin& origin,
[email protected]39571d12013-06-25 23:40:29112 const base::FilePath& data_directory,
cmumford95032d52016-08-17 18:11:52113 scoped_refptr<net::URLRequestContextGetter> request_context_getter,
cmumford2d8f8c912016-07-13 03:22:03114 IndexedDBDataLossInfo* data_loss_info,
[email protected]6e227a82014-06-24 17:27:27115 bool* disk_full,
[email protected]8f4c9202014-07-18 18:21:38116 leveldb::Status* status) = 0;
[email protected]907a8bc52013-06-07 16:32:34117
[email protected]8b9db1162014-04-30 01:34:18118 virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStoreHelper(
jsbellbebef322016-04-15 16:46:20119 const url::Origin& origin,
[email protected]8b9db1162014-04-30 01:34:18120 const base::FilePath& data_directory,
cmumford95032d52016-08-17 18:11:52121 scoped_refptr<net::URLRequestContextGetter> request_context_getter,
cmumford2d8f8c912016-07-13 03:22:03122 IndexedDBDataLossInfo* data_loss_info,
[email protected]8b9db1162014-04-30 01:34:18123 bool* disk_full,
[email protected]6e227a82014-06-24 17:27:27124 bool first_time,
[email protected]8f4c9202014-07-18 18:21:38125 leveldb::Status* status) = 0;
[email protected]59057f82013-09-11 20:52:24126
[email protected]907a8bc52013-06-07 16:32:34127 private:
[email protected]e8ca0f52014-06-07 08:46:34128 DISALLOW_COPY_AND_ASSIGN(IndexedDBFactory);
[email protected]72a4183d2013-05-31 18:33:10129};
130
131} // namespace content
132
133#endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_H_