OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/base64.h" | 7 #include "base/base64.h" |
8 #include "base/env_var.h" | 8 #include "base/env_var.h" |
9 #include "base/file_version_info.h" | 9 #include "base/file_version_info.h" |
10 #include "base/histogram.h" | 10 #include "base/histogram.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
13 #include "base/stl_util-inl.h" | 13 #include "base/stl_util-inl.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "base/task.h" | 15 #include "base/task.h" |
16 #include "base/timer.h" | 16 #include "base/timer.h" |
| 17 #include "chrome/app/chrome_version_info.h" |
17 #include "chrome/browser/chrome_thread.h" | 18 #include "chrome/browser/chrome_thread.h" |
18 #include "chrome/browser/net/url_request_context_getter.h" | 19 #include "chrome/browser/net/url_request_context_getter.h" |
19 #include "chrome/browser/profile.h" | 20 #include "chrome/browser/profile.h" |
20 #include "chrome/browser/safe_browsing/protocol_parser.h" | 21 #include "chrome/browser/safe_browsing/protocol_parser.h" |
21 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 22 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
22 #include "chrome/common/env_vars.h" | 23 #include "chrome/common/env_vars.h" |
23 #include "net/base/escape.h" | 24 #include "net/base/escape.h" |
24 #include "net/base/load_flags.h" | 25 #include "net/base/load_flags.h" |
25 #include "net/url_request/url_request_status.h" | 26 #include "net/url_request/url_request_status.h" |
26 | 27 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 update_size_(0), | 81 update_size_(0), |
81 client_name_(client_name), | 82 client_name_(client_name), |
82 request_context_getter_(request_context_getter) { | 83 request_context_getter_(request_context_getter) { |
83 // Set the backoff multiplier fuzz to a random value between 0 and 1. | 84 // Set the backoff multiplier fuzz to a random value between 0 and 1. |
84 back_off_fuzz_ = static_cast<float>(base::RandDouble()); | 85 back_off_fuzz_ = static_cast<float>(base::RandDouble()); |
85 | 86 |
86 // The first update must happen between 1-5 minutes of start up. | 87 // The first update must happen between 1-5 minutes of start up. |
87 next_update_sec_ = base::RandInt(60, kSbTimerStartIntervalSec); | 88 next_update_sec_ = base::RandInt(60, kSbTimerStartIntervalSec); |
88 | 89 |
89 scoped_ptr<FileVersionInfo> version_info( | 90 scoped_ptr<FileVersionInfo> version_info( |
90 FileVersionInfo::CreateFileVersionInfoForCurrentModule()); | 91 chrome_app::GetChromeVersionInfo()); |
91 if (!version_info.get()) | 92 if (!version_info.get()) |
92 version_ = "0.1"; | 93 version_ = "0.1"; |
93 else | 94 else |
94 version_ = WideToASCII(version_info->product_version()); | 95 version_ = WideToASCII(version_info->product_version()); |
95 } | 96 } |
96 | 97 |
97 SafeBrowsingProtocolManager::~SafeBrowsingProtocolManager() { | 98 SafeBrowsingProtocolManager::~SafeBrowsingProtocolManager() { |
98 // Delete in-progress SafeBrowsing requests. | 99 // Delete in-progress SafeBrowsing requests. |
99 STLDeleteContainerPairFirstPointers(hash_requests_.begin(), | 100 STLDeleteContainerPairFirstPointers(hash_requests_.begin(), |
100 hash_requests_.end()); | 101 hash_requests_.end()); |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 void SafeBrowsingProtocolManager::HandleGetHashError(const Time& now) { | 660 void SafeBrowsingProtocolManager::HandleGetHashError(const Time& now) { |
660 int next = GetNextBackOffTime(&gethash_error_count_, &gethash_back_off_mult_); | 661 int next = GetNextBackOffTime(&gethash_error_count_, &gethash_back_off_mult_); |
661 next_gethash_time_ = now + TimeDelta::FromSeconds(next); | 662 next_gethash_time_ = now + TimeDelta::FromSeconds(next); |
662 } | 663 } |
663 | 664 |
664 void SafeBrowsingProtocolManager::UpdateFinished(bool success) { | 665 void SafeBrowsingProtocolManager::UpdateFinished(bool success) { |
665 UMA_HISTOGRAM_COUNTS("SB2.UpdateSize", update_size_); | 666 UMA_HISTOGRAM_COUNTS("SB2.UpdateSize", update_size_); |
666 update_size_ = 0; | 667 update_size_ = 0; |
667 sb_service_->UpdateFinished(success); | 668 sb_service_->UpdateFinished(success); |
668 } | 669 } |
OLD | NEW |