| 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 #include "content/common/indexed_db/indexed_db_dispatcher.h" | 5 #include "content/common/indexed_db/indexed_db_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/threading/thread_local.h" | 8 #include "base/threading/thread_local.h" |
| 9 #include "content/common/child_thread.h" | 9 #include "content/common/child_thread.h" |
| 10 #include "content/common/indexed_db/indexed_db_messages.h" | 10 #include "content/common/indexed_db/indexed_db_messages.h" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 ResetCursorPrefetchCaches(); | 193 ResetCursorPrefetchCaches(); |
| 194 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 194 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 195 | 195 |
| 196 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 196 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
| 197 Send(new IndexedDBHostMsg_CursorDelete(idb_cursor_id, CurrentWorkerId(), | 197 Send(new IndexedDBHostMsg_CursorDelete(idb_cursor_id, CurrentWorkerId(), |
| 198 response_id, ec)); | 198 response_id, ec)); |
| 199 if (*ec) | 199 if (*ec) |
| 200 pending_callbacks_.Remove(response_id); | 200 pending_callbacks_.Remove(response_id); |
| 201 } | 201 } |
| 202 | 202 |
| 203 // TODO(jsbell): Remove this overload once WK90411 rolls. | |
| 204 void IndexedDBDispatcher::RequestIDBFactoryOpen( | |
| 205 const string16& name, | |
| 206 int64 version, | |
| 207 WebIDBCallbacks* callbacks_ptr, | |
| 208 const string16& origin, | |
| 209 WebFrame* web_frame) { | |
| 210 ResetCursorPrefetchCaches(); | |
| 211 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | |
| 212 | |
| 213 if (!CurrentWorkerId() && | |
| 214 !ChildThread::current()->IsWebFrameValid(web_frame)) | |
| 215 return; | |
| 216 | |
| 217 IndexedDBHostMsg_FactoryOpen_Params params; | |
| 218 params.thread_id = CurrentWorkerId(); | |
| 219 params.response_id = pending_callbacks_.Add(callbacks.release()); | |
| 220 params.database_response_id = 0; // Unused in this message. | |
| 221 params.origin = origin; | |
| 222 params.name = name; | |
| 223 params.version = version; | |
| 224 Send(new IndexedDBHostMsg_FactoryOpenLegacy(params)); | |
| 225 } | |
| 226 | |
| 227 void IndexedDBDispatcher::RequestIDBFactoryOpen( | 203 void IndexedDBDispatcher::RequestIDBFactoryOpen( |
| 228 const string16& name, | 204 const string16& name, |
| 229 int64 version, | 205 int64 version, |
| 230 WebIDBCallbacks* callbacks_ptr, | 206 WebIDBCallbacks* callbacks_ptr, |
| 231 WebIDBDatabaseCallbacks* database_callbacks_ptr, | 207 WebIDBDatabaseCallbacks* database_callbacks_ptr, |
| 232 const string16& origin, | 208 const string16& origin, |
| 233 WebFrame* web_frame) { | 209 WebFrame* web_frame) { |
| 234 ResetCursorPrefetchCaches(); | 210 ResetCursorPrefetchCaches(); |
| 235 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 211 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 236 scoped_ptr<WebIDBDatabaseCallbacks> | 212 scoped_ptr<WebIDBDatabaseCallbacks> |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 | 267 |
| 292 void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 idb_database_id) { | 268 void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 idb_database_id) { |
| 293 ResetCursorPrefetchCaches(); | 269 ResetCursorPrefetchCaches(); |
| 294 Send(new IndexedDBHostMsg_DatabaseClose(idb_database_id)); | 270 Send(new IndexedDBHostMsg_DatabaseClose(idb_database_id)); |
| 295 // There won't be pending database callbacks if the transaction was aborted in | 271 // There won't be pending database callbacks if the transaction was aborted in |
| 296 // the initial upgradeneeded event handler. | 272 // the initial upgradeneeded event handler. |
| 297 if (pending_database_callbacks_.Lookup(idb_database_id)) | 273 if (pending_database_callbacks_.Lookup(idb_database_id)) |
| 298 pending_database_callbacks_.Remove(idb_database_id); | 274 pending_database_callbacks_.Remove(idb_database_id); |
| 299 } | 275 } |
| 300 | 276 |
| 301 // TODO(jsbell): Remove once WK90411 has rolled. | |
| 302 void IndexedDBDispatcher::RequestIDBDatabaseOpen( | |
| 303 WebIDBDatabaseCallbacks* callbacks_ptr, | |
| 304 int32 idb_database_id) { | |
| 305 ResetCursorPrefetchCaches(); | |
| 306 scoped_ptr<WebIDBDatabaseCallbacks> callbacks(callbacks_ptr); | |
| 307 | |
| 308 DCHECK(!pending_database_callbacks_.Lookup(idb_database_id)); | |
| 309 pending_database_callbacks_.AddWithID(callbacks.release(), idb_database_id); | |
| 310 Send(new IndexedDBHostMsg_DatabaseOpen(idb_database_id, CurrentWorkerId(), | |
| 311 idb_database_id)); | |
| 312 } | |
| 313 | |
| 314 void IndexedDBDispatcher::RequestIDBDatabaseSetVersion( | 277 void IndexedDBDispatcher::RequestIDBDatabaseSetVersion( |
| 315 const string16& version, | 278 const string16& version, |
| 316 WebIDBCallbacks* callbacks_ptr, | 279 WebIDBCallbacks* callbacks_ptr, |
| 317 int32 idb_database_id, | 280 int32 idb_database_id, |
| 318 WebExceptionCode* ec) { | 281 WebExceptionCode* ec) { |
| 319 ResetCursorPrefetchCaches(); | 282 ResetCursorPrefetchCaches(); |
| 320 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 283 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 321 | 284 |
| 322 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 285 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
| 323 Send(new IndexedDBHostMsg_DatabaseSetVersion(idb_database_id, | 286 Send(new IndexedDBHostMsg_DatabaseSetVersion(idb_database_id, |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 } | 775 } |
| 813 | 776 |
| 814 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { | 777 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { |
| 815 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; | 778 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; |
| 816 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { | 779 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |
| 817 if (i->first == exception_cursor_id) | 780 if (i->first == exception_cursor_id) |
| 818 continue; | 781 continue; |
| 819 i->second->ResetPrefetchCache(); | 782 i->second->ResetPrefetchCache(); |
| 820 } | 783 } |
| 821 } | 784 } |
| OLD | NEW |