| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/search_provider_logos/logo_tracker.h" | 5 #include "components/search_provider_logos/logo_tracker.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 FROM_HERE, base::Bind(&DeleteLogoCacheOnFileThread, logo_cache_)); | 139 FROM_HERE, base::Bind(&DeleteLogoCacheOnFileThread, logo_cache_)); |
| 140 logo_cache_ = cache.release(); | 140 logo_cache_ = cache.release(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void LogoTracker::SetClockForTests(std::unique_ptr<base::Clock> clock) { | 143 void LogoTracker::SetClockForTests(std::unique_ptr<base::Clock> clock) { |
| 144 clock_ = std::move(clock); | 144 clock_ = std::move(clock); |
| 145 } | 145 } |
| 146 | 146 |
| 147 void LogoTracker::ReturnToIdle(int outcome) { | 147 void LogoTracker::ReturnToIdle(int outcome) { |
| 148 if (outcome != kDownloadOutcomeNotTracked) { | 148 if (outcome != kDownloadOutcomeNotTracked) { |
| 149 UMA_HISTOGRAM_ENUMERATION("NewTabPage.LogoDownloadOutcome", outcome, | 149 UMA_HISTOGRAM_ENUMERATION("NewTabPage.LogoDownloadOutcome", |
| 150 static_cast<LogoDownloadOutcome>(outcome), |
| 150 DOWNLOAD_OUTCOME_COUNT); | 151 DOWNLOAD_OUTCOME_COUNT); |
| 151 } | 152 } |
| 152 // Cancel the current asynchronous operation, if any. | 153 // Cancel the current asynchronous operation, if any. |
| 153 fetcher_.reset(); | 154 fetcher_.reset(); |
| 154 weak_ptr_factory_.InvalidateWeakPtrs(); | 155 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 155 | 156 |
| 156 // Reset state. | 157 // Reset state. |
| 157 is_idle_ = true; | 158 is_idle_ = true; |
| 158 cached_logo_.reset(); | 159 cached_logo_.reset(); |
| 159 is_cached_logo_valid_ = false; | 160 is_cached_logo_valid_ = false; |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 int64_t current, | 381 int64_t current, |
| 381 int64_t total, | 382 int64_t total, |
| 382 int64_t current_network_bytes) { | 383 int64_t current_network_bytes) { |
| 383 if (total > kMaxDownloadBytes || current > kMaxDownloadBytes) { | 384 if (total > kMaxDownloadBytes || current > kMaxDownloadBytes) { |
| 384 LOG(WARNING) << "Search provider logo exceeded download size limit"; | 385 LOG(WARNING) << "Search provider logo exceeded download size limit"; |
| 385 ReturnToIdle(DOWNLOAD_OUTCOME_DOWNLOAD_FAILED); | 386 ReturnToIdle(DOWNLOAD_OUTCOME_DOWNLOAD_FAILED); |
| 386 } | 387 } |
| 387 } | 388 } |
| 388 | 389 |
| 389 } // namespace search_provider_logos | 390 } // namespace search_provider_logos |
| OLD | NEW |