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

Issue 2249213002: [OBSOLETE] Reporting: Initial implementation. (Closed)

Created:
4 years, 4 months ago by Julia Tuttle
Modified:
3 years, 9 months ago
CC:
chromium-reviews, blundell+watchlist_chromium.org, sdefresne+watchlist_chromium.org, droger+watchlist_chromium.org, battre, vasilii
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Reporting: Initial implementation. This implements the draft Reporting API, as specified here: http://wicg.github.io/reporting/ Here is a design doc: https://docs.google.com/document/d/1uwNzFv7DltdYXgOSQFufFcnDzkJr9kugRSS2whhrN18/edit

Patch Set 1 #

Patch Set 2 : splat #

Patch Set 3 : splat #

Patch Set 4 : splat #

Patch Set 5 : Split into layered component, tons of other changes #

Patch Set 6 : Start adding unittests #

Patch Set 7 : Fix ProfileImplIOData #

Total comments: 22

Patch Set 8 : Make requested changes, add some comments. #

Patch Set 9 : Don't hold endpoint pointers across deliveries; don't build content on iOS #

Patch Set 10 : Fix android build failure. #

Patch Set 11 : Fix a couple more issues found by the trybots. #

Patch Set 12 : Export mojo interface #

Patch Set 13 : Make several refactors. #

Patch Set 14 : Get URLRequestContextGetter just-in-time. #

Patch Set 15 : rebase #

Patch Set 16 : Whole bunch of changes. #

Patch Set 17 : rebase #

Total comments: 52

Patch Set 18 : Major revision #

Patch Set 19 : Split out a bunch of code into other CLs. #

Patch Set 20 : Try fixing unittest compile error on Android? #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1764 lines, -0 lines) Patch
M net/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 2 chunks +6 lines, -0 lines 0 comments Download
A net/reporting/reporting_service.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +126 lines, -0 lines 0 comments Download
A net/reporting/reporting_service.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +626 lines, -0 lines 0 comments Download
A net/reporting/reporting_service_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +488 lines, -0 lines 0 comments Download
A net/reporting/reporting_uploader.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +38 lines, -0 lines 0 comments Download
A net/reporting/reporting_uploader.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +146 lines, -0 lines 0 comments Download
A net/reporting/reporting_uploader_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +334 lines, -0 lines 0 comments Download

Messages

