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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_database_unittest.cc

Issue 2259523003: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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) 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 // Unit tests for the SafeBrowsing storage system. 5 // Unit tests for the SafeBrowsing storage system.
6 6
7 #include "chrome/browser/safe_browsing/safe_browsing_database.h" 7 #include "chrome/browser/safe_browsing/safe_browsing_database.h"
8 8
9 #include <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 std::unique_ptr<ChunkData> raw_data(new ChunkData); 78 std::unique_ptr<ChunkData> raw_data(new ChunkData);
79 raw_data->set_chunk_number(chunk_number); 79 raw_data->set_chunk_number(chunk_number);
80 raw_data->set_chunk_type(chunk_type); 80 raw_data->set_chunk_type(chunk_type);
81 raw_data->set_prefix_type(prefix_type); 81 raw_data->set_prefix_type(prefix_type);
82 raw_data->set_hashes(data, data_size); 82 raw_data->set_hashes(data, data_size);
83 raw_data->clear_add_numbers(); 83 raw_data->clear_add_numbers();
84 for (size_t i = 0; i < add_chunk_numbers.size(); ++i) { 84 for (size_t i = 0; i < add_chunk_numbers.size(); ++i) {
85 raw_data->add_add_numbers(add_chunk_numbers[i]); 85 raw_data->add_add_numbers(add_chunk_numbers[i]);
86 } 86 }
87 87
88 return base::WrapUnique(new SBChunkData(std::move(raw_data))); 88 return base::MakeUnique<SBChunkData>(std::move(raw_data));
89 } 89 }
90 90
91 // Create add chunk with a single prefix. 91 // Create add chunk with a single prefix.
92 std::unique_ptr<SBChunkData> AddChunkPrefix(int chunk_number, SBPrefix prefix) { 92 std::unique_ptr<SBChunkData> AddChunkPrefix(int chunk_number, SBPrefix prefix) {
93 return BuildChunk(chunk_number, ChunkData::ADD, ChunkData::PREFIX_4B, &prefix, 93 return BuildChunk(chunk_number, ChunkData::ADD, ChunkData::PREFIX_4B, &prefix,
94 sizeof(prefix), std::vector<int>()); 94 sizeof(prefix), std::vector<int>());
95 } 95 }
96 96
97 // Create add chunk with a single prefix generated from |value|. 97 // Create add chunk with a single prefix generated from |value|.
98 std::unique_ptr<SBChunkData> AddChunkPrefixValue(int chunk_number, 98 std::unique_ptr<SBChunkData> AddChunkPrefixValue(int chunk_number,
(...skipping 2269 matching lines...) Expand 10 before | Expand all | Expand 10 after
2368 ASSERT_EQ(1U, prefix_hits.size()); 2368 ASSERT_EQ(1U, prefix_hits.size());
2369 EXPECT_EQ(SBPrefixForString(kExampleCollision), prefix_hits[0]); 2369 EXPECT_EQ(SBPrefixForString(kExampleCollision), prefix_hits[0]);
2370 EXPECT_TRUE(cache_hits.empty()); 2370 EXPECT_TRUE(cache_hits.empty());
2371 2371
2372 // This prefix collides, but no full hash match. 2372 // This prefix collides, but no full hash match.
2373 EXPECT_FALSE(database_->ContainsBrowseUrl( 2373 EXPECT_FALSE(database_->ContainsBrowseUrl(
2374 GURL(std::string("http://") + kExampleFine), &prefix_hits, &cache_hits)); 2374 GURL(std::string("http://") + kExampleFine), &prefix_hits, &cache_hits));
2375 } 2375 }
2376 2376
2377 } // namespace safe_browsing 2377 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698