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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 | 206 |
207 void NTPSnippetsFetcher::SetCallback( | 207 void NTPSnippetsFetcher::SetCallback( |
208 const SnippetsAvailableCallback& callback) { | 208 const SnippetsAvailableCallback& callback) { |
209 snippets_available_callback_ = callback; | 209 snippets_available_callback_ = callback; |
210 } | 210 } |
211 | 211 |
212 void NTPSnippetsFetcher::FetchSnippetsFromHosts( | 212 void NTPSnippetsFetcher::FetchSnippetsFromHosts( |
213 const std::set<std::string>& hosts, | 213 const std::set<std::string>& hosts, |
214 const std::string& language_code, | 214 const std::string& language_code, |
215 int count, | 215 int count, |
216 bool force_request) { | 216 bool interactive_request) { |
217 if (!request_throttler_.DemandQuotaForRequest(force_request)) | 217 if (!request_throttler_.DemandQuotaForRequest(interactive_request)) |
218 return; | 218 return; |
219 | 219 |
220 hosts_ = hosts; | 220 hosts_ = hosts; |
221 fetch_start_time_ = tick_clock_->NowTicks(); | 221 fetch_start_time_ = tick_clock_->NowTicks(); |
222 | 222 |
223 if (UsesHostRestrictions() && hosts_.empty()) { | 223 if (UsesHostRestrictions() && hosts_.empty()) { |
224 FetchFinished(OptionalSnippets(), FetchResult::EMPTY_HOSTS, | 224 FetchFinished(OptionalSnippets(), FetchResult::EMPTY_HOSTS, |
225 /*extra_message=*/std::string()); | 225 /*extra_message=*/std::string()); |
226 return; | 226 return; |
227 } | 227 } |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 } | 582 } |
583 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Snippets.FetchResult", | 583 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Snippets.FetchResult", |
584 static_cast<int>(result), | 584 static_cast<int>(result), |
585 static_cast<int>(FetchResult::RESULT_MAX)); | 585 static_cast<int>(FetchResult::RESULT_MAX)); |
586 | 586 |
587 if (!snippets_available_callback_.is_null()) | 587 if (!snippets_available_callback_.is_null()) |
588 snippets_available_callback_.Run(std::move(snippets)); | 588 snippets_available_callback_.Run(std::move(snippets)); |
589 } | 589 } |
590 | 590 |
591 } // namespace ntp_snippets | 591 } // namespace ntp_snippets |
OLD | NEW |