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

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

Issue 1233173002: Have ScriptPromiseResolver on the Oilpan heap always. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix webusb ScriptPromiseResolver usage Created 5 years, 4 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 MODULES_EXPORT ExceptionCode webCryptoErrorToExceptionCode(WebCryptoErrorType); 43 MODULES_EXPORT ExceptionCode webCryptoErrorToExceptionCode(WebCryptoErrorType);
44 44
45 // Wrapper around a Promise to notify completion of the crypto operation. 45 // Wrapper around a Promise to notify completion of the crypto operation.
46 // 46 //
47 // The thread on which CryptoResultImpl was created on is referred to as the 47 // The thread on which CryptoResultImpl was created on is referred to as the
48 // "origin thread". 48 // "origin thread".
49 // 49 //
50 // * At creation time there must be an active ExecutionContext. 50 // * At creation time there must be an active ExecutionContext.
51 // * All methods of the CryptoResult implementation must be called from 51 // * All methods of the CryptoResult implementation must be called from
52 // the origin thread. The exception is that ref(), deref(), and 52 // the origin thread. The exception is that destruction may happen on
53 // destruction may happen on another thread. 53 // another thread.
54 // * One of the completeWith***() functions must be called, or the 54 // * One of the completeWith***() functions must be called, or the
55 // m_resolver will be leaked until the ExecutionContext is destroyed. 55 // m_resolver will be leaked until the ExecutionContext is destroyed.
56 class CryptoResultImpl final : public CryptoResult { 56 class CryptoResultImpl final : public CryptoResult {
57 public: 57 public:
58 static PassRefPtrWillBeRawPtr<CryptoResultImpl> create(ScriptState*); 58 static CryptoResultImpl* create(ScriptState*);
59 59
60 ~CryptoResultImpl(); 60 ~CryptoResultImpl();
61 61
62 void completeWithError(WebCryptoErrorType, const WebString&) override; 62 void completeWithError(WebCryptoErrorType, const WebString&) override;
63 void completeWithBuffer(const void* bytes, unsigned bytesSize) override; 63 void completeWithBuffer(const void* bytes, unsigned bytesSize) override;
64 void completeWithJson(const char* utf8Data, unsigned length) override; 64 void completeWithJson(const char* utf8Data, unsigned length) override;
65 void completeWithBoolean(bool) override; 65 void completeWithBoolean(bool) override;
66 void completeWithKey(const WebCryptoKey&) override; 66 void completeWithKey(const WebCryptoKey&) override;
67 void completeWithKeyPair(const WebCryptoKey& publicKey, const WebCryptoKey& privateKey) override; 67 void completeWithKeyPair(const WebCryptoKey& publicKey, const WebCryptoKey& privateKey) override;
68 68
(...skipping 24 matching lines...) Expand all
93 ResultCancel(); 93 ResultCancel();
94 94
95 int m_cancelled; 95 int m_cancelled;
96 }; 96 };
97 97
98 explicit CryptoResultImpl(ScriptState*); 98 explicit CryptoResultImpl(ScriptState*);
99 99
100 void cancel(); 100 void cancel();
101 void clearResolver(); 101 void clearResolver();
102 102
103 RawPtrWillBeMember<Resolver> m_resolver; 103 Member<Resolver> m_resolver;
104 104
105 // Separately communicate cancellation to WebCryptoResults so as to 105 // Separately communicate cancellation to WebCryptoResults so as to
106 // allow this result object, which will be on the Oilpan heap, to be 106 // allow this result object, which will be on the Oilpan heap, to be
107 // GCed and destructed as needed. That is, it may end being GCed while 107 // GCed and destructed as needed. That is, it may end being GCed while
108 // the thread owning the heap is detached and shut down, which will 108 // the thread owning the heap is detached and shut down, which will
109 // in some cases happen before corresponding webcrypto operations have 109 // in some cases happen before corresponding webcrypto operations have
110 // all been processed. Hence these webcrypto operations cannot reliably 110 // all been processed. Hence these webcrypto operations cannot reliably
111 // check cancellation status via this result object. So, keep a separate 111 // check cancellation status via this result object. So, keep a separate
112 // cancellation status object for the purpose, which will outlive the 112 // cancellation status object for the purpose, which will outlive the
113 // result object and can be safely accessed by multiple threads. 113 // result object and can be safely accessed by multiple threads.
114 RefPtr<ResultCancel> m_cancel; 114 RefPtr<ResultCancel> m_cancel;
115 }; 115 };
116 116
117 } // namespace blink 117 } // namespace blink
118 118
119 #endif // CryptoResultImpl_h 119 #endif // CryptoResultImpl_h
OLDNEW
« no previous file with comments | « Source/modules/credentialmanager/CredentialsContainer.cpp ('k') | Source/modules/crypto/CryptoResultImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698