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

Issue 10078017: Added asynchronous notification of readiness to the StatisticsProvider, and (Closed)

Created:
8 years, 8 months ago by Joao da Silva
Modified:
8 years, 2 months ago
CC:
chromium-reviews, MAD, nkostylev+watch_chromium.org, stevenjb+watch_chromium.org, Ilya Sherman, davemoore+watch_chromium.org, jar (doing other things), petkov
Visibility:
Public.

Description

Added asynchronous notification of readiness to the StatisticsProvider, and updated the MetricsService to wait for this. BUG=chromium-os:29642 TEST=No more empty hardware_class fields in UMA reports

Patch Set 1 #

Total comments: 9

Patch Set 2 : Fixed non-chromeos builds #

Patch Set 3 : Addressed comments #

Total comments: 2

Patch Set 4 : Load hardware_class when available without delaying init of MetricsService #

Total comments: 6

Patch Set 5 : Addressed comments, rebased #

Total comments: 19

Patch Set 6 : Don't use base::Unretained. Rebased. #

Total comments: 22

Patch Set 7 : Timeout while waiting for the hardware_class; sample UMA stats #

Total comments: 6

Patch Set 8 : Addressed Jim's comments #

Patch Set 9 : Fixed clang build #

Patch Set 10 : Fixed clang build, reupload #

Patch Set 11 : Upload again... #

Patch Set 12 : . #

Total comments: 8

Patch Set 13 : Addressed Ilya's comments #

Total comments: 18
Unified diffs Side-by-side diffs Delta from patch set Stats (+190 lines, -53 lines) Patch
M chrome/browser/chromeos/system/mock_statistics_provider.h View 1 2 3 4 5 6 7 1 chunk +3 lines, -0 lines 0 comments Download
M chrome/browser/chromeos/system/statistics_provider.h View 1 2 3 4 5 6 7 8 1 chunk +25 lines, -3 lines 0 comments Download
M chrome/browser/chromeos/system/statistics_provider.cc View 1 2 3 4 5 6 7 8 9 chunks +68 lines, -14 lines 8 comments Download
M chrome/browser/metrics/metrics_service.h View 1 2 3 4 5 6 7 8 9 10 11 12 5 chunks +25 lines, -7 lines 0 comments Download
M chrome/browser/metrics/metrics_service.cc View 1 2 3 4 5 6 7 8 9 10 11 12 7 chunks +69 lines, -29 lines 10 comments Download

Messages

