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

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: Some (incomplete) work on struct traits. Created 4 years, 5 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 "base/id_map.h"
9 #include "base/macros.h"
10 #include "content/browser/bad_message.h"
11 #include "content/public/browser/browser_context.h"
12 #include "mojo/public/cpp/bindings/strong_binding.h"
13 #include "third_party/WebKit/public/platform/modules/indexeddb/indexed_db.mojom. h"
14
15 namespace content {
16 class IndexedDBConnection;
17 class IndexedDBContext;
18 }
19
20 namespace indexed_db {
21
22 class DatabaseImpl : public mojom::Database {
23 public:
24 DatabaseImpl(content::BrowserContext* context,
25 content::IndexedDBContext* indexed_db_context,
26 mojom::DatabaseRequest request);
27 ~DatabaseImpl() override;
28
29 static void Create(content::BrowserContext* context,
30 mojom::DatabaseRequest request);
31
32 private:
33 // IDMap for RefCounted types
34 template <typename RefCountedType>
35 class RefIDMap {
36 public:
37 typedef int32_t KeyType;
38
39 RefIDMap() {}
40 ~RefIDMap() {}
41
42 KeyType Add(RefCountedType* data) {
43 return map_.Add(new scoped_refptr<RefCountedType>(data));
44 }
45
46 RefCountedType* Lookup(KeyType id) {
47 scoped_refptr<RefCountedType>* ptr = map_.Lookup(id);
48 if (ptr == NULL)
49 return NULL;
50 return ptr->get();
51 }
52
53 void Remove(KeyType id) { map_.Remove(id); }
54
55 void set_check_on_null_data(bool value) {
56 map_.set_check_on_null_data(value);
57 }
58
59 private:
60 IDMap<scoped_refptr<RefCountedType>, IDMapOwnPointer> map_;
61
62 DISALLOW_COPY_AND_ASSIGN(RefIDMap);
63 };
64
65 // mojom::Database:
66 void CreateObjectStore(int64_t transaction_id,
67 int64_t object_store_id,
68 const mojo::String& name,
69 const ::content::IndexedDBKeyPath& key_path,
70 bool auto_increment) override;
71
72 void DeleteObjectStore(int64_t transaction_id,
73 int64_t object_store_id) override;
74
75 void CreateTransaction(int64_t id,
76 mojo::Array<int64_t> scope,
77 mojom::TransactionMode transaction_mode) override;
78
79 void Close() override;
80
81 void VersionChangeIgnored() override;
82
83 void Abort(int64_t transaction_id) override;
84
85 void Commit(int64_t transaction_id) override;
86
87 void CreateIndex(int64_t transaction_id,
88 int64_t object_store_id,
89 int64_t index_id,
90 const mojo::String& name,
91 const ::content::IndexedDBKeyPath& key_path,
92 bool unique,
93 bool multi_entry) override;
94
95 void DeleteIndex(int64_t transaction_id,
96 int64_t object_store_id,
97 int64_t index_id) override;
98
99 void Get(int64_t database_id,
100 int64_t transaction_id,
101 int64_t object_store_id,
102 int64_t index_id,
103 mojom::KeyRangePtr key_range,
104 bool key_only,
105 const GetCallback& callback) override;
106
107 void GetAll(int64_t transaction_id,
108 int64_t object_store_id,
109 int64_t index_id,
110 mojom::KeyRangePtr key_range,
111 int64_t max_count,
112 bool key_only) override;
113
114 void Put(int64_t transaction_id,
115 int64_t object_store_id,
116 mojo::Array<int8_t> value,
117 mojo::Array<mojom::BlobInfoPtr> blob_info,
118 mojom::KeyPtr key,
119 mojom::PutMode put_mode,
120 mojo::Array<int64_t> index_ids,
121 mojo::Array<mojo::Array<mojom::KeyPtr>> index_keys) override;
122
123 void DeleteRange(int64_t transaction_id,
124 int64_t object_store_id,
125 mojom::KeyRangePtr key_range) override;
126
127 void Clear(int64_t transaction_id, int64_t object_store_id) override;
128
129 void SetIndexKeys(
130 int64_t transaction_id,
131 int64_t object_store_id,
132 mojom::KeyPtr primary_key,
133 mojo::Array<int64_t> index_ids,
134 mojo::Array<mojo::Array<mojom::KeyPtr>> index_keys) override;
135
136 void SetIndexesReady(int64_t transaction_id,
137 int64_t object_store_id,
138 mojo::Array<int64_t> index_ids) override;
139
140 void OpenCursor(int64_t transaction_id,
141 int64_t object_store_id,
142 int64_t index_id,
143 mojom::KeyRangePtr key_range,
144 mojom::CursorDirection direction,
145 bool key_only,
146 mojom::TaskType task_type) override;
147
148 void Count(int64_t transaction_id,
149 int64_t object_store_id,
150 int64_t index_id,
151 mojom::KeyRangePtr key_range) override;
152
153 void AckReceivedBlobs(mojo::Array<mojo::String> uuids) override;
154
155 void CrashRendererAndClosePipe(content::bad_message::BadMessageReason reason);
156
157 content::RenderProcessHost* GetRenderProcessHost();
158
159 #if 0
160 int64_t HostTransactionId(int64_t transaction_id);
161 #endif
162
163 // Helper templates.
164 template <class ReturnType>
165 ReturnType* GetOrTerminateProcess(IDMap<ReturnType, IDMapOwnPointer>* map,
166 int32_t ipc_return_object_id);
167 template <class ReturnType>
168 ReturnType* GetOrTerminateProcess(RefIDMap<ReturnType>* map,
169 int32_t ipc_return_object_id);
170
171 template <typename MapType>
172 void DestroyObject(MapType* map, int32_t ipc_object_id);
173
174 content::BrowserContext* context_;
175 scoped_refptr<content::IndexedDBContext> indexed_db_context_;
176 IDMap<content::IndexedDBConnection, IDMapOwnPointer> connection_map_;
177 mojo::StrongBinding<mojom::Database> binding_;
178
179 DISALLOW_COPY_AND_ASSIGN(DatabaseImpl);
180 };
181
182 } // namespace indexed_db
183
184 #endif // CONTENT_BROWSER_INDEXED_DB_DATABASE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698