Chromium Code Reviews| OLD | NEW |
|---|---|
| 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> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 | 29 |
| 30 struct IndexedDBDatabaseMetadata; | 30 struct IndexedDBDatabaseMetadata; |
| 31 struct IndexedDBMsg_CallbacksSuccessCursorContinue_Params; | 31 struct IndexedDBMsg_CallbacksSuccessCursorContinue_Params; |
| 32 struct IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params; | 32 struct IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params; |
| 33 struct IndexedDBMsg_CallbacksSuccessIDBCursor_Params; | 33 struct IndexedDBMsg_CallbacksSuccessIDBCursor_Params; |
| 34 struct IndexedDBMsg_CallbacksSuccessArray_Params; | 34 struct IndexedDBMsg_CallbacksSuccessArray_Params; |
| 35 struct IndexedDBMsg_CallbacksSuccessValue_Params; | 35 struct IndexedDBMsg_CallbacksSuccessValue_Params; |
| 36 struct IndexedDBMsg_CallbacksUpgradeNeeded_Params; | 36 struct IndexedDBMsg_CallbacksUpgradeNeeded_Params; |
| 37 | 37 |
| 38 namespace blink { | 38 namespace blink { |
| 39 class IDBObserver; | |
| 39 class WebData; | 40 class WebData; |
| 40 } | 41 } |
| 41 | 42 |
| 42 namespace content { | 43 namespace content { |
| 43 class IndexedDBKey; | 44 class IndexedDBKey; |
| 44 class IndexedDBKeyPath; | 45 class IndexedDBKeyPath; |
| 45 class IndexedDBKeyRange; | 46 class IndexedDBKeyRange; |
| 46 class WebIDBCursorImpl; | 47 class WebIDBCursorImpl; |
| 47 class WebIDBDatabaseImpl; | 48 class WebIDBDatabaseImpl; |
| 48 class ThreadSafeSender; | 49 class ThreadSafeSender; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 66 // WorkerThread::Observer implementation. | 67 // WorkerThread::Observer implementation. |
| 67 void WillStopCurrentWorkerThread() override; | 68 void WillStopCurrentWorkerThread() override; |
| 68 | 69 |
| 69 static blink::WebIDBMetadata ConvertMetadata( | 70 static blink::WebIDBMetadata ConvertMetadata( |
| 70 const IndexedDBDatabaseMetadata& idb_metadata); | 71 const IndexedDBDatabaseMetadata& idb_metadata); |
| 71 | 72 |
| 72 void OnMessageReceived(const IPC::Message& msg); | 73 void OnMessageReceived(const IPC::Message& msg); |
| 73 | 74 |
| 74 // This method is virtual so it can be overridden in unit tests. | 75 // This method is virtual so it can be overridden in unit tests. |
| 75 virtual bool Send(IPC::Message* msg); | 76 virtual bool Send(IPC::Message* msg); |
| 76 | 77 |
|
dmurph
2016/06/15 12:49:44
Also add RemoveIDBObservers, which accepts a vecto
| |
| 78 void AddIDBObserver(int32_t ipc_database_id, | |
|
dmurph
2016/06/15 12:49:43
Have this return the observe ID so you can store i
palakj1
2016/06/16 07:05:41
Done
| |
| 79 int64_t transaction_id, | |
| 80 blink::IDBObserver* observer); | |
| 81 | |
| 77 void RequestIDBFactoryGetDatabaseNames(blink::WebIDBCallbacks* callbacks, | 82 void RequestIDBFactoryGetDatabaseNames(blink::WebIDBCallbacks* callbacks, |
| 78 const url::Origin& origin); | 83 const url::Origin& origin); |
| 79 | 84 |
| 80 void RequestIDBFactoryOpen(const base::string16& name, | 85 void RequestIDBFactoryOpen(const base::string16& name, |
| 81 int64_t version, | 86 int64_t version, |
| 82 int64_t transaction_id, | 87 int64_t transaction_id, |
| 83 blink::WebIDBCallbacks* callbacks, | 88 blink::WebIDBCallbacks* callbacks, |
| 84 blink::WebIDBDatabaseCallbacks* database_callbacks, | 89 blink::WebIDBDatabaseCallbacks* database_callbacks, |
| 85 const url::Origin& origin); | 90 const url::Origin& origin); |
| 86 | 91 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 void OnForcedClose(int32_t ipc_thread_id, int32_t ipc_database_id); | 249 void OnForcedClose(int32_t ipc_thread_id, int32_t ipc_database_id); |
| 245 void OnVersionChange(int32_t ipc_thread_id, | 250 void OnVersionChange(int32_t ipc_thread_id, |
| 246 int32_t ipc_database_id, | 251 int32_t ipc_database_id, |
| 247 int64_t old_version, | 252 int64_t old_version, |
| 248 int64_t new_version); | 253 int64_t new_version); |
| 249 | 254 |
| 250 // Reset cursor prefetch caches for all cursors except exception_cursor_id. | 255 // Reset cursor prefetch caches for all cursors except exception_cursor_id. |
| 251 void ResetCursorPrefetchCaches(int64_t transaction_id, | 256 void ResetCursorPrefetchCaches(int64_t transaction_id, |
| 252 int32_t ipc_exception_cursor_id); | 257 int32_t ipc_exception_cursor_id); |
| 253 | 258 |
| 259 // int64_t nextObserverId() { | |
| 260 // // Only keep a 32-bit counter to allow ports to use the other 32 | |
| 261 // // bits of the id. | |
| 262 // // overflow?? | |
| 263 // static int currentObserverId = 0; | |
| 264 // return atomicIncrement(¤tObserverId); | |
| 265 // } | |
| 266 | |
| 254 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 267 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| 255 | 268 |
| 256 // Maximum size (in bytes) of value/key pair allowed for put requests. Any | 269 // Maximum size (in bytes) of value/key pair allowed for put requests. Any |
| 257 // requests larger than this size will be rejected. | 270 // requests larger than this size will be rejected. |
| 258 // Used by unit tests to exercise behavior without allocating huge chunks | 271 // Used by unit tests to exercise behavior without allocating huge chunks |
| 259 // of memory. | 272 // of memory. |
| 260 size_t max_put_value_size_ = kMaxIDBMessageSizeInBytes; | 273 size_t max_put_value_size_ = kMaxIDBMessageSizeInBytes; |
| 261 | 274 int maxObserverId = 0; |
|
dmurph
2016/06/15 12:49:44
remove this since IDMap will handle id allocation.
| |
| 262 // Careful! WebIDBCallbacks wraps non-threadsafe data types. It must be | 275 // Careful! WebIDBCallbacks wraps non-threadsafe data types. It must be |
| 263 // destroyed and used on the same thread it was created on. | 276 // destroyed and used on the same thread it was created on. |
| 264 IDMap<blink::WebIDBCallbacks, IDMapOwnPointer> pending_callbacks_; | 277 IDMap<blink::WebIDBCallbacks, IDMapOwnPointer> pending_callbacks_; |
| 265 IDMap<blink::WebIDBDatabaseCallbacks, IDMapOwnPointer> | 278 IDMap<blink::WebIDBDatabaseCallbacks, IDMapOwnPointer> |
| 266 pending_database_callbacks_; | 279 pending_database_callbacks_; |
| 267 | 280 |
| 268 // Maps the ipc_callback_id from an open cursor request to the request's | 281 // Maps the ipc_callback_id from an open cursor request to the request's |
| 269 // transaction_id. Used to assign the transaction_id to the WebIDBCursorImpl | 282 // transaction_id. Used to assign the transaction_id to the WebIDBCursorImpl |
| 270 // when it is created. | 283 // when it is created. |
| 271 std::map<int32_t, int64_t> cursor_transaction_ids_; | 284 std::map<int32_t, int64_t> cursor_transaction_ids_; |
| 272 | 285 |
| 273 // Map from cursor id to WebIDBCursorImpl. | 286 // Map from cursor id to WebIDBCursorImpl. |
| 274 std::map<int32_t, WebIDBCursorImpl*> cursors_; | 287 std::map<int32_t, WebIDBCursorImpl*> cursors_; |
| 275 | 288 |
| 276 std::map<int32_t, WebIDBDatabaseImpl*> databases_; | 289 std::map<int32_t, WebIDBDatabaseImpl*> databases_; |
| 290 std::map<int64_t, blink::IDBObserver*> observers_; | |
|
dmurph
2016/06/15 12:49:44
Use IDMap like above, but we need to make sure the
palakj1
2016/06/16 07:05:40
Do we use IDMap cause it provides some performance
| |
| 277 | 291 |
| 278 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher); | 292 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher); |
| 279 }; | 293 }; |
| 280 | 294 |
| 281 } // namespace content | 295 } // namespace content |
| 282 | 296 |
| 283 #endif // CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ | 297 #endif // CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ |
| OLD | NEW |