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

Side by Side Diff: Source/bindings/modules/v8/ScriptValueSerializerForModules.cpp

Issue 797283005: replace COMPILE_ASSERT with static_assert in bindings/ (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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 "config.h" 5 #include "config.h"
6 #include "bindings/modules/v8/ScriptValueSerializerForModules.h" 6 #include "bindings/modules/v8/ScriptValueSerializerForModules.h"
7 7
8 #include "bindings/core/v8/SerializationTag.h" 8 #include "bindings/core/v8/SerializationTag.h"
9 #include "bindings/core/v8/V8Binding.h" 9 #include "bindings/core/v8/V8Binding.h"
10 #include "bindings/modules/v8/V8CryptoKey.h" 10 #include "bindings/modules/v8/V8CryptoKey.h"
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 return doWriteUint32(P384Tag); 242 return doWriteUint32(P384Tag);
243 case WebCryptoNamedCurveP521: 243 case WebCryptoNamedCurveP521:
244 return doWriteUint32(P521Tag); 244 return doWriteUint32(P521Tag);
245 } 245 }
246 ASSERT_NOT_REACHED(); 246 ASSERT_NOT_REACHED();
247 } 247 }
248 248
249 void SerializedScriptValueWriterForModules::doWriteKeyUsages(const WebCryptoKeyU sageMask usages, bool extractable) 249 void SerializedScriptValueWriterForModules::doWriteKeyUsages(const WebCryptoKeyU sageMask usages, bool extractable)
250 { 250 {
251 // Reminder to update this when adding new key usages. 251 // Reminder to update this when adding new key usages.
252 COMPILE_ASSERT(EndOfWebCryptoKeyUsage == (1 << 7) + 1, UpdateMe); 252 static_assert(EndOfWebCryptoKeyUsage == (1 << 7) + 1, "update required when adding new key usages");
253 253
254 uint32_t value = 0; 254 uint32_t value = 0;
255 255
256 if (extractable) 256 if (extractable)
257 value |= ExtractableUsage; 257 value |= ExtractableUsage;
258 258
259 if (usages & WebCryptoKeyUsageEncrypt) 259 if (usages & WebCryptoKeyUsageEncrypt)
260 value |= EncryptUsage; 260 value |= EncryptUsage;
261 if (usages & WebCryptoKeyUsageDecrypt) 261 if (usages & WebCryptoKeyUsageDecrypt)
262 value |= DecryptUsage; 262 value |= DecryptUsage;
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 namedCurve = WebCryptoNamedCurveP521; 547 namedCurve = WebCryptoNamedCurveP521;
548 return true; 548 return true;
549 } 549 }
550 550
551 return false; 551 return false;
552 } 552 }
553 553
554 bool SerializedScriptValueReaderForModules::doReadKeyUsages(WebCryptoKeyUsageMas k& usages, bool& extractable) 554 bool SerializedScriptValueReaderForModules::doReadKeyUsages(WebCryptoKeyUsageMas k& usages, bool& extractable)
555 { 555 {
556 // Reminder to update this when adding new key usages. 556 // Reminder to update this when adding new key usages.
557 COMPILE_ASSERT(EndOfWebCryptoKeyUsage == (1 << 7) + 1, UpdateMe); 557 static_assert(EndOfWebCryptoKeyUsage == (1 << 7) + 1, "update required when adding new key usages");
558 const uint32_t allPossibleUsages = ExtractableUsage | EncryptUsage | Decrypt Usage | SignUsage | VerifyUsage | DeriveKeyUsage | WrapKeyUsage | UnwrapKeyUsage | DeriveBitsUsage; 558 const uint32_t allPossibleUsages = ExtractableUsage | EncryptUsage | Decrypt Usage | SignUsage | VerifyUsage | DeriveKeyUsage | WrapKeyUsage | UnwrapKeyUsage | DeriveBitsUsage;
559 559
560 uint32_t rawUsages; 560 uint32_t rawUsages;
561 if (!doReadUint32(&rawUsages)) 561 if (!doReadUint32(&rawUsages))
562 return false; 562 return false;
563 563
564 // Make sure it doesn't contain an unrecognized usage value. 564 // Make sure it doesn't contain an unrecognized usage value.
565 if (rawUsages & ~allPossibleUsages) 565 if (rawUsages & ~allPossibleUsages)
566 return false; 566 return false;
567 567
(...skipping 25 matching lines...) Expand all
593 : ScriptValueDeserializer(reader, messagePorts, arrayBufferContents) 593 : ScriptValueDeserializer(reader, messagePorts, arrayBufferContents)
594 { 594 {
595 } 595 }
596 596
597 bool ScriptValueDeserializerForModules::read(v8::Local<v8::Value>* value) 597 bool ScriptValueDeserializerForModules::read(v8::Local<v8::Value>* value)
598 { 598 {
599 return toSerializedScriptValueReaderForModules(reader()).read(value, *this); 599 return toSerializedScriptValueReaderForModules(reader()).read(value, *this);
600 } 600 }
601 601
602 } // namespace blink 602 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/WrapperTypeInfo.h ('k') | Source/bindings/modules/v8/SerializedScriptValueForModulesFactory.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698