| 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 #include "content/renderer/renderer_webidbdatabase_impl.h" | 5 #include "content/renderer/renderer_webidbdatabase_impl.h" |
| 6 | 6 |
| 7 #include "content/common/indexed_db_messages.h" | 7 #include "content/common/indexed_db_messages.h" |
| 8 #include "content/renderer/indexed_db_dispatcher.h" | 8 #include "content/renderer/indexed_db_dispatcher.h" |
| 9 #include "content/renderer/render_thread_impl.h" | 9 #include "content/renderer/render_thread_impl.h" |
| 10 #include "content/renderer/renderer_webidbobjectstore_impl.h" | 10 #include "content/renderer/renderer_webidbobjectstore_impl.h" |
| 11 #include "content/renderer/renderer_webidbtransaction_impl.h" | 11 #include "content/renderer/renderer_webidbtransaction_impl.h" |
| 12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
| 14 #include "webkit/glue/worker_task_runner.h" |
| 14 | 15 |
| 15 using WebKit::WebDOMStringList; | 16 using WebKit::WebDOMStringList; |
| 16 using WebKit::WebExceptionCode; | 17 using WebKit::WebExceptionCode; |
| 17 using WebKit::WebFrame; | 18 using WebKit::WebFrame; |
| 18 using WebKit::WebIDBCallbacks; | 19 using WebKit::WebIDBCallbacks; |
| 19 using WebKit::WebIDBDatabaseCallbacks; | 20 using WebKit::WebIDBDatabaseCallbacks; |
| 20 using WebKit::WebIDBTransaction; | 21 using WebKit::WebIDBTransaction; |
| 21 using WebKit::WebString; | 22 using WebKit::WebString; |
| 22 using WebKit::WebVector; | 23 using WebKit::WebVector; |
| 24 using webkit_glue::WorkerTaskRunner; |
| 23 | 25 |
| 24 RendererWebIDBDatabaseImpl::RendererWebIDBDatabaseImpl(int32 idb_database_id) | 26 RendererWebIDBDatabaseImpl::RendererWebIDBDatabaseImpl(int32 idb_database_id) |
| 25 : idb_database_id_(idb_database_id) { | 27 : idb_database_id_(idb_database_id) { |
| 26 } | 28 } |
| 27 | 29 |
| 28 RendererWebIDBDatabaseImpl::~RendererWebIDBDatabaseImpl() { | 30 RendererWebIDBDatabaseImpl::~RendererWebIDBDatabaseImpl() { |
| 29 // It's not possible for there to be pending callbacks that address this | 31 // It's not possible for there to be pending callbacks that address this |
| 30 // object since inside WebKit, they hold a reference to the object which owns | 32 // object since inside WebKit, they hold a reference to the object which owns |
| 31 // this object. But, if that ever changed, then we'd need to invalidate | 33 // this object. But, if that ever changed, then we'd need to invalidate |
| 32 // any such pointers. | 34 // any such pointers. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 new IndexedDBHostMsg_DatabaseDeleteObjectStore( | 92 new IndexedDBHostMsg_DatabaseDeleteObjectStore( |
| 91 idb_database_id_, name, | 93 idb_database_id_, name, |
| 92 IndexedDBDispatcher::TransactionId(transaction), &ec)); | 94 IndexedDBDispatcher::TransactionId(transaction), &ec)); |
| 93 } | 95 } |
| 94 | 96 |
| 95 void RendererWebIDBDatabaseImpl::setVersion( | 97 void RendererWebIDBDatabaseImpl::setVersion( |
| 96 const WebString& version, | 98 const WebString& version, |
| 97 WebIDBCallbacks* callbacks, | 99 WebIDBCallbacks* callbacks, |
| 98 WebExceptionCode& ec) { | 100 WebExceptionCode& ec) { |
| 99 IndexedDBDispatcher* dispatcher = | 101 IndexedDBDispatcher* dispatcher = |
| 100 RenderThreadImpl::current()->indexed_db_dispatcher(); | 102 IndexedDBDispatcher::ThreadSpecificInstance(); |
| 101 dispatcher->RequestIDBDatabaseSetVersion( | 103 dispatcher->RequestIDBDatabaseSetVersion( |
| 102 version, callbacks, idb_database_id_, &ec); | 104 version, callbacks, idb_database_id_, &ec); |
| 103 } | 105 } |
| 104 | 106 |
| 105 WebKit::WebIDBTransaction* RendererWebIDBDatabaseImpl::transaction( | 107 WebKit::WebIDBTransaction* RendererWebIDBDatabaseImpl::transaction( |
| 106 const WebDOMStringList& names, | 108 const WebDOMStringList& names, |
| 107 unsigned short mode, | 109 unsigned short mode, |
| 108 WebExceptionCode& ec) { | 110 WebExceptionCode& ec) { |
| 109 std::vector<string16> object_stores; | 111 std::vector<string16> object_stores; |
| 110 object_stores.reserve(names.length()); | 112 object_stores.reserve(names.length()); |
| 111 for (unsigned int i = 0; i < names.length(); ++i) | 113 for (unsigned int i = 0; i < names.length(); ++i) |
| 112 object_stores.push_back(names.item(i)); | 114 object_stores.push_back(names.item(i)); |
| 113 | 115 |
| 114 int transaction_id; | 116 int transaction_id; |
| 115 ChildThread::current()->Send( | 117 ChildThread::current()->Send(new IndexedDBHostMsg_DatabaseTransaction( |
| 116 new IndexedDBHostMsg_DatabaseTransaction( | 118 WorkerTaskRunner::Instance()->CurrentWorkerId(), |
| 117 idb_database_id_, object_stores, mode, | 119 idb_database_id_, object_stores, mode, &transaction_id, &ec)); |
| 118 &transaction_id, &ec)); | |
| 119 if (!transaction_id) | 120 if (!transaction_id) |
| 120 return NULL; | 121 return NULL; |
| 121 return new RendererWebIDBTransactionImpl(transaction_id); | 122 return new RendererWebIDBTransactionImpl(transaction_id); |
| 122 } | 123 } |
| 123 | 124 |
| 124 void RendererWebIDBDatabaseImpl::close() { | 125 void RendererWebIDBDatabaseImpl::close() { |
| 125 IndexedDBDispatcher* dispatcher = | 126 IndexedDBDispatcher* dispatcher = |
| 126 RenderThreadImpl::current()->indexed_db_dispatcher(); | 127 IndexedDBDispatcher::ThreadSpecificInstance(); |
| 127 dispatcher->RequestIDBDatabaseClose(idb_database_id_); | 128 dispatcher->RequestIDBDatabaseClose(idb_database_id_); |
| 128 } | 129 } |
| 129 | 130 |
| 130 void RendererWebIDBDatabaseImpl::open(WebIDBDatabaseCallbacks* callbacks) { | 131 void RendererWebIDBDatabaseImpl::open(WebIDBDatabaseCallbacks* callbacks) { |
| 131 IndexedDBDispatcher* dispatcher = | 132 IndexedDBDispatcher* dispatcher = |
| 132 RenderThreadImpl::current()->indexed_db_dispatcher(); | 133 IndexedDBDispatcher::ThreadSpecificInstance(); |
| 134 DCHECK(dispatcher); |
| 133 dispatcher->RequestIDBDatabaseOpen(callbacks, idb_database_id_); | 135 dispatcher->RequestIDBDatabaseOpen(callbacks, idb_database_id_); |
| 134 } | 136 } |
| OLD | NEW |