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

Side by Side Diff: Source/bindings/core/v8/CallbackPromiseAdapter.h

Issue 779563003: [POC-WIP] Link window focus tokens with ExecutionContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 public: 113 public:
114 explicit CallbackPromiseAdapter(PassRefPtr<ScriptPromiseResolver> resolver) 114 explicit CallbackPromiseAdapter(PassRefPtr<ScriptPromiseResolver> resolver)
115 : m_resolver(resolver) 115 : m_resolver(resolver)
116 { 116 {
117 ASSERT(m_resolver); 117 ASSERT(m_resolver);
118 } 118 }
119 virtual ~CallbackPromiseAdapter() { } 119 virtual ~CallbackPromiseAdapter() { }
120 120
121 virtual void onSuccess() override 121 virtual void onSuccess() override
122 { 122 {
123 if (!m_resolver->executionContext() || m_resolver->executionContext()->a ctiveDOMObjectsAreStopped()) { 123 if (!m_resolver->executionContext() || m_resolver->executionContext()->a ctiveDOMObjectsAreStopped())
124 return; 124 return;
125 }
126 m_resolver->resolve(V8UndefinedType()); 125 m_resolver->resolve(V8UndefinedType());
127 } 126 }
128 127
129 virtual void onError(typename T::WebType* error) override 128 virtual void onError(typename T::WebType* error) override
129 {
130 if (!m_resolver->executionContext() || m_resolver->executionContext()->a ctiveDOMObjectsAreStopped()) {
131 T::dispose(error);
132 return;
133 }
134 m_resolver->reject(T::take(m_resolver.get(), error));
135 }
136
137 private:
138 RefPtr<ScriptPromiseResolver> m_resolver;
139 WTF_MAKE_NONCOPYABLE(CallbackPromiseAdapter);
140 };
141
142 template<typename T>
143 class CallbackPromiseAdapter<bool, T> final : public blink::WebCallbacks<bool, t ypename T::WebType> {
144 public:
145 explicit CallbackPromiseAdapter(PassRefPtr<ScriptPromiseResolver> resolver)
146 : m_resolver(resolver)
147 {
148 ASSERT(m_resolver);
149 }
150 virtual ~CallbackPromiseAdapter() { }
151
152 virtual void onSuccess(bool* result) override
153 {
154 if (!m_resolver->executionContext() || m_resolver->executionContext()->a ctiveDOMObjectsAreStopped())
155 return;
156 m_resolver->resolve(*result);
157 }
158
159 virtual void onError(typename T::WebType* error) override
130 { 160 {
131 if (!m_resolver->executionContext() || m_resolver->executionContext()->a ctiveDOMObjectsAreStopped()) { 161 if (!m_resolver->executionContext() || m_resolver->executionContext()->a ctiveDOMObjectsAreStopped()) {
132 T::dispose(error); 162 T::dispose(error);
133 return; 163 return;
134 } 164 }
135 m_resolver->reject(T::take(m_resolver.get(), error)); 165 m_resolver->reject(T::take(m_resolver.get(), error));
136 } 166 }
137 167
138 private: 168 private:
139 RefPtr<ScriptPromiseResolver> m_resolver; 169 RefPtr<ScriptPromiseResolver> m_resolver;
140 WTF_MAKE_NONCOPYABLE(CallbackPromiseAdapter); 170 WTF_MAKE_NONCOPYABLE(CallbackPromiseAdapter);
141 }; 171 };
142 172
143 } // namespace blink 173 } // namespace blink
144 174
145 #endif 175 #endif
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/serviceworker/resources/client-focus.js ('k') | Source/core/dom/ExecutionContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698