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

Issue 2158843002: Introduce a request throttler for limiting requests in mobile NTP. (Closed)

Created:
4 years, 5 months ago by jkrcal
Modified:
4 years, 5 months ago
CC:
chromium-reviews, ntp-dev+reviews_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Introduce a request throttler for limiting requests in mobile NTP. This CL adds a generic throttler of requests that - checks new requests against daily quota (configurable by Finch), - reports to UMA status of each request w.r.t. the quota, - reports to UMA the total count of request per day. As an example application, it adds throttler for NTPSnippetsFetcher. This throttler will be used in another CL. BUG=627073 Committed: https://crrev.com/505ea3a812f9a245c4e056e86c5dc59347d9440f Cr-Commit-Position: refs/heads/master@{#407124}

Patch Set 1 #

Patch Set 2 : Fixing #

Patch Set 3 : Fixing #2 #

Patch Set 4 : Disallow copy and assign #

Patch Set 5 : A minor fix #

Patch Set 6 : Fix a build error #

Patch Set 7 : A minor fix #2 #

Patch Set 8 : A minor fix #3 #

Total comments: 27

Patch Set 9 : Marc's comments #

Total comments: 39

Patch Set 10 : Marc's comments #2 #

Patch Set 11 : A minor fix #

Total comments: 30

Patch Set 12 : Marc's comments #3 #

Patch Set 13 : A minor fix #2 #

Total comments: 10

Patch Set 14 : Marc's comments #4 #

Total comments: 10

Patch Set 15 : Rebase #

Patch Set 16 : Marc's comments #5 + a bit of polish #

Patch Set 17 : Fix to compile unittests #

Total comments: 12

Patch Set 18 : Alexei's and Tim's comments #

Patch Set 19 : A minor change #

Total comments: 10

Patch Set 20 : Tim's comments #

Patch Set 21 : Tim's comments (renaming) #

Total comments: 8
Unified diffs Side-by-side diffs Delta from patch set Stats (+362 lines, -1 line) Patch
M chrome/browser/prefs/browser_prefs.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2 chunks +2 lines, -0 lines 0 comments Download
M components/ntp_snippets.gypi View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 chunk +2 lines, -0 lines 0 comments Download
M components/ntp_snippets/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2 chunks +3 lines, -0 lines 0 comments Download
M components/ntp_snippets/pref_names.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +7 lines, -1 line 0 comments Download
M components/ntp_snippets/pref_names.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 chunk +5 lines, -0 lines 0 comments Download
A components/ntp_snippets/request_throttler.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 chunk +88 lines, -0 lines 8 comments Download
A components/ntp_snippets/request_throttler.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 chunk +149 lines, -0 lines 0 comments Download
A components/ntp_snippets/request_throttler_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 chunk +71 lines, -0 lines 0 comments Download
M tools/metrics/histograms/histograms.xml View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 3 chunks +35 lines, -0 lines 0 comments Download

Dependent Patchsets:

Messages

