Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: components/ntp_snippets/ntp_snippets_fetcher.cc

Issue 2227973002: Add request throttler to thumbnail fetching for articles on mobile NTP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing the compile error Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 } 569 }
570 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Snippets.FetchResult", 570 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Snippets.FetchResult",
571 static_cast<int>(result), 571 static_cast<int>(result),
572 static_cast<int>(FetchResult::RESULT_MAX)); 572 static_cast<int>(FetchResult::RESULT_MAX));
573 573
574 if (!snippets_available_callback_.is_null()) 574 if (!snippets_available_callback_.is_null())
575 snippets_available_callback_.Run(std::move(snippets)); 575 snippets_available_callback_.Run(std::move(snippets));
576 } 576 }
577 577
578 } // namespace ntp_snippets 578 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698