Total messages: 88 (74 generated)
Randy Smith (Not in Mondays)
Initial round of comments--very high level, mostly to make sure I'm understanding the context for ...
4 years, 2 months ago (2016-10-21 20:15:11 UTC) #19
Julia Tuttle
PTAL, rdsmith. https://codereview.chromium.org/2249213002/diff/120001/components/reporting/content/browser/reporting_network_delegate.cc File components/reporting/content/browser/reporting_network_delegate.cc (right): https://codereview.chromium.org/2249213002/diff/120001/components/reporting/content/browser/reporting_network_delegate.cc#newcode62 components/reporting/content/browser/reporting_network_delegate.cc:62: FROM_HERE, base::Bind(ui_process_header_, origin, header_value)); On 2016/10/21 20:15:10, ...
4 years, 1 month ago (2016-11-02 20:44:39 UTC) #23
battre
Ryan, can you please take a look this? My gut feeling is that our discussions ...
3 years, 12 months ago (2016-12-23 13:25:30 UTC) #63
Julia Tuttle
On 2016/12/23 13:25:30, battre (OOO until Jan 2) wrote: > Ryan, can you please take ...
3 years, 12 months ago (2016-12-23 17:12:01 UTC) #64
Ryan Sleevi
Holidays and all, but yes, we should not be using the profile's URL request context ...
3 years, 12 months ago (2016-12-24 18:57:40 UTC) #66
Randy Smith (Not in Mondays)
On 2016/12/23 17:12:01, Julia Tuttle wrote: > On 2016/12/23 13:25:30, battre (OOO until Jan 2) ...
3 years, 11 months ago (2016-12-29 19:31:28 UTC) #67
battre
+vasilii as this discussion affects him as well for the Credential Management API
3 years, 11 months ago (2017-01-02 08:01:15 UTC) #69
Julia Tuttle
On 2016/12/29 19:31:28, Randy Smith - Not in Mondays wrote: > What are your thoughts ...
3 years, 11 months ago (2017-01-02 14:01:07 UTC) #70
Randy Smith (Not in Mondays)
On 2017/01/02 14:01:07, Julia Tuttle wrote: > On 2016/12/29 19:31:28, Randy Smith - Not in ...
3 years, 11 months ago (2017-01-03 13:03:42 UTC) #71
igrigorik
FWIW, stepping back.. I think it's completely reasonable to rule out authenticated reporting endpoints - ...
3 years, 11 months ago (2017-01-03 19:46:23 UTC) #72
Ryan Sleevi
On 2017/01/03 19:46:23, igrigorik wrote: > FWIW, stepping back.. I think it's completely reasonable to ...
3 years, 11 months ago (2017-01-03 19:48:43 UTC) #73
Ryan Sleevi
On 2017/01/02 14:01:07, Julia Tuttle wrote: > 2. It might leak data from private, proxied ...
3 years, 11 months ago (2017-01-03 19:50:47 UTC) #74
Ryan Sleevi
A whole lot of comments that I think stand (even as we look at the ...
3 years, 11 months ago (2017-01-03 21:28:14 UTC) #75
Julia Tuttle
3 years, 11 months ago (2017-01-25 20:27:46 UTC) #78
https://codereview.chromium.org/2249213002/diff/320001/net/net.gypi
File net/net.gypi (right):

https://codereview.chromium.org/2249213002/diff/320001/net/net.gypi#newcode1241
net/net.gypi:1241: 'reporting/reporting_controls.cc',
On 2017/01/03 21:28:12, Ryan Sleevi wrote:
> From a design perspective, could you explain more why you introduced a
top-level
> directory called //reporting ?
> 
> Given that the Reporting API is a Web Platform feature (e.g. not an intrinsic
> behaviour of an HTTP or networking client, spec'd as part of W3C/WICG), I can
> see a compelling argument that this belongs in //content instead (or possibly
> //third_party/WebKit).

Initially, I was going to put it in a component.

The reason I put it in //net is that other parts of //net (e.g. HPKP, HSTS,
Expect-Staple) would end up depending on it, and the interface for that looked
*really* hairy, and mmenke suggested putting it //net was a viable option.

If you can help me come up with a not-ugly way for it to live elsewhere, I'd be
okay with that. I confess I haven't thoroughly evaluated the "have a stub
interface in //net that's implemented by a component" approach yet.

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
File net/reporting/reporting_controls.cc (right):

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
net/reporting/reporting_controls.cc:52: return kDefaultEnabled;
On 2017/01/03 21:28:12, Ryan Sleevi wrote:
> As mentioned in the header, this all seems like something base::FeatureList is
> meant to embody, and it would be good to know if that was intentionally
avoided.
> 
> This will also hopefully eliminate the need for HistogramEnabledState(), since
> such configs can be represented using the field trial config reporting already
> used.

Obsolete; I'm now using base::Feature.

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
File net/reporting/reporting_controls.h (right):

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
net/reporting/reporting_controls.h:14: // default.
On 2017/01/03 21:28:12, Ryan Sleevi (OOO) wrote:
> 1) //net should never mention layers above it (in comments or code), because
> that's a layering violation. For example, it's impossible to evaluate what
this
> code would do in the case of Chrome for iOS or in the case of Cronet - both of
> which have //net part of them.
> 
> 2) From this header, it's not clear why a simple use of base::Feature wasn't
> used here?

Obsolete; I'm now using base::Feature.

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
File net/reporting/reporting_metrics.cc (right):

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
net/reporting/reporting_metrics.cc:17: DCHECK_NE(HEADER_FATE_MAX, fate);
On 2017/01/03 21:28:13, Ryan Sleevi wrote:
> All of these DCHECKs are arguably unnecessary
> 
> I appreciate you're trying to guard against programmer error, but in C++, any
> possible integer may have been coerced into such an enum, leaving it in an
> undefined state. It would appear from these DCHECKs that you're trying to
> validate that the enumeration value is in range of the histogram, but that's
not
> at all sufficient to do, and I'm not sure the programmer error you're
attempting
> to guard against is reasonable/likely.

