| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/doodle/doodle_fetcher.h" | 5 #include "components/doodle/doodle_fetcher.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/time/clock.h" | 10 #include "base/time/clock.h" |
| 11 #include "base/time/default_clock.h" | 11 #include "base/time/default_clock.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "components/data_use_measurement/core/data_use_user_data.h" |
| 14 #include "components/google/core/browser/google_url_tracker.h" | 15 #include "components/google/core/browser/google_url_tracker.h" |
| 15 #include "components/google/core/browser/google_util.h" | 16 #include "components/google/core/browser/google_util.h" |
| 16 #include "net/base/load_flags.h" | 17 #include "net/base/load_flags.h" |
| 17 #include "net/http/http_status_code.h" | 18 #include "net/http/http_status_code.h" |
| 18 #include "net/url_request/url_fetcher.h" | 19 #include "net/url_request/url_fetcher.h" |
| 19 | 20 |
| 20 using net::URLFetcher; | 21 using net::URLFetcher; |
| 21 | 22 |
| 22 namespace doodle { | 23 namespace doodle { |
| 23 | 24 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } | 95 } |
| 95 DCHECK(!fetcher_.get()); | 96 DCHECK(!fetcher_.get()); |
| 96 callbacks_.push_back(std::move(callback)); | 97 callbacks_.push_back(std::move(callback)); |
| 97 fetcher_ = URLFetcher::Create(GetGoogleBaseUrl().Resolve(kDoodleConfigPath), | 98 fetcher_ = URLFetcher::Create(GetGoogleBaseUrl().Resolve(kDoodleConfigPath), |
| 98 URLFetcher::GET, this); | 99 URLFetcher::GET, this); |
| 99 fetcher_->SetRequestContext(download_context_.get()); | 100 fetcher_->SetRequestContext(download_context_.get()); |
| 100 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 101 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 101 net::LOAD_DO_NOT_SAVE_COOKIES | | 102 net::LOAD_DO_NOT_SAVE_COOKIES | |
| 102 net::LOAD_DO_NOT_SEND_AUTH_DATA); | 103 net::LOAD_DO_NOT_SEND_AUTH_DATA); |
| 103 fetcher_->SetAutomaticallyRetryOnNetworkChanges(1); | 104 fetcher_->SetAutomaticallyRetryOnNetworkChanges(1); |
| 105 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 106 fetcher_.get(), data_use_measurement::DataUseUserData::DOODLE); |
| 104 fetcher_->Start(); | 107 fetcher_->Start(); |
| 105 } | 108 } |
| 106 | 109 |
| 107 void DoodleFetcher::OnURLFetchComplete(const URLFetcher* source) { | 110 void DoodleFetcher::OnURLFetchComplete(const URLFetcher* source) { |
| 108 DCHECK_EQ(fetcher_.get(), source); | 111 DCHECK_EQ(fetcher_.get(), source); |
| 109 std::unique_ptr<net::URLFetcher> free_fetcher = std::move(fetcher_); | 112 std::unique_ptr<net::URLFetcher> free_fetcher = std::move(fetcher_); |
| 110 | 113 |
| 111 std::string json_string; | 114 std::string json_string; |
| 112 if (!(source->GetStatus().is_success() && | 115 if (!(source->GetStatus().is_success() && |
| 113 source->GetResponseCode() == net::HTTP_OK && | 116 source->GetResponseCode() == net::HTTP_OK && |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 | 234 |
| 232 GURL DoodleFetcher::GetGoogleBaseUrl() const { | 235 GURL DoodleFetcher::GetGoogleBaseUrl() const { |
| 233 GURL cmd_line_url = google_util::CommandLineGoogleBaseURL(); | 236 GURL cmd_line_url = google_util::CommandLineGoogleBaseURL(); |
| 234 if (cmd_line_url.is_valid()) { | 237 if (cmd_line_url.is_valid()) { |
| 235 return cmd_line_url; | 238 return cmd_line_url; |
| 236 } | 239 } |
| 237 return google_url_tracker_->google_url(); | 240 return google_url_tracker_->google_url(); |
| 238 } | 241 } |
| 239 | 242 |
| 240 } // namespace doodle | 243 } // namespace doodle |
| OLD | NEW |