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

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

Issue 405433007: IndexedDB: Fix coding style issues c/o cpplint.py (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
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/guid.h" 9 #include "base/guid.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 static std::string CreateBlobData( 194 static std::string CreateBlobData(
195 const IndexedDBBlobInfo& blob_info, 195 const IndexedDBBlobInfo& blob_info,
196 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host, 196 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host,
197 webkit_blob::BlobStorageContext* blob_storage_context, 197 webkit_blob::BlobStorageContext* blob_storage_context,
198 base::TaskRunner* task_runner) { 198 base::TaskRunner* task_runner) {
199 std::string uuid = blob_info.uuid(); 199 std::string uuid = blob_info.uuid();
200 if (!uuid.empty()) { 200 if (!uuid.empty()) {
201 // We're sending back a live blob, not a reference into our backing store. 201 // We're sending back a live blob, not a reference into our backing store.
202 scoped_ptr<webkit_blob::BlobDataHandle> blob_data_handle( 202 scoped_ptr<webkit_blob::BlobDataHandle> blob_data_handle(
203 blob_storage_context->GetBlobDataFromUUID(uuid)); 203 blob_storage_context->GetBlobDataFromUUID(uuid));
204 dispatcher_host->HoldBlobDataHandle(uuid, blob_data_handle); 204 dispatcher_host->HoldBlobDataHandle(uuid, blob_data_handle.Pass());
205 return uuid; 205 return uuid;
206 } 206 }
207 scoped_refptr<ShareableFileReference> shareable_file = 207 scoped_refptr<ShareableFileReference> shareable_file =
208 ShareableFileReference::Get(blob_info.file_path()); 208 ShareableFileReference::Get(blob_info.file_path());
209 if (!shareable_file.get()) { 209 if (!shareable_file.get()) {
210 shareable_file = ShareableFileReference::GetOrCreate( 210 shareable_file = ShareableFileReference::GetOrCreate(
211 blob_info.file_path(), 211 blob_info.file_path(),
212 ShareableFileReference::DONT_DELETE_ON_FINAL_RELEASE, 212 ShareableFileReference::DONT_DELETE_ON_FINAL_RELEASE,
213 task_runner); 213 task_runner);
214 if (!blob_info.release_callback().is_null()) 214 if (!blob_info.release_callback().is_null())
215 shareable_file->AddFinalReleaseCallback(blob_info.release_callback()); 215 shareable_file->AddFinalReleaseCallback(blob_info.release_callback());
216 } 216 }
217 217
218 uuid = base::GenerateGUID(); 218 uuid = base::GenerateGUID();
219 scoped_refptr<webkit_blob::BlobData> blob_data = 219 scoped_refptr<webkit_blob::BlobData> blob_data =
220 new webkit_blob::BlobData(uuid); 220 new webkit_blob::BlobData(uuid);
221 blob_data->AppendFile( 221 blob_data->AppendFile(
222 blob_info.file_path(), 0, blob_info.size(), blob_info.last_modified()); 222 blob_info.file_path(), 0, blob_info.size(), blob_info.last_modified());
223 scoped_ptr<webkit_blob::BlobDataHandle> blob_data_handle( 223 scoped_ptr<webkit_blob::BlobDataHandle> blob_data_handle(
224 blob_storage_context->AddFinishedBlob(blob_data.get())); 224 blob_storage_context->AddFinishedBlob(blob_data.get()));
225 dispatcher_host->HoldBlobDataHandle(uuid, blob_data_handle); 225 dispatcher_host->HoldBlobDataHandle(uuid, blob_data_handle.Pass());
226 226
227 return uuid; 227 return uuid;
228 } 228 }
229 229
230 static bool CreateAllBlobs( 230 static bool CreateAllBlobs(
231 const std::vector<IndexedDBBlobInfo>& blob_info, 231 const std::vector<IndexedDBBlobInfo>& blob_info,
232 std::vector<IndexedDBMsg_BlobOrFileInfo>* blob_or_file_info, 232 std::vector<IndexedDBMsg_BlobOrFileInfo>* blob_or_file_info,
233 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host) { 233 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host) {
234 DCHECK_EQ(blob_info.size(), blob_or_file_info->size()); 234 DCHECK_EQ(blob_info.size(), blob_or_file_info->size());
235 size_t i; 235 size_t i;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 dispatcher_host_, 397 dispatcher_host_,
398 value->blob_info, 398 value->blob_info,
399 base::Unretained(&p->blob_or_file_info))); 399 base::Unretained(&p->blob_or_file_info)));
400 } 400 }
401 dispatcher_host_ = NULL; 401 dispatcher_host_ = NULL;
402 } 402 }
403 403
404 void IndexedDBCallbacks::OnSuccessWithPrefetch( 404 void IndexedDBCallbacks::OnSuccessWithPrefetch(
405 const std::vector<IndexedDBKey>& keys, 405 const std::vector<IndexedDBKey>& keys,
406 const std::vector<IndexedDBKey>& primary_keys, 406 const std::vector<IndexedDBKey>& primary_keys,
407 std::vector<IndexedDBValue>& values) { 407 std::vector<IndexedDBValue>* values) {
408 DCHECK_EQ(keys.size(), primary_keys.size()); 408 DCHECK_EQ(keys.size(), primary_keys.size());
409 DCHECK_EQ(keys.size(), values.size()); 409 DCHECK_EQ(keys.size(), values->size());
410 410
411 DCHECK(dispatcher_host_.get()); 411 DCHECK(dispatcher_host_.get());
412 412
413 DCHECK_NE(kNoCursor, ipc_cursor_id_); 413 DCHECK_NE(kNoCursor, ipc_cursor_id_);
414 DCHECK_EQ(kNoTransaction, host_transaction_id_); 414 DCHECK_EQ(kNoTransaction, host_transaction_id_);
415 DCHECK_EQ(kNoDatabase, ipc_database_id_); 415 DCHECK_EQ(kNoDatabase, ipc_database_id_);
416 DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_); 416 DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_);
417 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_); 417 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_);
418 418
419 std::vector<IndexedDBKey> msgKeys; 419 std::vector<IndexedDBKey> msgKeys;
420 std::vector<IndexedDBKey> msgPrimaryKeys; 420 std::vector<IndexedDBKey> msgPrimaryKeys;
421 421
422 for (size_t i = 0; i < keys.size(); ++i) { 422 for (size_t i = 0; i < keys.size(); ++i) {
423 msgKeys.push_back(keys[i]); 423 msgKeys.push_back(keys[i]);
424 msgPrimaryKeys.push_back(primary_keys[i]); 424 msgPrimaryKeys.push_back(primary_keys[i]);
425 } 425 }
426 426
427 scoped_ptr<IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params> params( 427 scoped_ptr<IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params> params(
428 new IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params()); 428 new IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params());
429 params->ipc_thread_id = ipc_thread_id_; 429 params->ipc_thread_id = ipc_thread_id_;
430 params->ipc_callbacks_id = ipc_callbacks_id_; 430 params->ipc_callbacks_id = ipc_callbacks_id_;
431 params->ipc_cursor_id = ipc_cursor_id_; 431 params->ipc_cursor_id = ipc_cursor_id_;
432 params->keys = msgKeys; 432 params->keys = msgKeys;
433 params->primary_keys = msgPrimaryKeys; 433 params->primary_keys = msgPrimaryKeys;
434 std::vector<std::string>& values_bits = params->values; 434 std::vector<std::string>& values_bits = params->values;
435 values_bits.resize(values.size()); 435 values_bits.resize(values->size());
436 std::vector<std::vector<IndexedDBMsg_BlobOrFileInfo> >& values_blob_infos = 436 std::vector<std::vector<IndexedDBMsg_BlobOrFileInfo> >& values_blob_infos =
437 params->blob_or_file_infos; 437 params->blob_or_file_infos;
438 values_blob_infos.resize(values.size()); 438 values_blob_infos.resize(values->size());
439 439
440 bool found_blob_info = false; 440 bool found_blob_info = false;
441 std::vector<IndexedDBValue>::iterator iter = values.begin(); 441 std::vector<IndexedDBValue>::iterator iter = values->begin();
442 for (size_t i = 0; iter != values.end(); ++iter, ++i) { 442 for (size_t i = 0; iter != values->end(); ++iter, ++i) {
443 values_bits[i].swap(iter->bits); 443 values_bits[i].swap(iter->bits);
444 if (iter->blob_info.size()) { 444 if (iter->blob_info.size()) {
445 found_blob_info = true; 445 found_blob_info = true;
446 FillInBlobData(iter->blob_info, &values_blob_infos[i]); 446 FillInBlobData(iter->blob_info, &values_blob_infos[i]);
447 std::vector<IndexedDBBlobInfo>::const_iterator blob_iter; 447 std::vector<IndexedDBBlobInfo>::const_iterator blob_iter;
448 for (blob_iter = iter->blob_info.begin(); 448 for (blob_iter = iter->blob_info.begin();
449 blob_iter != iter->blob_info.end(); 449 blob_iter != iter->blob_info.end();
450 ++blob_iter) { 450 ++blob_iter) {
451 if (!blob_iter->mark_used_callback().is_null()) 451 if (!blob_iter->mark_used_callback().is_null())
452 blob_iter->mark_used_callback().Run(); 452 blob_iter->mark_used_callback().Run();
453 } 453 }
454 } 454 }
455 } 455 }
456 456
457 if (found_blob_info) { 457 if (found_blob_info) {
458 BrowserThread::PostTask( 458 BrowserThread::PostTask(BrowserThread::IO,
459 BrowserThread::IO, 459 FROM_HERE,
460 FROM_HERE, 460 base::Bind(BlobLookupForCursorPrefetch,
461 base::Bind(BlobLookupForCursorPrefetch, 461 base::Owned(params.release()),
462 base::Owned(params.release()), 462 dispatcher_host_,
463 dispatcher_host_, 463 *values));
464 values));
465 } else { 464 } else {
466 dispatcher_host_->Send( 465 dispatcher_host_->Send(
467 new IndexedDBMsg_CallbacksSuccessCursorPrefetch(*params.get())); 466 new IndexedDBMsg_CallbacksSuccessCursorPrefetch(*params.get()));
468 } 467 }
469 dispatcher_host_ = NULL; 468 dispatcher_host_ = NULL;
470 } 469 }
471 470
472 void IndexedDBCallbacks::OnSuccess(IndexedDBValue* value, 471 void IndexedDBCallbacks::OnSuccess(IndexedDBValue* value,
473 const IndexedDBKey& key, 472 const IndexedDBKey& key,
474 const IndexedDBKeyPath& key_path) { 473 const IndexedDBKeyPath& key_path) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 DCHECK_EQ(kNoDatabase, ipc_database_id_); 573 DCHECK_EQ(kNoDatabase, ipc_database_id_);
575 DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_); 574 DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_);
576 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_); 575 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_);
577 576
578 dispatcher_host_->Send(new IndexedDBMsg_CallbacksSuccessUndefined( 577 dispatcher_host_->Send(new IndexedDBMsg_CallbacksSuccessUndefined(
579 ipc_thread_id_, ipc_callbacks_id_)); 578 ipc_thread_id_, ipc_callbacks_id_));
580 dispatcher_host_ = NULL; 579 dispatcher_host_ = NULL;
581 } 580 }
582 581
583 } // namespace content 582 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_callbacks.h ('k') | content/browser/indexed_db/indexed_db_cursor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698