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

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

Issue 2147413002: WebRTCCertificateGenerator should not use std::string. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 "bindings/modules/v8/ScriptValueSerializerForModules.h" 5 #include "bindings/modules/v8/ScriptValueSerializerForModules.h"
6 6
7 #include "bindings/core/v8/SerializationTag.h" 7 #include "bindings/core/v8/SerializationTag.h"
8 #include "bindings/core/v8/V8Binding.h" 8 #include "bindings/core/v8/V8Binding.h"
9 #include "bindings/modules/v8/V8CryptoKey.h" 9 #include "bindings/modules/v8/V8CryptoKey.h"
10 #include "bindings/modules/v8/V8DOMFileSystem.h" 10 #include "bindings/modules/v8/V8DOMFileSystem.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 doWriteUint32(keyData.size()); 152 doWriteUint32(keyData.size());
153 append(keyData.data(), keyData.size()); 153 append(keyData.data(), keyData.size());
154 return true; 154 return true;
155 } 155 }
156 156
157 void SerializedScriptValueWriterForModules::writeRTCCertificate(const RTCCertifi cate& certificate) 157 void SerializedScriptValueWriterForModules::writeRTCCertificate(const RTCCertifi cate& certificate)
158 { 158 {
159 append(RTCCertificateTag); 159 append(RTCCertificateTag);
160 160
161 WebRTCCertificatePEM pem = certificate.certificateShallowCopy()->toPEM(); 161 WebRTCCertificatePEM pem = certificate.certificateShallowCopy()->toPEM();
162 doWriteWebCoreString(String(pem.privateKey().c_str())); 162 doWriteWebCoreString(pem.privateKey());
163 doWriteWebCoreString(String(pem.certificate().c_str())); 163 doWriteWebCoreString(pem.certificate());
164 } 164 }
165 165
166 void SerializedScriptValueWriterForModules::doWriteHmacKey(const WebCryptoKey& k ey) 166 void SerializedScriptValueWriterForModules::doWriteHmacKey(const WebCryptoKey& k ey)
167 { 167 {
168 ASSERT(key.algorithm().paramsType() == WebCryptoKeyAlgorithmParamsTypeHmac); 168 ASSERT(key.algorithm().paramsType() == WebCryptoKeyAlgorithmParamsTypeHmac);
169 169
170 append(static_cast<uint8_t>(HmacKeyTag)); 170 append(static_cast<uint8_t>(HmacKeyTag));
171 ASSERT(!(key.algorithm().hmacParams()->lengthBits() % 8)); 171 ASSERT(!(key.algorithm().hmacParams()->lengthBits() % 8));
172 doWriteUint32(key.algorithm().hmacParams()->lengthBits() / 8); 172 doWriteUint32(key.algorithm().hmacParams()->lengthBits() / 8);
173 doWriteAlgorithmId(key.algorithm().hmacParams()->hash().id()); 173 doWriteAlgorithmId(key.algorithm().hmacParams()->hash().id());
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 return false; 443 return false;
444 String pemCertificate; 444 String pemCertificate;
445 if (!readWebCoreString(&pemCertificate)) 445 if (!readWebCoreString(&pemCertificate))
446 return false; 446 return false;
447 447
448 std::unique_ptr<WebRTCCertificateGenerator> certificateGenerator = wrapUniqu e( 448 std::unique_ptr<WebRTCCertificateGenerator> certificateGenerator = wrapUniqu e(
449 Platform::current()->createRTCCertificateGenerator()); 449 Platform::current()->createRTCCertificateGenerator());
450 450
451 std::unique_ptr<WebRTCCertificate> certificate( 451 std::unique_ptr<WebRTCCertificate> certificate(
452 certificateGenerator->fromPEM( 452 certificateGenerator->fromPEM(
453 pemPrivateKey.utf8().data(), 453 pemPrivateKey,
454 pemCertificate.utf8().data())); 454 pemCertificate));
455 RTCCertificate* jsCertificate = new RTCCertificate(std::move(certificate)); 455 RTCCertificate* jsCertificate = new RTCCertificate(std::move(certificate));
456 456
457 *value = toV8(jsCertificate, getScriptState()->context()->Global(), isolate( )); 457 *value = toV8(jsCertificate, getScriptState()->context()->Global(), isolate( ));
458 return !value->IsEmpty(); 458 return !value->IsEmpty();
459 } 459 }
460 460
461 bool SerializedScriptValueReaderForModules::doReadHmacKey(WebCryptoKeyAlgorithm& algorithm, WebCryptoKeyType& type) 461 bool SerializedScriptValueReaderForModules::doReadHmacKey(WebCryptoKeyAlgorithm& algorithm, WebCryptoKeyType& type)
462 { 462 {
463 uint32_t lengthBytes; 463 uint32_t lengthBytes;
464 if (!doReadUint32(&lengthBytes)) 464 if (!doReadUint32(&lengthBytes))
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 : ScriptValueDeserializer(reader, messagePorts, arrayBufferContents, imageBi tmapContents) 681 : ScriptValueDeserializer(reader, messagePorts, arrayBufferContents, imageBi tmapContents)
682 { 682 {
683 } 683 }
684 684
685 bool ScriptValueDeserializerForModules::read(v8::Local<v8::Value>* value) 685 bool ScriptValueDeserializerForModules::read(v8::Local<v8::Value>* value)
686 { 686 {
687 return toSerializedScriptValueReaderForModules(reader()).read(value, *this); 687 return toSerializedScriptValueReaderForModules(reader()).read(value, *this);
688 } 688 }
689 689
690 } // namespace blink 690 } // namespace blink
OLDNEW
« no previous file with comments | « content/renderer/media/rtc_certificate_generator.cc ('k') | third_party/WebKit/public/platform/WebRTCCertificate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698