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

Side by Side Diff: chrome/common/metrics_helpers.cc

Issue 7466003: MD5Update function uses StringPiece instead of raw buffer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added valid license Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/common/metrics_helpers.h" 5 #include "chrome/common/metrics_helpers.h"
6 6
7 #if defined(USE_SYSTEM_LIBBZ2) 7 #if defined(USE_SYSTEM_LIBBZ2)
8 #include <bzlib.h> 8 #include <bzlib.h>
9 #else 9 #else
10 #include "third_party/bzip2/bzlib.h" 10 #include "third_party/bzip2/bzlib.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 return std::string(reinterpret_cast<char*>(xml_wrapper_->buffer()->content)); 170 return std::string(reinterpret_cast<char*>(xml_wrapper_->buffer()->content));
171 } 171 }
172 172
173 int MetricsLogBase::GetElapsedSeconds() { 173 int MetricsLogBase::GetElapsedSeconds() {
174 return static_cast<int>((Time::Now() - start_time_).InSeconds()); 174 return static_cast<int>((Time::Now() - start_time_).InSeconds());
175 } 175 }
176 176
177 std::string MetricsLogBase::CreateHash(const std::string& value) { 177 std::string MetricsLogBase::CreateHash(const std::string& value) {
178 base::MD5Context ctx; 178 base::MD5Context ctx;
179 base::MD5Init(&ctx); 179 base::MD5Init(&ctx);
180 base::MD5Update(&ctx, value.data(), value.length()); 180 base::MD5Update(&ctx, value);
181 181
182 base::MD5Digest digest; 182 base::MD5Digest digest;
183 base::MD5Final(&digest, &ctx); 183 base::MD5Final(&digest, &ctx);
184 184
185 uint64 reverse_uint64; 185 uint64 reverse_uint64;
186 // UMA only uses first 8 chars of hash. We use the above uint64 instead 186 // UMA only uses first 8 chars of hash. We use the above uint64 instead
187 // of a unsigned char[8] so that we don't run into strict aliasing issues 187 // of a unsigned char[8] so that we don't run into strict aliasing issues
188 // in the LOG statement below when trying to interpret reverse as a uint64. 188 // in the LOG statement below when trying to interpret reverse as a uint64.
189 unsigned char* reverse = reinterpret_cast<unsigned char *>(&reverse_uint64); 189 unsigned char* reverse = reinterpret_cast<unsigned char *>(&reverse_uint64);
190 DCHECK(arraysize(digest.a) >= sizeof(reverse_uint64)); 190 DCHECK(arraysize(digest.a) >= sizeof(reverse_uint64));
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 snapshot.Subtract(*already_logged); 585 snapshot.Subtract(*already_logged);
586 } 586 }
587 587
588 // Snapshot now contains only a delta to what we've already_logged. 588 // Snapshot now contains only a delta to what we've already_logged.
589 if (snapshot.redundant_count() > 0) { 589 if (snapshot.redundant_count() > 0) {
590 TransmitHistogramDelta(histogram, snapshot); 590 TransmitHistogramDelta(histogram, snapshot);
591 // Add new data into our running total. 591 // Add new data into our running total.
592 already_logged->Add(snapshot); 592 already_logged->Add(snapshot);
593 } 593 }
594 } 594 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698