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

Unified Diff: blimp/common/blob_cache/id_util.cc

Issue 1867653002: Initial version of Blimp BlobCache. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git merge origin/master for good measure Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « blimp/common/blob_cache/id_util.h ('k') | blimp/common/blob_cache/in_memory_blob_cache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: blimp/common/blob_cache/id_util.cc
diff --git a/blimp/common/blob_cache/id_util.cc b/blimp/common/blob_cache/id_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c6f33fccfa47c3749ead008bf589ce7328f55f2d
--- /dev/null
+++ b/blimp/common/blob_cache/id_util.cc
@@ -0,0 +1,27 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "blimp/common/blob_cache/id_util.h"
+
+#include "base/sha1.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_util.h"
+#include "blimp/common/blob_cache/blob_cache.h"
+
+namespace blimp {
+
+const BlobId CalculateBlobId(const void* data, size_t data_size) {
+ std::vector<unsigned char> sha1_hash(base::kSHA1Length);
+ base::SHA1HashBytes(static_cast<const unsigned char*>(data), data_size,
davidben 2016/04/22 16:39:49 Drive-by comment: why is this using SHA-1 and not
+ sha1_hash.data());
+ return std::string(reinterpret_cast<char*>(sha1_hash.data()),
+ sha1_hash.size());
+}
+
+const std::string FormatBlobId(const BlobId& data) {
+ DCHECK_EQ(base::kSHA1Length, data.length());
+ return base::ToLowerASCII(base::HexEncode(data.data(), data.length()));
+}
+
+} // namespace blimp
« no previous file with comments | « blimp/common/blob_cache/id_util.h ('k') | blimp/common/blob_cache/in_memory_blob_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698