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

Side by Side Diff: content/child/indexed_db/indexed_db_dispatcher.h

Issue 1544273002: Switch to standard integer types in content/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « content/child/image_decoder.h ('k') | content/child/indexed_db/indexed_db_dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ 5 #ifndef CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_
6 #define CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ 6 #define CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_
7 7
8 #include <stddef.h>
9 #include <stdint.h>
10
8 #include <map> 11 #include <map>
9 #include <string> 12 #include <string>
10 #include <vector> 13 #include <vector>
11 14
12 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
13 #include "base/id_map.h" 16 #include "base/id_map.h"
17 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
15 #include "base/strings/nullable_string16.h" 19 #include "base/strings/nullable_string16.h"
16 #include "content/common/content_export.h" 20 #include "content/common/content_export.h"
17 #include "content/common/indexed_db/indexed_db_constants.h" 21 #include "content/common/indexed_db/indexed_db_constants.h"
18 #include "content/public/child/worker_thread.h" 22 #include "content/public/child/worker_thread.h"
19 #include "ipc/ipc_sync_message_filter.h" 23 #include "ipc/ipc_sync_message_filter.h"
20 #include "third_party/WebKit/public/platform/WebBlobInfo.h" 24 #include "third_party/WebKit/public/platform/WebBlobInfo.h"
21 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBCallbacks.h " 25 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBCallbacks.h "
22 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseCal lbacks.h" 26 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseCal lbacks.h"
23 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h" 27 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 70
67 void OnMessageReceived(const IPC::Message& msg); 71 void OnMessageReceived(const IPC::Message& msg);
68 72
69 // This method is virtual so it can be overridden in unit tests. 73 // This method is virtual so it can be overridden in unit tests.
70 virtual bool Send(IPC::Message* msg); 74 virtual bool Send(IPC::Message* msg);
71 75
72 void RequestIDBFactoryGetDatabaseNames( 76 void RequestIDBFactoryGetDatabaseNames(
73 blink::WebIDBCallbacks* callbacks, 77 blink::WebIDBCallbacks* callbacks,
74 const std::string& database_identifier); 78 const std::string& database_identifier);
75 79
76 void RequestIDBFactoryOpen( 80 void RequestIDBFactoryOpen(const base::string16& name,
77 const base::string16& name, 81 int64_t version,
78 int64 version, 82 int64_t transaction_id,
79 int64 transaction_id, 83 blink::WebIDBCallbacks* callbacks,
80 blink::WebIDBCallbacks* callbacks, 84 blink::WebIDBDatabaseCallbacks* database_callbacks,
81 blink::WebIDBDatabaseCallbacks* database_callbacks, 85 const std::string& database_identifier);
82 const std::string& database_identifier);
83 86
84 void RequestIDBFactoryDeleteDatabase(const base::string16& name, 87 void RequestIDBFactoryDeleteDatabase(const base::string16& name,
85 blink::WebIDBCallbacks* callbacks, 88 blink::WebIDBCallbacks* callbacks,
86 const std::string& database_identifier); 89 const std::string& database_identifier);
87 90
88 // This method is virtual so it can be overridden in unit tests. 91 // This method is virtual so it can be overridden in unit tests.
89 virtual void RequestIDBCursorAdvance(unsigned long count, 92 virtual void RequestIDBCursorAdvance(unsigned long count,
90 blink::WebIDBCallbacks* callbacks_ptr, 93 blink::WebIDBCallbacks* callbacks_ptr,
91 int32 ipc_cursor_id, 94 int32_t ipc_cursor_id,
92 int64 transaction_id); 95 int64_t transaction_id);
93 96
94 // This method is virtual so it can be overridden in unit tests. 97 // This method is virtual so it can be overridden in unit tests.
95 virtual void RequestIDBCursorContinue(const IndexedDBKey& key, 98 virtual void RequestIDBCursorContinue(const IndexedDBKey& key,
96 const IndexedDBKey& primary_key, 99 const IndexedDBKey& primary_key,
97 blink::WebIDBCallbacks* callbacks_ptr, 100 blink::WebIDBCallbacks* callbacks_ptr,
98 int32 ipc_cursor_id, 101 int32_t ipc_cursor_id,
99 int64 transaction_id); 102 int64_t transaction_id);
100 103
101 // This method is virtual so it can be overridden in unit tests. 104 // This method is virtual so it can be overridden in unit tests.
102 virtual void RequestIDBCursorPrefetch(int n, 105 virtual void RequestIDBCursorPrefetch(int n,
103 blink::WebIDBCallbacks* callbacks_ptr, 106 blink::WebIDBCallbacks* callbacks_ptr,
104 int32 ipc_cursor_id); 107 int32_t ipc_cursor_id);
105 108
106 // This method is virtual so it can be overridden in unit tests. 109 // This method is virtual so it can be overridden in unit tests.
107 virtual void RequestIDBCursorPrefetchReset(int used_prefetches, 110 virtual void RequestIDBCursorPrefetchReset(int used_prefetches,
108 int unused_prefetches, 111 int unused_prefetches,
109 int32 ipc_cursor_id); 112 int32_t ipc_cursor_id);
110 113
111 void RequestIDBDatabaseClose(int32 ipc_database_id, 114 void RequestIDBDatabaseClose(int32_t ipc_database_id,
112 int32 ipc_database_callbacks_id); 115 int32_t ipc_database_callbacks_id);
113 116
114 void NotifyIDBDatabaseVersionChangeIgnored(int32 ipc_database_id); 117 void NotifyIDBDatabaseVersionChangeIgnored(int32_t ipc_database_id);
115 118
116 void RequestIDBDatabaseCreateTransaction( 119 void RequestIDBDatabaseCreateTransaction(
117 int32 ipc_database_id, 120 int32_t ipc_database_id,
118 int64 transaction_id, 121 int64_t transaction_id,
119 blink::WebIDBDatabaseCallbacks* database_callbacks_ptr, 122 blink::WebIDBDatabaseCallbacks* database_callbacks_ptr,
120 blink::WebVector<long long> object_store_ids, 123 blink::WebVector<long long> object_store_ids,
121 blink::WebIDBTransactionMode mode); 124 blink::WebIDBTransactionMode mode);
122 125
123 void RequestIDBDatabaseGet(int32 ipc_database_id, 126 void RequestIDBDatabaseGet(int32_t ipc_database_id,
124 int64 transaction_id, 127 int64_t transaction_id,
125 int64 object_store_id, 128 int64_t object_store_id,
126 int64 index_id, 129 int64_t index_id,
127 const IndexedDBKeyRange& key_range, 130 const IndexedDBKeyRange& key_range,
128 bool key_only, 131 bool key_only,
129 blink::WebIDBCallbacks* callbacks); 132 blink::WebIDBCallbacks* callbacks);
130 133
131 void RequestIDBDatabaseGetAll(int32 ipc_database_id, 134 void RequestIDBDatabaseGetAll(int32_t ipc_database_id,
132 int64 transaction_id, 135 int64_t transaction_id,
133 int64 object_store_id, 136 int64_t object_store_id,
134 int64 index_id, 137 int64_t index_id,
135 const IndexedDBKeyRange& key_range, 138 const IndexedDBKeyRange& key_range,
136 bool key_only, 139 bool key_only,
137 int64 max_count, 140 int64_t max_count,
138 blink::WebIDBCallbacks* callbacks); 141 blink::WebIDBCallbacks* callbacks);
139 142
140 void RequestIDBDatabasePut( 143 void RequestIDBDatabasePut(
141 int32 ipc_database_id, 144 int32_t ipc_database_id,
142 int64 transaction_id, 145 int64_t transaction_id,
143 int64 object_store_id, 146 int64_t object_store_id,
144 const blink::WebData& value, 147 const blink::WebData& value,
145 const blink::WebVector<blink::WebBlobInfo>& web_blob_info, 148 const blink::WebVector<blink::WebBlobInfo>& web_blob_info,
146 const IndexedDBKey& key, 149 const IndexedDBKey& key,
147 blink::WebIDBPutMode put_mode, 150 blink::WebIDBPutMode put_mode,
148 blink::WebIDBCallbacks* callbacks, 151 blink::WebIDBCallbacks* callbacks,
149 const blink::WebVector<long long>& index_ids, 152 const blink::WebVector<long long>& index_ids,
150 const blink::WebVector<blink::WebVector<blink::WebIDBKey> >& index_keys); 153 const blink::WebVector<blink::WebVector<blink::WebIDBKey>>& index_keys);
151 154
152 void RequestIDBDatabaseOpenCursor(int32 ipc_database_id, 155 void RequestIDBDatabaseOpenCursor(int32_t ipc_database_id,
153 int64 transaction_id, 156 int64_t transaction_id,
154 int64 object_store_id, 157 int64_t object_store_id,
155 int64 index_id, 158 int64_t index_id,
156 const IndexedDBKeyRange& key_range, 159 const IndexedDBKeyRange& key_range,
157 blink::WebIDBCursorDirection direction, 160 blink::WebIDBCursorDirection direction,
158 bool key_only, 161 bool key_only,
159 blink::WebIDBTaskType task_type, 162 blink::WebIDBTaskType task_type,
160 blink::WebIDBCallbacks* callbacks); 163 blink::WebIDBCallbacks* callbacks);
161 164
162 void RequestIDBDatabaseCount(int32 ipc_database_id, 165 void RequestIDBDatabaseCount(int32_t ipc_database_id,
163 int64 transaction_id, 166 int64_t transaction_id,
164 int64 object_store_id, 167 int64_t object_store_id,
165 int64 index_id, 168 int64_t index_id,
166 const IndexedDBKeyRange& key_range, 169 const IndexedDBKeyRange& key_range,
167 blink::WebIDBCallbacks* callbacks); 170 blink::WebIDBCallbacks* callbacks);
168 171
169 void RequestIDBDatabaseDeleteRange(int32 ipc_database_id, 172 void RequestIDBDatabaseDeleteRange(int32_t ipc_database_id,
170 int64 transaction_id, 173 int64_t transaction_id,
171 int64 object_store_id, 174 int64_t object_store_id,
172 const IndexedDBKeyRange& key_range, 175 const IndexedDBKeyRange& key_range,
173 blink::WebIDBCallbacks* callbacks); 176 blink::WebIDBCallbacks* callbacks);
174 177
175 void RequestIDBDatabaseClear(int32 ipc_database_id, 178 void RequestIDBDatabaseClear(int32_t ipc_database_id,
176 int64 transaction_id, 179 int64_t transaction_id,
177 int64 object_store_id, 180 int64_t object_store_id,
178 blink::WebIDBCallbacks* callbacks); 181 blink::WebIDBCallbacks* callbacks);
179 182
180 virtual void CursorDestroyed(int32 ipc_cursor_id); 183 virtual void CursorDestroyed(int32_t ipc_cursor_id);
181 void DatabaseDestroyed(int32 ipc_database_id); 184 void DatabaseDestroyed(int32_t ipc_database_id);
182 185
183 private: 186 private:
184 FRIEND_TEST_ALL_PREFIXES(IndexedDBDispatcherTest, CursorReset); 187 FRIEND_TEST_ALL_PREFIXES(IndexedDBDispatcherTest, CursorReset);
185 FRIEND_TEST_ALL_PREFIXES(IndexedDBDispatcherTest, CursorTransactionId); 188 FRIEND_TEST_ALL_PREFIXES(IndexedDBDispatcherTest, CursorTransactionId);
186 FRIEND_TEST_ALL_PREFIXES(IndexedDBDispatcherTest, ValueSizeTest); 189 FRIEND_TEST_ALL_PREFIXES(IndexedDBDispatcherTest, ValueSizeTest);
187 FRIEND_TEST_ALL_PREFIXES(IndexedDBDispatcherTest, KeyAndValueSizeTest); 190 FRIEND_TEST_ALL_PREFIXES(IndexedDBDispatcherTest, KeyAndValueSizeTest);
188 191
189 enum { kAllCursors = -1 }; 192 enum { kAllCursors = -1 };
190 193
191 static int32 CurrentWorkerId() { return WorkerThread::GetCurrentId(); } 194 static int32_t CurrentWorkerId() { return WorkerThread::GetCurrentId(); }
192 195
193 template <typename T> 196 template <typename T>
194 void init_params(T* params, blink::WebIDBCallbacks* callbacks_ptr) { 197 void init_params(T* params, blink::WebIDBCallbacks* callbacks_ptr) {
195 scoped_ptr<blink::WebIDBCallbacks> callbacks(callbacks_ptr); 198 scoped_ptr<blink::WebIDBCallbacks> callbacks(callbacks_ptr);
196 params->ipc_thread_id = CurrentWorkerId(); 199 params->ipc_thread_id = CurrentWorkerId();
197 params->ipc_callbacks_id = pending_callbacks_.Add(callbacks.release()); 200 params->ipc_callbacks_id = pending_callbacks_.Add(callbacks.release());
198 } 201 }
199 202
200 // IDBCallback message handlers. 203 // IDBCallback message handlers.
201 void OnSuccessIDBDatabase(int32 ipc_thread_id, 204 void OnSuccessIDBDatabase(int32_t ipc_thread_id,
202 int32 ipc_callbacks_id, 205 int32_t ipc_callbacks_id,
203 int32 ipc_database_callbacks_id, 206 int32_t ipc_database_callbacks_id,
204 int32 ipc_object_id, 207 int32_t ipc_object_id,
205 const IndexedDBDatabaseMetadata& idb_metadata); 208 const IndexedDBDatabaseMetadata& idb_metadata);
206 void OnSuccessIndexedDBKey(int32 ipc_thread_id, 209 void OnSuccessIndexedDBKey(int32_t ipc_thread_id,
207 int32 ipc_callbacks_id, 210 int32_t ipc_callbacks_id,
208 const IndexedDBKey& key); 211 const IndexedDBKey& key);
209 212
210 void OnSuccessOpenCursor( 213 void OnSuccessOpenCursor(
211 const IndexedDBMsg_CallbacksSuccessIDBCursor_Params& p); 214 const IndexedDBMsg_CallbacksSuccessIDBCursor_Params& p);
212 void OnSuccessCursorContinue( 215 void OnSuccessCursorContinue(
213 const IndexedDBMsg_CallbacksSuccessCursorContinue_Params& p); 216 const IndexedDBMsg_CallbacksSuccessCursorContinue_Params& p);
214 void OnSuccessCursorPrefetch( 217 void OnSuccessCursorPrefetch(
215 const IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params& p); 218 const IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params& p);
216 void OnSuccessStringList(int32 ipc_thread_id, 219 void OnSuccessStringList(int32_t ipc_thread_id,
217 int32 ipc_callbacks_id, 220 int32_t ipc_callbacks_id,
218 const std::vector<base::string16>& value); 221 const std::vector<base::string16>& value);
219 void OnSuccessValue(const IndexedDBMsg_CallbacksSuccessValue_Params& p); 222 void OnSuccessValue(const IndexedDBMsg_CallbacksSuccessValue_Params& p);
220 void OnSuccessArray(const IndexedDBMsg_CallbacksSuccessArray_Params& p); 223 void OnSuccessArray(const IndexedDBMsg_CallbacksSuccessArray_Params& p);
221 void OnSuccessInteger(int32 ipc_thread_id, 224 void OnSuccessInteger(int32_t ipc_thread_id,
222 int32 ipc_callbacks_id, 225 int32_t ipc_callbacks_id,
223 int64 value); 226 int64_t value);
224 void OnSuccessUndefined(int32 ipc_thread_id, int32 ipc_callbacks_id); 227 void OnSuccessUndefined(int32_t ipc_thread_id, int32_t ipc_callbacks_id);
225 void OnError(int32 ipc_thread_id, 228 void OnError(int32_t ipc_thread_id,
226 int32 ipc_callbacks_id, 229 int32_t ipc_callbacks_id,
227 int code, 230 int code,
228 const base::string16& message); 231 const base::string16& message);
229 void OnIntBlocked(int32 ipc_thread_id, 232 void OnIntBlocked(int32_t ipc_thread_id,
230 int32 ipc_callbacks_id, 233 int32_t ipc_callbacks_id,
231 int64 existing_version); 234 int64_t existing_version);
232 void OnUpgradeNeeded(const IndexedDBMsg_CallbacksUpgradeNeeded_Params& p); 235 void OnUpgradeNeeded(const IndexedDBMsg_CallbacksUpgradeNeeded_Params& p);
233 void OnAbort(int32 ipc_thread_id, 236 void OnAbort(int32_t ipc_thread_id,
234 int32 ipc_database_id, 237 int32_t ipc_database_id,
235 int64 transaction_id, 238 int64_t transaction_id,
236 int code, 239 int code,
237 const base::string16& message); 240 const base::string16& message);
238 void OnComplete(int32 ipc_thread_id, 241 void OnComplete(int32_t ipc_thread_id,
239 int32 ipc_database_id, 242 int32_t ipc_database_id,
240 int64 transaction_id); 243 int64_t transaction_id);
241 void OnForcedClose(int32 ipc_thread_id, int32 ipc_database_id); 244 void OnForcedClose(int32_t ipc_thread_id, int32_t ipc_database_id);
242 void OnIntVersionChange(int32 ipc_thread_id, 245 void OnIntVersionChange(int32_t ipc_thread_id,
243 int32 ipc_database_id, 246 int32_t ipc_database_id,
244 int64 old_version, 247 int64_t old_version,
245 int64 new_version); 248 int64_t new_version);
246 249
247 // Reset cursor prefetch caches for all cursors except exception_cursor_id. 250 // Reset cursor prefetch caches for all cursors except exception_cursor_id.
248 void ResetCursorPrefetchCaches(int64 transaction_id, 251 void ResetCursorPrefetchCaches(int64_t transaction_id,
249 int32 ipc_exception_cursor_id); 252 int32_t ipc_exception_cursor_id);
250 253
251 scoped_refptr<ThreadSafeSender> thread_safe_sender_; 254 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
252 255
253 // Maximum size (in bytes) of value/key pair allowed for put requests. Any 256 // Maximum size (in bytes) of value/key pair allowed for put requests. Any
254 // requests larger than this size will be rejected. 257 // requests larger than this size will be rejected.
255 // Used by unit tests to exercise behavior without allocating huge chunks 258 // Used by unit tests to exercise behavior without allocating huge chunks
256 // of memory. 259 // of memory.
257 size_t max_put_value_size_ = kMaxIDBMessageSizeInBytes; 260 size_t max_put_value_size_ = kMaxIDBMessageSizeInBytes;
258 261
259 // Careful! WebIDBCallbacks wraps non-threadsafe data types. It must be 262 // Careful! WebIDBCallbacks wraps non-threadsafe data types. It must be
260 // destroyed and used on the same thread it was created on. 263 // destroyed and used on the same thread it was created on.
261 IDMap<blink::WebIDBCallbacks, IDMapOwnPointer> pending_callbacks_; 264 IDMap<blink::WebIDBCallbacks, IDMapOwnPointer> pending_callbacks_;
262 IDMap<blink::WebIDBDatabaseCallbacks, IDMapOwnPointer> 265 IDMap<blink::WebIDBDatabaseCallbacks, IDMapOwnPointer>
263 pending_database_callbacks_; 266 pending_database_callbacks_;
264 267
265 // Maps the ipc_callback_id from an open cursor request to the request's 268 // Maps the ipc_callback_id from an open cursor request to the request's
266 // transaction_id. Used to assign the transaction_id to the WebIDBCursorImpl 269 // transaction_id. Used to assign the transaction_id to the WebIDBCursorImpl
267 // when it is created. 270 // when it is created.
268 std::map<int32, int64> cursor_transaction_ids_; 271 std::map<int32_t, int64_t> cursor_transaction_ids_;
269 272
270 // Map from cursor id to WebIDBCursorImpl. 273 // Map from cursor id to WebIDBCursorImpl.
271 std::map<int32, WebIDBCursorImpl*> cursors_; 274 std::map<int32_t, WebIDBCursorImpl*> cursors_;
272 275
273 std::map<int32, WebIDBDatabaseImpl*> databases_; 276 std::map<int32_t, WebIDBDatabaseImpl*> databases_;
274 277
275 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher); 278 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher);
276 }; 279 };
277 280
278 } // namespace content 281 } // namespace content
279 282
280 #endif // CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ 283 #endif // CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_
OLDNEW
« no previous file with comments | « content/child/image_decoder.h ('k') | content/child/indexed_db/indexed_db_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698