| 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/proxy_webidbdatabase_impl.h" | 5 #include "content/common/indexed_db/proxy_webidbdatabase_impl.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 int object_store; | 110 int object_store; |
| 111 IndexedDBDispatcher::Send( | 111 IndexedDBDispatcher::Send( |
| 112 new IndexedDBHostMsg_DatabaseCreateObjectStore( | 112 new IndexedDBHostMsg_DatabaseCreateObjectStore( |
| 113 params, &object_store, &ec)); | 113 params, &object_store, &ec)); |
| 114 if (!object_store) | 114 if (!object_store) |
| 115 return NULL; | 115 return NULL; |
| 116 return new RendererWebIDBObjectStoreImpl(object_store); | 116 return new RendererWebIDBObjectStoreImpl(object_store); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void RendererWebIDBDatabaseImpl::deleteObjectStore( | 119 void RendererWebIDBDatabaseImpl::deleteObjectStore( |
| 120 const WebString& name, | |
| 121 const WebIDBTransaction& transaction, | |
| 122 WebExceptionCode& ec) { | |
| 123 IndexedDBDispatcher::Send( | |
| 124 new IndexedDBHostMsg_DatabaseDeleteObjectStoreOld( | |
| 125 idb_database_id_, name, | |
| 126 IndexedDBDispatcher::TransactionId(transaction), &ec)); | |
| 127 } | |
| 128 | |
| 129 void RendererWebIDBDatabaseImpl::deleteObjectStore( | |
| 130 long long object_store_id, | 120 long long object_store_id, |
| 131 const WebIDBTransaction& transaction, | 121 const WebIDBTransaction& transaction, |
| 132 WebExceptionCode& ec) { | 122 WebExceptionCode& ec) { |
| 133 IndexedDBDispatcher::Send( | 123 IndexedDBDispatcher::Send( |
| 134 new IndexedDBHostMsg_DatabaseDeleteObjectStore( | 124 new IndexedDBHostMsg_DatabaseDeleteObjectStore( |
| 135 idb_database_id_, object_store_id, | 125 idb_database_id_, object_store_id, |
| 136 IndexedDBDispatcher::TransactionId(transaction), &ec)); | 126 IndexedDBDispatcher::TransactionId(transaction), &ec)); |
| 137 } | 127 } |
| 138 | 128 |
| 139 void RendererWebIDBDatabaseImpl::setVersion( | 129 void RendererWebIDBDatabaseImpl::setVersion( |
| 140 const WebString& version, | 130 const WebString& version, |
| 141 WebIDBCallbacks* callbacks, | 131 WebIDBCallbacks* callbacks, |
| 142 WebExceptionCode& ec) { | 132 WebExceptionCode& ec) { |
| 143 IndexedDBDispatcher* dispatcher = | 133 IndexedDBDispatcher* dispatcher = |
| 144 IndexedDBDispatcher::ThreadSpecificInstance(); | 134 IndexedDBDispatcher::ThreadSpecificInstance(); |
| 145 dispatcher->RequestIDBDatabaseSetVersion( | 135 dispatcher->RequestIDBDatabaseSetVersion( |
| 146 version, callbacks, idb_database_id_, &ec); | 136 version, callbacks, idb_database_id_, &ec); |
| 147 } | 137 } |
| 148 | 138 |
| 149 WebKit::WebIDBTransaction* RendererWebIDBDatabaseImpl::transaction( | 139 WebKit::WebIDBTransaction* RendererWebIDBDatabaseImpl::transaction( |
| 150 const WebDOMStringList& names, | |
| 151 unsigned short mode, | |
| 152 WebExceptionCode& ec) { | |
| 153 std::vector<string16> object_stores; | |
| 154 object_stores.reserve(names.length()); | |
| 155 for (unsigned int i = 0; i < names.length(); ++i) | |
| 156 object_stores.push_back(names.item(i)); | |
| 157 | |
| 158 int transaction_id; | |
| 159 IndexedDBDispatcher::Send(new IndexedDBHostMsg_DatabaseTransactionOld( | |
| 160 WorkerTaskRunner::Instance()->CurrentWorkerId(), | |
| 161 idb_database_id_, object_stores, mode, &transaction_id, &ec)); | |
| 162 if (!transaction_id) | |
| 163 return NULL; | |
| 164 return new RendererWebIDBTransactionImpl(transaction_id); | |
| 165 } | |
| 166 | |
| 167 WebKit::WebIDBTransaction* RendererWebIDBDatabaseImpl::transaction( | |
| 168 const WebVector<long long>& object_store_ids, | 140 const WebVector<long long>& object_store_ids, |
| 169 unsigned short mode) { | 141 unsigned short mode) { |
| 170 std::vector<int64> object_stores; | 142 std::vector<int64> object_stores; |
| 171 object_stores.reserve(object_store_ids.size()); | 143 object_stores.reserve(object_store_ids.size()); |
| 172 for (unsigned int i = 0; i < object_store_ids.size(); ++i) | 144 for (unsigned int i = 0; i < object_store_ids.size(); ++i) |
| 173 object_stores.push_back(object_store_ids[i]); | 145 object_stores.push_back(object_store_ids[i]); |
| 174 | 146 |
| 175 int transaction_id; | 147 int transaction_id; |
| 176 IndexedDBDispatcher::Send(new IndexedDBHostMsg_DatabaseTransaction( | 148 IndexedDBDispatcher::Send(new IndexedDBHostMsg_DatabaseTransaction( |
| 177 WorkerTaskRunner::Instance()->CurrentWorkerId(), | 149 WorkerTaskRunner::Instance()->CurrentWorkerId(), |
| 178 idb_database_id_, object_stores, mode, &transaction_id)); | 150 idb_database_id_, object_stores, mode, &transaction_id)); |
| 179 if (!transaction_id) | 151 if (!transaction_id) |
| 180 return NULL; | 152 return NULL; |
| 181 return new RendererWebIDBTransactionImpl(transaction_id); | 153 return new RendererWebIDBTransactionImpl(transaction_id); |
| 182 } | 154 } |
| 183 | 155 |
| 184 void RendererWebIDBDatabaseImpl::close() { | 156 void RendererWebIDBDatabaseImpl::close() { |
| 185 IndexedDBDispatcher* dispatcher = | 157 IndexedDBDispatcher* dispatcher = |
| 186 IndexedDBDispatcher::ThreadSpecificInstance(); | 158 IndexedDBDispatcher::ThreadSpecificInstance(); |
| 187 dispatcher->RequestIDBDatabaseClose(idb_database_id_); | 159 dispatcher->RequestIDBDatabaseClose(idb_database_id_); |
| 188 } | 160 } |
| 189 | 161 |
| 190 } // namespace content | 162 } // namespace content |
| OLD | NEW |