Total messages: 38 (0 generated)
Joao da Silva
We're seeing a lot of UMA reports with hardware_class missing, and we now suspect it's ...
8 years, 8 months ago (2012-04-19 19:08:47 UTC) #1
Joao da Silva
(cc'ing @petkov, who helped investigate this issue)
8 years, 8 months ago (2012-04-19 19:09:20 UTC) #2
Ilya Sherman
http://codereview.chromium.org/10078017/diff/1/chrome/browser/metrics/metrics_service.cc File chrome/browser/metrics/metrics_service.cc (right): http://codereview.chromium.org/10078017/diff/1/chrome/browser/metrics/metrics_service.cc#newcode765 chrome/browser/metrics/metrics_service.cc:765: self)); Does the WhenReady() call have any sort of ...
8 years, 8 months ago (2012-04-19 19:35:32 UTC) #3
Joao da Silva
Thanks for jumping in Ilya! Please see replies inline. http://codereview.chromium.org/10078017/diff/1/chrome/browser/metrics/metrics_service.cc File chrome/browser/metrics/metrics_service.cc (right): http://codereview.chromium.org/10078017/diff/1/chrome/browser/metrics/metrics_service.cc#newcode765 chrome/browser/metrics/metrics_service.cc:765: ...
8 years, 8 months ago (2012-04-19 19:54:33 UTC) #4
Ilya Sherman
http://codereview.chromium.org/10078017/diff/1/chrome/browser/metrics/metrics_service.cc File chrome/browser/metrics/metrics_service.cc (right): http://codereview.chromium.org/10078017/diff/1/chrome/browser/metrics/metrics_service.cc#newcode765 chrome/browser/metrics/metrics_service.cc:765: self)); On 2012/04/19 19:54:33, Joao da Silva wrote: > ...
8 years, 8 months ago (2012-04-19 20:16:53 UTC) #5
Ilya Sherman
8 years, 8 months ago (2012-04-19 20:16:54 UTC) #6
Ilya Sherman
8 years, 8 months ago (2012-04-19 20:16:54 UTC) #7
jar (doing other things)
http://codereview.chromium.org/10078017/diff/13001/chrome/browser/metrics/metrics_service.h File chrome/browser/metrics/metrics_service.h (right): http://codereview.chromium.org/10078017/diff/13001/chrome/browser/metrics/metrics_service.h#newcode164 chrome/browser/metrics/metrics_service.h:164: void OnStatisticsProviderReady(); Rather than conditionally defining a method... and ...
8 years, 8 months ago (2012-04-20 00:37:39 UTC) #8
Joao da Silva
Thanks for the comments! Please have another look. http://codereview.chromium.org/10078017/diff/1/chrome/browser/metrics/metrics_service.cc File chrome/browser/metrics/metrics_service.cc (right): http://codereview.chromium.org/10078017/diff/1/chrome/browser/metrics/metrics_service.cc#newcode765 chrome/browser/metrics/metrics_service.cc:765: self)); ...
8 years, 8 months ago (2012-04-20 11:53:35 UTC) #9
Ilya Sherman
LGTM with a few small nits. Thanks :) http://codereview.chromium.org/10078017/diff/20001/chrome/browser/chromeos/system/statistics_provider.cc File chrome/browser/chromeos/system/statistics_provider.cc (right): http://codereview.chromium.org/10078017/diff/20001/chrome/browser/chromeos/system/statistics_provider.cc#newcode184 chrome/browser/chromeos/system/statistics_provider.cc:184: VLOG(1) ...
8 years, 8 months ago (2012-04-20 21:18:37 UTC) #10
Joao da Silva
@satorux: friendly ping :-) http://codereview.chromium.org/10078017/diff/20001/chrome/browser/chromeos/system/statistics_provider.cc File chrome/browser/chromeos/system/statistics_provider.cc (right): http://codereview.chromium.org/10078017/diff/20001/chrome/browser/chromeos/system/statistics_provider.cc#newcode184 chrome/browser/chromeos/system/statistics_provider.cc:184: VLOG(1) << "Finished loading statistics"; ...
8 years, 8 months ago (2012-04-23 09:36:49 UTC) #11
petkov
http://codereview.chromium.org/10078017/diff/29001/chrome/browser/metrics/metrics_service.cc File chrome/browser/metrics/metrics_service.cc (right): http://codereview.chromium.org/10078017/diff/29001/chrome/browser/metrics/metrics_service.cc#newcode838 chrome/browser/metrics/metrics_service.cc:838: chromeos::system::StatisticsProvider::GetInstance()->WhenReady( So, now we don't wait for the hardware ...
8 years, 8 months ago (2012-04-23 10:32:54 UTC) #12
Joao da Silva
http://codereview.chromium.org/10078017/diff/29001/chrome/browser/metrics/metrics_service.cc File chrome/browser/metrics/metrics_service.cc (right): http://codereview.chromium.org/10078017/diff/29001/chrome/browser/metrics/metrics_service.cc#newcode838 chrome/browser/metrics/metrics_service.cc:838: chromeos::system::StatisticsProvider::GetInstance()->WhenReady( On 2012/04/23 10:32:55, petkov wrote: > So, now ...
8 years, 8 months ago (2012-04-23 11:15:56 UTC) #13
satorux1
http://codereview.chromium.org/10078017/diff/29001/chrome/browser/chromeos/system/statistics_provider.cc File chrome/browser/chromeos/system/statistics_provider.cc (right): http://codereview.chromium.org/10078017/diff/29001/chrome/browser/chromeos/system/statistics_provider.cc#newcode191 chrome/browser/chromeos/system/statistics_provider.cc:191: base::Unretained(this))); base::Unretained should generally be avoided. Can we ensure ...
8 years, 8 months ago (2012-04-23 16:45:48 UTC) #14
satorux1
http://codereview.chromium.org/10078017/diff/29001/chrome/browser/chromeos/system/statistics_provider.cc File chrome/browser/chromeos/system/statistics_provider.cc (right): http://codereview.chromium.org/10078017/diff/29001/chrome/browser/chromeos/system/statistics_provider.cc#newcode116 chrome/browser/chromeos/system/statistics_provider.cc:116: on_statistics_loaded_.TimedWait(base::TimeDelta::FromSeconds(kTimeoutSecs)); Ideally, this waitable event stuff should be gone. ...
8 years, 8 months ago (2012-04-23 17:02:26 UTC) #15
Joao da Silva
Satoru: thanks for the comments! Please see inline. Ilya: can you comment on the suggestion ...
8 years, 8 months ago (2012-04-23 17:24:42 UTC) #16
satorux1
LGTM, with a request for adding some comment: http://codereview.chromium.org/10078017/diff/29001/chrome/browser/chromeos/system/statistics_provider.cc File chrome/browser/chromeos/system/statistics_provider.cc (right): http://codereview.chromium.org/10078017/diff/29001/chrome/browser/chromeos/system/statistics_provider.cc#newcode127 chrome/browser/chromeos/system/statistics_provider.cc:127: void ...
8 years, 8 months ago (2012-04-23 17:51:01 UTC) #17
Ilya Sherman
http://codereview.chromium.org/10078017/diff/29001/chrome/browser/metrics/metrics_service.cc File chrome/browser/metrics/metrics_service.cc (right): http://codereview.chromium.org/10078017/diff/29001/chrome/browser/metrics/metrics_service.cc#newcode838 chrome/browser/metrics/metrics_service.cc:838: chromeos::system::StatisticsProvider::GetInstance()->WhenReady( On 2012/04/23 11:15:56, Joao da Silva wrote: > ...
8 years, 8 months ago (2012-04-23 22:44:13 UTC) #18
petkov
http://codereview.chromium.org/10078017/diff/29001/chrome/browser/metrics/metrics_service.cc File chrome/browser/metrics/metrics_service.cc (right): http://codereview.chromium.org/10078017/diff/29001/chrome/browser/metrics/metrics_service.cc#newcode838 chrome/browser/metrics/metrics_service.cc:838: chromeos::system::StatisticsProvider::GetInstance()->WhenReady( I do queries on UMA data extremely rarely ...
8 years, 8 months ago (2012-04-24 07:42:18 UTC) #19
petkov
http://codereview.chromium.org/10078017/diff/29001/chrome/browser/metrics/metrics_service.cc File chrome/browser/metrics/metrics_service.cc (right): http://codereview.chromium.org/10078017/diff/29001/chrome/browser/metrics/metrics_service.cc#newcode838 chrome/browser/metrics/metrics_service.cc:838: chromeos::system::StatisticsProvider::GetInstance()->WhenReady( On 2012/04/24 07:42:18, petkov wrote: > I do ...
8 years, 8 months ago (2012-04-24 07:49:36 UTC) #20
Joao da Silva
@satorux: addressed your comments, thanks for the review! @isherman, @petkov: let's discuss offline what's the ...
8 years, 8 months ago (2012-04-24 09:47:06 UTC) #21
jar (doing other things)
Do we have a histogram showing how long it takes to get this interface ready ...
8 years, 8 months ago (2012-04-24 16:09:53 UTC) #22
jar (doing other things)
http://codereview.chromium.org/10078017/diff/34001/chrome/browser/chromeos/system/statistics_provider.cc File chrome/browser/chromeos/system/statistics_provider.cc (right): http://codereview.chromium.org/10078017/diff/34001/chrome/browser/chromeos/system/statistics_provider.cc#newcode108 chrome/browser/chromeos/system/statistics_provider.cc:108: const std::string& name, std::string* result) { nit: arguments should ...
8 years, 8 months ago (2012-04-24 18:37:40 UTC) #23
Joao da Silva
Thanks all for the comments here and via email. Please have another look at this ...
8 years, 8 months ago (2012-04-27 09:47:47 UTC) #24
jar (doing other things)
http://codereview.chromium.org/10078017/diff/34001/chrome/browser/chromeos/system/statistics_provider.cc File chrome/browser/chromeos/system/statistics_provider.cc (right): http://codereview.chromium.org/10078017/diff/34001/chrome/browser/chromeos/system/statistics_provider.cc#newcode137 chrome/browser/chromeos/system/statistics_provider.cc:137: return false; I think what you're saying is that ...
8 years, 8 months ago (2012-04-27 18:00:38 UTC) #25
Ilya Sherman
http://codereview.chromium.org/10078017/diff/48001/chrome/browser/metrics/metrics_service.cc File chrome/browser/metrics/metrics_service.cc (right): http://codereview.chromium.org/10078017/diff/48001/chrome/browser/metrics/metrics_service.cc#newcode815 chrome/browser/metrics/metrics_service.cc:815: void MetricsService::OnStatisticsProviderTimeout() { nit: Perhaps log a histogram/event for ...
8 years, 7 months ago (2012-04-30 07:36:40 UTC) #26
Ilya Sherman
Joao, what's the status of this CL?
8 years, 7 months ago (2012-05-07 20:15:22 UTC) #27
Joao da Silva
On Mon, May 7, 2012 at 10:15 PM, <isherman@chromium.org> wrote: > Joao, what's the status ...
8 years, 7 months ago (2012-05-07 22:12:51 UTC) #28
Joao da Silva
A CL back from the dead! :-) @isherman, @jar, @petkov: Please have another look I've ...
8 years, 7 months ago (2012-05-15 13:52:46 UTC) #29
Ilya Sherman
metrics/ changes LGTM with nits https://chromiumcodereview.appspot.com/10078017/diff/70003/chrome/browser/metrics/metrics_service.cc File chrome/browser/metrics/metrics_service.cc (right): https://chromiumcodereview.appspot.com/10078017/diff/70003/chrome/browser/metrics/metrics_service.cc#newcode790 chrome/browser/metrics/metrics_service.cc:790: #endif nit: Please add ...
8 years, 7 months ago (2012-05-16 01:01:17 UTC) #30
Joao da Silva
@jar, @petkov: friendly ping :-) http://codereview.chromium.org/10078017/diff/70003/chrome/browser/metrics/metrics_service.cc File chrome/browser/metrics/metrics_service.cc (right): http://codereview.chromium.org/10078017/diff/70003/chrome/browser/metrics/metrics_service.cc#newcode790 chrome/browser/metrics/metrics_service.cc:790: #endif On 2012/05/16 01:01:17, ...
8 years, 7 months ago (2012-05-16 12:53:34 UTC) #31
petkov
LGTM AFAICT. It might be nice to reduce the CHROMEOS ifdefs but I assume you've ...
8 years, 7 months ago (2012-05-16 15:05:05 UTC) #32
Joao da Silva
Jim, what do you think of the current patch? (friendly ping! :-) )
8 years, 7 months ago (2012-05-21 16:58:55 UTC) #33
jar (doing other things)
I'm missing, and/or confused by, some of the logic. Thanks in advance for explaining. http://codereview.chromium.org/10078017/diff/70005/chrome/browser/chromeos/system/statistics_provider.cc ...
8 years, 7 months ago (2012-05-21 18:10:02 UTC) #34
Joao da Silva
Thanks for your comments Jim. Please see inline; I'd like your comments on the comments ...
8 years, 7 months ago (2012-05-22 14:55:25 UTC) #35
jar (doing other things)
http://codereview.chromium.org/10078017/diff/70005/chrome/browser/metrics/metrics_service.cc File chrome/browser/metrics/metrics_service.cc (right): http://codereview.chromium.org/10078017/diff/70005/chrome/browser/metrics/metrics_service.cc#newcode800 chrome/browser/metrics/metrics_service.cc:800: if (!on_ready_callback_.IsCancelled()) Note: You could implement the "was_called" bool ...
8 years, 7 months ago (2012-05-22 17:07:58 UTC) #36
Joao da Silva
Thanks for the comments Jim. Just one last issue before I make another try at ...
8 years, 7 months ago (2012-05-22 19:10:06 UTC) #37
jar (doing other things)
8 years, 7 months ago (2012-05-22 20:09:30 UTC) #38
http://codereview.chromium.org/10078017/diff/70005/chrome/browser/chromeos/sy...
File chrome/browser/chromeos/system/statistics_provider.cc (right):

