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 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
| 16 #include "base/id_map.h" | 16 #include "base/id_map.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| 19 #include "base/strings/nullable_string16.h" | 19 #include "base/strings/nullable_string16.h" |
| 20 #include "content/common/content_export.h" | 20 #include "content/common/content_export.h" |
| 21 #include "content/common/indexed_db/indexed_db_constants.h" | 21 #include "content/common/indexed_db/indexed_db_constants.h" |
| 22 #include "content/public/child/worker_thread.h" | 22 #include "content/public/child/worker_thread.h" |
| 23 #include "ipc/ipc_sync_message_filter.h" | 23 #include "ipc/ipc_sync_message_filter.h" |
| 24 #include "third_party/WebKit/public/platform/WebBlobInfo.h" | 24 #include "third_party/WebKit/public/platform/WebBlobInfo.h" |
| 25 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBCallbacks.h " | 25 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBCallbacks.h " |
| 26 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseCal lbacks.h" | 26 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseCal lbacks.h" |
| 27 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBObserver.h" | |
| 27 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h" | 28 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h" |
| 28 #include "url/origin.h" | 29 #include "url/origin.h" |
| 29 | 30 |
| 30 struct IndexedDBDatabaseMetadata; | 31 struct IndexedDBDatabaseMetadata; |
| 31 struct IndexedDBMsg_CallbacksSuccessCursorContinue_Params; | 32 struct IndexedDBMsg_CallbacksSuccessCursorContinue_Params; |
| 32 struct IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params; | 33 struct IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params; |
| 33 struct IndexedDBMsg_CallbacksSuccessIDBCursor_Params; | 34 struct IndexedDBMsg_CallbacksSuccessIDBCursor_Params; |
| 34 struct IndexedDBMsg_CallbacksSuccessArray_Params; | 35 struct IndexedDBMsg_CallbacksSuccessArray_Params; |
| 35 struct IndexedDBMsg_CallbacksSuccessValue_Params; | 36 struct IndexedDBMsg_CallbacksSuccessValue_Params; |
| 36 struct IndexedDBMsg_CallbacksUpgradeNeeded_Params; | 37 struct IndexedDBMsg_CallbacksUpgradeNeeded_Params; |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 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 |
| 78 int32_t AddIDBObserver(int32_t ipc_database_id, | |
| 79 int64_t transaction_id, | |
| 80 blink::WebIDBObserver* observer); | |
|
dmurph
2016/06/22 01:09:50
please use std::unique_ptr as an argument, and the
| |
| 81 std::vector<int32_t> RemoveIDBObservers( | |
| 82 int32_t ipc_database_id, | |
| 83 blink::WebIDBObserver* observer, | |
| 84 std::vector<int32_t> database_observers_id); | |
|
dmurph
2016/06/22 01:09:50
const ref
| |
| 85 void ClearIDBObserver(std::vector<int32_t> observersToRemove); | |
|
dmurph
2016/06/22 01:09:50
const ref, no camelCase
| |
| 86 | |
| 77 void RequestIDBFactoryGetDatabaseNames(blink::WebIDBCallbacks* callbacks, | 87 void RequestIDBFactoryGetDatabaseNames(blink::WebIDBCallbacks* callbacks, |
| 78 const url::Origin& origin); | 88 const url::Origin& origin); |
| 79 | 89 |
| 80 void RequestIDBFactoryOpen(const base::string16& name, | 90 void RequestIDBFactoryOpen(const base::string16& name, |
| 81 int64_t version, | 91 int64_t version, |
| 82 int64_t transaction_id, | 92 int64_t transaction_id, |
| 83 blink::WebIDBCallbacks* callbacks, | 93 blink::WebIDBCallbacks* callbacks, |
| 84 blink::WebIDBDatabaseCallbacks* database_callbacks, | 94 blink::WebIDBDatabaseCallbacks* database_callbacks, |
| 85 const url::Origin& origin); | 95 const url::Origin& origin); |
| 86 | 96 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 void ResetCursorPrefetchCaches(int64_t transaction_id, | 261 void ResetCursorPrefetchCaches(int64_t transaction_id, |
| 252 int32_t ipc_exception_cursor_id); | 262 int32_t ipc_exception_cursor_id); |
| 253 | 263 |
| 254 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 264 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| 255 | 265 |
| 256 // Maximum size (in bytes) of value/key pair allowed for put requests. Any | 266 // Maximum size (in bytes) of value/key pair allowed for put requests. Any |
| 257 // requests larger than this size will be rejected. | 267 // requests larger than this size will be rejected. |
| 258 // Used by unit tests to exercise behavior without allocating huge chunks | 268 // Used by unit tests to exercise behavior without allocating huge chunks |
| 259 // of memory. | 269 // of memory. |
| 260 size_t max_put_value_size_ = kMaxIDBMessageSizeInBytes; | 270 size_t max_put_value_size_ = kMaxIDBMessageSizeInBytes; |
| 261 | |
| 262 // Careful! WebIDBCallbacks wraps non-threadsafe data types. It must be | 271 // Careful! WebIDBCallbacks wraps non-threadsafe data types. It must be |
| 263 // destroyed and used on the same thread it was created on. | 272 // destroyed and used on the same thread it was created on. |
| 264 IDMap<blink::WebIDBCallbacks, IDMapOwnPointer> pending_callbacks_; | 273 IDMap<blink::WebIDBCallbacks, IDMapOwnPointer> pending_callbacks_; |
| 265 IDMap<blink::WebIDBDatabaseCallbacks, IDMapOwnPointer> | 274 IDMap<blink::WebIDBDatabaseCallbacks, IDMapOwnPointer> |
| 266 pending_database_callbacks_; | 275 pending_database_callbacks_; |
| 276 IDMap<blink::WebIDBObserver, IDMapOwnPointer> observers_; | |
| 267 | 277 |
| 268 // Maps the ipc_callback_id from an open cursor request to the request's | 278 // 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 | 279 // transaction_id. Used to assign the transaction_id to the WebIDBCursorImpl |
| 270 // when it is created. | 280 // when it is created. |
| 271 std::map<int32_t, int64_t> cursor_transaction_ids_; | 281 std::map<int32_t, int64_t> cursor_transaction_ids_; |
| 272 | 282 |
| 273 // Map from cursor id to WebIDBCursorImpl. | 283 // Map from cursor id to WebIDBCursorImpl. |
| 274 std::map<int32_t, WebIDBCursorImpl*> cursors_; | 284 std::map<int32_t, WebIDBCursorImpl*> cursors_; |
| 275 | |
| 276 std::map<int32_t, WebIDBDatabaseImpl*> databases_; | 285 std::map<int32_t, WebIDBDatabaseImpl*> databases_; |
| 277 | 286 |
| 278 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher); | 287 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher); |
| 279 }; | 288 }; |
| 280 | 289 |
| 281 } // namespace content | 290 } // namespace content |
| 282 | 291 |
| 283 #endif // CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ | 292 #endif // CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ |
| OLD | NEW |