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

Side by Side Diff: third_party/WebKit/Source/platform/Crypto.cpp

Issue 2846303002: Replace ASSERT with DCHECK in platform/ (Closed)
Patch Set: rebase Created 3 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "platform/Crypto.h" 5 #include "platform/Crypto.h"
6 6
7 #include "public/platform/Platform.h" 7 #include "public/platform/Platform.h"
8 #include "public/platform/WebCrypto.h" 8 #include "public/platform/WebCrypto.h"
9 #include "public/platform/WebCryptoAlgorithm.h" 9 #include "public/platform/WebCryptoAlgorithm.h"
10 #include <memory> 10 #include <memory>
(...skipping 18 matching lines...) Expand all
29 29
30 bool ComputeDigest(HashAlgorithm algorithm, 30 bool ComputeDigest(HashAlgorithm algorithm,
31 const char* digestable, 31 const char* digestable,
32 size_t length, 32 size_t length,
33 DigestValue& digest_result) { 33 DigestValue& digest_result) {
34 WebCryptoAlgorithmId algorithm_id = ToWebCryptoAlgorithmId(algorithm); 34 WebCryptoAlgorithmId algorithm_id = ToWebCryptoAlgorithmId(algorithm);
35 WebCrypto* crypto = Platform::Current()->Crypto(); 35 WebCrypto* crypto = Platform::Current()->Crypto();
36 unsigned char* result; 36 unsigned char* result;
37 unsigned result_size; 37 unsigned result_size;
38 38
39 ASSERT(crypto); 39 DCHECK(crypto);
40 40
41 std::unique_ptr<WebCryptoDigestor> digestor = 41 std::unique_ptr<WebCryptoDigestor> digestor =
42 crypto->CreateDigestor(algorithm_id); 42 crypto->CreateDigestor(algorithm_id);
43 DCHECK(digestor); 43 DCHECK(digestor);
44 if (!digestor->Consume(reinterpret_cast<const unsigned char*>(digestable), 44 if (!digestor->Consume(reinterpret_cast<const unsigned char*>(digestable),
45 length) || 45 length) ||
46 !digestor->Finish(result, result_size)) 46 !digestor->Finish(result, result_size))
47 return false; 47 return false;
48 48
49 digest_result.Append(static_cast<uint8_t*>(result), result_size); 49 digest_result.Append(static_cast<uint8_t*>(result), result_size);
50 return true; 50 return true;
51 } 51 }
52 52
53 std::unique_ptr<WebCryptoDigestor> CreateDigestor(HashAlgorithm algorithm) { 53 std::unique_ptr<WebCryptoDigestor> CreateDigestor(HashAlgorithm algorithm) {
54 return Platform::Current()->Crypto()->CreateDigestor( 54 return Platform::Current()->Crypto()->CreateDigestor(
55 ToWebCryptoAlgorithmId(algorithm)); 55 ToWebCryptoAlgorithmId(algorithm));
56 } 56 }
57 57
58 void FinishDigestor(WebCryptoDigestor* digestor, DigestValue& digest_result) { 58 void FinishDigestor(WebCryptoDigestor* digestor, DigestValue& digest_result) {
59 unsigned char* result = 0; 59 unsigned char* result = 0;
60 unsigned result_size = 0; 60 unsigned result_size = 0;
61 61
62 if (!digestor->Finish(result, result_size)) 62 if (!digestor->Finish(result, result_size))
63 return; 63 return;
64 64
65 ASSERT(result); 65 DCHECK(result);
66 66
67 digest_result.Append(static_cast<uint8_t*>(result), result_size); 67 digest_result.Append(static_cast<uint8_t*>(result), result_size);
68 } 68 }
69 69
70 } // namespace blink 70 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/AsyncMethodRunner.h ('k') | third_party/WebKit/Source/platform/DateComponents.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698