| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 void WillStopCurrentWorkerThread() override; | 68 void WillStopCurrentWorkerThread() override; |
| 69 | 69 |
| 70 static blink::WebIDBMetadata ConvertMetadata( | 70 static blink::WebIDBMetadata ConvertMetadata( |
| 71 const IndexedDBDatabaseMetadata& idb_metadata); | 71 const IndexedDBDatabaseMetadata& idb_metadata); |
| 72 | 72 |
| 73 void OnMessageReceived(const IPC::Message& msg); | 73 void OnMessageReceived(const IPC::Message& msg); |
| 74 | 74 |
| 75 // 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. |
| 76 virtual bool Send(IPC::Message* msg); | 76 virtual bool Send(IPC::Message* msg); |
| 77 | 77 |
| 78 void AddIDBObserver(int32_t ipc_database_id, | 78 int32_t AddIDBObserver(int32_t ipc_database_id, |
| 79 int64_t transaction_id, | 79 int64_t transaction_id, |
| 80 blink::IDBObserver* observer); | 80 blink::IDBObserver* observer); |
| 81 std::vector<int32_t> RemoveIDBObserver(int32_t ipc_database_id, |
| 82 blink::IDBObserver* observer); |
| 81 | 83 |
| 82 void RequestIDBFactoryGetDatabaseNames(blink::WebIDBCallbacks* callbacks, | 84 void RequestIDBFactoryGetDatabaseNames(blink::WebIDBCallbacks* callbacks, |
| 83 const url::Origin& origin); | 85 const url::Origin& origin); |
| 84 | 86 |
| 85 void RequestIDBFactoryOpen(const base::string16& name, | 87 void RequestIDBFactoryOpen(const base::string16& name, |
| 86 int64_t version, | 88 int64_t version, |
| 87 int64_t transaction_id, | 89 int64_t transaction_id, |
| 88 blink::WebIDBCallbacks* callbacks, | 90 blink::WebIDBCallbacks* callbacks, |
| 89 blink::WebIDBDatabaseCallbacks* database_callbacks, | 91 blink::WebIDBDatabaseCallbacks* database_callbacks, |
| 90 const url::Origin& origin); | 92 const url::Origin& origin); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 void OnForcedClose(int32_t ipc_thread_id, int32_t ipc_database_id); | 251 void OnForcedClose(int32_t ipc_thread_id, int32_t ipc_database_id); |
| 250 void OnVersionChange(int32_t ipc_thread_id, | 252 void OnVersionChange(int32_t ipc_thread_id, |
| 251 int32_t ipc_database_id, | 253 int32_t ipc_database_id, |
| 252 int64_t old_version, | 254 int64_t old_version, |
| 253 int64_t new_version); | 255 int64_t new_version); |
| 254 | 256 |
| 255 // Reset cursor prefetch caches for all cursors except exception_cursor_id. | 257 // Reset cursor prefetch caches for all cursors except exception_cursor_id. |
| 256 void ResetCursorPrefetchCaches(int64_t transaction_id, | 258 void ResetCursorPrefetchCaches(int64_t transaction_id, |
| 257 int32_t ipc_exception_cursor_id); | 259 int32_t ipc_exception_cursor_id); |
| 258 | 260 |
| 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 | |
| 267 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 261 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| 268 | 262 |
| 269 // Maximum size (in bytes) of value/key pair allowed for put requests. Any | 263 // Maximum size (in bytes) of value/key pair allowed for put requests. Any |
| 270 // requests larger than this size will be rejected. | 264 // requests larger than this size will be rejected. |
| 271 // Used by unit tests to exercise behavior without allocating huge chunks | 265 // Used by unit tests to exercise behavior without allocating huge chunks |
| 272 // of memory. | 266 // of memory. |
| 273 size_t max_put_value_size_ = kMaxIDBMessageSizeInBytes; | 267 size_t max_put_value_size_ = kMaxIDBMessageSizeInBytes; |
| 274 int maxObserverId = 0; | |
| 275 // Careful! WebIDBCallbacks wraps non-threadsafe data types. It must be | 268 // Careful! WebIDBCallbacks wraps non-threadsafe data types. It must be |
| 276 // destroyed and used on the same thread it was created on. | 269 // destroyed and used on the same thread it was created on. |
| 277 IDMap<blink::WebIDBCallbacks, IDMapOwnPointer> pending_callbacks_; | 270 IDMap<blink::WebIDBCallbacks, IDMapOwnPointer> pending_callbacks_; |
| 278 IDMap<blink::WebIDBDatabaseCallbacks, IDMapOwnPointer> | 271 IDMap<blink::WebIDBDatabaseCallbacks, IDMapOwnPointer> |
| 279 pending_database_callbacks_; | 272 pending_database_callbacks_; |
| 280 | 273 |
| 281 // Maps the ipc_callback_id from an open cursor request to the request's | 274 // Maps the ipc_callback_id from an open cursor request to the request's |
| 282 // transaction_id. Used to assign the transaction_id to the WebIDBCursorImpl | 275 // transaction_id. Used to assign the transaction_id to the WebIDBCursorImpl |
| 283 // when it is created. | 276 // when it is created. |
| 284 std::map<int32_t, int64_t> cursor_transaction_ids_; | 277 std::map<int32_t, int64_t> cursor_transaction_ids_; |
| 285 | 278 |
| 286 // Map from cursor id to WebIDBCursorImpl. | 279 // Map from cursor id to WebIDBCursorImpl. |
| 287 std::map<int32_t, WebIDBCursorImpl*> cursors_; | 280 std::map<int32_t, WebIDBCursorImpl*> cursors_; |
| 288 | |
| 289 std::map<int32_t, WebIDBDatabaseImpl*> databases_; | 281 std::map<int32_t, WebIDBDatabaseImpl*> databases_; |
| 290 std::map<int64_t, blink::IDBObserver*> observers_; | 282 std::map<int32_t, blink::IDBObserver*> observers_; |
| 291 | 283 |
| 292 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher); | 284 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher); |
| 293 }; | 285 }; |
| 294 | 286 |
| 295 } // namespace content | 287 } // namespace content |
| 296 | 288 |
| 297 #endif // CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ | 289 #endif // CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ |
| OLD | NEW |