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

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

Issue 1551503002: Convert Pass()→std::move() in //chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 "chrome/browser/safe_browsing/safe_browsing_database.h" 5 #include "chrome/browser/safe_browsing/safe_browsing_database.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9
10 #include <algorithm> 9 #include <algorithm>
11 #include <iterator> 10 #include <iterator>
11 #include <utility>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/files/file_util.h" 14 #include "base/files/file_util.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
17 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
18 #include "base/process/process_handle.h" 18 #include "base/process/process_handle.h"
19 #include "base/process/process_metrics.h" 19 #include "base/process/process_metrics.h"
20 #include "base/sha1.h" 20 #include "base/sha1.h"
21 #include "base/strings/string_number_conversions.h" 21 #include "base/strings/string_number_conversions.h"
(...skipping 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 new_prefix_set = builder.GetPrefixSet(full_hash_results); 1404 new_prefix_set = builder.GetPrefixSet(full_hash_results);
1405 } else { 1405 } else {
1406 // TODO(gab): Ensure that stores which do not want full hashes just don't 1406 // TODO(gab): Ensure that stores which do not want full hashes just don't
1407 // have full hashes in the first place and remove 1407 // have full hashes in the first place and remove
1408 // |store_full_hashes_in_prefix_set| and the code specialization incurred 1408 // |store_full_hashes_in_prefix_set| and the code specialization incurred
1409 // here. 1409 // here.
1410 new_prefix_set = builder.GetPrefixSetNoHashes(); 1410 new_prefix_set = builder.GetPrefixSetNoHashes();
1411 } 1411 }
1412 1412
1413 // Swap in the newly built filter. 1413 // Swap in the newly built filter.
1414 state_manager_.BeginWriteTransaction()->SwapPrefixSet(prefix_set_id, 1414 state_manager_.BeginWriteTransaction()->SwapPrefixSet(
1415 new_prefix_set.Pass()); 1415 prefix_set_id, std::move(new_prefix_set));
1416 1416
1417 UMA_HISTOGRAM_LONG_TIMES("SB2.BuildFilter", base::TimeTicks::Now() - before); 1417 UMA_HISTOGRAM_LONG_TIMES("SB2.BuildFilter", base::TimeTicks::Now() - before);
1418 1418
1419 WritePrefixSet(db_filename, prefix_set_id, write_failure_type); 1419 WritePrefixSet(db_filename, prefix_set_id, write_failure_type);
1420 1420
1421 // Gather statistics. 1421 // Gather statistics.
1422 if (got_counters && metric->GetIOCounters(&io_after)) { 1422 if (got_counters && metric->GetIOCounters(&io_after)) {
1423 UMA_HISTOGRAM_COUNTS("SB2.BuildReadKilobytes", 1423 UMA_HISTOGRAM_COUNTS("SB2.BuildReadKilobytes",
1424 static_cast<int>(io_after.ReadTransferCount - 1424 static_cast<int>(io_after.ReadTransferCount -
1425 io_before.ReadTransferCount) / 1425 io_before.ReadTransferCount) /
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1513 // TODO(shess): Track existence to drive removal of this code? 1513 // TODO(shess): Track existence to drive removal of this code?
1514 const base::FilePath bloom_filter_filename = 1514 const base::FilePath bloom_filter_filename =
1515 BloomFilterForFilename(db_filename); 1515 BloomFilterForFilename(db_filename);
1516 base::DeleteFile(bloom_filter_filename, false); 1516 base::DeleteFile(bloom_filter_filename, false);
1517 1517
1518 const base::TimeTicks before = base::TimeTicks::Now(); 1518 const base::TimeTicks before = base::TimeTicks::Now();
1519 scoped_ptr<const PrefixSet> new_prefix_set = 1519 scoped_ptr<const PrefixSet> new_prefix_set =
1520 PrefixSet::LoadFile(PrefixSetForFilename(db_filename)); 1520 PrefixSet::LoadFile(PrefixSetForFilename(db_filename));
1521 if (!new_prefix_set.get()) 1521 if (!new_prefix_set.get())
1522 RecordFailure(read_failure_type); 1522 RecordFailure(read_failure_type);
1523 txn->SwapPrefixSet(prefix_set_id, new_prefix_set.Pass()); 1523 txn->SwapPrefixSet(prefix_set_id, std::move(new_prefix_set));
1524 UMA_HISTOGRAM_TIMES("SB2.PrefixSetLoad", base::TimeTicks::Now() - before); 1524 UMA_HISTOGRAM_TIMES("SB2.PrefixSetLoad", base::TimeTicks::Now() - before);
1525 } 1525 }
1526 1526
1527 bool SafeBrowsingDatabaseNew::Delete() { 1527 bool SafeBrowsingDatabaseNew::Delete() {
1528 DCHECK(db_task_runner_->RunsTasksOnCurrentThread()); 1528 DCHECK(db_task_runner_->RunsTasksOnCurrentThread());
1529 DCHECK(!db_state_manager_.filename_base().empty()); 1529 DCHECK(!db_state_manager_.filename_base().empty());
1530 1530
1531 // TODO(shess): This is a mess. SafeBrowsingFileStore::Delete() closes the 1531 // TODO(shess): This is a mess. SafeBrowsingFileStore::Delete() closes the
1532 // store before calling DeleteStore(). DeleteStore() deletes transient files 1532 // store before calling DeleteStore(). DeleteStore() deletes transient files
1533 // in addition to the main file. Probably all of these should be converted to 1533 // in addition to the main file. Probably all of these should be converted to
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1765 1765
1766 // Histogram properties as in UMA_HISTOGRAM_COUNTS macro. 1766 // Histogram properties as in UMA_HISTOGRAM_COUNTS macro.
1767 base::HistogramBase* histogram_pointer = base::Histogram::FactoryGet( 1767 base::HistogramBase* histogram_pointer = base::Histogram::FactoryGet(
1768 histogram_name, 1, 1000000, 50, 1768 histogram_name, 1, 1000000, 50,
1769 base::HistogramBase::kUmaTargetedHistogramFlag); 1769 base::HistogramBase::kUmaTargetedHistogramFlag);
1770 1770
1771 histogram_pointer->Add(file_size_kilobytes); 1771 histogram_pointer->Add(file_size_kilobytes);
1772 } 1772 }
1773 1773
1774 } // namespace safe_browsing 1774 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698