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

Side by Side Diff: chrome/browser/safe_browsing/protocol_manager.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/protocol_manager.h" 5 #include "chrome/browser/safe_browsing/protocol_manager.h"
6 6
7 #include "base/file_version_info.h" 7 #include "base/file_version_info.h"
8 #include "base/histogram.h" 8 #include "base/histogram.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 } else if (update_state_ == SECOND_REQUEST) { 322 } else if (update_state_ == SECOND_REQUEST) {
323 next_update_sec_ = base::RandInt(15 * 60, 45 * 60); 323 next_update_sec_ = base::RandInt(15 * 60, 45 * 60);
324 } 324 }
325 325
326 // We need to request a new set of keys for MAC. 326 // We need to request a new set of keys for MAC.
327 if (re_key) 327 if (re_key)
328 HandleReKey(); 328 HandleReKey();
329 329
330 // New chunks to download. 330 // New chunks to download.
331 if (!chunk_urls.empty()) { 331 if (!chunk_urls.empty()) {
332 UMA_HISTOGRAM_COUNTS(L"SB2.UpdateUrls", chunk_urls.size()); 332 UMA_HISTOGRAM_COUNTS("SB2.UpdateUrls", chunk_urls.size());
333 for (size_t i = 0; i < chunk_urls.size(); ++i) 333 for (size_t i = 0; i < chunk_urls.size(); ++i)
334 chunk_request_urls_.push_back(chunk_urls[i]); 334 chunk_request_urls_.push_back(chunk_urls[i]);
335 } 335 }
336 336
337 // Handle the case were the SafeBrowsing service tells us to dump our 337 // Handle the case were the SafeBrowsing service tells us to dump our
338 // database. 338 // database.
339 if (reset) { 339 if (reset) {
340 sb_service_->ResetDatabase(); 340 sb_service_->ResetDatabase();
341 delete chunk_deletes; 341 delete chunk_deletes;
342 return true; 342 return true;
343 } 343 }
344 344
345 // Chunks to delete from our storage. 345 // Chunks to delete from our storage.
346 if (!chunk_deletes->empty()) 346 if (!chunk_deletes->empty())
347 sb_service_->HandleChunkDelete(chunk_deletes); 347 sb_service_->HandleChunkDelete(chunk_deletes);
348 else 348 else
349 delete chunk_deletes; 349 delete chunk_deletes;
350 350
351 break; 351 break;
352 } 352 }
353 case CHUNK_REQUEST: { 353 case CHUNK_REQUEST: {
354 if (sb_service_->new_safe_browsing()) 354 if (sb_service_->new_safe_browsing())
355 UMA_HISTOGRAM_TIMES(L"SB2.ChunkRequest", 355 UMA_HISTOGRAM_TIMES("SB2.ChunkRequest",
356 base::Time::Now() - chunk_request_start_); 356 base::Time::Now() - chunk_request_start_);
357 357
358 const ChunkUrl chunk_url = chunk_request_urls_.front(); 358 const ChunkUrl chunk_url = chunk_request_urls_.front();
359 bool re_key = false; 359 bool re_key = false;
360 std::deque<SBChunk>* chunks = new std::deque<SBChunk>; 360 std::deque<SBChunk>* chunks = new std::deque<SBChunk>;
361 UMA_HISTOGRAM_COUNTS(L"SB2.ChunkSize", length); 361 UMA_HISTOGRAM_COUNTS("SB2.ChunkSize", length);
362 update_size_ += length; 362 update_size_ += length;
363 if (!parser.ParseChunk(data, length, 363 if (!parser.ParseChunk(data, length,
364 client_key_, chunk_url.mac, 364 client_key_, chunk_url.mac,
365 &re_key, chunks)) { 365 &re_key, chunks)) {
366 #ifndef NDEBUG 366 #ifndef NDEBUG
367 std::string data_str; 367 std::string data_str;
368 data_str.assign(data, length); 368 data_str.assign(data, length);
369 std::string encoded_chunk; 369 std::string encoded_chunk;
370 net::Base64Encode(data, &encoded_chunk); 370 net::Base64Encode(data, &encoded_chunk);
371 SB_DLOG(INFO) << "ParseChunk error for chunk: " << chunk_url.url 371 SB_DLOG(INFO) << "ParseChunk error for chunk: " << chunk_url.url
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 request_->set_upload_data("text/plain", list_data); 558 request_->set_upload_data("text/plain", list_data);
559 request_->Start(); 559 request_->Start();
560 } 560 }
561 561
562 void SafeBrowsingProtocolManager::OnChunkInserted() { 562 void SafeBrowsingProtocolManager::OnChunkInserted() {
563 chunk_pending_to_write_ = false; 563 chunk_pending_to_write_ = false;
564 564
565 if (chunk_request_urls_.empty()) { 565 if (chunk_request_urls_.empty()) {
566 // Don't pollute old implementation histograms with new implemetation data. 566 // Don't pollute old implementation histograms with new implemetation data.
567 if (sb_service_->new_safe_browsing()) 567 if (sb_service_->new_safe_browsing())
568 UMA_HISTOGRAM_LONG_TIMES(L"SB2.Update", Time::Now() - last_update_); 568 UMA_HISTOGRAM_LONG_TIMES("SB2.Update", Time::Now() - last_update_);
569 else 569 else
570 UMA_HISTOGRAM_LONG_TIMES(L"SB.Update", Time::Now() - last_update_); 570 UMA_HISTOGRAM_LONG_TIMES("SB.Update", Time::Now() - last_update_);
571 UpdateFinished(true); 571 UpdateFinished(true);
572 } else { 572 } else {
573 IssueChunkRequest(); 573 IssueChunkRequest();
574 } 574 }
575 } 575 }
576 576
577 void SafeBrowsingProtocolManager::ReportMalware(const GURL& malware_url, 577 void SafeBrowsingProtocolManager::ReportMalware(const GURL& malware_url,
578 const GURL& page_url, 578 const GURL& page_url,
579 const GURL& referrer_url) { 579 const GURL& referrer_url) {
580 std::string report_str = StringPrintf( 580 std::string report_str = StringPrintf(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 wrapped_key_.clear(); 620 wrapped_key_.clear();
621 IssueKeyRequest(); 621 IssueKeyRequest();
622 } 622 }
623 623
624 void SafeBrowsingProtocolManager::HandleGetHashError() { 624 void SafeBrowsingProtocolManager::HandleGetHashError() {
625 int next = GetNextBackOffTime(&gethash_error_count_, &gethash_back_off_mult_); 625 int next = GetNextBackOffTime(&gethash_error_count_, &gethash_back_off_mult_);
626 next_gethash_time_ = Time::Now() + TimeDelta::FromSeconds(next); 626 next_gethash_time_ = Time::Now() + TimeDelta::FromSeconds(next);
627 } 627 }
628 628
629 void SafeBrowsingProtocolManager::UpdateFinished(bool success) { 629 void SafeBrowsingProtocolManager::UpdateFinished(bool success) {
630 UMA_HISTOGRAM_COUNTS(L"SB2.UpdateSize", update_size_); 630 UMA_HISTOGRAM_COUNTS("SB2.UpdateSize", update_size_);
631 update_size_ = 0; 631 update_size_ = 0;
632 sb_service_->UpdateFinished(success); 632 sb_service_->UpdateFinished(success);
633 } 633 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/resource_message_filter.cc ('k') | chrome/browser/safe_browsing/safe_browsing_database_bloom.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698