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 <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/id_map.h" | 12 #include "base/id_map.h" |
| 13 #include "base/memory/ref_counted.h" |
13 #include "base/strings/nullable_string16.h" | 14 #include "base/strings/nullable_string16.h" |
14 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
15 #include "ipc/ipc_sync_message_filter.h" | 16 #include "ipc/ipc_sync_message_filter.h" |
16 #include "third_party/WebKit/public/platform/WebIDBCallbacks.h" | 17 #include "third_party/WebKit/public/platform/WebIDBCallbacks.h" |
17 #include "third_party/WebKit/public/platform/WebIDBCursor.h" | 18 #include "third_party/WebKit/public/platform/WebIDBCursor.h" |
18 #include "third_party/WebKit/public/platform/WebIDBDatabase.h" | 19 #include "third_party/WebKit/public/platform/WebIDBDatabase.h" |
19 #include "third_party/WebKit/public/platform/WebIDBDatabaseCallbacks.h" | 20 #include "third_party/WebKit/public/platform/WebIDBDatabaseCallbacks.h" |
20 #include "webkit/child/worker_task_runner.h" | 21 #include "webkit/child/worker_task_runner.h" |
21 | 22 |
22 struct IndexedDBDatabaseMetadata; | 23 struct IndexedDBDatabaseMetadata; |
23 struct IndexedDBMsg_CallbacksSuccessCursorContinue_Params; | 24 struct IndexedDBMsg_CallbacksSuccessCursorContinue_Params; |
24 struct IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params; | 25 struct IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params; |
25 struct IndexedDBMsg_CallbacksSuccessIDBCursor_Params; | 26 struct IndexedDBMsg_CallbacksSuccessIDBCursor_Params; |
26 struct IndexedDBMsg_CallbacksUpgradeNeeded_Params; | 27 struct IndexedDBMsg_CallbacksUpgradeNeeded_Params; |
27 | 28 |
28 namespace WebKit { | 29 namespace WebKit { |
29 class WebData; | 30 class WebData; |
30 } | 31 } |
31 | 32 |
32 namespace content { | 33 namespace content { |
33 class IndexedDBKey; | 34 class IndexedDBKey; |
34 class IndexedDBKeyPath; | 35 class IndexedDBKeyPath; |
35 class IndexedDBKeyRange; | 36 class IndexedDBKeyRange; |
36 class RendererWebIDBCursorImpl; | 37 class RendererWebIDBCursorImpl; |
37 class RendererWebIDBDatabaseImpl; | 38 class RendererWebIDBDatabaseImpl; |
| 39 class ThreadSafeSender; |
38 | 40 |
39 CONTENT_EXPORT extern const size_t kMaxIDBValueSizeInBytes; | 41 CONTENT_EXPORT extern const size_t kMaxIDBValueSizeInBytes; |
40 | 42 |
41 // Handle the indexed db related communication for this context thread - the | 43 // Handle the indexed db related communication for this context thread - the |
42 // main thread and each worker thread have their own copies. | 44 // main thread and each worker thread have their own copies. |
43 class CONTENT_EXPORT IndexedDBDispatcher | 45 class CONTENT_EXPORT IndexedDBDispatcher |
44 : public webkit_glue::WorkerTaskRunner::Observer { | 46 : public webkit_glue::WorkerTaskRunner::Observer { |
45 public: | 47 public: |
46 // Constructor made public to allow RenderThreadImpl to own a copy without | 48 // Constructor made public to allow RenderThreadImpl to own a copy without |
47 // failing a NOTREACHED in ThreadSpecificInstance in tests that instantiate | 49 // failing a NOTREACHED in ThreadSpecificInstance in tests that instantiate |
48 // two copies of RenderThreadImpl on the same thread. Everyone else probably | 50 // two copies of RenderThreadImpl on the same thread. Everyone else probably |
49 // wants to use ThreadSpecificInstance(). | 51 // wants to use ThreadSpecificInstance(). |
50 IndexedDBDispatcher(); | 52 explicit IndexedDBDispatcher(ThreadSafeSender* thread_safe_sender); |
51 virtual ~IndexedDBDispatcher(); | 53 virtual ~IndexedDBDispatcher(); |
52 static IndexedDBDispatcher* ThreadSpecificInstance(); | 54 |
| 55 // |thread_safe_sender| needs to be passed in because if the call leads to |
| 56 // construction it will be needed. |
| 57 static IndexedDBDispatcher* ThreadSpecificInstance( |
| 58 ThreadSafeSender* thread_safe_sender); |
53 | 59 |
54 // webkit_glue::WorkerTaskRunner::Observer implementation. | 60 // webkit_glue::WorkerTaskRunner::Observer implementation. |
55 virtual void OnWorkerRunLoopStopped() OVERRIDE; | 61 virtual void OnWorkerRunLoopStopped() OVERRIDE; |
56 | 62 |
57 static WebKit::WebIDBMetadata ConvertMetadata( | 63 static WebKit::WebIDBMetadata ConvertMetadata( |
58 const IndexedDBDatabaseMetadata& idb_metadata); | 64 const IndexedDBDatabaseMetadata& idb_metadata); |
59 | 65 |
60 void OnMessageReceived(const IPC::Message& msg); | 66 void OnMessageReceived(const IPC::Message& msg); |
61 static bool Send(IPC::Message* msg); | 67 bool Send(IPC::Message* msg); |
62 | 68 |
63 void RequestIDBFactoryGetDatabaseNames( | 69 void RequestIDBFactoryGetDatabaseNames( |
64 WebKit::WebIDBCallbacks* callbacks, | 70 WebKit::WebIDBCallbacks* callbacks, |
65 const std::string& database_identifier); | 71 const std::string& database_identifier); |
66 | 72 |
67 void RequestIDBFactoryOpen( | 73 void RequestIDBFactoryOpen( |
68 const string16& name, | 74 const string16& name, |
69 int64 version, | 75 int64 version, |
70 int64 transaction_id, | 76 int64 transaction_id, |
71 WebKit::WebIDBCallbacks* callbacks, | 77 WebKit::WebIDBCallbacks* callbacks, |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 int64 transaction_id); | 222 int64 transaction_id); |
217 void OnForcedClose(int32 ipc_thread_id, int32 ipc_database_id); | 223 void OnForcedClose(int32 ipc_thread_id, int32 ipc_database_id); |
218 void OnIntVersionChange(int32 ipc_thread_id, | 224 void OnIntVersionChange(int32 ipc_thread_id, |
219 int32 ipc_database_id, | 225 int32 ipc_database_id, |
220 int64 old_version, | 226 int64 old_version, |
221 int64 new_version); | 227 int64 new_version); |
222 | 228 |
223 // Reset cursor prefetch caches for all cursors except exception_cursor_id. | 229 // Reset cursor prefetch caches for all cursors except exception_cursor_id. |
224 void ResetCursorPrefetchCaches(int32 ipc_exception_cursor_id = -1); | 230 void ResetCursorPrefetchCaches(int32 ipc_exception_cursor_id = -1); |
225 | 231 |
| 232 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| 233 |
226 // Careful! WebIDBCallbacks wraps non-threadsafe data types. It must be | 234 // Careful! WebIDBCallbacks wraps non-threadsafe data types. It must be |
227 // destroyed and used on the same thread it was created on. | 235 // destroyed and used on the same thread it was created on. |
228 IDMap<WebKit::WebIDBCallbacks, IDMapOwnPointer> pending_callbacks_; | 236 IDMap<WebKit::WebIDBCallbacks, IDMapOwnPointer> pending_callbacks_; |
229 IDMap<WebKit::WebIDBDatabaseCallbacks, IDMapOwnPointer> | 237 IDMap<WebKit::WebIDBDatabaseCallbacks, IDMapOwnPointer> |
230 pending_database_callbacks_; | 238 pending_database_callbacks_; |
231 | 239 |
232 // Map from cursor id to RendererWebIDBCursorImpl. | 240 // Map from cursor id to RendererWebIDBCursorImpl. |
233 std::map<int32, RendererWebIDBCursorImpl*> cursors_; | 241 std::map<int32, RendererWebIDBCursorImpl*> cursors_; |
234 | 242 |
235 std::map<int32, RendererWebIDBDatabaseImpl*> databases_; | 243 std::map<int32, RendererWebIDBDatabaseImpl*> databases_; |
236 | 244 |
237 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher); | 245 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher); |
238 }; | 246 }; |
239 | 247 |
240 } // namespace content | 248 } // namespace content |
241 | 249 |
242 #endif // CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ | 250 #endif // CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ |
OLD | NEW |