Done.

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
net/reporting/reporting_metrics.cc:25: if (ttl > base::TimeDelta()) {
On 2017/01/03 21:28:13, Ryan Sleevi wrote:
> This is subtle and under-documented (in your design or your header) as to why
a
> negative TTL is not measured, even though you anticipated it enough to defend
> against it.

I'm not defending against a negative TTL; I'm differentiating a *zero* TTL
(which means "remove this endpoint") from a positive TTL (which means "set or
update this endpoint").

I've added a comment above the if to clarify.

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
net/reporting/reporting_metrics.cc:50:
UMA_HISTOGRAM_COUNTS_100000("Reporting.DeliveryByteCount", byte_count);
On 2017/01/03 21:28:13, Ryan Sleevi wrote:
> I'm very skeptical of a lot of these metrics, and don't see the design doc
> really showing how they'll be owned or influence the design.
> 
> I appreciate and am sensitive to the fact that unless we measure from the
> get-go, we won't know, but I'd like to push back on each and every one of
these
> measurements to make sure we know precisely why we're going to measure them
and
> what we anticipate using them for, so that we only collect what is needed to
> influence the feature and the user experience.

Alright, let me give it some thought.

The ones I'm particularly interested in are ones related to reports and
deliveries -- are we successfully uploading most reports within a reasonable
amount of time, and not losing too many to network changes and such?

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
File net/reporting/reporting_metrics.h (right):

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
net/reporting/reporting_metrics.h:12: enum EnabledState {
On 2017/01/03 21:28:13, Ryan Sleevi wrote:
> 1) Do all of these need to be in "public" headers? Ideally, no.

They don't need to be visible outside //net, no. What makes a header file
"public"?

> 2) Document - none of these states are self-obvious

Is it good or bad to let histograms.xml be the canonical documentation for the
states?

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
net/reporting/reporting_metrics.h:67: void HistogramEnabledState(EnabledState
state);
On 2017/01/03 21:28:13, Ryan Sleevi wrote:
> naming/design:
> 
> It seems not at all self-obvious when reading code and seeing a call to 
> 
> net::HistogramEnabledState(ENABLED_STATE_ENABLED_DEFAULT)
> 
> is going to do, documentation or not. It seems like much of this may be better
> served being grouped in a logical namespace (net::reporting)?
> 
> In thinking very carefully how //net will be used in the future, does this API
> benefit from splitting (like QUIC to some extent, and like //content
> exclusively) into the notion of "public" and "private" implementation parts?
It
> seems like this bleeds a lot into a namespace without very clear naming.

I think it totally would benefit from that, but I'm unsure how to do it. Is it
just enforced by custom (and presubmit) that stuff outside //content can't
depend on headers outside //content/public?

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
File net/reporting/reporting_report.cc (right):

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
net/reporting/reporting_report.cc:11: ReportingReport::ReportingReport() {}
On 2017/01/03 21:28:13, Ryan Sleevi wrote:
> = default;

Done.

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
File net/reporting/reporting_report.h (right):

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
net/reporting/reporting_report.h:15: struct ReportingReport {
On 2017/01/03 21:28:13, Ryan Sleevi wrote:
> From a design standpoint, this feels more like a class (or will evolve into
one)
> than a struct, per
> https://google.github.io/styleguide/cppguide.html#Structs_vs._Classes

My gut feeling is that it's a struct, but I'm making it a class since it's got a
unique_ptr member and (therefore, and since I don't *need* to copy or assign it)
I'm adding DISALLOW_COPY_OR_ASSIGN.

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
net/reporting/reporting_report.h:18: ~ReportingReport();
On 2017/01/03 21:28:13, Ryan Sleevi wrote:
> Rule of three applies here - in general, if you provide a dtor, you should
> provide copy and assignment.
> 
> It would seem you're not doing so here because you're only concerned about
> squelching warnings about complex ctors/dtors (and the code-size implication
> they have), but the same applies here to copy/assignment.
> 
> Further, the copy/assignment is complex (because of line 22) - so it deserves
> either a DISALLOW_COPY_AND_ASSIGN (which further deflates the "is-a struct"
> argument) or explicit management (which I'm unclear of what the right answer
is)

Done.

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
net/reporting/reporting_report.h:20: std::string ToString() const;
On 2017/01/03 21:28:13, Ryan Sleevi wrote:
> From reading the header: Why does this exist? What does this do? Is it for
> debugging? GTEst? Is it the serializing of the class?

It was for testing, but I'm gonna remove it for now.

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
net/reporting/reporting_report.h:22: std::unique_ptr<base::Value> body;
On 2017/01/03 21:28:13, Ryan Sleevi wrote:
> What is this? Why is it a base::Value versus another structure? Does anything
> guarantee any form of consistency (or non-mutability)?

It's the report body, which is any JSON.

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
net/reporting/reporting_report.h:23: // URL of content that triggered report.
On 2017/01/03 21:28:13, Ryan Sleevi wrote:
> nelines between 22-23

Done.

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
net/reporting/reporting_report.h:27: // separately, so they are separate fields
for now.
On 2017/01/03 21:28:13, Ryan Sleevi wrote:
> Line break between 24-25 and 29-30
> 
> As comments go, I think this leaves more questions than answers. For example,
is
> there a bug filed on this? Why does the spec allow callers to separate them?
> What's an example of when you should or should not? What happens if origin
isn't
> valid at all - what do you do?

There is a bug filed, at https://github.com/WICG/reporting/issues/25. If the
origin isn't valid at all, the report will never get picked up for delivery, and
will expire after an hour or so.

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
net/reporting/reporting_report.h:33: base::TimeTicks timestamp;
On 2017/01/03 21:28:13, Ryan Sleevi wrote:
> naming: "timestamp" is self-describing without adding new information. Should
> this be base::TimeTicks creation_time?

Renamed to "queued".

> Does this require monotonicity? Civil time conversion? How is this used? All
> unclear.

Added a comment to specify how it's used. It's reported to the endpoint as an
age, and reports aren't persisted across sessions, so I *think* TimeTicks is
preferable to Time.

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
net/reporting/reporting_report.h:35: int attempts;
On 2017/01/03 21:28:13, Ryan Sleevi wrote:
> size_t for counts -
>
https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md...

Done.

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
net/reporting/reporting_report.h:37: bool pending;
On 2017/01/03 21:28:13, Ryan Sleevi wrote:
> This feels like an interface bleed - why should the report keep track of
whether
> it itself is pending? This seems to leak in details about how the report is
> used, rather than what a report is.
> 
> The same applies to |attempts|. Both of these seem to represent a state
about-a
> report, not state that is-a report.

Obsolete; I'm making Report an inner, private class of ReportingService, so
callers don't have to deal with it at all.

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
File net/reporting/reporting_service.h (right):

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
net/reporting/reporting_service.h:26: class NET_EXPORT ReportingService {
On 2017/01/03 21:28:13, Ryan Sleevi wrote:
> High level Design remarks:
> 1) This feels like a lot of the implementation details have bled into the
public
> header - meaning anytime the implementatino changes, that's sort of spread
> through to every consumer.
> 
> Concrete Suggestions:
> a) Forward declare whenever possible
> b) Carefully evaluate whether you need a private class member function versus
a
> function within an unnamed namespace
> c) Carefully evaluate whether this class is doing "too much"
> 
> 2) The testing seems to be litering *ForTesting functions in to the public
> interface. While a presubmit helps minimize that, it feels like it might
result
> in a more carefully balanced operation if you make use of text fixtures,
rather
> than public interface.
>   a) Similarly, if you're needing that much of your "implementation detail" to
> be provided via ForTesting() methods, it may be a sign that your layering or
> design is trying to do too much, and would benefit from more decoupling.

