| OLD | NEW |
| 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/base64.h" |
| 7 #include "base/file_version_info.h" | 8 #include "base/file_version_info.h" |
| 8 #include "base/histogram.h" | 9 #include "base/histogram.h" |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
| 11 #include "base/stl_util-inl.h" | 12 #include "base/stl_util-inl.h" |
| 12 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 13 #include "base/sys_info.h" | 14 #include "base/sys_info.h" |
| 14 #include "base/task.h" | 15 #include "base/task.h" |
| 15 #include "base/timer.h" | 16 #include "base/timer.h" |
| 16 #include "chrome/browser/chrome_thread.h" | 17 #include "chrome/browser/chrome_thread.h" |
| 17 #include "chrome/browser/net/url_request_context_getter.h" | 18 #include "chrome/browser/net/url_request_context_getter.h" |
| 18 #include "chrome/browser/profile.h" | 19 #include "chrome/browser/profile.h" |
| 19 #include "chrome/browser/safe_browsing/protocol_parser.h" | 20 #include "chrome/browser/safe_browsing/protocol_parser.h" |
| 20 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 21 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 21 #include "chrome/common/env_vars.h" | 22 #include "chrome/common/env_vars.h" |
| 22 #include "net/base/base64.h" | |
| 23 #include "net/base/escape.h" | 23 #include "net/base/escape.h" |
| 24 #include "net/base/load_flags.h" | 24 #include "net/base/load_flags.h" |
| 25 | 25 |
| 26 using base::Time; | 26 using base::Time; |
| 27 using base::TimeDelta; | 27 using base::TimeDelta; |
| 28 | 28 |
| 29 // Maximum time, in seconds, from start up before we must issue an update query. | 29 // Maximum time, in seconds, from start up before we must issue an update query. |
| 30 static const int kSbTimerStartIntervalSec = 5 * 60; | 30 static const int kSbTimerStartIntervalSec = 5 * 60; |
| 31 | 31 |
| 32 // The maximum time, in seconds, to wait for a response to an update request. | 32 // The maximum time, in seconds, to wait for a response to an update request. |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 std::deque<SBChunk>* chunks = new std::deque<SBChunk>; | 379 std::deque<SBChunk>* chunks = new std::deque<SBChunk>; |
| 380 UMA_HISTOGRAM_COUNTS("SB2.ChunkSize", length); | 380 UMA_HISTOGRAM_COUNTS("SB2.ChunkSize", length); |
| 381 update_size_ += length; | 381 update_size_ += length; |
| 382 if (!parser.ParseChunk(data, length, | 382 if (!parser.ParseChunk(data, length, |
| 383 client_key_, chunk_url.mac, | 383 client_key_, chunk_url.mac, |
| 384 &re_key, chunks)) { | 384 &re_key, chunks)) { |
| 385 #ifndef NDEBUG | 385 #ifndef NDEBUG |
| 386 std::string data_str; | 386 std::string data_str; |
| 387 data_str.assign(data, length); | 387 data_str.assign(data, length); |
| 388 std::string encoded_chunk; | 388 std::string encoded_chunk; |
| 389 net::Base64Encode(data, &encoded_chunk); | 389 base::Base64Encode(data, &encoded_chunk); |
| 390 SB_DLOG(INFO) << "ParseChunk error for chunk: " << chunk_url.url | 390 SB_DLOG(INFO) << "ParseChunk error for chunk: " << chunk_url.url |
| 391 << ", client_key: " << client_key_ | 391 << ", client_key: " << client_key_ |
| 392 << ", wrapped_key: " << wrapped_key_ | 392 << ", wrapped_key: " << wrapped_key_ |
| 393 << ", mac: " << chunk_url.mac | 393 << ", mac: " << chunk_url.mac |
| 394 << ", Base64Encode(data): " << encoded_chunk | 394 << ", Base64Encode(data): " << encoded_chunk |
| 395 << ", length: " << length; | 395 << ", length: " << length; |
| 396 #endif | 396 #endif |
| 397 safe_browsing_util::FreeChunks(chunks); | 397 safe_browsing_util::FreeChunks(chunks); |
| 398 delete chunks; | 398 delete chunks; |
| 399 return false; | 399 return false; |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 void SafeBrowsingProtocolManager::HandleGetHashError(const Time& now) { | 655 void SafeBrowsingProtocolManager::HandleGetHashError(const Time& now) { |
| 656 int next = GetNextBackOffTime(&gethash_error_count_, &gethash_back_off_mult_); | 656 int next = GetNextBackOffTime(&gethash_error_count_, &gethash_back_off_mult_); |
| 657 next_gethash_time_ = now + TimeDelta::FromSeconds(next); | 657 next_gethash_time_ = now + TimeDelta::FromSeconds(next); |
| 658 } | 658 } |
| 659 | 659 |
| 660 void SafeBrowsingProtocolManager::UpdateFinished(bool success) { | 660 void SafeBrowsingProtocolManager::UpdateFinished(bool success) { |
| 661 UMA_HISTOGRAM_COUNTS("SB2.UpdateSize", update_size_); | 661 UMA_HISTOGRAM_COUNTS("SB2.UpdateSize", update_size_); |
| 662 update_size_ = 0; | 662 update_size_ = 0; |
| 663 sb_service_->UpdateFinished(success); | 663 sb_service_->UpdateFinished(success); |
| 664 } | 664 } |
| OLD | NEW |