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

Issue 3007037: Cleanup our Registry API. (Closed)

Created:
10 years, 4 months ago by tfarina
Modified:
9 years, 7 months ago
Reviewers:
M-A Ruel
CC:
chromium-reviews, brettw-cc_chromium.org, kuchhal, ben+cc_chromium.org, Paweł Hajdan Jr.
Base URL:
git://git.chromium.org/chromium.git
Visibility:
Public.

Description

Cleanup our Registry API. - Use wchar_t instead of TCHAR. - Use DCHECK instead of assert. - Remove this keyword (we don't use it on chromium). - Add DISALLOW_COPY_AND_ASSIGN to the classes. - Make it more compliant with chromium code style. - Remove ununsed methods. - Use arraysize macro for array size calculation instead of doing it manually. BUG=44644 TEST=trybots TODO: Write unittests for this API. TODO: Remove all the default arguments from the methods in this API. They aren't allowed by our style guide. Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=55375

Patch Set 1 #

Patch Set 2 : fix win bot #

Patch Set 3 : fix win #

Patch Set 4 : fix win3 #

Total comments: 10

Patch Set 5 : wchar_t #

Patch Set 6 : more fixes #

Patch Set 7 : fix win bot #

Patch Set 8 : fix common #

Total comments: 16

Patch Set 9 : review #

Patch Set 10 : fix include issue #

Patch Set 11 : more fixes, include shlwapi #

Total comments: 3

Patch Set 12 : fix nit #

Unified diffs Side-by-side diffs Delta from patch set Stats (+170 lines, -226 lines) Patch
M base/registry.h View 1 2 3 4 5 6 7 8 9 3 chunks +72 lines, -80 lines 0 comments Download
M base/registry.cc View 1 2 3 4 5 6 7 8 9 10 11 15 chunks +88 lines, -138 lines 0 comments Download
M chrome/browser/importer/firefox_importer_utils_win.cc View 4 5 6 7 8 2 chunks +2 lines, -2 lines 0 comments Download
M chrome/common/chrome_plugin_lib.cc View 1 chunk +4 lines, -4 lines 0 comments Download
chrome/installer/util/google_update_settings_unittest.cc View 2 chunks +4 lines, -2 lines 0 comments Download

Messages

Total messages: 8 (0 generated)
tfarina
10 years, 4 months ago (2010-08-06 02:19:50 UTC) #1
M-A Ruel
Thanks, this file is by far the ugliest in our code base. I'd like to ...
10 years, 4 months ago (2010-08-06 14:12:48 UTC) #2
tfarina
Ready for another look. http://codereview.chromium.org/3007037/diff/5002/7002 File base/registry.h (right): http://codereview.chromium.org/3007037/diff/5002/7002#newcode10 base/registry.h:10: #include <tchar.h> On 2010/08/06 14:12:48, ...
10 years, 4 months ago (2010-08-07 03:47:44 UTC) #3
M-A Ruel
http://codereview.chromium.org/3007037/diff/22001/23001 File base/registry.cc (right): http://codereview.chromium.org/3007037/diff/22001/23001#newcode12 base/registry.cc:12: LPCTSTR folder_key) { const wchar_t* instead http://codereview.chromium.org/3007037/diff/22001/23001#newcode74 base/registry.cc:74: LPCTSTR ...
10 years, 4 months ago (2010-08-07 11:28:55 UTC) #4
tfarina
http://codereview.chromium.org/3007037/diff/22001/23001 File base/registry.cc (right): http://codereview.chromium.org/3007037/diff/22001/23001#newcode12 base/registry.cc:12: LPCTSTR folder_key) { On 2010/08/07 11:28:55, Marc-Antoine Ruel wrote: ...
10 years, 4 months ago (2010-08-07 15:35:39 UTC) #5
M-A Ruel
lgtm! The code is still full of awful limitations like arbitrary limits on name length ...
10 years, 4 months ago (2010-08-08 22:34:59 UTC) #6
tfarina
On 2010/08/08 22:34:59, Marc-Antoine Ruel wrote: > lgtm! > > The code is still full ...
10 years, 4 months ago (2010-08-08 23:52:28 UTC) #7
M-A Ruel
10 years, 4 months ago (2010-08-09 00:12:35 UTC) #8
On 2010/08/08 23:52:28, tfarina wrote:
> On 2010/08/08 22:34:59, Marc-Antoine Ruel wrote:
> > lgtm!
> > 
> > The code is still full of awful limitations like arbitrary limits on name
> length
> > but this refactor is fine as-is.
> > 
> > I've added 2 nits but you can commit anyway. Thanks.
> >  
> > http://codereview.chromium.org/3007037/diff/3003/34005
> > File chrome/installer/util/google_update_settings_unittest.cc (right):
> > 
> > http://codereview.chromium.org/3007037/diff/3003/34005#newcode18
> > chrome/installer/util/google_update_settings_unittest.cc:18: const wchar_t
> > kHKCUReplacement[] =
> > In fact I prefer const wchar_t* const (const pointer to const data) than an
> > array. I agree that a non-const global pointer was a bad idea!
> 
> The best answer I know for this is that const char[] = "foo"; just creates a
> single variable in assembly.
> 
> Quoting from http://kernelnewbies.org/KernelJanitors:
> 
> "
> From: Jeff Garzik
> 
> The string form
> 
>         [const] char *foo = "blah";
> creates two variables in the final assembly output, a static string,
> and a char pointer to the static string. The alternate string form
> 
>         [const] char foo[] = "blah";
> is better because it declares a single variable.
> "
> 
> Logically there is a size difference between these two forms, the latter saves
> some memory too.

And that's exactly not what I said; I said to use the form:
  const char* const foo = "blah";

As a shortcut:
1) const char* foo = "blah";
2) const char foo[] = "blah";
3) const char* const foo = "blah";

Form 1) is just plain bad, it declares a non const global variable. It should
never be used.
Form 2) only creates one symbol, the data.
Form 3) causes the compiler to create 2 symbols: the pointer and the data. The
nice thing is that the compiler can inline the actual pointer since it's a const
value, but only if there is link-time optimization or if the pointer is only
used through the source file it is defined in. So when it's optimized in, only
the actual data remains.

Now things become interesting when people define their const strings into an
empty namespace or declare it a static variable.
For form 2), the data isn't shared since the data is using two different symbol
names.
For form 3), the data is shared since the actual data is nameless.

Sadly, http://msdn.microsoft.com/en-us/library/s0s0asdt.aspx is quite thin on
details of the inner working.

It always depends on the optimization options, etc. Anyway, no big deal.

M-A

Powered by Google App Engine
This is Rietveld 408576698