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

Side by Side Diff: content/child/webcrypto/webcrypto_impl.cc

Issue 278513004: [webcrypto] Fix a race in BlinkPlatformImpl::crypto(), by using eager initilization of WebCryptoImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address sleevi comments Created 6 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 | Annotate | Revision Log
« no previous file with comments | « content/child/webcrypto/webcrypto_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/child/webcrypto/webcrypto_impl.h" 5 #include "content/child/webcrypto/webcrypto_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 state->usages, 545 state->usages,
546 &state->unwrapped_key); 546 &state->unwrapped_key);
547 547
548 state->origin_thread->PostTask( 548 state->origin_thread->PostTask(
549 FROM_HERE, base::Bind(DoUnwrapKeyReply, Passed(&passed_state))); 549 FROM_HERE, base::Bind(DoUnwrapKeyReply, Passed(&passed_state)));
550 } 550 }
551 551
552 } // namespace 552 } // namespace
553 553
554 WebCryptoImpl::WebCryptoImpl() { 554 WebCryptoImpl::WebCryptoImpl() {
555 webcrypto::Init();
556 } 555 }
557 556
558 WebCryptoImpl::~WebCryptoImpl() { 557 WebCryptoImpl::~WebCryptoImpl() {
559 } 558 }
560 559
560 void WebCryptoImpl::EnsureInit() {
561 webcrypto::Init();
562 }
563
561 void WebCryptoImpl::encrypt(const blink::WebCryptoAlgorithm& algorithm, 564 void WebCryptoImpl::encrypt(const blink::WebCryptoAlgorithm& algorithm,
562 const blink::WebCryptoKey& key, 565 const blink::WebCryptoKey& key,
563 const unsigned char* data, 566 const unsigned char* data,
564 unsigned int data_size, 567 unsigned int data_size,
565 blink::WebCryptoResult result) { 568 blink::WebCryptoResult result) {
566 DCHECK(!algorithm.isNull()); 569 DCHECK(!algorithm.isNull());
567 570
568 scoped_ptr<EncryptState> state( 571 scoped_ptr<EncryptState> state(
569 new EncryptState(algorithm, key, data, data_size, result)); 572 new EncryptState(algorithm, key, data, data_size, result));
570 if (!CryptoThreadPool::PostTask(FROM_HERE, 573 if (!CryptoThreadPool::PostTask(FROM_HERE,
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 &key); 739 &key);
737 } 740 }
738 741
739 bool WebCryptoImpl::serializeKeyForClone( 742 bool WebCryptoImpl::serializeKeyForClone(
740 const blink::WebCryptoKey& key, 743 const blink::WebCryptoKey& key,
741 blink::WebVector<unsigned char>& key_data) { 744 blink::WebVector<unsigned char>& key_data) {
742 return webcrypto::SerializeKeyForClone(key, &key_data); 745 return webcrypto::SerializeKeyForClone(key, &key_data);
743 } 746 }
744 747
745 } // namespace content 748 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/webcrypto_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698