| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_COMMON_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ | 5 #ifndef CONTENT_COMMON_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ |
| 6 #define CONTENT_COMMON_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ | 6 #define CONTENT_COMMON_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/id_map.h" | 11 #include "base/id_map.h" |
| 12 #include "base/nullable_string16.h" | 12 #include "base/nullable_string16.h" |
| 13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 14 #include "ipc/ipc_sync_message_filter.h" | 14 #include "ipc/ipc_sync_message_filter.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/WebIDBCursor.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h" |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseCallbac
ks.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseCallbac
ks.h" |
| 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBObjectStore.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBObjectStore.h" |
| 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h" |
| 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransactionCall
backs.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransactionCall
backs.h" |
| 23 #include "webkit/glue/worker_task_runner.h" | 23 #include "webkit/glue/worker_task_runner.h" |
| 24 | 24 |
| 25 struct IndexedDBMsg_CallbacksSuccessCursorContinue_Params; | 25 struct IndexedDBMsg_CallbacksSuccessCursorContinue_Params; |
| 26 struct IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params; | 26 struct IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params; |
| 27 struct IndexedDBMsg_CallbacksSuccessIDBCursor_Params; | 27 struct IndexedDBMsg_CallbacksSuccessIDBCursor_Params; |
| 28 class RendererWebIDBCursorImpl; | |
| 29 class RendererWebIDBDatabaseImpl; | |
| 30 | |
| 31 namespace IPC { | |
| 32 class Message; | |
| 33 } | |
| 34 | 28 |
| 35 namespace WebKit { | 29 namespace WebKit { |
| 36 class WebFrame; | 30 class WebFrame; |
| 37 class WebIDBKeyRange; | 31 class WebIDBKeyRange; |
| 38 } | 32 } |
| 39 | 33 |
| 40 namespace content { | 34 namespace content { |
| 41 class IndexedDBKey; | 35 class IndexedDBKey; |
| 42 class IndexedDBKeyPath; | 36 class IndexedDBKeyPath; |
| 43 class IndexedDBKeyRange; | 37 class IndexedDBKeyRange; |
| 38 class RendererWebIDBCursorImpl; |
| 39 class RendererWebIDBDatabaseImpl; |
| 44 class SerializedScriptValue; | 40 class SerializedScriptValue; |
| 45 } | |
| 46 | 41 |
| 47 CONTENT_EXPORT extern const size_t kMaxIDBValueSizeInBytes; | 42 CONTENT_EXPORT extern const size_t kMaxIDBValueSizeInBytes; |
| 48 | 43 |
| 49 // Handle the indexed db related communication for this context thread - the | 44 // Handle the indexed db related communication for this context thread - the |
| 50 // main thread and each worker thread have their own copies. | 45 // main thread and each worker thread have their own copies. |
| 51 class CONTENT_EXPORT IndexedDBDispatcher | 46 class CONTENT_EXPORT IndexedDBDispatcher |
| 52 : public webkit_glue::WorkerTaskRunner::Observer { | 47 : public webkit_glue::WorkerTaskRunner::Observer { |
| 53 public: | 48 public: |
| 54 // Constructor made public to allow RenderThreadImpl to own a copy without | 49 // Constructor made public to allow RenderThreadImpl to own a copy without |
| 55 // failing a NOTREACHED in ThreadSpecificInstance in tests that instantiate | 50 // failing a NOTREACHED in ThreadSpecificInstance in tests that instantiate |
| (...skipping 28 matching lines...) Expand all Loading... |
| 84 const string16& origin, | 79 const string16& origin, |
| 85 WebKit::WebFrame* web_frame); | 80 WebKit::WebFrame* web_frame); |
| 86 | 81 |
| 87 void RequestIDBCursorAdvance( | 82 void RequestIDBCursorAdvance( |
| 88 unsigned long count, | 83 unsigned long count, |
| 89 WebKit::WebIDBCallbacks* callbacks_ptr, | 84 WebKit::WebIDBCallbacks* callbacks_ptr, |
| 90 int32 idb_cursor_id, | 85 int32 idb_cursor_id, |
| 91 WebKit::WebExceptionCode* ec); | 86 WebKit::WebExceptionCode* ec); |
| 92 | 87 |
| 93 void RequestIDBCursorContinue( | 88 void RequestIDBCursorContinue( |
| 94 const content::IndexedDBKey& key, | 89 const IndexedDBKey& key, |
| 95 WebKit::WebIDBCallbacks* callbacks_ptr, | 90 WebKit::WebIDBCallbacks* callbacks_ptr, |
| 96 int32 idb_cursor_id, | 91 int32 idb_cursor_id, |
| 97 WebKit::WebExceptionCode* ec); | 92 WebKit::WebExceptionCode* ec); |
| 98 | 93 |
| 99 void RequestIDBCursorPrefetch( | 94 void RequestIDBCursorPrefetch( |
| 100 int n, | 95 int n, |
| 101 WebKit::WebIDBCallbacks* callbacks_ptr, | 96 WebKit::WebIDBCallbacks* callbacks_ptr, |
| 102 int32 idb_cursor_id, | 97 int32 idb_cursor_id, |
| 103 WebKit::WebExceptionCode* ec); | 98 WebKit::WebExceptionCode* ec); |
| 104 | 99 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 WebKit::WebExceptionCode* ec); | 131 WebKit::WebExceptionCode* ec); |
| 137 | 132 |
| 138 void RequestIDBIndexCount( | 133 void RequestIDBIndexCount( |
| 139 const WebKit::WebIDBKeyRange& idb_key_range, | 134 const WebKit::WebIDBKeyRange& idb_key_range, |
| 140 WebKit::WebIDBCallbacks* callbacks, | 135 WebKit::WebIDBCallbacks* callbacks, |
| 141 int32 idb_index_id, | 136 int32 idb_index_id, |
| 142 const WebKit::WebIDBTransaction& transaction, | 137 const WebKit::WebIDBTransaction& transaction, |
| 143 WebKit::WebExceptionCode* ec); | 138 WebKit::WebExceptionCode* ec); |
| 144 | 139 |
| 145 void RequestIDBIndexGetObject( | 140 void RequestIDBIndexGetObject( |
| 146 const content::IndexedDBKeyRange& key_range, | 141 const IndexedDBKeyRange& key_range, |
| 147 WebKit::WebIDBCallbacks* callbacks, | 142 WebKit::WebIDBCallbacks* callbacks, |
| 148 int32 idb_index_id, | 143 int32 idb_index_id, |
| 149 const WebKit::WebIDBTransaction& transaction, | 144 const WebKit::WebIDBTransaction& transaction, |
| 150 WebKit::WebExceptionCode* ec); | 145 WebKit::WebExceptionCode* ec); |
| 151 | 146 |
| 152 void RequestIDBIndexGetKey( | 147 void RequestIDBIndexGetKey( |
| 153 const content::IndexedDBKeyRange& key_range, | 148 const IndexedDBKeyRange& key_range, |
| 154 WebKit::WebIDBCallbacks* callbacks, | 149 WebKit::WebIDBCallbacks* callbacks, |
| 155 int32 idb_index_id, | 150 int32 idb_index_id, |
| 156 const WebKit::WebIDBTransaction& transaction, | 151 const WebKit::WebIDBTransaction& transaction, |
| 157 WebKit::WebExceptionCode* ec); | 152 WebKit::WebExceptionCode* ec); |
| 158 | 153 |
| 159 void RequestIDBObjectStoreGet( | 154 void RequestIDBObjectStoreGet( |
| 160 const content::IndexedDBKeyRange& key_range, | 155 const IndexedDBKeyRange& key_range, |
| 161 WebKit::WebIDBCallbacks* callbacks, | 156 WebKit::WebIDBCallbacks* callbacks, |
| 162 int32 idb_object_store_id, | 157 int32 idb_object_store_id, |
| 163 const WebKit::WebIDBTransaction& transaction, | 158 const WebKit::WebIDBTransaction& transaction, |
| 164 WebKit::WebExceptionCode* ec); | 159 WebKit::WebExceptionCode* ec); |
| 165 | 160 |
| 166 void RequestIDBObjectStorePut( | 161 void RequestIDBObjectStorePut( |
| 167 const content::SerializedScriptValue& value, | 162 const SerializedScriptValue& value, |
| 168 const content::IndexedDBKey& key, | 163 const IndexedDBKey& key, |
| 169 WebKit::WebIDBObjectStore::PutMode putMode, | 164 WebKit::WebIDBObjectStore::PutMode putMode, |
| 170 WebKit::WebIDBCallbacks* callbacks, | 165 WebKit::WebIDBCallbacks* callbacks, |
| 171 int32 idb_object_store_id, | 166 int32 idb_object_store_id, |
| 172 const WebKit::WebIDBTransaction& transaction, | 167 const WebKit::WebIDBTransaction& transaction, |
| 173 const WebKit::WebVector<WebKit::WebString>& indexNames, | 168 const WebKit::WebVector<WebKit::WebString>& indexNames, |
| 174 const WebKit::WebVector<WebKit::WebVector<WebKit::WebIDBKey> >& indexKeys, | 169 const WebKit::WebVector<WebKit::WebVector<WebKit::WebIDBKey> >& indexKeys, |
| 175 WebKit::WebExceptionCode* ec); | 170 WebKit::WebExceptionCode* ec); |
| 176 | 171 |
| 177 void RequestIDBObjectStoreDelete( | 172 void RequestIDBObjectStoreDelete( |
| 178 const content::IndexedDBKeyRange& key_range, | 173 const IndexedDBKeyRange& key_range, |
| 179 WebKit::WebIDBCallbacks* callbacks, | 174 WebKit::WebIDBCallbacks* callbacks, |
| 180 int32 idb_object_store_id, | 175 int32 idb_object_store_id, |
| 181 const WebKit::WebIDBTransaction& transaction, | 176 const WebKit::WebIDBTransaction& transaction, |
| 182 WebKit::WebExceptionCode* ec); | 177 WebKit::WebExceptionCode* ec); |
| 183 | 178 |
| 184 void RequestIDBObjectStoreClear( | 179 void RequestIDBObjectStoreClear( |
| 185 WebKit::WebIDBCallbacks* callbacks, | 180 WebKit::WebIDBCallbacks* callbacks, |
| 186 int32 idb_object_store_id, | 181 int32 idb_object_store_id, |
| 187 const WebKit::WebIDBTransaction& transaction, | 182 const WebKit::WebIDBTransaction& transaction, |
| 188 WebKit::WebExceptionCode* ec); | 183 WebKit::WebExceptionCode* ec); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 214 | 209 |
| 215 private: | 210 private: |
| 216 FRIEND_TEST_ALL_PREFIXES(IndexedDBDispatcherTest, ValueSizeTest); | 211 FRIEND_TEST_ALL_PREFIXES(IndexedDBDispatcherTest, ValueSizeTest); |
| 217 | 212 |
| 218 // IDBCallback message handlers. | 213 // IDBCallback message handlers. |
| 219 void OnSuccessIDBDatabase(int32 thread_id, | 214 void OnSuccessIDBDatabase(int32 thread_id, |
| 220 int32 response_id, | 215 int32 response_id, |
| 221 int32 object_id); | 216 int32 object_id); |
| 222 void OnSuccessIndexedDBKey(int32 thread_id, | 217 void OnSuccessIndexedDBKey(int32 thread_id, |
| 223 int32 response_id, | 218 int32 response_id, |
| 224 const content::IndexedDBKey& key); | 219 const IndexedDBKey& key); |
| 225 void OnSuccessIDBTransaction(int32 thread_id, | 220 void OnSuccessIDBTransaction(int32 thread_id, |
| 226 int32 response_id, | 221 int32 response_id, |
| 227 int32 object_id); | 222 int32 object_id); |
| 228 void OnSuccessOpenCursor( | 223 void OnSuccessOpenCursor( |
| 229 const IndexedDBMsg_CallbacksSuccessIDBCursor_Params& p); | 224 const IndexedDBMsg_CallbacksSuccessIDBCursor_Params& p); |
| 230 void OnSuccessCursorContinue( | 225 void OnSuccessCursorContinue( |
| 231 const IndexedDBMsg_CallbacksSuccessCursorContinue_Params& p); | 226 const IndexedDBMsg_CallbacksSuccessCursorContinue_Params& p); |
| 232 void OnSuccessCursorPrefetch( | 227 void OnSuccessCursorPrefetch( |
| 233 const IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params& p); | 228 const IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params& p); |
| 234 void OnSuccessStringList(int32 thread_id, | 229 void OnSuccessStringList(int32 thread_id, |
| 235 int32 response_id, | 230 int32 response_id, |
| 236 const std::vector<string16>& value); | 231 const std::vector<string16>& value); |
| 237 void OnSuccessSerializedScriptValue( | 232 void OnSuccessSerializedScriptValue( |
| 238 int32 thread_id, | 233 int32 thread_id, |
| 239 int32 response_id, | 234 int32 response_id, |
| 240 const content::SerializedScriptValue& value); | 235 const SerializedScriptValue& value); |
| 241 void OnSuccessSerializedScriptValueWithKey( | 236 void OnSuccessSerializedScriptValueWithKey( |
| 242 int32 thread_id, | 237 int32 thread_id, |
| 243 int32 response_id, | 238 int32 response_id, |
| 244 const content::SerializedScriptValue& value, | 239 const SerializedScriptValue& value, |
| 245 const content::IndexedDBKey& primary_key, | 240 const IndexedDBKey& primary_key, |
| 246 const content::IndexedDBKeyPath& key_path); | 241 const IndexedDBKeyPath& key_path); |
| 247 void OnSuccessInteger( | 242 void OnSuccessInteger( |
| 248 int32 thread_id, | 243 int32 thread_id, |
| 249 int32 response_id, | 244 int32 response_id, |
| 250 int64 value); | 245 int64 value); |
| 251 void OnSuccessUndefined( | 246 void OnSuccessUndefined( |
| 252 int32 thread_id, | 247 int32 thread_id, |
| 253 int32 response_id); | 248 int32 response_id); |
| 254 void OnError(int32 thread_id, | 249 void OnError(int32 thread_id, |
| 255 int32 response_id, | 250 int32 response_id, |
| 256 int code, | 251 int code, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 pending_database_callbacks_; | 283 pending_database_callbacks_; |
| 289 | 284 |
| 290 // Map from cursor id to RendererWebIDBCursorImpl. | 285 // Map from cursor id to RendererWebIDBCursorImpl. |
| 291 std::map<int32, RendererWebIDBCursorImpl*> cursors_; | 286 std::map<int32, RendererWebIDBCursorImpl*> cursors_; |
| 292 | 287 |
| 293 std::map<int32, RendererWebIDBDatabaseImpl*> databases_; | 288 std::map<int32, RendererWebIDBDatabaseImpl*> databases_; |
| 294 | 289 |
| 295 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher); | 290 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher); |
| 296 }; | 291 }; |
| 297 | 292 |
| 293 } // namespace content |
| 294 |
| 298 #endif // CONTENT_COMMON_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ | 295 #endif // CONTENT_COMMON_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ |
| OLD | NEW |