| 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" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/task_runner_util.h" | 13 #include "base/task_runner_util.h" |
| 14 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
| 15 #include "base/time/default_clock.h" | 15 #include "base/time/default_clock.h" |
| 16 #include "components/data_use_measurement/core/data_use_user_data.h" |
| 16 #include "components/search_provider_logos/switches.h" | 17 #include "components/search_provider_logos/switches.h" |
| 17 #include "net/http/http_response_headers.h" | 18 #include "net/http/http_response_headers.h" |
| 18 #include "net/http/http_status_code.h" | 19 #include "net/http/http_status_code.h" |
| 19 #include "net/url_request/url_fetcher.h" | 20 #include "net/url_request/url_fetcher.h" |
| 20 #include "net/url_request/url_request_context_getter.h" | 21 #include "net/url_request/url_request_context_getter.h" |
| 21 #include "net/url_request/url_request_status.h" | 22 #include "net/url_request/url_request_status.h" |
| 22 | 23 |
| 23 namespace search_provider_logos { | 24 namespace search_provider_logos { |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 221 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 221 if (command_line->HasSwitch(switches::kGoogleDoodleUrl)) { | 222 if (command_line->HasSwitch(switches::kGoogleDoodleUrl)) { |
| 222 url = GURL(command_line->GetSwitchValueASCII(switches::kGoogleDoodleUrl)); | 223 url = GURL(command_line->GetSwitchValueASCII(switches::kGoogleDoodleUrl)); |
| 223 } else { | 224 } else { |
| 224 url = append_queryparams_func_.Run( | 225 url = append_queryparams_func_.Run( |
| 225 logo_url_, fingerprint, wants_cta_, transparent_); | 226 logo_url_, fingerprint, wants_cta_, transparent_); |
| 226 } | 227 } |
| 227 | 228 |
| 228 fetcher_ = net::URLFetcher::Create(url, net::URLFetcher::GET, this); | 229 fetcher_ = net::URLFetcher::Create(url, net::URLFetcher::GET, this); |
| 229 fetcher_->SetRequestContext(request_context_getter_.get()); | 230 fetcher_->SetRequestContext(request_context_getter_.get()); |
| 231 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 232 fetcher_.get(), |
| 233 data_use_measurement::DataUseUserData::SEARCH_PROVIDER_LOGOS); |
| 230 fetcher_->Start(); | 234 fetcher_->Start(); |
| 231 logo_download_start_time_ = base::TimeTicks::Now(); | 235 logo_download_start_time_ = base::TimeTicks::Now(); |
| 232 } | 236 } |
| 233 | 237 |
| 234 void LogoTracker::OnFreshLogoParsed(bool* parsing_failed, | 238 void LogoTracker::OnFreshLogoParsed(bool* parsing_failed, |
| 235 std::unique_ptr<EncodedLogo> logo) { | 239 std::unique_ptr<EncodedLogo> logo) { |
| 236 DCHECK(!is_idle_); | 240 DCHECK(!is_idle_); |
| 237 | 241 |
| 238 if (logo) | 242 if (logo) |
| 239 logo->metadata.source_url = logo_url_.spec(); | 243 logo->metadata.source_url = logo_url_.spec(); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 int64_t current, | 348 int64_t current, |
| 345 int64_t total, | 349 int64_t total, |
| 346 int64_t current_network_bytes) { | 350 int64_t current_network_bytes) { |
| 347 if (total > kMaxDownloadBytes || current > kMaxDownloadBytes) { | 351 if (total > kMaxDownloadBytes || current > kMaxDownloadBytes) { |
| 348 LOG(WARNING) << "Search provider logo exceeded download size limit"; | 352 LOG(WARNING) << "Search provider logo exceeded download size limit"; |
| 349 ReturnToIdle(DOWNLOAD_OUTCOME_DOWNLOAD_FAILED); | 353 ReturnToIdle(DOWNLOAD_OUTCOME_DOWNLOAD_FAILED); |
| 350 } | 354 } |
| 351 } | 355 } |
| 352 | 356 |
| 353 } // namespace search_provider_logos | 357 } // namespace search_provider_logos |
| OLD | NEW |