| OLD | NEW |
| 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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 DCHECK(state->key.handle()); | 450 DCHECK(state->key.handle()); |
| 451 DCHECK(!state->key.algorithm().isNull()); | 451 DCHECK(!state->key.algorithm().isNull()); |
| 452 DCHECK_EQ(state->extractable, state->key.extractable()); | 452 DCHECK_EQ(state->extractable, state->key.extractable()); |
| 453 } | 453 } |
| 454 | 454 |
| 455 state->origin_thread->PostTask( | 455 state->origin_thread->PostTask( |
| 456 FROM_HERE, base::Bind(DoImportKeyReply, Passed(&passed_state))); | 456 FROM_HERE, base::Bind(DoImportKeyReply, Passed(&passed_state))); |
| 457 } | 457 } |
| 458 | 458 |
| 459 void DoExportKeyReply(scoped_ptr<ExportKeyState> state) { | 459 void DoExportKeyReply(scoped_ptr<ExportKeyState> state) { |
| 460 #ifndef WEBCRYPTO_RESULT_ACCEPTS_JSON | |
| 461 // TODO(eroman): Remove idfef once blink rolls. | |
| 462 CompleteWithBufferOrError(state->status, state->buffer, &state->result); | |
| 463 #else | |
| 464 if (state->format != blink::WebCryptoKeyFormatJwk) { | 460 if (state->format != blink::WebCryptoKeyFormatJwk) { |
| 465 CompleteWithBufferOrError(state->status, state->buffer, &state->result); | 461 CompleteWithBufferOrError(state->status, state->buffer, &state->result); |
| 466 return; | 462 return; |
| 467 } | 463 } |
| 468 | 464 |
| 469 if (state->status.IsError()) { | 465 if (state->status.IsError()) { |
| 470 CompleteWithError(state->status, &state->result); | 466 CompleteWithError(state->status, &state->result); |
| 471 } else { | 467 } else { |
| 472 state->result.completeWithJson( | 468 state->result.completeWithJson( |
| 473 reinterpret_cast<const char*>( | 469 reinterpret_cast<const char*>( |
| 474 webcrypto::Uint8VectorStart(&state->buffer)), | 470 webcrypto::Uint8VectorStart(&state->buffer)), |
| 475 state->buffer.size()); | 471 state->buffer.size()); |
| 476 } | 472 } |
| 477 #endif | |
| 478 } | 473 } |
| 479 | 474 |
| 480 void DoExportKey(scoped_ptr<ExportKeyState> passed_state) { | 475 void DoExportKey(scoped_ptr<ExportKeyState> passed_state) { |
| 481 ExportKeyState* state = passed_state.get(); | 476 ExportKeyState* state = passed_state.get(); |
| 482 state->status = | 477 state->status = |
| 483 webcrypto::ExportKey(state->format, state->key, &state->buffer); | 478 webcrypto::ExportKey(state->format, state->key, &state->buffer); |
| 484 state->origin_thread->PostTask( | 479 state->origin_thread->PostTask( |
| 485 FROM_HERE, base::Bind(DoExportKeyReply, Passed(&passed_state))); | 480 FROM_HERE, base::Bind(DoExportKeyReply, Passed(&passed_state))); |
| 486 } | 481 } |
| 487 | 482 |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 &key); | 742 &key); |
| 748 } | 743 } |
| 749 | 744 |
| 750 bool WebCryptoImpl::serializeKeyForClone( | 745 bool WebCryptoImpl::serializeKeyForClone( |
| 751 const blink::WebCryptoKey& key, | 746 const blink::WebCryptoKey& key, |
| 752 blink::WebVector<unsigned char>& key_data) { | 747 blink::WebVector<unsigned char>& key_data) { |
| 753 return webcrypto::SerializeKeyForClone(key, &key_data); | 748 return webcrypto::SerializeKeyForClone(key, &key_data); |
| 754 } | 749 } |
| 755 | 750 |
| 756 } // namespace content | 751 } // namespace content |
| OLD | NEW |