OLD | NEW |
---|---|
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 27 matching lines...) Expand all Loading... | |
38 | 38 |
39 namespace WebCore { | 39 namespace WebCore { |
40 | 40 |
41 // ScriptPromise is the class for representing Promise values in C++ world. | 41 // ScriptPromise is the class for representing Promise values in C++ world. |
42 // ScriptPromise holds a Promise. | 42 // ScriptPromise holds a Promise. |
43 // So holding a ScriptPromise as a member variable in DOM object causes | 43 // So holding a ScriptPromise as a member variable in DOM object causes |
44 // memory leaks since it has a reference from C++ to V8. | 44 // memory leaks since it has a reference from C++ to V8. |
45 // | 45 // |
46 class ScriptPromise { | 46 class ScriptPromise { |
47 public: | 47 public: |
48 // Constructs an empty promise. | |
48 ScriptPromise() | 49 ScriptPromise() |
49 : m_promise() | 50 : m_promise() |
50 { | 51 { |
51 } | 52 } |
52 | 53 |
53 explicit ScriptPromise(const ScriptValue& promise) | 54 explicit ScriptPromise(const ScriptValue& promise) |
54 : m_promise(promise) | 55 : m_promise(promise) |
55 { | 56 { |
56 ASSERT(!m_promise.hasNoValue()); | 57 ASSERT(!m_promise.hasNoValue()); |
57 } | 58 } |
(...skipping 27 matching lines...) Expand all Loading... | |
85 bool hasNoValue() const | 86 bool hasNoValue() const |
86 { | 87 { |
87 return m_promise.hasNoValue(); | 88 return m_promise.hasNoValue(); |
88 } | 89 } |
89 | 90 |
90 void clear() | 91 void clear() |
91 { | 92 { |
92 m_promise.clear(); | 93 m_promise.clear(); |
93 } | 94 } |
94 | 95 |
96 // Creates a pending promise. | |
97 static ScriptPromise create(); | |
98 // Creates a pending promise. | |
99 static ScriptPromise create(ScriptExecutionContext*); | |
abarth-chromium
2013/10/11 18:18:02
Rather than write comments like these, we prefer i
yhirano
2013/10/14 02:49:53
Done.
| |
100 | |
95 private: | 101 private: |
96 ScriptValue m_promise; | 102 ScriptValue m_promise; |
97 }; | 103 }; |
98 | 104 |
99 } // namespace WebCore | 105 } // namespace WebCore |
100 | 106 |
101 | 107 |
102 #endif // ScriptPromise_h | 108 #endif // ScriptPromise_h |
OLD | NEW |