OLD | NEW |
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/protocol_manager.h" | 5 #include "chrome/browser/safe_browsing/protocol_manager.h" |
6 | 6 |
7 #ifndef NDEBUG | 7 #ifndef NDEBUG |
8 #include "base/base64.h" | 8 #include "base/base64.h" |
9 #endif | 9 #endif |
10 #include "base/environment.h" | 10 #include "base/environment.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 kSbTimerStartIntervalSecMax))), | 117 kSbTimerStartIntervalSecMax))), |
118 update_state_(FIRST_REQUEST), | 118 update_state_(FIRST_REQUEST), |
119 chunk_pending_to_write_(false), | 119 chunk_pending_to_write_(false), |
120 version_(config.version), | 120 version_(config.version), |
121 update_size_(0), | 121 update_size_(0), |
122 client_name_(config.client_name), | 122 client_name_(config.client_name), |
123 request_context_getter_(request_context_getter), | 123 request_context_getter_(request_context_getter), |
124 url_prefix_(config.url_prefix), | 124 url_prefix_(config.url_prefix), |
125 backup_update_reason_(BACKUP_UPDATE_REASON_MAX), | 125 backup_update_reason_(BACKUP_UPDATE_REASON_MAX), |
126 disable_auto_update_(config.disable_auto_update), | 126 disable_auto_update_(config.disable_auto_update), |
127 url_fetcher_id_(0) { | 127 url_fetcher_id_(0), |
| 128 app_in_foreground_(true) { |
128 DCHECK(!url_prefix_.empty()); | 129 DCHECK(!url_prefix_.empty()); |
129 | 130 |
130 backup_url_prefixes_[BACKUP_UPDATE_REASON_CONNECT] = | 131 backup_url_prefixes_[BACKUP_UPDATE_REASON_CONNECT] = |
131 config.backup_connect_error_url_prefix; | 132 config.backup_connect_error_url_prefix; |
132 backup_url_prefixes_[BACKUP_UPDATE_REASON_HTTP] = | 133 backup_url_prefixes_[BACKUP_UPDATE_REASON_HTTP] = |
133 config.backup_http_error_url_prefix; | 134 config.backup_http_error_url_prefix; |
134 backup_url_prefixes_[BACKUP_UPDATE_REASON_NETWORK] = | 135 backup_url_prefixes_[BACKUP_UPDATE_REASON_NETWORK] = |
135 config.backup_network_error_url_prefix; | 136 config.backup_network_error_url_prefix; |
136 | 137 |
137 // Set the backoff multiplier fuzz to a random value between 0 and 1. | 138 // Set the backoff multiplier fuzz to a random value between 0 and 1. |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 &gethash_error_count_, &gethash_back_off_mult_); | 700 &gethash_error_count_, &gethash_back_off_mult_); |
700 next_gethash_time_ = now + next; | 701 next_gethash_time_ = now + next; |
701 } | 702 } |
702 | 703 |
703 void SafeBrowsingProtocolManager::UpdateFinished(bool success) { | 704 void SafeBrowsingProtocolManager::UpdateFinished(bool success) { |
704 UpdateFinished(success, !success); | 705 UpdateFinished(success, !success); |
705 } | 706 } |
706 | 707 |
707 void SafeBrowsingProtocolManager::UpdateFinished(bool success, bool back_off) { | 708 void SafeBrowsingProtocolManager::UpdateFinished(bool success, bool back_off) { |
708 DCHECK(CalledOnValidThread()); | 709 DCHECK(CalledOnValidThread()); |
| 710 #if defined(OS_ANDROID) |
| 711 if (app_in_foreground_) |
| 712 UMA_HISTOGRAM_COUNTS("SB2.UpdateSizeForeground", update_size_); |
| 713 else |
| 714 UMA_HISTOGRAM_COUNTS("SB2.UpdateSizeBackground", update_size_); |
| 715 #endif |
709 UMA_HISTOGRAM_COUNTS("SB2.UpdateSize", update_size_); | 716 UMA_HISTOGRAM_COUNTS("SB2.UpdateSize", update_size_); |
710 update_size_ = 0; | 717 update_size_ = 0; |
711 bool update_success = success || request_type_ == CHUNK_REQUEST; | 718 bool update_success = success || request_type_ == CHUNK_REQUEST; |
712 if (backup_update_reason_ == BACKUP_UPDATE_REASON_MAX) { | 719 if (backup_update_reason_ == BACKUP_UPDATE_REASON_MAX) { |
713 RecordUpdateResult( | 720 RecordUpdateResult( |
714 update_success ? UPDATE_RESULT_SUCCESS : UPDATE_RESULT_FAIL); | 721 update_success ? UPDATE_RESULT_SUCCESS : UPDATE_RESULT_FAIL); |
715 } else { | 722 } else { |
716 UpdateResult update_result = static_cast<UpdateResult>( | 723 UpdateResult update_result = static_cast<UpdateResult>( |
717 UPDATE_RESULT_BACKUP_START + | 724 UPDATE_RESULT_BACKUP_START + |
718 (static_cast<int>(backup_update_reason_) * 2) + | 725 (static_cast<int>(backup_update_reason_) * 2) + |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 FullHashCallback callback, bool is_download) | 790 FullHashCallback callback, bool is_download) |
784 : callback(callback), | 791 : callback(callback), |
785 is_download(is_download) { | 792 is_download(is_download) { |
786 } | 793 } |
787 | 794 |
788 SafeBrowsingProtocolManager::FullHashDetails::~FullHashDetails() { | 795 SafeBrowsingProtocolManager::FullHashDetails::~FullHashDetails() { |
789 } | 796 } |
790 | 797 |
791 SafeBrowsingProtocolManagerDelegate::~SafeBrowsingProtocolManagerDelegate() { | 798 SafeBrowsingProtocolManagerDelegate::~SafeBrowsingProtocolManagerDelegate() { |
792 } | 799 } |
OLD | NEW |