Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(661)

Side by Side Diff: content/browser/indexed_db/indexed_db_callbacks.cc

Issue 1074493002: IndexedDB: Added IDBObjectStore.getAll() implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Using IPC::Channel::kMaximumMessageSize in lieu of 10MB. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_callbacks.h" 5 #include "content/browser/indexed_db/indexed_db_callbacks.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 for (size_t i = 0; i < values.size(); ++i) { 278 for (size_t i = 0; i < values.size(); ++i) {
279 if (!CreateAllBlobs(values[i].blob_info, 279 if (!CreateAllBlobs(values[i].blob_info,
280 &params->values[i].blob_or_file_info, dispatcher_host)) 280 &params->values[i].blob_or_file_info, dispatcher_host))
281 return; 281 return;
282 } 282 }
283 283
284 dispatcher_host->Send( 284 dispatcher_host->Send(
285 new IndexedDBMsg_CallbacksSuccessCursorPrefetch(*params)); 285 new IndexedDBMsg_CallbacksSuccessCursorPrefetch(*params));
286 } 286 }
287 287
288 static void BlobLookupForGetAll(
289 IndexedDBMsg_CallbacksSuccessArray_Params* params,
290 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host,
291 const std::vector<IndexedDBReturnValue>& values) {
292 DCHECK_CURRENTLY_ON(BrowserThread::IO);
293 DCHECK_EQ(values.size(), params->values.size());
294
295 for (size_t i = 0; i < values.size(); ++i) {
296 if (!CreateAllBlobs(values[i].blob_info,
297 &params->values[i].blob_or_file_info, dispatcher_host))
298 return;
299 }
300
301 dispatcher_host->Send(new IndexedDBMsg_CallbacksSuccessArray(*params));
302 }
303
288 static void FillInBlobData( 304 static void FillInBlobData(
289 const std::vector<IndexedDBBlobInfo>& blob_info, 305 const std::vector<IndexedDBBlobInfo>& blob_info,
290 std::vector<IndexedDBMsg_BlobOrFileInfo>* blob_or_file_info) { 306 std::vector<IndexedDBMsg_BlobOrFileInfo>* blob_or_file_info) {
291 for (const auto& iter : blob_info) { 307 for (const auto& iter : blob_info) {
292 if (iter.is_file()) { 308 if (iter.is_file()) {
293 IndexedDBMsg_BlobOrFileInfo info; 309 IndexedDBMsg_BlobOrFileInfo info;
294 info.is_file = true; 310 info.is_file = true;
295 info.mime_type = iter.type(); 311 info.mime_type = iter.type();
296 info.file_name = iter.file_name(); 312 info.file_name = iter.file_name();
297 info.file_path = iter.file_path().AsUTF16Unsafe(); 313 info.file_path = iter.file_path().AsUTF16Unsafe();
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 value->blob_info, 513 value->blob_info,
498 base::Bind(CreateBlobsAndSend<IndexedDBMsg_CallbacksSuccessValue_Params, 514 base::Bind(CreateBlobsAndSend<IndexedDBMsg_CallbacksSuccessValue_Params,
499 IndexedDBMsg_CallbacksSuccessValue>, 515 IndexedDBMsg_CallbacksSuccessValue>,
500 base::Owned(params.release()), dispatcher_host_, 516 base::Owned(params.release()), dispatcher_host_,
501 value->blob_info, 517 value->blob_info,
502 base::Unretained(&p->value.blob_or_file_info))); 518 base::Unretained(&p->value.blob_or_file_info)));
503 } 519 }
504 dispatcher_host_ = NULL; 520 dispatcher_host_ = NULL;
505 } 521 }
506 522
523 void IndexedDBCallbacks::OnSuccessArray(
524 std::vector<IndexedDBReturnValue>* values,
525 const IndexedDBKeyPath& key_path) {
526 DCHECK(dispatcher_host_.get());
527
528 DCHECK_EQ(kNoTransaction, host_transaction_id_);
529 DCHECK_EQ(kNoDatabase, ipc_database_id_);
530 DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_);
531 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_);
532
533 scoped_ptr<IndexedDBMsg_CallbacksSuccessArray_Params> params(
534 new IndexedDBMsg_CallbacksSuccessArray_Params());
535 params->ipc_thread_id = ipc_thread_id_;
536 params->ipc_callbacks_id = ipc_callbacks_id_;
537 params->values.resize(values->size());
538
539 bool found_blob_info = false;
540 for (size_t i = 0; i < values->size(); ++i) {
541 IndexedDBMsg_ReturnValue& pvalue = params->values[i];
542 IndexedDBReturnValue& value = (*values)[i];
543 pvalue.bits.swap(value.bits);
544 if (!value.blob_info.empty()) {
545 found_blob_info = true;
546 FillInBlobData(value.blob_info, &pvalue.blob_or_file_info);
547 for (const auto& blob_info : value.blob_info) {
548 if (!blob_info.mark_used_callback().is_null())
549 blob_info.mark_used_callback().Run();
550 }
551 }
552 pvalue.primary_key = value.primary_key;
553 pvalue.key_path = key_path;
554 }
555
556 if (found_blob_info) {
557 BrowserThread::PostTask(
558 BrowserThread::IO, FROM_HERE,
559 base::Bind(BlobLookupForGetAll, base::Owned(params.release()),
560 dispatcher_host_, *values));
561 } else {
562 dispatcher_host_->Send(
563 new IndexedDBMsg_CallbacksSuccessArray(*params.get()));
564 }
565 dispatcher_host_ = NULL;
566 }
567
507 void IndexedDBCallbacks::OnSuccess(const IndexedDBKey& value) { 568 void IndexedDBCallbacks::OnSuccess(const IndexedDBKey& value) {
508 DCHECK(dispatcher_host_.get()); 569 DCHECK(dispatcher_host_.get());
509 570
510 DCHECK_EQ(kNoCursor, ipc_cursor_id_); 571 DCHECK_EQ(kNoCursor, ipc_cursor_id_);
511 DCHECK_EQ(kNoTransaction, host_transaction_id_); 572 DCHECK_EQ(kNoTransaction, host_transaction_id_);
512 DCHECK_EQ(kNoDatabase, ipc_database_id_); 573 DCHECK_EQ(kNoDatabase, ipc_database_id_);
513 DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_); 574 DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_);
514 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_); 575 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_);
515 576
516 dispatcher_host_->Send(new IndexedDBMsg_CallbacksSuccessIndexedDBKey( 577 dispatcher_host_->Send(new IndexedDBMsg_CallbacksSuccessIndexedDBKey(
(...skipping 28 matching lines...) Expand all
545 ipc_thread_id_, ipc_callbacks_id_)); 606 ipc_thread_id_, ipc_callbacks_id_));
546 dispatcher_host_ = NULL; 607 dispatcher_host_ = NULL;
547 } 608 }
548 609
549 void IndexedDBCallbacks::SetConnectionOpenStartTime( 610 void IndexedDBCallbacks::SetConnectionOpenStartTime(
550 const base::TimeTicks& start_time) { 611 const base::TimeTicks& start_time) {
551 connection_open_start_time_ = start_time; 612 connection_open_start_time_ = start_time;
552 } 613 }
553 614
554 } // namespace content 615 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698