My original design had a separate "ReportingCache" class that just did the data
storage, so it was easier for tests to check the effect of parsing headers or
queueing reports. Maybe I should go back to that design.

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
net/reporting/reporting_service.h:50: static Policy GetDefault();
On 2017/01/03 21:28:13, Ryan Sleevi wrote:
> DESIGN: Why is an explicit GetDefault required? Why can't default constructing
> the object return a sane default?

Done.

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
net/reporting/reporting_service.h:56: void
set_uploader(std::unique_ptr<ReportingUploader> uploader);
On 2017/01/03 21:28:13, Ryan Sleevi wrote:
> This seems to have more subtlety than just "set_uploader"

Not really; it's just a separate setter instead of a constructor parameter so it
can be cleared early in profile destruction to avoid circular dependencies like
the mess we had with Domain Reliability.

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
net/reporting/reporting_service.h:65: void
set_clock_for_testing(std::unique_ptr<base::TickClock> clock);
On 2017/01/03 21:28:13, Ryan Sleevi wrote:
> SetClockForTesting

Why? It is actually just a plain setter under the hood.

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
net/reporting/reporting_service.h:73: struct Client {
On 2017/01/03 21:28:13, Ryan Sleevi wrote:
> Why can't you forward declare this?

Done.

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
net/reporting/reporting_service.h:92: struct Endpoint {
On 2017/01/03 21:28:13, Ryan Sleevi wrote:
> Why can't you forward declare this?

Done.

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
net/reporting/reporting_service.h:114: struct EndpointTuple {
On 2017/01/03 21:28:13, Ryan Sleevi wrote:
> Why can't you forward declare this?

Done.

https://codereview.chromium.org/2249213002/diff/320001/net/reporting/reportin...
net/reporting/reporting_service.h:130: struct Delivery {
On 2017/01/03 21:28:13, Ryan Sleevi wrote:
> Why can't you forward declare this?

Done.

Powered by Google App Engine
This is Rietveld 408576698