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

Side by Side Diff: Source/modules/crypto/CryptoResultImpl.cpp

Issue 295423004: Expose WebCrypto's algorithm normalization. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 6 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 29 matching lines...) Expand all
40 #include "modules/crypto/Key.h" 40 #include "modules/crypto/Key.h"
41 #include "modules/crypto/KeyPair.h" 41 #include "modules/crypto/KeyPair.h"
42 #include "modules/crypto/NormalizeAlgorithm.h" 42 #include "modules/crypto/NormalizeAlgorithm.h"
43 #include "public/platform/Platform.h" 43 #include "public/platform/Platform.h"
44 #include "public/platform/WebArrayBuffer.h" 44 #include "public/platform/WebArrayBuffer.h"
45 #include "public/platform/WebCryptoAlgorithm.h" 45 #include "public/platform/WebCryptoAlgorithm.h"
46 #include "wtf/ArrayBufferView.h" 46 #include "wtf/ArrayBufferView.h"
47 47
48 namespace WebCore { 48 namespace WebCore {
49 49
50 namespace {
51
52 ExceptionCode toExceptionCode(blink::WebCryptoErrorType errorType) 50 ExceptionCode toExceptionCode(blink::WebCryptoErrorType errorType)
53 { 51 {
54 switch (errorType) { 52 switch (errorType) {
55 case blink::WebCryptoErrorTypeNotSupported: 53 case blink::WebCryptoErrorTypeNotSupported:
56 return NotSupportedError; 54 return NotSupportedError;
57 case blink::WebCryptoErrorTypeSyntax: 55 case blink::WebCryptoErrorTypeSyntax:
58 return SyntaxError; 56 return SyntaxError;
59 case blink::WebCryptoErrorTypeInvalidState: 57 case blink::WebCryptoErrorTypeInvalidState:
60 return InvalidStateError; 58 return InvalidStateError;
61 case blink::WebCryptoErrorTypeInvalidAccess: 59 case blink::WebCryptoErrorTypeInvalidAccess:
62 return InvalidAccessError; 60 return InvalidAccessError;
63 case blink::WebCryptoErrorTypeUnknown: 61 case blink::WebCryptoErrorTypeUnknown:
64 return UnknownError; 62 return UnknownError;
65 case blink::WebCryptoErrorTypeData: 63 case blink::WebCryptoErrorTypeData:
66 return DataError; 64 return DataError;
67 case blink::WebCryptoErrorTypeOperation: 65 case blink::WebCryptoErrorTypeOperation:
68 return OperationError; 66 return OperationError;
69 case blink::WebCryptoErrorTypeType: 67 case blink::WebCryptoErrorTypeType:
70 // FIXME: This should construct a TypeError instead. For now do 68 // FIXME: This should construct a TypeError instead. For now do
71 // something to facilitate refactor, but this will need to be 69 // something to facilitate refactor, but this will need to be
72 // revisited. 70 // revisited.
73 return DataError; 71 return DataError;
74 } 72 }
75 73
76 ASSERT_NOT_REACHED(); 74 ASSERT_NOT_REACHED();
77 return 0; 75 return 0;
78 } 76 }
79 77
80 } // namespace
81
82 // The PromiseState class contains all the state which is tied to an 78 // The PromiseState class contains all the state which is tied to an
83 // ExecutionContext. Whereas CryptoResultImpl can be deleted from any thread, 79 // ExecutionContext. Whereas CryptoResultImpl can be deleted from any thread,
84 // PromiseState is not thread safe and must only be accessed and deleted from 80 // PromiseState is not thread safe and must only be accessed and deleted from
85 // the blink thread. 81 // the blink thread.
86 // 82 //
87 // This is achieved by making CryptoResultImpl hold a WeakPtr to the PromiseStat e. 83 // This is achieved by making CryptoResultImpl hold a WeakPtr to the PromiseStat e.
88 // The PromiseState deletes itself after being notified of completion. 84 // The PromiseState deletes itself after being notified of completion.
89 // Additionally the PromiseState is deleted when the ExecutionContext is 85 // Additionally the PromiseState is deleted when the ExecutionContext is
90 // destroyed (necessary to avoid leaks when dealing with WebWorker threads, 86 // destroyed (necessary to avoid leaks when dealing with WebWorker threads,
91 // which may die before the operation is completed). 87 // which may die before the operation is completed).
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 : m_promiseState(PromiseState::create(context)) 214 : m_promiseState(PromiseState::create(context))
219 { 215 {
220 } 216 }
221 217
222 ScriptPromise CryptoResultImpl::promise() 218 ScriptPromise CryptoResultImpl::promise()
223 { 219 {
224 return m_promiseState->promise(); 220 return m_promiseState->promise();
225 } 221 }
226 222
227 } // namespace WebCore 223 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698