| 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 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/task_runner_util.h" | 10 #include "base/task_runner_util.h" |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 236 |
| 237 void LogoTracker::OnFreshLogoAvailable(scoped_ptr<EncodedLogo> encoded_logo, | 237 void LogoTracker::OnFreshLogoAvailable(scoped_ptr<EncodedLogo> encoded_logo, |
| 238 const SkBitmap& image) { | 238 const SkBitmap& image) { |
| 239 DCHECK(!is_idle_); | 239 DCHECK(!is_idle_); |
| 240 | 240 |
| 241 if (encoded_logo && !encoded_logo->encoded_image.get() && cached_logo_ && | 241 if (encoded_logo && !encoded_logo->encoded_image.get() && cached_logo_ && |
| 242 !encoded_logo->metadata.fingerprint.empty() && | 242 !encoded_logo->metadata.fingerprint.empty() && |
| 243 encoded_logo->metadata.fingerprint == | 243 encoded_logo->metadata.fingerprint == |
| 244 cached_logo_->metadata.fingerprint) { | 244 cached_logo_->metadata.fingerprint) { |
| 245 // The cached logo was revalidated, i.e. its fingerprint was verified. | 245 // The cached logo was revalidated, i.e. its fingerprint was verified. |
| 246 // mime_type isn't sent when revalidating, so copy it from the cached logo. |
| 247 encoded_logo->metadata.mime_type = cached_logo_->metadata.mime_type; |
| 246 SetCachedMetadata(encoded_logo->metadata); | 248 SetCachedMetadata(encoded_logo->metadata); |
| 247 } else if (encoded_logo && image.isNull()) { | 249 } else if (encoded_logo && image.isNull()) { |
| 248 // Image decoding failed. Do nothing. | 250 // Image decoding failed. Do nothing. |
| 249 } else { | 251 } else { |
| 250 scoped_ptr<Logo> logo; | 252 scoped_ptr<Logo> logo; |
| 251 // Check if the server returned a valid, non-empty response. | 253 // Check if the server returned a valid, non-empty response. |
| 252 if (encoded_logo) { | 254 if (encoded_logo) { |
| 253 DCHECK(!image.isNull()); | 255 DCHECK(!image.isNull()); |
| 254 logo.reset(new Logo()); | 256 logo.reset(new Logo()); |
| 255 logo->metadata = encoded_logo->metadata; | 257 logo->metadata = encoded_logo->metadata; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 void LogoTracker::OnURLFetchDownloadProgress(const net::URLFetcher* source, | 296 void LogoTracker::OnURLFetchDownloadProgress(const net::URLFetcher* source, |
| 295 int64 current, | 297 int64 current, |
| 296 int64 total) { | 298 int64 total) { |
| 297 if (total > kMaxDownloadBytes || current > kMaxDownloadBytes) { | 299 if (total > kMaxDownloadBytes || current > kMaxDownloadBytes) { |
| 298 LOG(WARNING) << "Search provider logo exceeded download size limit"; | 300 LOG(WARNING) << "Search provider logo exceeded download size limit"; |
| 299 ReturnToIdle(); | 301 ReturnToIdle(); |
| 300 } | 302 } |
| 301 } | 303 } |
| 302 | 304 |
| 303 } // namespace search_provider_logos | 305 } // namespace search_provider_logos |
| OLD | NEW |