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/browser/indexed_db/indexed_db_dispatcher_host.h" | 5 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/command_line.h" | 10 #include "base/command_line.h" |
9 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
10 #include "base/guid.h" | 12 #include "base/guid.h" |
11 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
12 #include "base/process/process.h" | 14 #include "base/process/process.h" |
13 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
14 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
15 #include "content/browser/bad_message.h" | 17 #include "content/browser/bad_message.h" |
16 #include "content/browser/child_process_security_policy_impl.h" | 18 #include "content/browser/child_process_security_policy_impl.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 cursor_dispatcher_host_(new CursorDispatcherHost(this)), | 71 cursor_dispatcher_host_(new CursorDispatcherHost(this)), |
70 ipc_process_id_(ipc_process_id) { | 72 ipc_process_id_(ipc_process_id) { |
71 DCHECK(indexed_db_context_.get()); | 73 DCHECK(indexed_db_context_.get()); |
72 } | 74 } |
73 | 75 |
74 IndexedDBDispatcherHost::~IndexedDBDispatcherHost() { | 76 IndexedDBDispatcherHost::~IndexedDBDispatcherHost() { |
75 for (auto& iter : blob_data_handle_map_) | 77 for (auto& iter : blob_data_handle_map_) |
76 delete iter.second.first; | 78 delete iter.second.first; |
77 } | 79 } |
78 | 80 |
79 void IndexedDBDispatcherHost::OnChannelConnected(int32 peer_pid) { | 81 void IndexedDBDispatcherHost::OnChannelConnected(int32_t peer_pid) { |
80 BrowserMessageFilter::OnChannelConnected(peer_pid); | 82 BrowserMessageFilter::OnChannelConnected(peer_pid); |
81 | 83 |
82 if (request_context_getter_.get()) { | 84 if (request_context_getter_.get()) { |
83 DCHECK(!request_context_); | 85 DCHECK(!request_context_); |
84 request_context_ = request_context_getter_->GetURLRequestContext(); | 86 request_context_ = request_context_getter_->GetURLRequestContext(); |
85 request_context_getter_ = NULL; | 87 request_context_getter_ = NULL; |
86 DCHECK(request_context_); | 88 DCHECK(request_context_); |
87 } | 89 } |
88 } | 90 } |
89 | 91 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryOpen, OnIDBFactoryOpen) | 155 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryOpen, OnIDBFactoryOpen) |
154 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryDeleteDatabase, | 156 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryDeleteDatabase, |
155 OnIDBFactoryDeleteDatabase) | 157 OnIDBFactoryDeleteDatabase) |
156 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_AckReceivedBlobs, OnAckReceivedBlobs) | 158 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_AckReceivedBlobs, OnAckReceivedBlobs) |
157 IPC_MESSAGE_UNHANDLED(handled = false) | 159 IPC_MESSAGE_UNHANDLED(handled = false) |
158 IPC_END_MESSAGE_MAP() | 160 IPC_END_MESSAGE_MAP() |
159 } | 161 } |
160 return handled; | 162 return handled; |
161 } | 163 } |
162 | 164 |
163 int32 IndexedDBDispatcherHost::Add(IndexedDBCursor* cursor) { | 165 int32_t IndexedDBDispatcherHost::Add(IndexedDBCursor* cursor) { |
164 if (!cursor_dispatcher_host_) { | 166 if (!cursor_dispatcher_host_) { |
165 return 0; | 167 return 0; |
166 } | 168 } |
167 return cursor_dispatcher_host_->map_.Add(cursor); | 169 return cursor_dispatcher_host_->map_.Add(cursor); |
168 } | 170 } |
169 | 171 |
170 int32 IndexedDBDispatcherHost::Add(IndexedDBConnection* connection, | 172 int32_t IndexedDBDispatcherHost::Add(IndexedDBConnection* connection, |
171 int32 ipc_thread_id, | 173 int32_t ipc_thread_id, |
172 const GURL& origin_url) { | 174 const GURL& origin_url) { |
173 if (!database_dispatcher_host_) { | 175 if (!database_dispatcher_host_) { |
174 connection->Close(); | 176 connection->Close(); |
175 delete connection; | 177 delete connection; |
176 return -1; | 178 return -1; |
177 } | 179 } |
178 int32 ipc_database_id = database_dispatcher_host_->map_.Add(connection); | 180 int32_t ipc_database_id = database_dispatcher_host_->map_.Add(connection); |
179 Context()->ConnectionOpened(origin_url, connection); | 181 Context()->ConnectionOpened(origin_url, connection); |
180 database_dispatcher_host_->database_url_map_[ipc_database_id] = origin_url; | 182 database_dispatcher_host_->database_url_map_[ipc_database_id] = origin_url; |
181 return ipc_database_id; | 183 return ipc_database_id; |
182 } | 184 } |
183 | 185 |
184 void IndexedDBDispatcherHost::RegisterTransactionId(int64 host_transaction_id, | 186 void IndexedDBDispatcherHost::RegisterTransactionId(int64_t host_transaction_id, |
185 const GURL& url) { | 187 const GURL& url) { |
186 if (!database_dispatcher_host_) | 188 if (!database_dispatcher_host_) |
187 return; | 189 return; |
188 database_dispatcher_host_->transaction_url_map_[host_transaction_id] = url; | 190 database_dispatcher_host_->transaction_url_map_[host_transaction_id] = url; |
189 } | 191 } |
190 | 192 |
191 int64 IndexedDBDispatcherHost::HostTransactionId(int64 transaction_id) { | 193 int64_t IndexedDBDispatcherHost::HostTransactionId(int64_t transaction_id) { |
192 // Inject the renderer process id into the transaction id, to | 194 // Inject the renderer process id into the transaction id, to |
193 // uniquely identify this transaction, and effectively bind it to | 195 // uniquely identify this transaction, and effectively bind it to |
194 // the renderer that initiated it. The lower 32 bits of | 196 // the renderer that initiated it. The lower 32 bits of |
195 // transaction_id are guaranteed to be unique within that renderer. | 197 // transaction_id are guaranteed to be unique within that renderer. |
196 base::ProcessId pid = peer_pid(); | 198 base::ProcessId pid = peer_pid(); |
197 DCHECK(!(transaction_id >> 32)) << "Transaction ids can only be 32 bits"; | 199 DCHECK(!(transaction_id >> 32)) << "Transaction ids can only be 32 bits"; |
198 static_assert(sizeof(base::ProcessId) <= sizeof(int32), | 200 static_assert(sizeof(base::ProcessId) <= sizeof(int32_t), |
199 "Process ID must fit in 32 bits"); | 201 "Process ID must fit in 32 bits"); |
200 | 202 |
201 return transaction_id | (static_cast<uint64>(pid) << 32); | 203 return transaction_id | (static_cast<uint64_t>(pid) << 32); |
202 } | 204 } |
203 | 205 |
204 int64 IndexedDBDispatcherHost::RendererTransactionId( | 206 int64_t IndexedDBDispatcherHost::RendererTransactionId( |
205 int64 host_transaction_id) { | 207 int64_t host_transaction_id) { |
206 DCHECK(host_transaction_id >> 32 == peer_pid()) | 208 DCHECK(host_transaction_id >> 32 == peer_pid()) |
207 << "Invalid renderer target for transaction id"; | 209 << "Invalid renderer target for transaction id"; |
208 return host_transaction_id & 0xffffffff; | 210 return host_transaction_id & 0xffffffff; |
209 } | 211 } |
210 | 212 |
211 // static | 213 // static |
212 uint32 IndexedDBDispatcherHost::TransactionIdToRendererTransactionId( | 214 uint32_t IndexedDBDispatcherHost::TransactionIdToRendererTransactionId( |
213 int64 host_transaction_id) { | 215 int64_t host_transaction_id) { |
214 return host_transaction_id & 0xffffffff; | 216 return host_transaction_id & 0xffffffff; |
215 } | 217 } |
216 | 218 |
217 // static | 219 // static |
218 uint32 IndexedDBDispatcherHost::TransactionIdToProcessId( | 220 uint32_t IndexedDBDispatcherHost::TransactionIdToProcessId( |
219 int64 host_transaction_id) { | 221 int64_t host_transaction_id) { |
220 return (host_transaction_id >> 32) & 0xffffffff; | 222 return (host_transaction_id >> 32) & 0xffffffff; |
221 } | 223 } |
222 | 224 |
223 std::string IndexedDBDispatcherHost::HoldBlobData( | 225 std::string IndexedDBDispatcherHost::HoldBlobData( |
224 const IndexedDBBlobInfo& blob_info) { | 226 const IndexedDBBlobInfo& blob_info) { |
225 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 227 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
226 std::string uuid = blob_info.uuid(); | 228 std::string uuid = blob_info.uuid(); |
227 storage::BlobStorageContext* context = blob_storage_context_->context(); | 229 storage::BlobStorageContext* context = blob_storage_context_->context(); |
228 scoped_ptr<storage::BlobDataHandle> blob_data_handle; | 230 scoped_ptr<storage::BlobDataHandle> blob_data_handle; |
229 if (uuid.empty()) { | 231 if (uuid.empty()) { |
(...skipping 26 matching lines...) Expand all Loading... |
256 delete iter->second.first; | 258 delete iter->second.first; |
257 blob_data_handle_map_.erase(iter); | 259 blob_data_handle_map_.erase(iter); |
258 } else { | 260 } else { |
259 iter->second.second -= 1; | 261 iter->second.second -= 1; |
260 } | 262 } |
261 } else { | 263 } else { |
262 DLOG(FATAL) << "Failed to find blob UUID in map:" << uuid; | 264 DLOG(FATAL) << "Failed to find blob UUID in map:" << uuid; |
263 } | 265 } |
264 } | 266 } |
265 | 267 |
266 IndexedDBCursor* IndexedDBDispatcherHost::GetCursorFromId(int32 ipc_cursor_id) { | 268 IndexedDBCursor* IndexedDBDispatcherHost::GetCursorFromId( |
| 269 int32_t ipc_cursor_id) { |
267 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 270 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
268 return cursor_dispatcher_host_->map_.Lookup(ipc_cursor_id); | 271 return cursor_dispatcher_host_->map_.Lookup(ipc_cursor_id); |
269 } | 272 } |
270 | 273 |
271 ::IndexedDBDatabaseMetadata IndexedDBDispatcherHost::ConvertMetadata( | 274 ::IndexedDBDatabaseMetadata IndexedDBDispatcherHost::ConvertMetadata( |
272 const content::IndexedDBDatabaseMetadata& web_metadata) { | 275 const content::IndexedDBDatabaseMetadata& web_metadata) { |
273 ::IndexedDBDatabaseMetadata metadata; | 276 ::IndexedDBDatabaseMetadata metadata; |
274 metadata.id = web_metadata.id; | 277 metadata.id = web_metadata.id; |
275 metadata.name = web_metadata.name; | 278 metadata.name = web_metadata.name; |
276 metadata.version = web_metadata.version; | 279 metadata.version = web_metadata.version; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 | 324 |
322 void IndexedDBDispatcherHost::OnIDBFactoryOpen( | 325 void IndexedDBDispatcherHost::OnIDBFactoryOpen( |
323 const IndexedDBHostMsg_FactoryOpen_Params& params) { | 326 const IndexedDBHostMsg_FactoryOpen_Params& params) { |
324 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 327 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
325 base::TimeTicks begin_time = base::TimeTicks::Now(); | 328 base::TimeTicks begin_time = base::TimeTicks::Now(); |
326 base::FilePath indexed_db_path = indexed_db_context_->data_path(); | 329 base::FilePath indexed_db_path = indexed_db_context_->data_path(); |
327 | 330 |
328 GURL origin_url = | 331 GURL origin_url = |
329 storage::GetOriginFromIdentifier(params.database_identifier); | 332 storage::GetOriginFromIdentifier(params.database_identifier); |
330 | 333 |
331 int64 host_transaction_id = HostTransactionId(params.transaction_id); | 334 int64_t host_transaction_id = HostTransactionId(params.transaction_id); |
332 | 335 |
333 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore | 336 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore |
334 // created) if this origin is already over quota. | 337 // created) if this origin is already over quota. |
335 scoped_refptr<IndexedDBCallbacks> callbacks = | 338 scoped_refptr<IndexedDBCallbacks> callbacks = |
336 new IndexedDBCallbacks(this, | 339 new IndexedDBCallbacks(this, |
337 params.ipc_thread_id, | 340 params.ipc_thread_id, |
338 params.ipc_callbacks_id, | 341 params.ipc_callbacks_id, |
339 params.ipc_database_callbacks_id, | 342 params.ipc_database_callbacks_id, |
340 host_transaction_id, | 343 host_transaction_id, |
341 origin_url); | 344 origin_url); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 database_dispatcher_host_->OnPut(params, handles); | 380 database_dispatcher_host_->OnPut(params, handles); |
378 } | 381 } |
379 | 382 |
380 void IndexedDBDispatcherHost::OnAckReceivedBlobs( | 383 void IndexedDBDispatcherHost::OnAckReceivedBlobs( |
381 const std::vector<std::string>& uuids) { | 384 const std::vector<std::string>& uuids) { |
382 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 385 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
383 for (const auto& uuid : uuids) | 386 for (const auto& uuid : uuids) |
384 DropBlobData(uuid); | 387 DropBlobData(uuid); |
385 } | 388 } |
386 | 389 |
387 void IndexedDBDispatcherHost::FinishTransaction(int64 host_transaction_id, | 390 void IndexedDBDispatcherHost::FinishTransaction(int64_t host_transaction_id, |
388 bool committed) { | 391 bool committed) { |
389 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 392 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
390 if (!database_dispatcher_host_) | 393 if (!database_dispatcher_host_) |
391 return; | 394 return; |
392 TransactionIDToURLMap& transaction_url_map = | 395 TransactionIDToURLMap& transaction_url_map = |
393 database_dispatcher_host_->transaction_url_map_; | 396 database_dispatcher_host_->transaction_url_map_; |
394 TransactionIDToSizeMap& transaction_size_map = | 397 TransactionIDToSizeMap& transaction_size_map = |
395 database_dispatcher_host_->transaction_size_map_; | 398 database_dispatcher_host_->transaction_size_map_; |
396 TransactionIDToDatabaseIDMap& transaction_database_map = | 399 TransactionIDToDatabaseIDMap& transaction_database_map = |
397 database_dispatcher_host_->transaction_database_map_; | 400 database_dispatcher_host_->transaction_database_map_; |
398 if (committed) | 401 if (committed) |
399 Context()->TransactionComplete(transaction_url_map[host_transaction_id]); | 402 Context()->TransactionComplete(transaction_url_map[host_transaction_id]); |
400 transaction_url_map.erase(host_transaction_id); | 403 transaction_url_map.erase(host_transaction_id); |
401 transaction_size_map.erase(host_transaction_id); | 404 transaction_size_map.erase(host_transaction_id); |
402 transaction_database_map.erase(host_transaction_id); | 405 transaction_database_map.erase(host_transaction_id); |
403 } | 406 } |
404 | 407 |
405 ////////////////////////////////////////////////////////////////////// | 408 ////////////////////////////////////////////////////////////////////// |
406 // Helper templates. | 409 // Helper templates. |
407 // | 410 // |
408 | 411 |
409 template <typename ObjectType> | 412 template <typename ObjectType> |
410 ObjectType* IndexedDBDispatcherHost::GetOrTerminateProcess( | 413 ObjectType* IndexedDBDispatcherHost::GetOrTerminateProcess( |
411 IDMap<ObjectType, IDMapOwnPointer>* map, | 414 IDMap<ObjectType, IDMapOwnPointer>* map, |
412 int32 ipc_return_object_id) { | 415 int32_t ipc_return_object_id) { |
413 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 416 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
414 ObjectType* return_object = map->Lookup(ipc_return_object_id); | 417 ObjectType* return_object = map->Lookup(ipc_return_object_id); |
415 if (!return_object) { | 418 if (!return_object) { |
416 NOTREACHED() << "Uh oh, couldn't find object with id " | 419 NOTREACHED() << "Uh oh, couldn't find object with id " |
417 << ipc_return_object_id; | 420 << ipc_return_object_id; |
418 bad_message::ReceivedBadMessage(this, bad_message::IDBDH_GET_OR_TERMINATE); | 421 bad_message::ReceivedBadMessage(this, bad_message::IDBDH_GET_OR_TERMINATE); |
419 } | 422 } |
420 return return_object; | 423 return return_object; |
421 } | 424 } |
422 | 425 |
423 template <typename ObjectType> | 426 template <typename ObjectType> |
424 ObjectType* IndexedDBDispatcherHost::GetOrTerminateProcess( | 427 ObjectType* IndexedDBDispatcherHost::GetOrTerminateProcess( |
425 RefIDMap<ObjectType>* map, | 428 RefIDMap<ObjectType>* map, |
426 int32 ipc_return_object_id) { | 429 int32_t ipc_return_object_id) { |
427 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 430 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
428 ObjectType* return_object = map->Lookup(ipc_return_object_id); | 431 ObjectType* return_object = map->Lookup(ipc_return_object_id); |
429 if (!return_object) { | 432 if (!return_object) { |
430 NOTREACHED() << "Uh oh, couldn't find object with id " | 433 NOTREACHED() << "Uh oh, couldn't find object with id " |
431 << ipc_return_object_id; | 434 << ipc_return_object_id; |
432 bad_message::ReceivedBadMessage(this, bad_message::IDBDH_GET_OR_TERMINATE); | 435 bad_message::ReceivedBadMessage(this, bad_message::IDBDH_GET_OR_TERMINATE); |
433 } | 436 } |
434 return return_object; | 437 return return_object; |
435 } | 438 } |
436 | 439 |
437 template <typename MapType> | 440 template <typename MapType> |
438 void IndexedDBDispatcherHost::DestroyObject(MapType* map, int32 ipc_object_id) { | 441 void IndexedDBDispatcherHost::DestroyObject(MapType* map, |
| 442 int32_t ipc_object_id) { |
439 GetOrTerminateProcess(map, ipc_object_id); | 443 GetOrTerminateProcess(map, ipc_object_id); |
440 map->Remove(ipc_object_id); | 444 map->Remove(ipc_object_id); |
441 } | 445 } |
442 | 446 |
443 ////////////////////////////////////////////////////////////////////// | 447 ////////////////////////////////////////////////////////////////////// |
444 // IndexedDBDispatcherHost::DatabaseDispatcherHost | 448 // IndexedDBDispatcherHost::DatabaseDispatcherHost |
445 // | 449 // |
446 | 450 |
447 IndexedDBDispatcherHost::DatabaseDispatcherHost::DatabaseDispatcherHost( | 451 IndexedDBDispatcherHost::DatabaseDispatcherHost::DatabaseDispatcherHost( |
448 IndexedDBDispatcherHost* parent) | 452 IndexedDBDispatcherHost* parent) |
449 : parent_(parent) { | 453 : parent_(parent) { |
450 map_.set_check_on_null_data(true); | 454 map_.set_check_on_null_data(true); |
451 } | 455 } |
452 | 456 |
453 IndexedDBDispatcherHost::DatabaseDispatcherHost::~DatabaseDispatcherHost() { | 457 IndexedDBDispatcherHost::DatabaseDispatcherHost::~DatabaseDispatcherHost() { |
454 // TODO(alecflett): uncomment these when we find the source of these leaks. | 458 // TODO(alecflett): uncomment these when we find the source of these leaks. |
455 // DCHECK(transaction_size_map_.empty()); | 459 // DCHECK(transaction_size_map_.empty()); |
456 // DCHECK(transaction_url_map_.empty()); | 460 // DCHECK(transaction_url_map_.empty()); |
457 } | 461 } |
458 | 462 |
459 void IndexedDBDispatcherHost::DatabaseDispatcherHost::CloseAll() { | 463 void IndexedDBDispatcherHost::DatabaseDispatcherHost::CloseAll() { |
460 DCHECK( | 464 DCHECK( |
461 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 465 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
462 // Abort outstanding transactions started by connections in the associated | 466 // Abort outstanding transactions started by connections in the associated |
463 // front-end to unblock later transactions. This should only occur on unclean | 467 // front-end to unblock later transactions. This should only occur on unclean |
464 // (crash) or abrupt (process-kill) shutdowns. | 468 // (crash) or abrupt (process-kill) shutdowns. |
465 for (TransactionIDToDatabaseIDMap::iterator iter = | 469 for (TransactionIDToDatabaseIDMap::iterator iter = |
466 transaction_database_map_.begin(); | 470 transaction_database_map_.begin(); |
467 iter != transaction_database_map_.end();) { | 471 iter != transaction_database_map_.end();) { |
468 int64 transaction_id = iter->first; | 472 int64_t transaction_id = iter->first; |
469 int32 ipc_database_id = iter->second; | 473 int32_t ipc_database_id = iter->second; |
470 ++iter; | 474 ++iter; |
471 IndexedDBConnection* connection = map_.Lookup(ipc_database_id); | 475 IndexedDBConnection* connection = map_.Lookup(ipc_database_id); |
472 if (connection && connection->IsConnected()) { | 476 if (connection && connection->IsConnected()) { |
473 connection->database()->Abort( | 477 connection->database()->Abort( |
474 transaction_id, | 478 transaction_id, |
475 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError)); | 479 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError)); |
476 } | 480 } |
477 } | 481 } |
478 DCHECK(transaction_database_map_.empty()); | 482 DCHECK(transaction_database_map_.empty()); |
479 | 483 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 | 532 |
529 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateObjectStore( | 533 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateObjectStore( |
530 const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params) { | 534 const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params) { |
531 DCHECK( | 535 DCHECK( |
532 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 536 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
533 IndexedDBConnection* connection = | 537 IndexedDBConnection* connection = |
534 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); | 538 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
535 if (!connection || !connection->IsConnected()) | 539 if (!connection || !connection->IsConnected()) |
536 return; | 540 return; |
537 | 541 |
538 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); | 542 int64_t host_transaction_id = |
| 543 parent_->HostTransactionId(params.transaction_id); |
539 connection->database()->CreateObjectStore(host_transaction_id, | 544 connection->database()->CreateObjectStore(host_transaction_id, |
540 params.object_store_id, | 545 params.object_store_id, |
541 params.name, | 546 params.name, |
542 params.key_path, | 547 params.key_path, |
543 params.auto_increment); | 548 params.auto_increment); |
544 if (parent_->Context()->IsOverQuota( | 549 if (parent_->Context()->IsOverQuota( |
545 database_url_map_[params.ipc_database_id])) { | 550 database_url_map_[params.ipc_database_id])) { |
546 connection->database()->Abort( | 551 connection->database()->Abort( |
547 host_transaction_id, | 552 host_transaction_id, |
548 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionQuotaError)); | 553 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionQuotaError)); |
549 } | 554 } |
550 } | 555 } |
551 | 556 |
552 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteObjectStore( | 557 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteObjectStore( |
553 int32 ipc_database_id, | 558 int32_t ipc_database_id, |
554 int64 transaction_id, | 559 int64_t transaction_id, |
555 int64 object_store_id) { | 560 int64_t object_store_id) { |
556 DCHECK( | 561 DCHECK( |
557 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 562 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
558 IndexedDBConnection* connection = | 563 IndexedDBConnection* connection = |
559 parent_->GetOrTerminateProcess(&map_, ipc_database_id); | 564 parent_->GetOrTerminateProcess(&map_, ipc_database_id); |
560 if (!connection || !connection->IsConnected()) | 565 if (!connection || !connection->IsConnected()) |
561 return; | 566 return; |
562 | 567 |
563 connection->database()->DeleteObjectStore( | 568 connection->database()->DeleteObjectStore( |
564 parent_->HostTransactionId(transaction_id), object_store_id); | 569 parent_->HostTransactionId(transaction_id), object_store_id); |
565 } | 570 } |
566 | 571 |
567 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateTransaction( | 572 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateTransaction( |
568 const IndexedDBHostMsg_DatabaseCreateTransaction_Params& params) { | 573 const IndexedDBHostMsg_DatabaseCreateTransaction_Params& params) { |
569 DCHECK( | 574 DCHECK( |
570 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 575 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
571 IndexedDBConnection* connection = | 576 IndexedDBConnection* connection = |
572 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); | 577 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
573 if (!connection || !connection->IsConnected()) | 578 if (!connection || !connection->IsConnected()) |
574 return; | 579 return; |
575 | 580 |
576 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); | 581 int64_t host_transaction_id = |
| 582 parent_->HostTransactionId(params.transaction_id); |
577 | 583 |
578 if (transaction_database_map_.find(host_transaction_id) != | 584 if (transaction_database_map_.find(host_transaction_id) != |
579 transaction_database_map_.end()) { | 585 transaction_database_map_.end()) { |
580 DLOG(ERROR) << "Duplicate host_transaction_id."; | 586 DLOG(ERROR) << "Duplicate host_transaction_id."; |
581 return; | 587 return; |
582 } | 588 } |
583 | 589 |
584 connection->database()->CreateTransaction( | 590 connection->database()->CreateTransaction( |
585 host_transaction_id, connection, params.object_store_ids, params.mode); | 591 host_transaction_id, connection, params.object_store_ids, params.mode); |
586 transaction_database_map_[host_transaction_id] = params.ipc_database_id; | 592 transaction_database_map_[host_transaction_id] = params.ipc_database_id; |
587 parent_->RegisterTransactionId(host_transaction_id, | 593 parent_->RegisterTransactionId(host_transaction_id, |
588 database_url_map_[params.ipc_database_id]); | 594 database_url_map_[params.ipc_database_id]); |
589 } | 595 } |
590 | 596 |
591 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClose( | 597 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClose( |
592 int32 ipc_database_id) { | 598 int32_t ipc_database_id) { |
593 DCHECK( | 599 DCHECK( |
594 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 600 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
595 IndexedDBConnection* connection = | 601 IndexedDBConnection* connection = |
596 parent_->GetOrTerminateProcess(&map_, ipc_database_id); | 602 parent_->GetOrTerminateProcess(&map_, ipc_database_id); |
597 if (!connection || !connection->IsConnected()) | 603 if (!connection || !connection->IsConnected()) |
598 return; | 604 return; |
599 connection->Close(); | 605 connection->Close(); |
600 } | 606 } |
601 | 607 |
602 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnVersionChangeIgnored( | 608 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnVersionChangeIgnored( |
603 int32 ipc_database_id) { | 609 int32_t ipc_database_id) { |
604 DCHECK( | 610 DCHECK( |
605 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 611 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
606 IndexedDBConnection* connection = | 612 IndexedDBConnection* connection = |
607 parent_->GetOrTerminateProcess(&map_, ipc_database_id); | 613 parent_->GetOrTerminateProcess(&map_, ipc_database_id); |
608 if (!connection || !connection->IsConnected()) | 614 if (!connection || !connection->IsConnected()) |
609 return; | 615 return; |
610 connection->VersionChangeIgnored(); | 616 connection->VersionChangeIgnored(); |
611 } | 617 } |
612 | 618 |
613 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed( | 619 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed( |
614 int32 ipc_object_id) { | 620 int32_t ipc_object_id) { |
615 DCHECK( | 621 DCHECK( |
616 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 622 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
617 IndexedDBConnection* connection = | 623 IndexedDBConnection* connection = |
618 parent_->GetOrTerminateProcess(&map_, ipc_object_id); | 624 parent_->GetOrTerminateProcess(&map_, ipc_object_id); |
619 if (!connection) | 625 if (!connection) |
620 return; | 626 return; |
621 if (connection->IsConnected()) | 627 if (connection->IsConnected()) |
622 connection->Close(); | 628 connection->Close(); |
623 parent_->Context() | 629 parent_->Context() |
624 ->ConnectionClosed(database_url_map_[ipc_object_id], connection); | 630 ->ConnectionClosed(database_url_map_[ipc_object_id], connection); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 ScopedVector<storage::BlobDataHandle> scoped_handles; | 693 ScopedVector<storage::BlobDataHandle> scoped_handles; |
688 scoped_handles.swap(handles); | 694 scoped_handles.swap(handles); |
689 | 695 |
690 IndexedDBConnection* connection = | 696 IndexedDBConnection* connection = |
691 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); | 697 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
692 if (!connection || !connection->IsConnected()) | 698 if (!connection || !connection->IsConnected()) |
693 return; | 699 return; |
694 scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( | 700 scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( |
695 parent_, params.ipc_thread_id, params.ipc_callbacks_id)); | 701 parent_, params.ipc_thread_id, params.ipc_callbacks_id)); |
696 | 702 |
697 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); | 703 int64_t host_transaction_id = |
| 704 parent_->HostTransactionId(params.transaction_id); |
698 | 705 |
699 std::vector<IndexedDBBlobInfo> blob_info( | 706 std::vector<IndexedDBBlobInfo> blob_info( |
700 params.value.blob_or_file_info.size()); | 707 params.value.blob_or_file_info.size()); |
701 | 708 |
702 ChildProcessSecurityPolicyImpl* policy = | 709 ChildProcessSecurityPolicyImpl* policy = |
703 ChildProcessSecurityPolicyImpl::GetInstance(); | 710 ChildProcessSecurityPolicyImpl::GetInstance(); |
704 | 711 |
705 for (size_t i = 0; i < params.value.blob_or_file_info.size(); ++i) { | 712 for (size_t i = 0; i < params.value.blob_or_file_info.size(); ++i) { |
706 const IndexedDBMsg_BlobOrFileInfo& info = params.value.blob_or_file_info[i]; | 713 const IndexedDBMsg_BlobOrFileInfo& info = params.value.blob_or_file_info[i]; |
707 if (info.is_file) { | 714 if (info.is_file) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 | 754 |
748 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexKeys( | 755 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexKeys( |
749 const IndexedDBHostMsg_DatabaseSetIndexKeys_Params& params) { | 756 const IndexedDBHostMsg_DatabaseSetIndexKeys_Params& params) { |
750 DCHECK( | 757 DCHECK( |
751 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 758 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
752 IndexedDBConnection* connection = | 759 IndexedDBConnection* connection = |
753 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); | 760 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
754 if (!connection || !connection->IsConnected()) | 761 if (!connection || !connection->IsConnected()) |
755 return; | 762 return; |
756 | 763 |
757 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); | 764 int64_t host_transaction_id = |
| 765 parent_->HostTransactionId(params.transaction_id); |
758 connection->database()->SetIndexKeys( | 766 connection->database()->SetIndexKeys( |
759 host_transaction_id, | 767 host_transaction_id, |
760 params.object_store_id, | 768 params.object_store_id, |
761 make_scoped_ptr(new IndexedDBKey(params.primary_key)), | 769 make_scoped_ptr(new IndexedDBKey(params.primary_key)), |
762 params.index_keys); | 770 params.index_keys); |
763 } | 771 } |
764 | 772 |
765 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexesReady( | 773 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexesReady( |
766 int32 ipc_database_id, | 774 int32_t ipc_database_id, |
767 int64 transaction_id, | 775 int64_t transaction_id, |
768 int64 object_store_id, | 776 int64_t object_store_id, |
769 const std::vector<int64>& index_ids) { | 777 const std::vector<int64_t>& index_ids) { |
770 DCHECK( | 778 DCHECK( |
771 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 779 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
772 IndexedDBConnection* connection = | 780 IndexedDBConnection* connection = |
773 parent_->GetOrTerminateProcess(&map_, ipc_database_id); | 781 parent_->GetOrTerminateProcess(&map_, ipc_database_id); |
774 if (!connection || !connection->IsConnected()) | 782 if (!connection || !connection->IsConnected()) |
775 return; | 783 return; |
776 | 784 |
777 connection->database()->SetIndexesReady( | 785 connection->database()->SetIndexesReady( |
778 parent_->HostTransactionId(transaction_id), object_store_id, index_ids); | 786 parent_->HostTransactionId(transaction_id), object_store_id, index_ids); |
779 } | 787 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( | 839 scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( |
832 parent_, params.ipc_thread_id, params.ipc_callbacks_id)); | 840 parent_, params.ipc_thread_id, params.ipc_callbacks_id)); |
833 connection->database()->DeleteRange( | 841 connection->database()->DeleteRange( |
834 parent_->HostTransactionId(params.transaction_id), | 842 parent_->HostTransactionId(params.transaction_id), |
835 params.object_store_id, | 843 params.object_store_id, |
836 make_scoped_ptr(new IndexedDBKeyRange(params.key_range)), | 844 make_scoped_ptr(new IndexedDBKeyRange(params.key_range)), |
837 callbacks); | 845 callbacks); |
838 } | 846 } |
839 | 847 |
840 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClear( | 848 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClear( |
841 int32 ipc_thread_id, | 849 int32_t ipc_thread_id, |
842 int32 ipc_callbacks_id, | 850 int32_t ipc_callbacks_id, |
843 int32 ipc_database_id, | 851 int32_t ipc_database_id, |
844 int64 transaction_id, | 852 int64_t transaction_id, |
845 int64 object_store_id) { | 853 int64_t object_store_id) { |
846 DCHECK( | 854 DCHECK( |
847 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 855 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
848 IndexedDBConnection* connection = | 856 IndexedDBConnection* connection = |
849 parent_->GetOrTerminateProcess(&map_, ipc_database_id); | 857 parent_->GetOrTerminateProcess(&map_, ipc_database_id); |
850 if (!connection || !connection->IsConnected()) | 858 if (!connection || !connection->IsConnected()) |
851 return; | 859 return; |
852 | 860 |
853 scoped_refptr<IndexedDBCallbacks> callbacks( | 861 scoped_refptr<IndexedDBCallbacks> callbacks( |
854 new IndexedDBCallbacks(parent_, ipc_thread_id, ipc_callbacks_id)); | 862 new IndexedDBCallbacks(parent_, ipc_thread_id, ipc_callbacks_id)); |
855 | 863 |
856 connection->database()->Clear( | 864 connection->database()->Clear( |
857 parent_->HostTransactionId(transaction_id), object_store_id, callbacks); | 865 parent_->HostTransactionId(transaction_id), object_store_id, callbacks); |
858 } | 866 } |
859 | 867 |
860 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnAbort( | 868 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnAbort( |
861 int32 ipc_database_id, | 869 int32_t ipc_database_id, |
862 int64 transaction_id) { | 870 int64_t transaction_id) { |
863 DCHECK( | 871 DCHECK( |
864 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 872 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
865 IndexedDBConnection* connection = | 873 IndexedDBConnection* connection = |
866 parent_->GetOrTerminateProcess(&map_, ipc_database_id); | 874 parent_->GetOrTerminateProcess(&map_, ipc_database_id); |
867 if (!connection || !connection->IsConnected()) | 875 if (!connection || !connection->IsConnected()) |
868 return; | 876 return; |
869 | 877 |
870 connection->database()->Abort(parent_->HostTransactionId(transaction_id)); | 878 connection->database()->Abort(parent_->HostTransactionId(transaction_id)); |
871 } | 879 } |
872 | 880 |
873 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCommit( | 881 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCommit( |
874 int32 ipc_database_id, | 882 int32_t ipc_database_id, |
875 int64 transaction_id) { | 883 int64_t transaction_id) { |
876 DCHECK( | 884 DCHECK( |
877 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 885 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
878 IndexedDBConnection* connection = | 886 IndexedDBConnection* connection = |
879 parent_->GetOrTerminateProcess(&map_, ipc_database_id); | 887 parent_->GetOrTerminateProcess(&map_, ipc_database_id); |
880 if (!connection || !connection->IsConnected()) | 888 if (!connection || !connection->IsConnected()) |
881 return; | 889 return; |
882 | 890 |
883 int64 host_transaction_id = parent_->HostTransactionId(transaction_id); | 891 int64_t host_transaction_id = parent_->HostTransactionId(transaction_id); |
884 int64 transaction_size = transaction_size_map_[host_transaction_id]; | 892 int64_t transaction_size = transaction_size_map_[host_transaction_id]; |
885 if (transaction_size && | 893 if (transaction_size && |
886 parent_->Context()->WouldBeOverQuota( | 894 parent_->Context()->WouldBeOverQuota( |
887 transaction_url_map_[host_transaction_id], transaction_size)) { | 895 transaction_url_map_[host_transaction_id], transaction_size)) { |
888 connection->database()->Abort( | 896 connection->database()->Abort( |
889 host_transaction_id, | 897 host_transaction_id, |
890 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionQuotaError)); | 898 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionQuotaError)); |
891 return; | 899 return; |
892 } | 900 } |
893 | 901 |
894 connection->database()->Commit(host_transaction_id); | 902 connection->database()->Commit(host_transaction_id); |
895 } | 903 } |
896 | 904 |
897 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateIndex( | 905 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateIndex( |
898 const IndexedDBHostMsg_DatabaseCreateIndex_Params& params) { | 906 const IndexedDBHostMsg_DatabaseCreateIndex_Params& params) { |
899 DCHECK( | 907 DCHECK( |
900 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 908 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
901 IndexedDBConnection* connection = | 909 IndexedDBConnection* connection = |
902 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); | 910 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
903 if (!connection || !connection->IsConnected()) | 911 if (!connection || !connection->IsConnected()) |
904 return; | 912 return; |
905 | 913 |
906 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); | 914 int64_t host_transaction_id = |
| 915 parent_->HostTransactionId(params.transaction_id); |
907 connection->database()->CreateIndex(host_transaction_id, | 916 connection->database()->CreateIndex(host_transaction_id, |
908 params.object_store_id, | 917 params.object_store_id, |
909 params.index_id, | 918 params.index_id, |
910 params.name, | 919 params.name, |
911 params.key_path, | 920 params.key_path, |
912 params.unique, | 921 params.unique, |
913 params.multi_entry); | 922 params.multi_entry); |
914 if (parent_->Context()->IsOverQuota( | 923 if (parent_->Context()->IsOverQuota( |
915 database_url_map_[params.ipc_database_id])) { | 924 database_url_map_[params.ipc_database_id])) { |
916 connection->database()->Abort( | 925 connection->database()->Abort( |
917 host_transaction_id, | 926 host_transaction_id, |
918 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionQuotaError)); | 927 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionQuotaError)); |
919 } | 928 } |
920 } | 929 } |
921 | 930 |
922 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteIndex( | 931 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteIndex( |
923 int32 ipc_database_id, | 932 int32_t ipc_database_id, |
924 int64 transaction_id, | 933 int64_t transaction_id, |
925 int64 object_store_id, | 934 int64_t object_store_id, |
926 int64 index_id) { | 935 int64_t index_id) { |
927 DCHECK( | 936 DCHECK( |
928 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 937 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
929 IndexedDBConnection* connection = | 938 IndexedDBConnection* connection = |
930 parent_->GetOrTerminateProcess(&map_, ipc_database_id); | 939 parent_->GetOrTerminateProcess(&map_, ipc_database_id); |
931 if (!connection || !connection->IsConnected()) | 940 if (!connection || !connection->IsConnected()) |
932 return; | 941 return; |
933 | 942 |
934 connection->database()->DeleteIndex( | 943 connection->database()->DeleteIndex( |
935 parent_->HostTransactionId(transaction_id), object_store_id, index_id); | 944 parent_->HostTransactionId(transaction_id), object_store_id, index_id); |
936 } | 945 } |
(...skipping 24 matching lines...) Expand all Loading... |
961 IPC_END_MESSAGE_MAP() | 970 IPC_END_MESSAGE_MAP() |
962 | 971 |
963 DCHECK( | 972 DCHECK( |
964 !handled || | 973 !handled || |
965 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 974 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
966 | 975 |
967 return handled; | 976 return handled; |
968 } | 977 } |
969 | 978 |
970 void IndexedDBDispatcherHost::CursorDispatcherHost::OnAdvance( | 979 void IndexedDBDispatcherHost::CursorDispatcherHost::OnAdvance( |
971 int32 ipc_cursor_id, | 980 int32_t ipc_cursor_id, |
972 int32 ipc_thread_id, | 981 int32_t ipc_thread_id, |
973 int32 ipc_callbacks_id, | 982 int32_t ipc_callbacks_id, |
974 uint32 count) { | 983 uint32_t count) { |
975 DCHECK( | 984 DCHECK( |
976 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 985 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
977 IndexedDBCursor* idb_cursor = | 986 IndexedDBCursor* idb_cursor = |
978 parent_->GetOrTerminateProcess(&map_, ipc_cursor_id); | 987 parent_->GetOrTerminateProcess(&map_, ipc_cursor_id); |
979 if (!idb_cursor) | 988 if (!idb_cursor) |
980 return; | 989 return; |
981 | 990 |
982 idb_cursor->Advance( | 991 idb_cursor->Advance( |
983 count, | 992 count, |
984 new IndexedDBCallbacks( | 993 new IndexedDBCallbacks( |
985 parent_, ipc_thread_id, ipc_callbacks_id, ipc_cursor_id)); | 994 parent_, ipc_thread_id, ipc_callbacks_id, ipc_cursor_id)); |
986 } | 995 } |
987 | 996 |
988 void IndexedDBDispatcherHost::CursorDispatcherHost::OnContinue( | 997 void IndexedDBDispatcherHost::CursorDispatcherHost::OnContinue( |
989 int32 ipc_cursor_id, | 998 int32_t ipc_cursor_id, |
990 int32 ipc_thread_id, | 999 int32_t ipc_thread_id, |
991 int32 ipc_callbacks_id, | 1000 int32_t ipc_callbacks_id, |
992 const IndexedDBKey& key, | 1001 const IndexedDBKey& key, |
993 const IndexedDBKey& primary_key) { | 1002 const IndexedDBKey& primary_key) { |
994 DCHECK( | 1003 DCHECK( |
995 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 1004 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
996 IndexedDBCursor* idb_cursor = | 1005 IndexedDBCursor* idb_cursor = |
997 parent_->GetOrTerminateProcess(&map_, ipc_cursor_id); | 1006 parent_->GetOrTerminateProcess(&map_, ipc_cursor_id); |
998 if (!idb_cursor) | 1007 if (!idb_cursor) |
999 return; | 1008 return; |
1000 | 1009 |
1001 idb_cursor->Continue( | 1010 idb_cursor->Continue( |
1002 key.IsValid() ? make_scoped_ptr(new IndexedDBKey(key)) | 1011 key.IsValid() ? make_scoped_ptr(new IndexedDBKey(key)) |
1003 : scoped_ptr<IndexedDBKey>(), | 1012 : scoped_ptr<IndexedDBKey>(), |
1004 primary_key.IsValid() ? make_scoped_ptr(new IndexedDBKey(primary_key)) | 1013 primary_key.IsValid() ? make_scoped_ptr(new IndexedDBKey(primary_key)) |
1005 : scoped_ptr<IndexedDBKey>(), | 1014 : scoped_ptr<IndexedDBKey>(), |
1006 new IndexedDBCallbacks( | 1015 new IndexedDBCallbacks( |
1007 parent_, ipc_thread_id, ipc_callbacks_id, ipc_cursor_id)); | 1016 parent_, ipc_thread_id, ipc_callbacks_id, ipc_cursor_id)); |
1008 } | 1017 } |
1009 | 1018 |
1010 void IndexedDBDispatcherHost::CursorDispatcherHost::OnPrefetch( | 1019 void IndexedDBDispatcherHost::CursorDispatcherHost::OnPrefetch( |
1011 int32 ipc_cursor_id, | 1020 int32_t ipc_cursor_id, |
1012 int32 ipc_thread_id, | 1021 int32_t ipc_thread_id, |
1013 int32 ipc_callbacks_id, | 1022 int32_t ipc_callbacks_id, |
1014 int n) { | 1023 int n) { |
1015 DCHECK( | 1024 DCHECK( |
1016 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 1025 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
1017 IndexedDBCursor* idb_cursor = | 1026 IndexedDBCursor* idb_cursor = |
1018 parent_->GetOrTerminateProcess(&map_, ipc_cursor_id); | 1027 parent_->GetOrTerminateProcess(&map_, ipc_cursor_id); |
1019 if (!idb_cursor) | 1028 if (!idb_cursor) |
1020 return; | 1029 return; |
1021 | 1030 |
1022 idb_cursor->PrefetchContinue( | 1031 idb_cursor->PrefetchContinue( |
1023 n, | 1032 n, |
1024 new IndexedDBCallbacks( | 1033 new IndexedDBCallbacks( |
1025 parent_, ipc_thread_id, ipc_callbacks_id, ipc_cursor_id)); | 1034 parent_, ipc_thread_id, ipc_callbacks_id, ipc_cursor_id)); |
1026 } | 1035 } |
1027 | 1036 |
1028 void IndexedDBDispatcherHost::CursorDispatcherHost::OnPrefetchReset( | 1037 void IndexedDBDispatcherHost::CursorDispatcherHost::OnPrefetchReset( |
1029 int32 ipc_cursor_id, | 1038 int32_t ipc_cursor_id, |
1030 int used_prefetches, | 1039 int used_prefetches, |
1031 int unused_prefetches) { | 1040 int unused_prefetches) { |
1032 DCHECK( | 1041 DCHECK( |
1033 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 1042 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
1034 IndexedDBCursor* idb_cursor = | 1043 IndexedDBCursor* idb_cursor = |
1035 parent_->GetOrTerminateProcess(&map_, ipc_cursor_id); | 1044 parent_->GetOrTerminateProcess(&map_, ipc_cursor_id); |
1036 if (!idb_cursor) | 1045 if (!idb_cursor) |
1037 return; | 1046 return; |
1038 | 1047 |
1039 leveldb::Status s = | 1048 leveldb::Status s = |
1040 idb_cursor->PrefetchReset(used_prefetches, unused_prefetches); | 1049 idb_cursor->PrefetchReset(used_prefetches, unused_prefetches); |
1041 // TODO(cmumford): Handle this error (crbug.com/363397) | 1050 // TODO(cmumford): Handle this error (crbug.com/363397) |
1042 if (!s.ok()) | 1051 if (!s.ok()) |
1043 DLOG(ERROR) << "Unable to reset prefetch"; | 1052 DLOG(ERROR) << "Unable to reset prefetch"; |
1044 } | 1053 } |
1045 | 1054 |
1046 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( | 1055 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( |
1047 int32 ipc_object_id) { | 1056 int32_t ipc_object_id) { |
1048 DCHECK( | 1057 DCHECK( |
1049 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 1058 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
1050 parent_->DestroyObject(&map_, ipc_object_id); | 1059 parent_->DestroyObject(&map_, ipc_object_id); |
1051 } | 1060 } |
1052 | 1061 |
1053 } // namespace content | 1062 } // namespace content |
OLD | NEW |