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

Issue 6661025: Add base::SHA1HashBytes (Closed)

Created:
9 years, 9 months ago by hans
Modified:
9 years, 5 months ago
Reviewers:
wtc, jorlow
CC:
chromium-reviews, brettw-cc_chromium.org
Visibility:
Public.

Description

Add base::SHA1HashBytes. We need this for LevelDB. BUG=64078 TEST=base_unittest --gtest_filter=SHA1Test Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=77973

Patch Set 1 #

Patch Set 2 : Make Windows happy #

Patch Set 3 : Add base::SHA1HashBytes #

Patch Set 4 : Actually, base/sha1_win.cc is not used, so don't touch it #

Total comments: 6

Patch Set 5 : Addressing wtc's comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+70 lines, -4 lines) Patch
M base/sha1.h View 1 2 3 4 1 chunk +5 lines, -0 lines 0 comments Download
M base/sha1_portable.cc View 1 2 3 4 2 chunks +13 lines, -4 lines 0 comments Download
M base/sha1_unittest.cc View 1 2 1 chunk +52 lines, -0 lines 0 comments Download

Messages

Total messages: 8 (0 generated)
hans
9 years, 9 months ago (2011-03-10 17:12:09 UTC) #1
wtc
hans: I maintain these two files. I can review this CL for you. The two ...
9 years, 9 months ago (2011-03-10 17:49:33 UTC) #2
jorlow
LGTM...wait for wtc tho
9 years, 9 months ago (2011-03-10 17:51:01 UTC) #3
hans
On 2011/03/10 17:49:33, wtc wrote: > hans: I maintain these two files. I can review ...
9 years, 9 months ago (2011-03-10 18:02:31 UTC) #4
hans
On 2011/03/10 18:02:31, hans wrote: > On 2011/03/10 17:49:33, wtc wrote: > > hans: I ...
9 years, 9 months ago (2011-03-11 15:44:56 UTC) #5
jorlow
LGTM
9 years, 9 months ago (2011-03-11 17:29:34 UTC) #6
wtc
LGTM. Please make the changes I suggested below before checking this in. Feel free to ...
9 years, 9 months ago (2011-03-11 18:46:15 UTC) #7
hans
9 years, 9 months ago (2011-03-13 19:48:16 UTC) #8
Thanks for the review.

> IMPORTANT: Chromium uses std::string to hold binary data.
> (This is confusing to a C programmer like me.)
Me too :)

> I just wanted
> to make sure SHA1HashString is not suitable for you, for
> example, you want to avoid the overhead of copying the
> input or output to/from a std::string.
Yes, we plan to call this a lot, so want to avoid the extra copying.

I might also look into crbug.com/47218 if this can affect our performance.

http://codereview.chromium.org/6661025/diff/9001/base/sha1.h
File base/sha1.h (right):

http://codereview.chromium.org/6661025/diff/9001/base/sha1.h#newcode26
base/sha1.h:26: unsigned char* hash_array);
On 2011/03/11 18:46:15, wtc wrote:
> Nit: |hash_array| can be shortened to |hash|.
done

> 
> Please document that |hash_array| must be SHA1_LENGTH bytes
> long.
done

http://codereview.chromium.org/6661025/diff/9001/base/sha1_portable.cc
File base/sha1_portable.cc (right):

http://codereview.chromium.org/6661025/diff/9001/base/sha1_portable.cc#newcode8
base/sha1_portable.cc:8: #include <cstring>
On 2011/03/11 18:46:15, wtc wrote:
> 1. Nit: I recommend including the C header <string.h>
> instead of <cstring> for consistency with existing usage
> in the Chromium code base.  See line 25, for example.  (I
> know it's inside a comment.)
done

> 
> 2. The headers should be listed in this order:
> 
> #include "base/sha1.h"
> 
> #include <string.h> // or <cstring>
> 
> #include "base/basictypes.h"
> 
> See the Style Guide:
>
http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Names_and_Orde...

done

http://codereview.chromium.org/6661025/diff/9001/base/sha1_portable.cc#newcod...
base/sha1_portable.cc:198: std::string SHA1HashString(const std::string& str) {
On 2011/03/11 18:46:15, wtc wrote:
> Nit: ideally this function should be reimplemented using
> SHA1HashBytes.

Done.

Powered by Google App Engine
This is Rietveld 408576698