| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ntp_snippets/ntp_snippets_fetcher.h" | 5 #include "components/ntp_snippets/ntp_snippets_fetcher.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 | 205 |
| 206 void NTPSnippetsFetcher::SetCallback( | 206 void NTPSnippetsFetcher::SetCallback( |
| 207 const SnippetsAvailableCallback& callback) { | 207 const SnippetsAvailableCallback& callback) { |
| 208 snippets_available_callback_ = callback; | 208 snippets_available_callback_ = callback; |
| 209 } | 209 } |
| 210 | 210 |
| 211 void NTPSnippetsFetcher::FetchSnippetsFromHosts( | 211 void NTPSnippetsFetcher::FetchSnippetsFromHosts( |
| 212 const std::set<std::string>& hosts, | 212 const std::set<std::string>& hosts, |
| 213 const std::string& language_code, | 213 const std::string& language_code, |
| 214 int count, | 214 int count, |
| 215 bool force_request) { | 215 bool interactive_request) { |
| 216 if (!request_throttler_.DemandQuotaForRequest(force_request)) | 216 if (!request_throttler_.DemandQuotaForRequest(interactive_request)) |
| 217 return; | 217 return; |
| 218 | 218 |
| 219 hosts_ = hosts; | 219 hosts_ = hosts; |
| 220 fetch_start_time_ = tick_clock_->NowTicks(); | 220 fetch_start_time_ = tick_clock_->NowTicks(); |
| 221 | 221 |
| 222 if (UsesHostRestrictions() && hosts_.empty()) { | 222 if (UsesHostRestrictions() && hosts_.empty()) { |
| 223 FetchFinished(OptionalSnippets(), FetchResult::EMPTY_HOSTS, | 223 FetchFinished(OptionalSnippets(), FetchResult::EMPTY_HOSTS, |
| 224 /*extra_message=*/std::string()); | 224 /*extra_message=*/std::string()); |
| 225 return; | 225 return; |
| 226 } | 226 } |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 tick_clock_->NowTicks() - fetch_start_time_); | 564 tick_clock_->NowTicks() - fetch_start_time_); |
| 565 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Snippets.FetchResult", | 565 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Snippets.FetchResult", |
| 566 static_cast<int>(result), | 566 static_cast<int>(result), |
| 567 static_cast<int>(FetchResult::RESULT_MAX)); | 567 static_cast<int>(FetchResult::RESULT_MAX)); |
| 568 | 568 |
| 569 if (!snippets_available_callback_.is_null()) | 569 if (!snippets_available_callback_.is_null()) |
| 570 snippets_available_callback_.Run(std::move(snippets)); | 570 snippets_available_callback_.Run(std::move(snippets)); |
| 571 } | 571 } |
| 572 | 572 |
| 573 } // namespace ntp_snippets | 573 } // namespace ntp_snippets |
| OLD | NEW |