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

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

Issue 28046: Use string for Histogram names since these are all ASCII anyway wide-characte... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_bloom.h" 5 #include "chrome/browser/safe_browsing/safe_browsing_database_bloom.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // If we're missing either of the database or filter files, we wait until the 84 // If we're missing either of the database or filter files, we wait until the
85 // next update to generate a new filter. 85 // next update to generate a new filter.
86 // TODO(paulg): Investigate how often the filter file is missing and how 86 // TODO(paulg): Investigate how often the filter file is missing and how
87 // expensive it would be to regenerate it. 87 // expensive it would be to regenerate it.
88 int64 size_64; 88 int64 size_64;
89 if (!file_util::GetFileSize(filename_, &size_64) || size_64 == 0) 89 if (!file_util::GetFileSize(filename_, &size_64) || size_64 == 0)
90 return; 90 return;
91 91
92 if (!file_util::GetFileSize(bloom_filter_filename_, &size_64) || 92 if (!file_util::GetFileSize(bloom_filter_filename_, &size_64) ||
93 size_64 == 0) { 93 size_64 == 0) {
94 UMA_HISTOGRAM_COUNTS(L"SB2.FilterMissing", 1); 94 UMA_HISTOGRAM_COUNTS("SB2.FilterMissing", 1);
95 return; 95 return;
96 } 96 }
97 97
98 // We have a bloom filter file, so use that as our filter. 98 // We have a bloom filter file, so use that as our filter.
99 int size = static_cast<int>(size_64); 99 int size = static_cast<int>(size_64);
100 char* data = new char[size]; 100 char* data = new char[size];
101 CHECK(data); 101 CHECK(data);
102 102
103 Time before = Time::Now(); 103 Time before = Time::Now();
104 file_util::ReadFile(bloom_filter_filename_, data, size); 104 file_util::ReadFile(bloom_filter_filename_, data, size);
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 } else { 396 } else {
397 while (!chunk.hosts.empty()) { 397 while (!chunk.hosts.empty()) {
398 chunk.hosts.front().entry->Destroy(); 398 chunk.hosts.front().entry->Destroy();
399 chunk.hosts.pop_front(); 399 chunk.hosts.pop_front();
400 } 400 }
401 } 401 }
402 402
403 chunks->pop_front(); 403 chunks->pop_front();
404 } 404 }
405 405
406 UMA_HISTOGRAM_TIMES(L"SB2.ChunkInsert", base::Time::Now() - insert_start); 406 UMA_HISTOGRAM_TIMES("SB2.ChunkInsert", base::Time::Now() - insert_start);
407 407
408 delete chunks; 408 delete chunks;
409 409
410 if (chunk_inserted_callback_.get()) 410 if (chunk_inserted_callback_.get())
411 chunk_inserted_callback_->Run(); 411 chunk_inserted_callback_->Run();
412 } 412 }
413 413
414 bool SafeBrowsingDatabaseBloom::UpdateStarted() { 414 bool SafeBrowsingDatabaseBloom::UpdateStarted() {
415 DCHECK(insert_transaction_.get() == NULL); 415 DCHECK(insert_transaction_.get() == NULL);
416 416
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 1309
1310 // Save the chunk numbers we've received to the database for reporting in 1310 // Save the chunk numbers we've received to the database for reporting in
1311 // future update requests. 1311 // future update requests.
1312 if (!WriteChunkNumbers()) 1312 if (!WriteChunkNumbers())
1313 return; 1313 return;
1314 1314
1315 // Commit all the changes to the database. 1315 // Commit all the changes to the database.
1316 int rv = insert_transaction_->Commit(); 1316 int rv = insert_transaction_->Commit();
1317 if (rv != SQLITE_OK) { 1317 if (rv != SQLITE_OK) {
1318 NOTREACHED() << "SafeBrowsing update transaction failed to commit."; 1318 NOTREACHED() << "SafeBrowsing update transaction failed to commit.";
1319 UMA_HISTOGRAM_COUNTS(L"SB2.FailedUpdate", 1); 1319 UMA_HISTOGRAM_COUNTS("SB2.FailedUpdate", 1);
1320 return; 1320 return;
1321 } 1321 }
1322 1322
1323 // Swap in the newly built filter and cache. If there were any matching subs, 1323 // Swap in the newly built filter and cache. If there were any matching subs,
1324 // the size (add_count_) will be smaller. 1324 // the size (add_count_) will be smaller.
1325 { 1325 {
1326 AutoLock lock(lookup_lock_); 1326 AutoLock lock(lookup_lock_);
1327 add_count_ = new_count; 1327 add_count_ = new_count;
1328 bloom_filter_ = filter; 1328 bloom_filter_ = filter;
1329 hash_cache_.swap(add_cache); 1329 hash_cache_.swap(add_cache);
1330 } 1330 }
1331 1331
1332 TimeDelta bloom_gen = Time::Now() - before; 1332 TimeDelta bloom_gen = Time::Now() - before;
1333 1333
1334 // Persist the bloom filter to disk. 1334 // Persist the bloom filter to disk.
1335 WriteBloomFilter(); 1335 WriteBloomFilter();
1336 1336
1337 // Gather statistics. 1337 // Gather statistics.
1338 #if defined(OS_WIN) 1338 #if defined(OS_WIN)
1339 metric->GetIOCounters(&io_after); 1339 metric->GetIOCounters(&io_after);
1340 UMA_HISTOGRAM_COUNTS(L"SB2.BuildReadBytes", 1340 UMA_HISTOGRAM_COUNTS("SB2.BuildReadBytes",
1341 static_cast<int>(io_after.ReadTransferCount - 1341 static_cast<int>(io_after.ReadTransferCount -
1342 io_before.ReadTransferCount)); 1342 io_before.ReadTransferCount));
1343 UMA_HISTOGRAM_COUNTS(L"SB2.BuildWriteBytes", 1343 UMA_HISTOGRAM_COUNTS("SB2.BuildWriteBytes",
1344 static_cast<int>(io_after.WriteTransferCount - 1344 static_cast<int>(io_after.WriteTransferCount -
1345 io_before.WriteTransferCount)); 1345 io_before.WriteTransferCount));
1346 UMA_HISTOGRAM_COUNTS(L"SB2.BuildReadOperations", 1346 UMA_HISTOGRAM_COUNTS("SB2.BuildReadOperations",
1347 static_cast<int>(io_after.ReadOperationCount - 1347 static_cast<int>(io_after.ReadOperationCount -
1348 io_before.ReadOperationCount)); 1348 io_before.ReadOperationCount));
1349 UMA_HISTOGRAM_COUNTS(L"SB2.BuildWriteOperations", 1349 UMA_HISTOGRAM_COUNTS("SB2.BuildWriteOperations",
1350 static_cast<int>(io_after.WriteOperationCount - 1350 static_cast<int>(io_after.WriteOperationCount -
1351 io_before.WriteOperationCount)); 1351 io_before.WriteOperationCount));
1352 #endif 1352 #endif
1353 SB_DLOG(INFO) << "SafeBrowsingDatabaseImpl built bloom filter in " 1353 SB_DLOG(INFO) << "SafeBrowsingDatabaseImpl built bloom filter in "
1354 << bloom_gen.InMilliseconds() 1354 << bloom_gen.InMilliseconds()
1355 << " ms total. prefix count: "<< add_count_; 1355 << " ms total. prefix count: "<< add_count_;
1356 UMA_HISTOGRAM_LONG_TIMES(L"SB2.BuildFilter", bloom_gen); 1356 UMA_HISTOGRAM_LONG_TIMES("SB2.BuildFilter", bloom_gen);
1357 UMA_HISTOGRAM_COUNTS(L"SB2.AddPrefixes", add_count_); 1357 UMA_HISTOGRAM_COUNTS("SB2.AddPrefixes", add_count_);
1358 UMA_HISTOGRAM_COUNTS(L"SB2.SubPrefixes", subs); 1358 UMA_HISTOGRAM_COUNTS("SB2.SubPrefixes", subs);
1359 int64 size_64; 1359 int64 size_64;
1360 if (file_util::GetFileSize(filename_, &size_64)) 1360 if (file_util::GetFileSize(filename_, &size_64))
1361 UMA_HISTOGRAM_COUNTS(L"SB2.DatabaseBytes", static_cast<int>(size_64)); 1361 UMA_HISTOGRAM_COUNTS("SB2.DatabaseBytes", static_cast<int>(size_64));
1362 } 1362 }
1363 1363
1364 void SafeBrowsingDatabaseBloom::GetCachedFullHashes( 1364 void SafeBrowsingDatabaseBloom::GetCachedFullHashes(
1365 const std::vector<SBPrefix>* prefix_hits, 1365 const std::vector<SBPrefix>* prefix_hits,
1366 std::vector<SBFullHashResult>* full_hits, 1366 std::vector<SBFullHashResult>* full_hits,
1367 Time last_update) { 1367 Time last_update) {
1368 DCHECK(prefix_hits && full_hits); 1368 DCHECK(prefix_hits && full_hits);
1369 1369
1370 Time max_age = Time::Now() - TimeDelta::FromMinutes(kMaxStalenessMinutes); 1370 Time max_age = Time::Now() - TimeDelta::FromMinutes(kMaxStalenessMinutes);
1371 1371
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 if (did_resume_) { 1487 if (did_resume_) {
1488 PlatformThread::Sleep(kOnResumeHoldupMs); 1488 PlatformThread::Sleep(kOnResumeHoldupMs);
1489 did_resume_ = false; 1489 did_resume_ = false;
1490 } 1490 }
1491 } 1491 }
1492 1492
1493 // This database is always synchronous since we don't need to worry about 1493 // This database is always synchronous since we don't need to worry about
1494 // blocking any incoming reads. 1494 // blocking any incoming reads.
1495 void SafeBrowsingDatabaseBloom::SetSynchronous() { 1495 void SafeBrowsingDatabaseBloom::SetSynchronous() {
1496 } 1496 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/protocol_manager.cc ('k') | chrome/browser/safe_browsing/safe_browsing_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698