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

Side by Side Diff: Source/bindings/v8/ThenableCoercions.h

Issue 24403002: [ABANDONED] Implement ThenableCoercions for AP2 Promises (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 2 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
« no previous file with comments | « Source/bindings/bindings.gypi ('k') | Source/bindings/v8/ThenableCoercions.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2013, Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24
25 #ifndef ThenableCoercions_h
26 #define ThenableCoercions_h
27
28 #include "bindings/v8/ScopedPersistent.h"
29 #include "wtf/Assertions.h"
30 #include "wtf/DoublyLinkedList.h"
31 #include "wtf/Noncopyable.h"
32 #include "wtf/PassOwnPtr.h"
33 #include "wtf/Vector.h"
34
35 #include <v8.h>
36
37 namespace WebCore {
38
39 class ThenableCoercions {
40 WTF_MAKE_NONCOPYABLE(ThenableCoercions);
41 public:
42 static PassOwnPtr<ThenableCoercions> create();
43
44 ~ThenableCoercions();
45
46 bool has(v8::Handle<v8::Object> thenable);
47 v8::Handle<v8::Object> get(v8::Handle<v8::Object> thenable);
48 void set(v8::Handle<v8::Object> thenable, v8::Handle<v8::Object> promise, v8 ::Isolate*);
49
50 private:
51 ThenableCoercions();
52
53 class Entry : public DoublyLinkedListNode<Entry> {
54 WTF_MAKE_NONCOPYABLE(Entry);
55 friend class DoublyLinkedListNode<Entry>;
56 public:
57 static Entry* create(v8::Handle<v8::Object> thenable, v8::Handle<v8::Obj ect> promise, ThenableCoercions* thenableCoercions, v8::Isolate* isolate)
58 {
59 return new Entry(thenable, promise, thenableCoercions, isolate);
60 }
61
62 v8::Local<v8::Object> thenable()
63 {
64 return m_thenable.newLocal(m_isolate);
65 }
66
67 v8::Local<v8::Object> promise()
68 {
69 return m_promise.newLocal(m_isolate);
70 }
71
72 private:
73 Entry(v8::Handle<v8::Object> thenable, v8::Handle<v8::Object> promise, T henableCoercions*, v8::Isolate*);
74
75 static void makeWeakCallback(v8::Isolate*, v8::Persistent<v8::Object>* t henable, Entry*);
76
77 Entry* m_next;
78 Entry* m_prev;
79 ScopedPersistent<v8::Object> m_thenable;
80 ScopedPersistent<v8::Object> m_promise;
81 ThenableCoercions* m_thenableCoercions;
82 v8::Isolate* m_isolate;
83 };
84
85 class GuardEntriesListAgainstGC {
86 WTF_MAKE_NONCOPYABLE(GuardEntriesListAgainstGC);
87 public:
88 GuardEntriesListAgainstGC(ThenableCoercions*);
89 ~GuardEntriesListAgainstGC();
90
91 private:
92 ThenableCoercions* m_thenableCoercions;
93 };
94
95 friend class Entry;
96 friend class GuardEntriesListAgainstGC;
97
98 void tryToDelete(Entry*);
99 void deleteInternal(Entry*);
100
101 DoublyLinkedList<Entry> m_entries;
102 Vector<Entry*> m_entriesToDelete;
103 bool m_entriesListGuarded : 1;
104 };
105
106 } // namespace WebCore
107
108 #endif // ThenableCoercions_h
OLDNEW
« no previous file with comments | « Source/bindings/bindings.gypi ('k') | Source/bindings/v8/ThenableCoercions.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698