Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_RENDERER_INDEXED_DB_DISPATCHER_H_ | 5 #ifndef CONTENT_RENDERER_INDEXED_DB_DISPATCHER_H_ |
| 6 #define CONTENT_RENDERER_INDEXED_DB_DISPATCHER_H_ | 6 #define CONTENT_RENDERER_INDEXED_DB_DISPATCHER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/id_map.h" | 12 #include "base/id_map.h" |
| 13 #include "base/nullable_string16.h" | 13 #include "base/nullable_string16.h" |
| 14 #include "ipc/ipc_channel.h" | 14 #include "base/threading/thread_local.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebExceptionCode.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebExceptionCode.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCallbacks.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCallbacks.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h" |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseCallbac ks.h" | |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBObjectStore.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBObjectStore.h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransactionCall backs.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransactionCall backs.h" |
| 21 #include "webkit/glue/worker_task_runner.h" | |
| 20 | 22 |
| 21 class IndexedDBKey; | 23 class IndexedDBKey; |
| 24 struct IndexedDBMsg_CallbacksSuccessCursorContinue_Params; | |
| 25 struct IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params; | |
| 26 struct IndexedDBMsg_CallbacksSuccessIDBCursor_Params; | |
| 22 class RendererWebIDBCursorImpl; | 27 class RendererWebIDBCursorImpl; |
| 23 | 28 |
| 29 namespace IPC { | |
| 30 class Message; | |
| 31 } | |
| 32 | |
| 24 namespace WebKit { | 33 namespace WebKit { |
| 25 class WebFrame; | 34 class WebFrame; |
| 26 class WebIDBKeyRange; | 35 class WebIDBKeyRange; |
| 27 class WebIDBTransaction; | 36 class WebIDBTransaction; |
| 28 } | 37 } |
| 29 | 38 |
| 30 namespace content { | 39 namespace content { |
| 31 class SerializedScriptValue; | 40 class SerializedScriptValue; |
| 32 } | 41 } |
| 33 | 42 |
| 34 // Handle the indexed db related communication for this entire renderer. | 43 // Handle the indexed db related communication for this context thread - the |
| 35 class IndexedDBDispatcher : public IPC::Channel::Listener { | 44 // main thread and each worker thread have their own copies. |
| 45 class IndexedDBDispatcher : public webkit_glue::WorkerTaskRunner::Observer { | |
| 36 public: | 46 public: |
| 37 IndexedDBDispatcher(); | |
| 38 virtual ~IndexedDBDispatcher(); | 47 virtual ~IndexedDBDispatcher(); |
| 48 static void Init(); | |
|
michaeln
2011/12/15 02:20:48
the Init() method declaration can be removed now t
dgrogan
2011/12/15 02:47:44
Done.
| |
| 49 static IndexedDBDispatcher* ThreadSpecificInstance(); | |
| 39 | 50 |
| 40 // IPC::Channel::Listener implementation. | 51 // webkit_glue::WorkerTaskRunner::Observer implementation. |
| 41 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 52 virtual void OnWorkerRunLoopStopped() OVERRIDE; |
| 53 | |
| 54 void OnMessageReceived(const IPC::Message& msg); | |
| 42 void Send(IPC::Message* msg); | 55 void Send(IPC::Message* msg); |
| 43 | 56 |
| 44 void RequestIDBFactoryGetDatabaseNames( | 57 void RequestIDBFactoryGetDatabaseNames( |
| 45 WebKit::WebIDBCallbacks* callbacks, | 58 WebKit::WebIDBCallbacks* callbacks, |
| 46 const string16& origin, | 59 const string16& origin, |
| 47 WebKit::WebFrame* web_frame); | 60 WebKit::WebFrame* web_frame); |
| 48 | 61 |
| 49 void RequestIDBFactoryOpen( | 62 void RequestIDBFactoryOpen( |
| 50 const string16& name, | 63 const string16& name, |
| 51 WebKit::WebIDBCallbacks* callbacks, | 64 WebKit::WebIDBCallbacks* callbacks, |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 | 175 |
| 163 void RegisterWebIDBTransactionCallbacks( | 176 void RegisterWebIDBTransactionCallbacks( |
| 164 WebKit::WebIDBTransactionCallbacks* callbacks, | 177 WebKit::WebIDBTransactionCallbacks* callbacks, |
| 165 int32 id); | 178 int32 id); |
| 166 | 179 |
| 167 void CursorDestroyed(int32 cursor_id); | 180 void CursorDestroyed(int32 cursor_id); |
| 168 | 181 |
| 169 static int32 TransactionId(const WebKit::WebIDBTransaction& transaction); | 182 static int32 TransactionId(const WebKit::WebIDBTransaction& transaction); |
| 170 | 183 |
| 171 private: | 184 private: |
| 185 IndexedDBDispatcher(); | |
| 172 // IDBCallback message handlers. | 186 // IDBCallback message handlers. |
| 173 void OnSuccessNull(int32 response_id); | 187 void OnSuccessNull(int32 response_id); |
| 174 void OnSuccessIDBDatabase(int32 response_id, int32 object_id); | 188 void OnSuccessIDBDatabase(int32 thread_id, |
| 175 void OnSuccessIndexedDBKey(int32 response_id, const IndexedDBKey& key); | 189 int32 response_id, |
| 176 void OnSuccessIDBTransaction(int32 response_id, int32 object_id); | 190 int32 object_id); |
| 177 void OnSuccessOpenCursor(int32 response_id, int32 object_id, | 191 void OnSuccessIndexedDBKey(int32 thread_id, |
| 178 const IndexedDBKey& key, | 192 int32 response_id, |
| 179 const IndexedDBKey& primary_key, | 193 const IndexedDBKey& key); |
| 180 const content::SerializedScriptValue& value); | 194 void OnSuccessIDBTransaction(int32 thread_id, |
| 181 void OnSuccessCursorContinue(int32 response_id, | 195 int32 response_id, |
| 182 int32 cursor_id, | 196 int32 object_id); |
| 183 const IndexedDBKey& key, | 197 void OnSuccessOpenCursor( |
| 184 const IndexedDBKey& primary_key, | 198 const IndexedDBMsg_CallbacksSuccessIDBCursor_Params& p); |
| 185 const content::SerializedScriptValue& value); | 199 void OnSuccessCursorContinue( |
| 200 const IndexedDBMsg_CallbacksSuccessCursorContinue_Params& p); | |
| 186 void OnSuccessCursorPrefetch( | 201 void OnSuccessCursorPrefetch( |
| 187 int32 response_id, | 202 const IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params& p); |
| 188 int32 cursor_id, | 203 void OnSuccessStringList(int32 thread_id, |
| 189 const std::vector<IndexedDBKey>& keys, | 204 int32 response_id, |
| 190 const std::vector<IndexedDBKey>& primary_keys, | |
| 191 const std::vector<content::SerializedScriptValue>& values); | |
| 192 void OnSuccessStringList(int32 response_id, | |
| 193 const std::vector<string16>& value); | 205 const std::vector<string16>& value); |
| 194 void OnSuccessSerializedScriptValue( | 206 void OnSuccessSerializedScriptValue( |
| 207 int32 thread_id, | |
| 195 int32 response_id, | 208 int32 response_id, |
| 196 const content::SerializedScriptValue& value); | 209 const content::SerializedScriptValue& value); |
| 197 void OnError(int32 response_id, int code, const string16& message); | 210 void OnError(int32 thread_id, |
| 198 void OnBlocked(int32 response_id); | 211 int32 response_id, |
| 199 void OnAbort(int32 transaction_id); | 212 int code, |
| 200 void OnComplete(int32 transaction_id); | 213 const string16& message); |
| 201 void OnVersionChange(int32 database_id, const string16& newVersion); | 214 void OnBlocked(int32 thread_id, int32 response_id); |
| 215 void OnAbort(int32 thread_id, int32 transaction_id); | |
| 216 void OnComplete(int32 thread_id, int32 transaction_id); | |
| 217 void OnVersionChange(int32 thread_id, | |
| 218 int32 database_id, | |
| 219 const string16& newVersion); | |
| 202 | 220 |
| 203 // Reset cursor prefetch caches for all cursors except exception_cursor_id. | 221 // Reset cursor prefetch caches for all cursors except exception_cursor_id. |
| 204 void ResetCursorPrefetchCaches(int32 exception_cursor_id = -1); | 222 void ResetCursorPrefetchCaches(int32 exception_cursor_id = -1); |
| 205 | 223 |
| 206 // Careful! WebIDBCallbacks wraps non-threadsafe data types. It must be | 224 // Careful! WebIDBCallbacks wraps non-threadsafe data types. It must be |
| 207 // destroyed and used on the same thread it was created on. | 225 // destroyed and used on the same thread it was created on. |
| 208 IDMap<WebKit::WebIDBCallbacks, IDMapOwnPointer> pending_callbacks_; | 226 IDMap<WebKit::WebIDBCallbacks, IDMapOwnPointer> pending_callbacks_; |
| 209 IDMap<WebKit::WebIDBTransactionCallbacks, IDMapOwnPointer> | 227 IDMap<WebKit::WebIDBTransactionCallbacks, IDMapOwnPointer> |
| 210 pending_transaction_callbacks_; | 228 pending_transaction_callbacks_; |
| 211 IDMap<WebKit::WebIDBDatabaseCallbacks, IDMapOwnPointer> | 229 IDMap<WebKit::WebIDBDatabaseCallbacks, IDMapOwnPointer> |
| 212 pending_database_callbacks_; | 230 pending_database_callbacks_; |
| 213 | 231 |
| 214 // Map from cursor id to RendererWebIDBCursorImpl. | 232 // Map from cursor id to RendererWebIDBCursorImpl. |
| 215 std::map<int32, RendererWebIDBCursorImpl*> cursors_; | 233 std::map<int32, RendererWebIDBCursorImpl*> cursors_; |
| 216 | 234 |
| 217 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher); | 235 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher); |
| 218 }; | 236 }; |
| 219 | 237 |
| 220 #endif // CONTENT_RENDERER_INDEXED_DB_DISPATCHER_H_ | 238 #endif // CONTENT_RENDERER_INDEXED_DB_DISPATCHER_H_ |
| OLD | NEW |