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

Issue 431008: Make SystemMonitor not a Singleton and move it out of base (Closed)

Created:
11 years, 1 month ago by Paweł Hajdan Jr.
Modified:
9 years, 7 months ago
CC:
chromium-reviews_googlegroups.com, brettw+cc_chromium.org, ben+cc_chromium.org, John Grabowski, jam, pam+watch_chromium.org, kuchhal, darin (slow to review), native-client-reviews_googlegroups.com
Visibility:
Public.

Description

Make SystemMonitor not a Singleton and move it out of base SystemMonitor makes an assumption that through its lifetime a MessageLoop exists and stays the same. It is difficult and error-prone to satisfy that when it is a Singleton. It has caused problems in the past. Additionally, extract HighResoltionTimerManager out of time_win.cc, eliminating yet another Singleton. TEST=none BUG=none Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=33214

Patch Set 1 #

Total comments: 3

Patch Set 2 : '' #

Patch Set 3 : made it cross-platform #

Patch Set 4 : fixes #

Patch Set 5 : fix ChromeFrame build #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+198 lines, -186 lines) Patch
M app/app.gyp View 3 chunks +8 lines, -0 lines 0 comments Download
A app/hi_res_timer_manager.h View 1 chunk +29 lines, -0 lines 0 comments Download
A app/hi_res_timer_manager_posix.cc View 1 chunk +19 lines, -0 lines 0 comments Download
A app/hi_res_timer_manager_win.cc View 1 chunk +31 lines, -0 lines 0 comments Download
A + app/system_monitor.h View 4 chunks +9 lines, -20 lines 0 comments Download
A + app/system_monitor.cc View 3 chunks +26 lines, -26 lines 0 comments Download
A + app/system_monitor_posix.cc View 1 chunk +2 lines, -6 lines 0 comments Download
A + app/system_monitor_unittest.cc View 2 chunks +12 lines, -11 lines 0 comments Download
A + app/system_monitor_win.cc View 2 chunks +2 lines, -8 lines 0 comments Download
M base/base.gyp View 1 2 3 2 chunks +0 lines, -5 lines 0 comments Download
M base/test/test_suite.h View 1 2 1 chunk +4 lines, -4 lines 0 comments Download
M base/time.h View 1 2 1 chunk +3 lines, -6 lines 0 comments Download
M base/time_win.cc View 1 2 3 chunks +12 lines, -67 lines 0 comments Download
M chrome/browser/browser_main.cc View 1 2 3 3 chunks +4 lines, -8 lines 0 comments Download
M chrome/browser/profile_manager.h View 1 2 3 2 chunks +2 lines, -2 lines 0 comments Download
M chrome/browser/profile_manager.cc View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M chrome/browser/session_history_uitest.cc View 1 2 1 chunk +3 lines, -2 lines 1 comment Download
M chrome/browser/tabs/tab_strip_model_unittest.cc View 1 2 3 2 chunks +5 lines, -0 lines 0 comments Download
M chrome/chrome.gyp View 1 2 3 4 1 chunk +2 lines, -0 lines 0 comments Download
M chrome/nacl/nacl_main.cc View 1 2 3 2 chunks +4 lines, -3 lines 0 comments Download
M chrome/plugin/plugin_main.cc View 1 2 3 2 chunks +4 lines, -3 lines 0 comments Download
MM chrome/profile_import/profile_import_main.cc View 1 2 1 chunk +0 lines, -1 line 0 comments Download
M chrome/renderer/renderer_main.cc View 1 2 3 3 chunks +4 lines, -3 lines 0 comments Download
M chrome/utility/utility_main.cc View 1 2 3 2 chunks +4 lines, -3 lines 0 comments Download
M chrome/worker/worker_main.cc View 1 2 3 2 chunks +4 lines, -3 lines 0 comments Download
M chrome_frame/test/net/fake_external_tab.cc View 1 chunk +1 line, -1 line 0 comments Download
M views/widget/widget_win.h View 1 2 1 chunk +0 lines, -1 line 0 comments Download
M views/widget/widget_win.cc View 1 2 3 2 chunks +2 lines, -1 line 0 comments Download

Messages

Total messages: 10 (0 generated)
Paweł Hajdan Jr.
This is not yet tested on other systems, etc. Just to show my idea how ...
11 years, 1 month ago (2009-11-23 14:36:24 UTC) #1
Mike Belshe
Overall, I would have left the SystemMonitor in base. I think it is potentially useful ...
11 years, 1 month ago (2009-11-23 16:43:45 UTC) #2
Paweł Hajdan Jr.
On 2009/11/23 16:43:45, Mike Belshe wrote: > Overall, I would have left the SystemMonitor in ...
11 years, 1 month ago (2009-11-23 17:40:49 UTC) #3
Evan Martin
Re base/ vs chrome/: one metric for this is that base is starting to get ...
11 years, 1 month ago (2009-11-23 17:56:47 UTC) #4
Peter Kasting
I don't think I'm qualified to review this.
11 years, 1 month ago (2009-11-23 18:22:16 UTC) #5
darin (slow to review)
To avoid clutter in base/, we have generally used the rule that things should only ...
11 years, 1 month ago (2009-11-24 05:26:54 UTC) #6
Paweł Hajdan Jr.
Should be ready for the final review.
11 years, 1 month ago (2009-11-24 18:30:35 UTC) #7
Paweł Hajdan Jr.
ping!
11 years ago (2009-11-26 09:44:21 UTC) #8
Mike Belshe
lgtm. Maybe we should add a unit test. Also - what happens if someone manually ...
11 years ago (2009-11-26 17:03:12 UTC) #9
Paweł Hajdan Jr.
11 years ago (2009-11-26 20:34:17 UTC) #10
On 2009/11/26 17:03:12, Mike Belshe wrote:
> Also - what happens if someone manually instantiates a system monitor observer
> before starting the system monitor?

NULL pointer dereference.
> I hope it fails nicely.  I suspect it would
> be easier to make this mistake now? 

Actually it's neither harder nor easier. It just fails in a more predictable
way. Previously you could attempt to use it without a MessageLoop, or destroy
the loop while SM was still running. That was failing in a very mysterious way.
NULL pointer dereference on SystemMonitor::Get is quite obvious.

>  It would also be easier to just forget to instantiate these.  I wonder if the
> time could assert that a HiResTimerManager is running somehow?

I don't see a good way to test that other than some forms of global data.

> This would at least catch the case where we accidentally forgot to run one. 
The singleton
> code didn't have this problem because encapsulation was better.

The same is true for most of the initialization code, although it's probably
harder to spot that we run the lower-resolution timer. Anyway, IMHO being more
careful when reviewing changes to process startup code (which is copy-pasted
anyway, and copy-pasting on current code will yield correct results) is better
than really nasty debugging problems.

> http://codereview.chromium.org/431008/diff/1068/88
> File chrome/browser/session_history_uitest.cc (right):
> 
> http://codereview.chromium.org/431008/diff/1068/88#newcode495
> chrome/browser/session_history_uitest.cc:495:
> ASSERT_TRUE(tab_->NavigateToURLBlockUntilNavigationsComplete(
> Is this an accidental file inclusion to this CL?  It doesn't seem related to
> SystemMonitor.

Good catch. Removed and committed.

Powered by Google App Engine
This is Rietveld 408576698