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

Side by Side Diff: Source/modules/crypto/CryptoOperation.h

Issue 19776013: WebCrypto: Refactor the WebCryptoOperation interface to support errors. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase onto master Created 7 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 | Annotate | Revision Log
« no previous file with comments | « LayoutTests/crypto/digest-expected.txt ('k') | Source/modules/crypto/CryptoOperation.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 28 matching lines...) Expand all
39 #include "wtf/Forward.h" 39 #include "wtf/Forward.h"
40 #include "wtf/PassRefPtr.h" 40 #include "wtf/PassRefPtr.h"
41 #include "wtf/RefCounted.h" 41 #include "wtf/RefCounted.h"
42 42
43 namespace WebCore { 43 namespace WebCore {
44 44
45 class ScriptPromiseResolver; 45 class ScriptPromiseResolver;
46 46
47 typedef int ExceptionCode; 47 typedef int ExceptionCode;
48 48
49 class CryptoOperation : public ScriptWrappable, public RefCounted<CryptoOperatio n> { 49 class CryptoOperation : public ScriptWrappable, public WebKit::WebCryptoOperatio nResult, public RefCounted<CryptoOperation> {
50 public: 50 public:
51 ~CryptoOperation(); 51 ~CryptoOperation();
52 static PassRefPtr<CryptoOperation> create(const WebKit::WebCryptoAlgorithm&, WebKit::WebCryptoOperation*); 52 static PassRefPtr<CryptoOperation> create(const WebKit::WebCryptoAlgorithm&, ExceptionCode*);
53 53
54 CryptoOperation* process(ArrayBuffer* data); 54 CryptoOperation* process(ArrayBuffer* data);
55 CryptoOperation* process(ArrayBufferView* data); 55 CryptoOperation* process(ArrayBufferView* data);
56 56
57 ScriptObject finish(); 57 ScriptObject finish();
58 ScriptObject abort(); 58 ScriptObject abort();
59 59
60 Algorithm* algorithm(); 60 Algorithm* algorithm();
61 61
62 // Implementation of WebKit::WebCryptoOperationResult.
63 virtual void initializationFailed() OVERRIDE;
64 virtual void initializationSucceded(WebKit::WebCryptoOperation*) OVERRIDE;
65 virtual void completeWithError() OVERRIDE;
66 virtual void completeWithArrayBuffer(const WebKit::WebArrayBuffer&) OVERRIDE ;
67
62 private: 68 private:
63 class Result; 69 enum State {
64 friend class Result; 70 // Constructing the WebCryptoOperation.
71 Initializing,
65 72
66 enum State {
67 // Accepting calls to process(). 73 // Accepting calls to process().
68 Processing, 74 Processing,
69 75
70 // finish() has been called, but the Promise has not been resolved yet. 76 // finish() has been called, but the Promise has not been resolved yet.
71 Finishing, 77 Finishing,
72 78
73 // The operation either: 79 // The operation either:
74 // - completed successfully 80 // - completed successfully
75 // - failed 81 // - failed
76 // - was aborted 82 // - was aborted
77 Done, 83 Done,
78 }; 84 };
79 85
80 CryptoOperation(const WebKit::WebCryptoAlgorithm&, WebKit::WebCryptoOperatio n*); 86 CryptoOperation(const WebKit::WebCryptoAlgorithm&, ExceptionCode*);
81 87
82 void process(const unsigned char*, size_t); 88 void process(const unsigned char*, size_t);
83 89
84 // Aborts and clears m_impl. If the operation has already comleted then 90 // Aborts and clears m_impl. If the operation has already comleted then
85 // returns false. 91 // returns false.
86 bool abortImpl(); 92 bool abortImpl();
87 93
88 ScriptPromiseResolver* promiseResolver(); 94 ScriptPromiseResolver* promiseResolver();
89 95
90 WebKit::WebCryptoAlgorithm m_algorithm; 96 WebKit::WebCryptoAlgorithm m_algorithm;
91 WebKit::WebCryptoOperation* m_impl; 97 WebKit::WebCryptoOperation* m_impl;
92 RefPtr<Algorithm> m_algorithmNode; 98 RefPtr<Algorithm> m_algorithmNode;
93 State m_state; 99 State m_state;
94 100
95 RefPtr<ScriptPromiseResolver> m_promiseResolver; 101 RefPtr<ScriptPromiseResolver> m_promiseResolver;
96 102
97 OwnPtr<Result> m_result; 103 ExceptionCode* m_exceptionCode;
98 }; 104 };
99 105
100 } // namespace WebCore 106 } // namespace WebCore
101 107
102 #endif 108 #endif
OLDNEW
« no previous file with comments | « LayoutTests/crypto/digest-expected.txt ('k') | Source/modules/crypto/CryptoOperation.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698