http://codereview.chromium.org/10078017/diff/70005/chrome/browser/chromeos/sy...
chrome/browser/chromeos/system/statistics_provider.cc:149:
observer_list_.AddObserver(observer);
The "callback" version was re-inventing the wheel... and probably re-inventing
all the evolutionary bugs.  I think the current direction is better.

To maintain symmetry, I'd suggest you remove the observer after you notify it,
so that the end result is the same for both immediate notification, or async
notification.

You are right, you still have to clean up, just in case.


On 2012/05/22 14:55:25, Joao da Silva wrote:
> On 2012/05/21 18:10:02, jar wrote:
> > I see an observer optionally being added... but I don't see the
corresponding
> > call to remove the observer, presumably when the callback is made.  Note
that
> if
> > you make the callback on line 147, you effectively remove (actually, avoid
> > adding) the observer.
> 
> Right, this is a bit confusing. Removing an observer that wasn't added is OK,
> therefore this code. But observers that go away before the signal is ready
> should be able to unregister themselves.
> 
> This is a one-shot event, and adding an observer after the signal is ready
won't
> do anything, since it won't be notified again. I think the callback version
was
> clearer for this; "Observers" could just invalidate the callback (using
> CancellableCallback or invalidating a WeakPtr), and wouldn't have to worry
about
> unregistering.
> 
> I see two options now:
> 
> (1) automatically remove observers right after notifying them.
RemoveObserver()
> is still required to remove observers that go away before the statistics are
> ready.
> 
> (2) go back to the callback version :-)
> 
> I prefer (2); what's your opinion?

http://codereview.chromium.org/10078017/diff/70005/chrome/browser/chromeos/sy...
chrome/browser/chromeos/system/statistics_provider.cc:246:
FOR_EACH_OBSERVER(Observer, observer_list_, OnMachineStatisticsReady());
On 2012/05/21 18:10:02, jar wrote:
> This, for instance, would be a great place to remove the observers (after
we've
> done the callbacks).

Note that it would get messy if you tried to use async registration from other
threads while you were iterating here.  Again, single thread registration and
notification seems like a much clearer picture.

Powered by Google App Engine
This is Rietveld 408576698