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

Issue 5527004: Access singletons with a new GetInstance() method instead of Singleton<T>. (Closed)

Created:
10 years ago by Satish
Modified:
9 years, 7 months ago
CC:
chromium-reviews, cbentzel+watch_chromium.org, ben+cc_chromium.org, Erik does not do reviews, brettw-cc_chromium.org, jam, Aaron Boodman, pam+watch_chromium.org, Paweł Hajdan Jr., darin-cc_chromium.org, jshin+watch_chromium.org
Visibility:
Public.

Description

This CL add a GetInstance() method to singleton classes instead of relying on the callers to use Singleton<T>. In some cases I have used the LazyInstance<T> pattern as that was simpler. This is a small step towards making all singleton classes use the Singleton<T> pattern within their code and not expect the callers to know about it. I have selected all files under src/app and src/base which use Singleton<T> in this CL. Once this CL goes in I'll work on the rest of the files. BUG=65298 TEST=all existing tests should continue to pass. Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=68300

Patch Set 1 : . #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+206 lines, -134 lines) Patch
M app/active_window_watcher_x.h View 1 chunk +1 line, -0 lines 2 comments Download
M app/active_window_watcher_x.cc View 1 chunk +7 lines, -2 lines 0 comments Download
M app/surface/io_surface_support_mac.cc View 1 chunk +1 line, -3 lines 0 comments Download
M base/crypto/cssm_init.cc View 4 chunks +16 lines, -6 lines 0 comments Download
M base/debug/trace_event.h View 4 chunks +5 lines, -3 lines 0 comments Download
M base/debug/trace_event.cc View 2 chunks +8 lines, -6 lines 0 comments Download
M base/debug/trace_event_win.h View 1 chunk +1 line, -1 line 0 comments Download
M base/debug/trace_event_win.cc View 2 chunks +3 lines, -3 lines 0 comments Download
M base/debug/trace_event_win_unittest.cc View 2 chunks +2 lines, -2 lines 0 comments Download
M base/i18n/file_util_icu.cc View 6 chunks +27 lines, -19 lines 0 comments Download
M base/logging_win.h View 3 chunks +5 lines, -1 line 2 comments Download
M base/logging_win.cc View 5 chunks +8 lines, -12 lines 0 comments Download
M base/mime_util_xdg.cc View 13 chunks +15 lines, -12 lines 0 comments Download
M base/string_util.cc View 2 chunks +7 lines, -3 lines 0 comments Download
M base/time_win.cc View 4 chunks +18 lines, -14 lines 0 comments Download
M chrome/browser/printing/print_dialog_cloud_uitest.cc View 11 chunks +29 lines, -17 lines 0 comments Download
M chrome/common/extensions/extension_message_bundle.h View 1 chunk +0 lines, -9 lines 0 comments Download
M chrome/common/extensions/extension_message_bundle.cc View 2 chunks +16 lines, -4 lines 0 comments Download
M chrome/renderer/extensions/event_bindings.cc View 2 chunks +5 lines, -2 lines 0 comments Download
M chrome/renderer/extensions/extension_process_bindings.cc View 2 chunks +8 lines, -6 lines 0 comments Download
M gfx/window_impl.cc View 2 chunks +5 lines, -1 line 0 comments Download
M ipc/ipc_channel_posix.cc View 5 chunks +12 lines, -6 lines 0 comments Download
M net/base/net_util.cc View 3 chunks +7 lines, -2 lines 0 comments Download

Messages

Total messages: 11 (0 generated)
Satish
10 years ago (2010-12-03 20:04:54 UTC) #1
M-A Ruel
lgtm with nits http://codereview.chromium.org/5527004/diff/12001/app/active_window_watcher_x.h File app/active_window_watcher_x.h (right): http://codereview.chromium.org/5527004/diff/12001/app/active_window_watcher_x.h#newcode31 app/active_window_watcher_x.h:31: static ActiveWindowWatcherX* GetInstance(); I don't think ...
10 years ago (2010-12-03 21:06:06 UTC) #2
darin (slow to review)
Can we do anything clever to prevent multiple instantiations of Singleton<T> for the same value ...
10 years ago (2010-12-03 21:15:38 UTC) #3
M-A Ruel
On 2010/12/03 21:15:38, darin wrote: > Can we do anything clever to prevent multiple instantiations ...
10 years ago (2010-12-03 21:27:39 UTC) #4
darin (slow to review)
On Fri, Dec 3, 2010 at 1:27 PM, <maruel@chromium.org> wrote: > On 2010/12/03 21:15:38, darin ...
10 years ago (2010-12-03 22:26:16 UTC) #5
Satish
I was planning to make all members of Singleton<T> private, and mark T as a ...
10 years ago (2010-12-03 23:44:48 UTC) #6
darin (slow to review)
Yes... class Foo { public: inline Foo* GetInstance() { return Singleton<Foo>::get(); } }; -Darin On ...
10 years ago (2010-12-04 00:39:01 UTC) #7
darin (slow to review)
But I think your idea is very good, and maybe my example is not compelling ...
10 years ago (2010-12-04 00:39:46 UTC) #8
Satish
Yes using the Singleton<T> inline in the header file is an issue I considered. Would ...
10 years ago (2010-12-04 12:12:31 UTC) #9
darin (slow to review)
SGTM! On Sat, Dec 4, 2010 at 4:12 AM, <satish@chromium.org> wrote: > Yes using the ...
10 years ago (2010-12-04 21:05:27 UTC) #10
Satish
10 years ago (2010-12-04 23:00:40 UTC) #11
http://codereview.chromium.org/5527004/diff/12001/app/active_window_watcher_x.h
File app/active_window_watcher_x.h (right):

http://codereview.chromium.org/5527004/diff/12001/app/active_window_watcher_x...
app/active_window_watcher_x.h:31: static ActiveWindowWatcherX* GetInstance();
On 2010/12/03 21:06:07, Marc-Antoine Ruel wrote:
> I don't think this class is necessary.

Removed

http://codereview.chromium.org/5527004/diff/12001/base/logging_win.h
File base/logging_win.h (right):

http://codereview.chromium.org/5527004/diff/12001/base/logging_win.h#newcode13
base/logging_win.h:13: #include "base/singleton.h"
On 2010/12/03 21:06:07, Marc-Antoine Ruel wrote:
> I think you could forward declare the trait instead.

Done.

Powered by Google App Engine
This is Rietveld 408576698