| 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 209 |
| 210 void NTPSnippetsFetcher::SetCallback( | 210 void NTPSnippetsFetcher::SetCallback( |
| 211 const SnippetsAvailableCallback& callback) { | 211 const SnippetsAvailableCallback& callback) { |
| 212 snippets_available_callback_ = callback; | 212 snippets_available_callback_ = callback; |
| 213 } | 213 } |
| 214 | 214 |
| 215 void NTPSnippetsFetcher::FetchSnippetsFromHosts( | 215 void NTPSnippetsFetcher::FetchSnippetsFromHosts( |
| 216 const std::set<std::string>& hosts, | 216 const std::set<std::string>& hosts, |
| 217 const std::string& language_code, | 217 const std::string& language_code, |
| 218 int count, | 218 int count, |
| 219 bool force_request) { | 219 bool interactive_request) { |
| 220 if (!request_throttler_.DemandQuotaForRequest(force_request)) | 220 if (!request_throttler_.DemandQuotaForRequest(interactive_request)) |
| 221 return; | 221 return; |
| 222 | 222 |
| 223 hosts_ = hosts; | 223 hosts_ = hosts; |
| 224 fetch_start_time_ = tick_clock_->NowTicks(); | 224 fetch_start_time_ = tick_clock_->NowTicks(); |
| 225 | 225 |
| 226 if (UsesHostRestrictions() && hosts_.empty()) { | 226 if (UsesHostRestrictions() && hosts_.empty()) { |
| 227 FetchFinished(OptionalSnippets(), FetchResult::EMPTY_HOSTS, | 227 FetchFinished(OptionalSnippets(), FetchResult::EMPTY_HOSTS, |
| 228 /*extra_message=*/std::string()); | 228 /*extra_message=*/std::string()); |
| 229 return; | 229 return; |
| 230 } | 230 } |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 } | 593 } |
| 594 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Snippets.FetchResult", | 594 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Snippets.FetchResult", |
| 595 static_cast<int>(result), | 595 static_cast<int>(result), |
| 596 static_cast<int>(FetchResult::RESULT_MAX)); | 596 static_cast<int>(FetchResult::RESULT_MAX)); |
| 597 | 597 |
| 598 if (!snippets_available_callback_.is_null()) | 598 if (!snippets_available_callback_.is_null()) |
| 599 snippets_available_callback_.Run(std::move(snippets)); | 599 snippets_available_callback_.Run(std::move(snippets)); |
| 600 } | 600 } |
| 601 | 601 |
| 602 } // namespace ntp_snippets | 602 } // namespace ntp_snippets |
| OLD | NEW |