Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(826)

Side by Side Diff: content/browser/indexed_db/database_impl.h

Issue 1963293002: Replacing Indexed DB Chromium IPC with Mojo Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactoring after Passing URLRequestContextGetter. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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_DATABASE_IMPL_H_
6 #define CONTENT_BROWSER_INDEXED_DB_DATABASE_IMPL_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "Source/modules/indexeddb/indexed_db.mojom.h"
12 #include "base/id_map.h"
13 #include "base/macros.h"
14 #include "content/browser/bad_message.h"
15 #include "content/public/browser/browser_context.h"
16 #include "mojo/public/cpp/bindings/strong_binding.h"
17
18 namespace content {
19
20 class IndexedDBConnection;
21 class IndexedDBContext;
22
23 class DatabaseImpl : public indexed_db::mojom::Database {
24 public:
25 DatabaseImpl(BrowserContext* context,
26 IndexedDBContext* indexed_db_context,
27 indexed_db::mojom::DatabaseRequest request);
28 ~DatabaseImpl() override;
29
30 static void Create(BrowserContext* context,
31 indexed_db::mojom::DatabaseRequest request);
32
33 private:
34 // IDMap for RefCounted types
35 template <typename RefCountedType>
36 class RefIDMap {
37 public:
38 typedef int32_t KeyType;
39
40 RefIDMap() {}
41 ~RefIDMap() {}
42
43 KeyType Add(RefCountedType* data) {
44 return map_.Add(new scoped_refptr<RefCountedType>(data));
45 }
46
47 RefCountedType* Lookup(KeyType id) {
48 scoped_refptr<RefCountedType>* ptr = map_.Lookup(id);
49 if (ptr == NULL)
50 return NULL;
51 return ptr->get();
52 }
53
54 void Remove(KeyType id) { map_.Remove(id); }
55
56 void set_check_on_null_data(bool value) {
57 map_.set_check_on_null_data(value);
58 }
59
60 private:
61 IDMap<scoped_refptr<RefCountedType>, IDMapOwnPointer> map_;
62
63 DISALLOW_COPY_AND_ASSIGN(RefIDMap);
64 };
65
66 // indexed_db::mojom::Database:
67 void CreateObjectStore(int64_t transaction_id,
68 int64_t object_store_id,
69 const std::string& name,
70 const IndexedDBKeyPath& key_path,
71 bool auto_increment) override;
72
73 void DeleteObjectStore(int64_t transaction_id,
74 int64_t object_store_id) override;
75
76 void CreateTransaction(
77 int64_t id,
78 const std::vector<int64_t>& scope,
79 indexed_db::mojom::TransactionMode transaction_mode) override;
80
81 void Close() override;
82
83 void VersionChangeIgnored() override;
84
85 void Abort(int64_t transaction_id) override;
86
87 void Commit(int64_t transaction_id) override;
88
89 void CreateIndex(int64_t transaction_id,
90 int64_t object_store_id,
91 int64_t index_id,
92 const std::string& name,
93 const IndexedDBKeyPath& key_path,
94 bool unique,
95 bool multi_entry) override;
96
97 void DeleteIndex(int64_t transaction_id,
98 int64_t object_store_id,
99 int64_t index_id) override;
100
101 void Get(int64_t transaction_id,
102 int64_t object_store_id,
103 int64_t index_id,
104 indexed_db::mojom::KeyRangePtr key_range,
105 bool key_only,
106 const GetCallback& callback) override;
107
108 void GetAll(int64_t transaction_id,
109 int64_t object_store_id,
110 int64_t index_id,
111 indexed_db::mojom::KeyRangePtr key_range,
112 int64_t max_count,
113 bool key_only) override;
114
115 void Put(
116 int64_t transaction_id,
117 int64_t object_store_id,
118 const std::vector<int8_t>& value,
119 std::vector<indexed_db::mojom::BlobInfoPtr> blob_info,
120 indexed_db::mojom::KeyPtr key,
121 indexed_db::mojom::PutMode put_mode,
122 const std::vector<int64_t>& index_ids,
123 std::vector<std::vector<indexed_db::mojom::KeyPtr>> index_keys) override;
124
125 void DeleteRange(int64_t transaction_id,
126 int64_t object_store_id,
127 indexed_db::mojom::KeyRangePtr key_range) override;
128
129 void Clear(int64_t transaction_id, int64_t object_store_id) override;
130
131 void SetIndexKeys(
132 int64_t transaction_id,
133 int64_t object_store_id,
134 indexed_db::mojom::KeyPtr primary_key,
135 const std::vector<int64_t>& index_ids,
136 std::vector<std::vector<indexed_db::mojom::KeyPtr>> index_keys) override;
137
138 void SetIndexesReady(int64_t transaction_id,
139 int64_t object_store_id,
140 const std::vector<int64_t>& index_ids) override;
141
142 void OpenCursor(int64_t transaction_id,
143 int64_t object_store_id,
144 int64_t index_id,
145 indexed_db::mojom::KeyRangePtr key_range,
146 indexed_db::mojom::CursorDirection direction,
147 bool key_only,
148 indexed_db::mojom::TaskType task_type) override;
149
150 void Count(int64_t transaction_id,
151 int64_t object_store_id,
152 int64_t index_id,
153 indexed_db::mojom::KeyRangePtr key_range) override;
154
155 void AckReceivedBlobs(const std::vector<std::string>& uuids) override;
156
157 void CrashRendererAndClosePipe(bad_message::BadMessageReason reason);
158
159 RenderProcessHost* GetRenderProcessHost();
160
161 #if 0
162 int64_t HostTransactionId(int64_t transaction_id);
163 #endif
164
165 // Helper templates.
166 template <class ReturnType>
167 ReturnType* GetOrTerminateProcess(IDMap<ReturnType, IDMapOwnPointer>* map,
168 int32_t ipc_return_object_id);
169 template <class ReturnType>
170 ReturnType* GetOrTerminateProcess(RefIDMap<ReturnType>* map,
171 int32_t ipc_return_object_id);
172
173 template <typename MapType>
174 void DestroyObject(MapType* map, int32_t ipc_object_id);
175
176 BrowserContext* context_;
177 scoped_refptr<IndexedDBContext> indexed_db_context_;
178 IDMap<IndexedDBConnection, IDMapOwnPointer> connection_map_;
179 mojo::StrongBinding<indexed_db::mojom::Database> binding_;
180
181 DISALLOW_COPY_AND_ASSIGN(DatabaseImpl);
182 };
183
184 } // namespace content
185
186 #endif // CONTENT_BROWSER_INDEXED_DB_DATABASE_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/indexed_db/database_factory_impl.cc ('k') | content/browser/indexed_db/database_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698