[Mac] Implement Ambient Light API
[chromium-blink-merge.git] / content / browser / indexed_db / indexed_db_factory.h
blob935ba56c550286ba1038093feb992d11b558b84d
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_
8 #include <map>
9 #include <set>
10 #include <string>
11 #include <utility>
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"
21 #include "url/gurl.h"
23 namespace net {
24 class URLRequestContext;
27 namespace content {
29 class IndexedDBBackingStore;
30 struct IndexedDBPendingConnection;
32 class CONTENT_EXPORT IndexedDBFactory
33 : NON_EXPORTED_BASE(public base::RefCountedThreadSafe<IndexedDBFactory>) {
34 public:
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;
80 protected:
81 friend class base::RefCountedThreadSafe<IndexedDBFactory>;
83 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,
92 bool* disk_full,
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,
101 bool* disk_full,
102 bool first_time,
103 leveldb::Status* status) = 0;
105 private:
106 DISALLOW_COPY_AND_ASSIGN(IndexedDBFactory);
109 } // namespace content
111 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FACTORY_H_