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); | |
| 81 | |
| 82 /* The |observer_ids_to_remove| are observing the |ipc_database_id|. | |
|
dmurph
2016/06/28 18:53:50
Can you change this to all single-line comments to
palakj1
2016/06/29 23:02:41
Done.
| |
| 83 We remove our references to these observer object, and send an IPC to remove | |
| 84 the observers in the backend. */ | |
| 85 void RemoveIDBObserversFromDatabase( | |
| 86 int32_t ipc_database_id, | |
| 87 const std::vector<int32_t>& observer_ids_to_remove); | |
| 88 | |
| 89 // Removes observers from our local map observers_ . No IPC message generated. | |
| 90 void RemoveIDBObservers(const std::set<int32_t>& observer_ids_to_remove); | |
| 91 | |
| 77 void RequestIDBFactoryGetDatabaseNames(blink::WebIDBCallbacks* callbacks, | 92 void RequestIDBFactoryGetDatabaseNames(blink::WebIDBCallbacks* callbacks, |
| 78 const url::Origin& origin); | 93 const url::Origin& origin); |
| 79 | 94 |
| 80 void RequestIDBFactoryOpen(const base::string16& name, | 95 void RequestIDBFactoryOpen(const base::string16& name, |
| 81 int64_t version, | 96 int64_t version, |
| 82 int64_t transaction_id, | 97 int64_t transaction_id, |
| 83 blink::WebIDBCallbacks* callbacks, | 98 blink::WebIDBCallbacks* callbacks, |
| 84 blink::WebIDBDatabaseCallbacks* database_callbacks, | 99 blink::WebIDBDatabaseCallbacks* database_callbacks, |
| 85 const url::Origin& origin); | 100 const url::Origin& origin); |
| 86 | 101 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 void ResetCursorPrefetchCaches(int64_t transaction_id, | 266 void ResetCursorPrefetchCaches(int64_t transaction_id, |
| 252 int32_t ipc_exception_cursor_id); | 267 int32_t ipc_exception_cursor_id); |
| 253 | 268 |
| 254 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 269 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| 255 | 270 |
| 256 // Maximum size (in bytes) of value/key pair allowed for put requests. Any | 271 // Maximum size (in bytes) of value/key pair allowed for put requests. Any |
| 257 // requests larger than this size will be rejected. | 272 // requests larger than this size will be rejected. |
| 258 // Used by unit tests to exercise behavior without allocating huge chunks | 273 // Used by unit tests to exercise behavior without allocating huge chunks |
| 259 // of memory. | 274 // of memory. |
| 260 size_t max_put_value_size_ = kMaxIDBMessageSizeInBytes; | 275 size_t max_put_value_size_ = kMaxIDBMessageSizeInBytes; |
| 261 | |
|
Marijn Kruisselbrink
2016/06/28 18:58:31
nit: don't remove empty line
palakj1
2016/06/29 23:02:41
Done.
| |
| 262 // Careful! WebIDBCallbacks wraps non-threadsafe data types. It must be | 276 // Careful! WebIDBCallbacks wraps non-threadsafe data types. It must be |
| 263 // destroyed and used on the same thread it was created on. | 277 // destroyed and used on the same thread it was created on. |
| 264 IDMap<blink::WebIDBCallbacks, IDMapOwnPointer> pending_callbacks_; | 278 IDMap<blink::WebIDBCallbacks, IDMapOwnPointer> pending_callbacks_; |
| 265 IDMap<blink::WebIDBDatabaseCallbacks, IDMapOwnPointer> | 279 IDMap<blink::WebIDBDatabaseCallbacks, IDMapOwnPointer> |
| 266 pending_database_callbacks_; | 280 pending_database_callbacks_; |
| 281 IDMap<blink::WebIDBObserver, IDMapOwnPointer> observers_; | |
| 267 | 282 |
| 268 // Maps the ipc_callback_id from an open cursor request to the request's | 283 // 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 | 284 // transaction_id. Used to assign the transaction_id to the WebIDBCursorImpl |
| 270 // when it is created. | 285 // when it is created. |
| 271 std::map<int32_t, int64_t> cursor_transaction_ids_; | 286 std::map<int32_t, int64_t> cursor_transaction_ids_; |
| 272 | 287 |
| 273 // Map from cursor id to WebIDBCursorImpl. | 288 // Map from cursor id to WebIDBCursorImpl. |
| 274 std::map<int32_t, WebIDBCursorImpl*> cursors_; | 289 std::map<int32_t, WebIDBCursorImpl*> cursors_; |
| 275 | |
|
Marijn Kruisselbrink
2016/06/28 18:58:31
nit: don't remove empty line
palakj1
2016/06/29 23:02:41
Done.
| |
| 276 std::map<int32_t, WebIDBDatabaseImpl*> databases_; | 290 std::map<int32_t, WebIDBDatabaseImpl*> databases_; |
| 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 |