| 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 Send(new IndexedDBHostMsg_CursorDelete(idb_cursor_id, CurrentWorkerId(), | 195 Send(new IndexedDBHostMsg_CursorDelete(idb_cursor_id, CurrentWorkerId(), |
| 196 response_id, ec)); | 196 response_id, ec)); |
| 197 if (*ec) | 197 if (*ec) |
| 198 pending_callbacks_.Remove(response_id); | 198 pending_callbacks_.Remove(response_id); |
| 199 } | 199 } |
| 200 | 200 |
| 201 void IndexedDBDispatcher::RequestIDBFactoryOpen( | 201 void IndexedDBDispatcher::RequestIDBFactoryOpen( |
| 202 const string16& name, | 202 const string16& name, |
| 203 int64 version, | 203 int64 version, |
| 204 WebIDBCallbacks* callbacks_ptr, | 204 WebIDBCallbacks* callbacks_ptr, |
| 205 WebIDBDatabaseCallbacks* database_callbacks_ptr, |
| 205 const string16& origin, | 206 const string16& origin, |
| 206 WebFrame* web_frame) { | 207 WebFrame* web_frame) { |
| 207 ResetCursorPrefetchCaches(); | 208 ResetCursorPrefetchCaches(); |
| 208 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 209 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 210 scoped_ptr<WebIDBDatabaseCallbacks> |
| 211 database_callbacks(database_callbacks_ptr); |
| 209 | 212 |
| 210 if (!CurrentWorkerId() && | 213 if (!CurrentWorkerId() && |
| 211 !ChildThread::current()->IsWebFrameValid(web_frame)) | 214 !ChildThread::current()->IsWebFrameValid(web_frame)) |
| 212 return; | 215 return; |
| 213 | 216 |
| 214 IndexedDBHostMsg_FactoryOpen_Params params; | 217 IndexedDBHostMsg_FactoryOpen_Params params; |
| 215 params.thread_id = CurrentWorkerId(); | 218 params.thread_id = CurrentWorkerId(); |
| 216 params.response_id = pending_callbacks_.Add(callbacks.release()); | 219 params.response_id = pending_callbacks_.Add(callbacks.release()); |
| 220 params.database_response_id = pending_database_callbacks_.Add( |
| 221 database_callbacks.release()); |
| 217 params.origin = origin; | 222 params.origin = origin; |
| 218 params.name = name; | 223 params.name = name; |
| 219 params.version = version; | 224 params.version = version; |
| 220 Send(new IndexedDBHostMsg_FactoryOpen(params)); | 225 Send(new IndexedDBHostMsg_FactoryOpen(params)); |
| 221 } | 226 } |
| 222 | 227 |
| 223 void IndexedDBDispatcher::RequestIDBFactoryGetDatabaseNames( | 228 void IndexedDBDispatcher::RequestIDBFactoryGetDatabaseNames( |
| 224 WebIDBCallbacks* callbacks_ptr, | 229 WebIDBCallbacks* callbacks_ptr, |
| 225 const string16& origin, | 230 const string16& origin, |
| 226 WebFrame* web_frame) { | 231 WebFrame* web_frame) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 | 265 |
| 261 void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 idb_database_id) { | 266 void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 idb_database_id) { |
| 262 ResetCursorPrefetchCaches(); | 267 ResetCursorPrefetchCaches(); |
| 263 Send(new IndexedDBHostMsg_DatabaseClose(idb_database_id)); | 268 Send(new IndexedDBHostMsg_DatabaseClose(idb_database_id)); |
| 264 // There won't be pending database callbacks if the transaction was aborted in | 269 // There won't be pending database callbacks if the transaction was aborted in |
| 265 // the initial upgradeneeded event handler. | 270 // the initial upgradeneeded event handler. |
| 266 if (pending_database_callbacks_.Lookup(idb_database_id)) | 271 if (pending_database_callbacks_.Lookup(idb_database_id)) |
| 267 pending_database_callbacks_.Remove(idb_database_id); | 272 pending_database_callbacks_.Remove(idb_database_id); |
| 268 } | 273 } |
| 269 | 274 |
| 270 void IndexedDBDispatcher::RequestIDBDatabaseOpen( | |
| 271 WebIDBDatabaseCallbacks* callbacks_ptr, | |
| 272 int32 idb_database_id) { | |
| 273 ResetCursorPrefetchCaches(); | |
| 274 scoped_ptr<WebIDBDatabaseCallbacks> callbacks(callbacks_ptr); | |
| 275 | |
| 276 DCHECK(!pending_database_callbacks_.Lookup(idb_database_id)); | |
| 277 pending_database_callbacks_.AddWithID(callbacks.release(), idb_database_id); | |
| 278 Send(new IndexedDBHostMsg_DatabaseOpen(idb_database_id, CurrentWorkerId(), | |
| 279 idb_database_id)); | |
| 280 } | |
| 281 | |
| 282 void IndexedDBDispatcher::RequestIDBDatabaseSetVersion( | 275 void IndexedDBDispatcher::RequestIDBDatabaseSetVersion( |
| 283 const string16& version, | 276 const string16& version, |
| 284 WebIDBCallbacks* callbacks_ptr, | 277 WebIDBCallbacks* callbacks_ptr, |
| 285 int32 idb_database_id, | 278 int32 idb_database_id, |
| 286 WebExceptionCode* ec) { | 279 WebExceptionCode* ec) { |
| 287 ResetCursorPrefetchCaches(); | 280 ResetCursorPrefetchCaches(); |
| 288 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 281 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 289 | 282 |
| 290 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 283 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
| 291 Send(new IndexedDBHostMsg_DatabaseSetVersion(idb_database_id, | 284 Send(new IndexedDBHostMsg_DatabaseSetVersion(idb_database_id, |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 } | 763 } |
| 771 | 764 |
| 772 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { | 765 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { |
| 773 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; | 766 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; |
| 774 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { | 767 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |
| 775 if (i->first == exception_cursor_id) | 768 if (i->first == exception_cursor_id) |
| 776 continue; | 769 continue; |
| 777 i->second->ResetPrefetchCache(); | 770 i->second->ResetPrefetchCache(); |
| 778 } | 771 } |
| 779 } | 772 } |
| OLD | NEW |