Total messages: 69 (35 generated)
jkrcal
PTAL, Marc.
4 years, 5 months ago (2016-07-18 12:58:28 UTC) #2
jkrcal
On 2016/07/18 12:58:28, jkrcal wrote: > PTAL, Marc. As a reference, first application of the ...
4 years, 5 months ago (2016-07-18 13:51:58 UTC) #5
Marc Treib
https://codereview.chromium.org/2158843002/diff/140001/components/ntp_snippets/pref_names.cc File components/ntp_snippets/pref_names.cc (right): https://codereview.chromium.org/2158843002/diff/140001/components/ntp_snippets/pref_names.cc#newcode13 components/ntp_snippets/pref_names.cc:13: const char kSnippetQuotaCountFormat[] = "ntp_snippets.quota.%s.count"; Hmmm, this is very ...
4 years, 5 months ago (2016-07-19 09:06:18 UTC) #12
jkrcal
Thanks, PTAL, again! (I am sorry for not having a separate rebase pathset :|) https://codereview.chromium.org/2158843002/diff/140001/components/ntp_snippets/pref_names.cc ...
4 years, 5 months ago (2016-07-20 09:40:40 UTC) #14
Marc Treib
https://codereview.chromium.org/2158843002/diff/140001/components/ntp_snippets/request_counter.cc File components/ntp_snippets/request_counter.cc (right): https://codereview.chromium.org/2158843002/diff/140001/components/ntp_snippets/request_counter.cc#newcode39 components/ntp_snippets/request_counter.cc:39: if (!base::StringToInt(quota, &quota_)) { On 2016/07/20 09:40:40, jkrcal wrote: ...
4 years, 5 months ago (2016-07-20 10:19:06 UTC) #15
jkrcal
Thanks, again! Very useful. PTAL. https://codereview.chromium.org/2158843002/diff/140001/components/ntp_snippets/request_counter.cc File components/ntp_snippets/request_counter.cc (right): https://codereview.chromium.org/2158843002/diff/140001/components/ntp_snippets/request_counter.cc#newcode39 components/ntp_snippets/request_counter.cc:39: if (!base::StringToInt(quota, &quota_)) { ...
4 years, 5 months ago (2016-07-20 12:09:28 UTC) #16
Marc Treib
https://codereview.chromium.org/2158843002/diff/160001/components/ntp_snippets/request_counter.cc File components/ntp_snippets/request_counter.cc (right): https://codereview.chromium.org/2158843002/diff/160001/components/ntp_snippets/request_counter.cc#newcode36 components/ntp_snippets/request_counter.cc:36: std::string quota = variations::GetVariationParamValue( On 2016/07/20 12:09:27, jkrcal wrote: ...
4 years, 5 months ago (2016-07-20 12:58:28 UTC) #17
jkrcal
Thanks, again! I must admit, this whole CL does not make me feel very competent ...
4 years, 5 months ago (2016-07-20 14:20:17 UTC) #18
Marc Treib
https://codereview.chromium.org/2158843002/diff/200001/chrome/browser/prefs/browser_prefs.cc File chrome/browser/prefs/browser_prefs.cc (right): https://codereview.chromium.org/2158843002/diff/200001/chrome/browser/prefs/browser_prefs.cc#newcode465 chrome/browser/prefs/browser_prefs.cc:465: ntp_snippets::RequestCounter::RegisterProfilePrefs(registry); On 2016/07/20 14:20:17, jkrcal wrote: > On 2016/07/20 ...
4 years, 5 months ago (2016-07-20 15:13:58 UTC) #19
jkrcal
Marc, thanks and PTAL, again! https://codereview.chromium.org/2158843002/diff/200001/components/ntp_snippets/request_counter.h File components/ntp_snippets/request_counter.h (right): https://codereview.chromium.org/2158843002/diff/200001/components/ntp_snippets/request_counter.h#newcode35 components/ntp_snippets/request_counter.h:35: // RegisterProfilePrefs()), On 2016/07/20 ...
4 years, 5 months ago (2016-07-20 15:46:23 UTC) #20
jkrcal
Dominic, PTAL at browser_prefs.cc. Alexei, PTAL at histograms.xml + a bonus question: Why does histogram ...
4 years, 5 months ago (2016-07-20 15:49:11 UTC) #22
Marc Treib
LGTM with some last nits :) https://codereview.chromium.org/2158843002/diff/240001/components/ntp_snippets/request_counter.cc File components/ntp_snippets/request_counter.cc (right): https://codereview.chromium.org/2158843002/diff/240001/components/ntp_snippets/request_counter.cc#newcode77 components/ntp_snippets/request_counter.cc:77: for (unsigned int ...
4 years, 5 months ago (2016-07-20 16:15:14 UTC) #23
jkrcal
Huge thanks, Marc! https://codereview.chromium.org/2158843002/diff/240001/components/ntp_snippets/request_counter.cc File components/ntp_snippets/request_counter.cc (right): https://codereview.chromium.org/2158843002/diff/240001/components/ntp_snippets/request_counter.cc#newcode77 components/ntp_snippets/request_counter.cc:77: for (unsigned int i = 0; ...
4 years, 5 months ago (2016-07-21 07:44:28 UTC) #24
tschumann
https://codereview.chromium.org/2158843002/diff/320001/components/ntp_snippets/pref_names.h File components/ntp_snippets/pref_names.h (right): https://codereview.chromium.org/2158843002/diff/320001/components/ntp_snippets/pref_names.h#newcode17 components/ntp_snippets/pref_names.h:17: // The count of NTPSnippetsFetcher requests for today, so ...
4 years, 5 months ago (2016-07-21 11:37:09 UTC) #30
Marc Treib
https://codereview.chromium.org/2158843002/diff/320001/components/ntp_snippets/pref_names.h File components/ntp_snippets/pref_names.h (right): https://codereview.chromium.org/2158843002/diff/320001/components/ntp_snippets/pref_names.h#newcode17 components/ntp_snippets/pref_names.h:17: // The count of NTPSnippetsFetcher requests for today, so ...
4 years, 5 months ago (2016-07-21 11:43:50 UTC) #31
Alexei Svitkine (slow)
lgtm % comments > Why does histogram created by UMA_HISTOGRAM_ENUMERATION have one more bucket > ...
4 years, 5 months ago (2016-07-21 14:13:30 UTC) #32
jkrcal
Thanks for the comments! (Alexei, wouldn't the overflow bucket be worth a comment in the ...
4 years, 5 months ago (2016-07-21 18:17:58 UTC) #33
Alexei Svitkine (slow)
+1 to documenting the macro better. Happy to review your CL if you want to ...
4 years, 5 months ago (2016-07-21 18:20:52 UTC) #34
tschumann
https://codereview.chromium.org/2158843002/diff/360001/components/ntp_snippets/request_counter.h File components/ntp_snippets/request_counter.h (right): https://codereview.chromium.org/2158843002/diff/360001/components/ntp_snippets/request_counter.h#newcode44 components/ntp_snippets/request_counter.h:44: CONTENT_SUGGESTION_FETCHER are there plans for further types? if not, ...
4 years, 5 months ago (2016-07-21 18:27:45 UTC) #35
jkrcal
Thanks, Tim! https://codereview.chromium.org/2158843002/diff/360001/components/ntp_snippets/request_counter.h File components/ntp_snippets/request_counter.h (right): https://codereview.chromium.org/2158843002/diff/360001/components/ntp_snippets/request_counter.h#newcode44 components/ntp_snippets/request_counter.h:44: CONTENT_SUGGESTION_FETCHER On 2016/07/21 18:27:45, tschumann wrote: > ...
4 years, 5 months ago (2016-07-21 19:17:39 UTC) #36
battre
lgtm
4 years, 5 months ago (2016-07-21 20:52:03 UTC) #37
tschumann
lgtm one more thing: I'm not sure RequestCounter is the best name for this class ...
4 years, 5 months ago (2016-07-22 07:49:08 UTC) #47
jkrcal
Thanks, Tim. I renamed the whole thing. After all, it is the same amount of ...
4 years, 5 months ago (2016-07-22 09:10:04 UTC) #49
tschumann
lgtm
4 years, 5 months ago (2016-07-22 09:13:55 UTC) #52
tschumann
lgtm lgtm Thanks!
4 years, 5 months ago (2016-07-22 09:13:59 UTC) #53
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2158843002/400001
4 years, 5 months ago (2016-07-22 10:15:47 UTC) #58
commit-bot: I haz the power
Committed patchset #21 (id:400001)
4 years, 5 months ago (2016-07-22 10:20:57 UTC) #60
commit-bot: I haz the power
Patchset 21 (id:??) landed as https://crrev.com/505ea3a812f9a245c4e056e86c5dc59347d9440f Cr-Commit-Position: refs/heads/master@{#407124}
4 years, 5 months ago (2016-07-22 10:22:46 UTC) #62
Bernhard Bauer
Some post-commit drive-by nits: https://codereview.chromium.org/2158843002/diff/400001/components/ntp_snippets/request_throttler.h File components/ntp_snippets/request_throttler.h (right): https://codereview.chromium.org/2158843002/diff/400001/components/ntp_snippets/request_throttler.h#newcode21 components/ntp_snippets/request_throttler.h:21: struct RequestTypeInfo; This type could ...
4 years, 5 months ago (2016-07-22 13:58:24 UTC) #64
jkrcal
Thanks, Bernhard! https://codereview.chromium.org/2158843002/diff/400001/components/ntp_snippets/request_throttler.h File components/ntp_snippets/request_throttler.h (right): https://codereview.chromium.org/2158843002/diff/400001/components/ntp_snippets/request_throttler.h#newcode21 components/ntp_snippets/request_throttler.h:21: struct RequestTypeInfo; On 2016/07/22 13:58:24, Bernhard Bauer ...
4 years, 5 months ago (2016-07-25 10:02:36 UTC) #65
Marc Treib
https://codereview.chromium.org/2158843002/diff/400001/components/ntp_snippets/request_throttler.h File components/ntp_snippets/request_throttler.h (right): https://codereview.chromium.org/2158843002/diff/400001/components/ntp_snippets/request_throttler.h#newcode21 components/ntp_snippets/request_throttler.h:21: struct RequestTypeInfo; On 2016/07/25 10:02:36, jkrcal wrote: > On ...
4 years, 5 months ago (2016-07-25 10:06:16 UTC) #66
jkrcal
https://codereview.chromium.org/2158843002/diff/400001/components/ntp_snippets/request_throttler.h File components/ntp_snippets/request_throttler.h (right): https://codereview.chromium.org/2158843002/diff/400001/components/ntp_snippets/request_throttler.h#newcode21 components/ntp_snippets/request_throttler.h:21: struct RequestTypeInfo; On 2016/07/25 10:06:16, Marc Treib wrote: > ...
4 years, 5 months ago (2016-07-25 10:14:46 UTC) #67
Marc Treib
https://codereview.chromium.org/2158843002/diff/400001/components/ntp_snippets/request_throttler.h File components/ntp_snippets/request_throttler.h (right): https://codereview.chromium.org/2158843002/diff/400001/components/ntp_snippets/request_throttler.h#newcode21 components/ntp_snippets/request_throttler.h:21: struct RequestTypeInfo; On 2016/07/25 10:14:45, jkrcal wrote: > On ...
4 years, 5 months ago (2016-07-25 10:22:16 UTC) #68
Bernhard Bauer
4 years, 5 months ago (2016-07-25 11:15:03 UTC) #69
Message was sent while issue was closed.
https://codereview.chromium.org/2158843002/diff/400001/components/ntp_snippet...
File components/ntp_snippets/request_throttler.h (right):

https://codereview.chromium.org/2158843002/diff/400001/components/ntp_snippet...
components/ntp_snippets/request_throttler.h:21: struct RequestTypeInfo;
On 2016/07/25 10:22:15, Marc Treib wrote:
> On 2016/07/25 10:14:45, jkrcal wrote:
> > On 2016/07/25 10:06:16, Marc Treib wrote:
> > > On 2016/07/25 10:02:36, jkrcal wrote:
> > > > On 2016/07/22 13:58:24, Bernhard Bauer wrote:
> > > > > This type could be made a private member of the class.
> > > > 
> > > > I would keep it there as I did already move it back and forth. 
> > > > 
> > > > Out of curiosity: what is dividing line in your opinion between the
> > situations
> > > > where one of the following is more appropriate?
> > > >  - defining such a struct as a private member 
> > > >  - defining it in the .cc file (potentially in an anonymous namespace)
> > > 
> > > Generally, keep the scope as small as possible. That means, prefer the
> > anonymous
> > > namespace, unless you need it in the header. If you do, make it a private
> > > member, but keep the definition in the .cc file if possible (that's the
case
> > > here). So, you can just move this one line into the class.
> > 
> > Thanks! 
> > If it is a private member, how should I define the kRequestTypeInfo constant
> > list in the .cc file. Do I need to make kRequestTypeInfo a member of
> > RequestThrottler? Is it desirable?
> 
> Ah, right - that would need to become a static member then. That's kinda
> awkward. I'm not sure if the actual definition could stay in the .cc file
then?

Yeah, you would still declare it in the header as a private static member, then
define it in the .cc file.  (And I think that's still better than what this does
right now, which is exporting the type declaration to files that include this
header, without making the definition available).

Powered by Google App Engine
This is Rietveld 408576698