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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 tick_clock_->NowTicks() - fetch_start_time_); | 552 tick_clock_->NowTicks() - fetch_start_time_); |
553 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Snippets.FetchResult", | 553 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Snippets.FetchResult", |
554 static_cast<int>(result), | 554 static_cast<int>(result), |
555 static_cast<int>(FetchResult::RESULT_MAX)); | 555 static_cast<int>(FetchResult::RESULT_MAX)); |
556 | 556 |
557 if (!snippets_available_callback_.is_null()) | 557 if (!snippets_available_callback_.is_null()) |
558 snippets_available_callback_.Run(std::move(snippets)); | 558 snippets_available_callback_.Run(std::move(snippets)); |
559 } | 559 } |
560 | 560 |
561 } // namespace ntp_snippets | 561 } // namespace ntp_snippets |
OLD | NEW |