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 <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/id_map.h" | 13 #include "base/id_map.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/strings/nullable_string16.h" | 15 #include "base/strings/nullable_string16.h" |
16 #include "content/child/worker_task_runner.h" | 16 #include "content/child/worker_task_runner.h" |
17 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
| 18 #include "content/common/indexed_db/indexed_db_constants.h" |
18 #include "ipc/ipc_sync_message_filter.h" | 19 #include "ipc/ipc_sync_message_filter.h" |
19 #include "third_party/WebKit/public/platform/WebBlobInfo.h" | 20 #include "third_party/WebKit/public/platform/WebBlobInfo.h" |
20 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBCallbacks.h
" | 21 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBCallbacks.h
" |
21 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseCal
lbacks.h" | 22 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseCal
lbacks.h" |
22 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h" | 23 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h" |
23 | 24 |
24 struct IndexedDBDatabaseMetadata; | 25 struct IndexedDBDatabaseMetadata; |
25 struct IndexedDBMsg_CallbacksSuccessCursorContinue_Params; | 26 struct IndexedDBMsg_CallbacksSuccessCursorContinue_Params; |
26 struct IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params; | 27 struct IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params; |
27 struct IndexedDBMsg_CallbacksSuccessIDBCursor_Params; | 28 struct IndexedDBMsg_CallbacksSuccessIDBCursor_Params; |
28 struct IndexedDBMsg_CallbacksSuccessArray_Params; | 29 struct IndexedDBMsg_CallbacksSuccessArray_Params; |
29 struct IndexedDBMsg_CallbacksSuccessValue_Params; | 30 struct IndexedDBMsg_CallbacksSuccessValue_Params; |
30 struct IndexedDBMsg_CallbacksUpgradeNeeded_Params; | 31 struct IndexedDBMsg_CallbacksUpgradeNeeded_Params; |
31 | 32 |
32 namespace blink { | 33 namespace blink { |
33 class WebData; | 34 class WebData; |
34 } | 35 } |
35 | 36 |
36 namespace content { | 37 namespace content { |
37 class IndexedDBKey; | 38 class IndexedDBKey; |
38 class IndexedDBKeyPath; | 39 class IndexedDBKeyPath; |
39 class IndexedDBKeyRange; | 40 class IndexedDBKeyRange; |
40 class WebIDBCursorImpl; | 41 class WebIDBCursorImpl; |
41 class WebIDBDatabaseImpl; | 42 class WebIDBDatabaseImpl; |
42 class ThreadSafeSender; | 43 class ThreadSafeSender; |
43 | 44 |
44 CONTENT_EXPORT extern const size_t kMaxIDBValueSizeInBytes; | |
45 | |
46 // Handle the indexed db related communication for this context thread - the | 45 // Handle the indexed db related communication for this context thread - the |
47 // main thread and each worker thread have their own copies. | 46 // main thread and each worker thread have their own copies. |
48 class CONTENT_EXPORT IndexedDBDispatcher : public WorkerTaskRunner::Observer { | 47 class CONTENT_EXPORT IndexedDBDispatcher : public WorkerTaskRunner::Observer { |
49 public: | 48 public: |
50 // Constructor made public to allow RenderThreadImpl to own a copy without | 49 // Constructor made public to allow RenderThreadImpl to own a copy without |
51 // failing a NOTREACHED in ThreadSpecificInstance in tests that instantiate | 50 // failing a NOTREACHED in ThreadSpecificInstance in tests that instantiate |
52 // two copies of RenderThreadImpl on the same thread. Everyone else probably | 51 // two copies of RenderThreadImpl on the same thread. Everyone else probably |
53 // wants to use ThreadSpecificInstance(). | 52 // wants to use ThreadSpecificInstance(). |
54 explicit IndexedDBDispatcher(ThreadSafeSender* thread_safe_sender); | 53 explicit IndexedDBDispatcher(ThreadSafeSender* thread_safe_sender); |
55 ~IndexedDBDispatcher() override; | 54 ~IndexedDBDispatcher() override; |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 // Reset cursor prefetch caches for all cursors except exception_cursor_id. | 249 // Reset cursor prefetch caches for all cursors except exception_cursor_id. |
251 void ResetCursorPrefetchCaches(int64 transaction_id, | 250 void ResetCursorPrefetchCaches(int64 transaction_id, |
252 int32 ipc_exception_cursor_id); | 251 int32 ipc_exception_cursor_id); |
253 | 252 |
254 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 253 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
255 | 254 |
256 // Maximum size (in bytes) of value/key pair allowed for put requests. Any | 255 // Maximum size (in bytes) of value/key pair allowed for put requests. Any |
257 // requests larger than this size will be rejected. | 256 // requests larger than this size will be rejected. |
258 // Used by unit tests to exercise behavior without allocating huge chunks | 257 // Used by unit tests to exercise behavior without allocating huge chunks |
259 // of memory. | 258 // of memory. |
260 size_t max_put_value_size_; | 259 size_t max_put_value_size_ = kMaxIDBMessageSizeInBytes; |
261 | 260 |
262 // Careful! WebIDBCallbacks wraps non-threadsafe data types. It must be | 261 // Careful! WebIDBCallbacks wraps non-threadsafe data types. It must be |
263 // destroyed and used on the same thread it was created on. | 262 // destroyed and used on the same thread it was created on. |
264 IDMap<blink::WebIDBCallbacks, IDMapOwnPointer> pending_callbacks_; | 263 IDMap<blink::WebIDBCallbacks, IDMapOwnPointer> pending_callbacks_; |
265 IDMap<blink::WebIDBDatabaseCallbacks, IDMapOwnPointer> | 264 IDMap<blink::WebIDBDatabaseCallbacks, IDMapOwnPointer> |
266 pending_database_callbacks_; | 265 pending_database_callbacks_; |
267 | 266 |
268 // Maps the ipc_callback_id from an open cursor request to the request's | 267 // 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 | 268 // transaction_id. Used to assign the transaction_id to the WebIDBCursorImpl |
270 // when it is created. | 269 // when it is created. |
271 std::map<int32, int64> cursor_transaction_ids_; | 270 std::map<int32, int64> cursor_transaction_ids_; |
272 | 271 |
273 // Map from cursor id to WebIDBCursorImpl. | 272 // Map from cursor id to WebIDBCursorImpl. |
274 std::map<int32, WebIDBCursorImpl*> cursors_; | 273 std::map<int32, WebIDBCursorImpl*> cursors_; |
275 | 274 |
276 std::map<int32, WebIDBDatabaseImpl*> databases_; | 275 std::map<int32, WebIDBDatabaseImpl*> databases_; |
277 | 276 |
278 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher); | 277 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher); |
279 }; | 278 }; |
280 | 279 |
281 } // namespace content | 280 } // namespace content |
282 | 281 |
283 #endif // CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ | 282 #endif // CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ |
OLD | NEW |