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

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

Issue 2233153002: IndexedDB: WrapUnique(new T(args..)) -> MakeUnique<T>(args...) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review feedback Created 4 years, 4 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_leveldb_coding.h" 5 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 369
370 bool DecodeIDBKey(StringPiece* slice, std::unique_ptr<IndexedDBKey>* value) { 370 bool DecodeIDBKey(StringPiece* slice, std::unique_ptr<IndexedDBKey>* value) {
371 if (slice->empty()) 371 if (slice->empty())
372 return false; 372 return false;
373 373
374 unsigned char type = (*slice)[0]; 374 unsigned char type = (*slice)[0];
375 slice->remove_prefix(1); 375 slice->remove_prefix(1);
376 376
377 switch (type) { 377 switch (type) {
378 case kIndexedDBKeyNullTypeByte: 378 case kIndexedDBKeyNullTypeByte:
379 *value = base::WrapUnique(new IndexedDBKey()); 379 *value = base::MakeUnique<IndexedDBKey>();
380 return true; 380 return true;
381 381
382 case kIndexedDBKeyArrayTypeByte: { 382 case kIndexedDBKeyArrayTypeByte: {
383 int64_t length = 0; 383 int64_t length = 0;
384 if (!DecodeVarInt(slice, &length) || length < 0) 384 if (!DecodeVarInt(slice, &length) || length < 0)
385 return false; 385 return false;
386 IndexedDBKey::KeyArray array; 386 IndexedDBKey::KeyArray array;
387 while (length--) { 387 while (length--) {
388 std::unique_ptr<IndexedDBKey> key; 388 std::unique_ptr<IndexedDBKey> key;
389 if (!DecodeIDBKey(slice, &key)) 389 if (!DecodeIDBKey(slice, &key))
390 return false; 390 return false;
391 array.push_back(*key); 391 array.push_back(*key);
392 } 392 }
393 *value = base::WrapUnique(new IndexedDBKey(array)); 393 *value = base::MakeUnique<IndexedDBKey>(array);
394 return true; 394 return true;
395 } 395 }
396 case kIndexedDBKeyBinaryTypeByte: { 396 case kIndexedDBKeyBinaryTypeByte: {
397 std::string binary; 397 std::string binary;
398 if (!DecodeBinary(slice, &binary)) 398 if (!DecodeBinary(slice, &binary))
399 return false; 399 return false;
400 *value = base::WrapUnique(new IndexedDBKey(binary)); 400 *value = base::MakeUnique<IndexedDBKey>(binary);
401 return true; 401 return true;
402 } 402 }
403 case kIndexedDBKeyStringTypeByte: { 403 case kIndexedDBKeyStringTypeByte: {
404 base::string16 s; 404 base::string16 s;
405 if (!DecodeStringWithLength(slice, &s)) 405 if (!DecodeStringWithLength(slice, &s))
406 return false; 406 return false;
407 *value = base::WrapUnique(new IndexedDBKey(s)); 407 *value = base::MakeUnique<IndexedDBKey>(s);
408 return true; 408 return true;
409 } 409 }
410 case kIndexedDBKeyDateTypeByte: { 410 case kIndexedDBKeyDateTypeByte: {
411 double d; 411 double d;
412 if (!DecodeDouble(slice, &d)) 412 if (!DecodeDouble(slice, &d))
413 return false; 413 return false;
414 *value = base::WrapUnique(new IndexedDBKey(d, WebIDBKeyTypeDate)); 414 *value = base::MakeUnique<IndexedDBKey>(d, WebIDBKeyTypeDate);
415 return true; 415 return true;
416 } 416 }
417 case kIndexedDBKeyNumberTypeByte: { 417 case kIndexedDBKeyNumberTypeByte: {
418 double d; 418 double d;
419 if (!DecodeDouble(slice, &d)) 419 if (!DecodeDouble(slice, &d))
420 return false; 420 return false;
421 *value = base::WrapUnique(new IndexedDBKey(d, WebIDBKeyTypeNumber)); 421 *value = base::MakeUnique<IndexedDBKey>(d, WebIDBKeyTypeNumber);
422 return true; 422 return true;
423 } 423 }
424 } 424 }
425 425
426 NOTREACHED(); 426 NOTREACHED();
427 return false; 427 return false;
428 } 428 }
429 429
430 bool DecodeDouble(StringPiece* slice, double* value) { 430 bool DecodeDouble(StringPiece* slice, double* value) {
431 if (slice->size() < sizeof(*value)) 431 if (slice->size() < sizeof(*value))
(...skipping 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1897 std::unique_ptr<IndexedDBKey> IndexDataKey::primary_key() const { 1897 std::unique_ptr<IndexedDBKey> IndexDataKey::primary_key() const {
1898 std::unique_ptr<IndexedDBKey> key; 1898 std::unique_ptr<IndexedDBKey> key;
1899 StringPiece slice(encoded_primary_key_); 1899 StringPiece slice(encoded_primary_key_);
1900 if (!DecodeIDBKey(&slice, &key)) { 1900 if (!DecodeIDBKey(&slice, &key)) {
1901 // TODO(jsbell): Return error. 1901 // TODO(jsbell): Return error.
1902 } 1902 }
1903 return key; 1903 return key;
1904 } 1904 }
1905 1905
1906 } // namespace content 1906 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_index_writer.cc ('k') | content/browser/indexed_db/indexed_db_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698