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

Side by Side Diff: sky/engine/bindings/builtin_natives.cc

Issue 941153003: Add dart_invoke to tonic for calls into App code. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: cr comments Created 5 years, 10 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 | « no previous file | sky/engine/bindings/dart_callback.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sky/engine/config.h" 5 #include "sky/engine/config.h"
6 #include "sky/engine/bindings/builtin_natives.h" 6 #include "sky/engine/bindings/builtin_natives.h"
7 7
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "dart/runtime/include/dart_api.h" 15 #include "dart/runtime/include/dart_api.h"
16 #include "sky/engine/bindings/builtin.h" 16 #include "sky/engine/bindings/builtin.h"
17 #include "sky/engine/core/dom/Microtask.h" 17 #include "sky/engine/core/dom/Microtask.h"
18 #include "sky/engine/core/script/dom_dart_state.h" 18 #include "sky/engine/core/script/dom_dart_state.h"
19 #include "sky/engine/tonic/dart_api_scope.h" 19 #include "sky/engine/tonic/dart_api_scope.h"
20 #include "sky/engine/tonic/dart_builtin.h" 20 #include "sky/engine/tonic/dart_builtin.h"
21 #include "sky/engine/tonic/dart_error.h" 21 #include "sky/engine/tonic/dart_error.h"
22 #include "sky/engine/tonic/dart_invoke.h"
22 #include "sky/engine/tonic/dart_isolate_scope.h" 23 #include "sky/engine/tonic/dart_isolate_scope.h"
23 #include "sky/engine/tonic/dart_state.h" 24 #include "sky/engine/tonic/dart_state.h"
24 #include "sky/engine/tonic/dart_value.h" 25 #include "sky/engine/tonic/dart_value.h"
25 #include "sky/engine/wtf/text/WTFString.h" 26 #include "sky/engine/wtf/text/WTFString.h"
26 27
27 namespace blink { 28 namespace blink {
28 29
29 #define REGISTER_FUNCTION(name, count) \ 30 #define REGISTER_FUNCTION(name, count) \
30 { "" #name, name, count }, 31 { "" #name, name, count },
31 #define DECLARE_FUNCTION(name, count) \ 32 #define DECLARE_FUNCTION(name, count) \
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 #endif 148 #endif
148 } 149 }
149 } 150 }
150 151
151 static void ExecuteMicrotask(base::WeakPtr<DartState> dart_state, 152 static void ExecuteMicrotask(base::WeakPtr<DartState> dart_state,
152 RefPtr<DartValue> callback) { 153 RefPtr<DartValue> callback) {
153 if (!dart_state) 154 if (!dart_state)
154 return; 155 return;
155 DartIsolateScope scope(dart_state->isolate()); 156 DartIsolateScope scope(dart_state->isolate());
156 DartApiScope api_scope; 157 DartApiScope api_scope;
157 LogIfError(Dart_InvokeClosure(callback->dart_value(), 0, nullptr)); 158 DartInvokeAppClosure(callback->dart_value(), 0, nullptr);
158 } 159 }
159 160
160 void ScheduleMicrotask(Dart_NativeArguments args) { 161 void ScheduleMicrotask(Dart_NativeArguments args) {
161 Dart_Handle closure = Dart_GetNativeArgument(args, 0); 162 Dart_Handle closure = Dart_GetNativeArgument(args, 0);
162 if (LogIfError(closure) || !Dart_IsClosure(closure)) 163 if (LogIfError(closure) || !Dart_IsClosure(closure))
163 return; 164 return;
164 DartState* dart_state = DartState::Current(); 165 DartState* dart_state = DartState::Current();
165 Microtask::enqueueMicrotask(base::Bind(&ExecuteMicrotask, 166 Microtask::enqueueMicrotask(base::Bind(&ExecuteMicrotask,
166 dart_state->GetWeakPtr(), DartValue::Create(dart_state, closure))); 167 dart_state->GetWeakPtr(), DartValue::Create(dart_state, closure)));
167 } 168 }
(...skipping 22 matching lines...) Expand all
190 191
191 void Timer_cancel(Dart_NativeArguments args) { 192 void Timer_cancel(Dart_NativeArguments args) {
192 int64_t timer_id = 0; 193 int64_t timer_id = 0;
193 DART_CHECK_VALID(Dart_GetNativeIntegerArgument(args, 0, &timer_id)); 194 DART_CHECK_VALID(Dart_GetNativeIntegerArgument(args, 0, &timer_id));
194 195
195 DOMDartState* state = DOMDartState::Current(); 196 DOMDartState* state = DOMDartState::Current();
196 DOMTimer::removeByID(state->document(), timer_id); 197 DOMTimer::removeByID(state->document(), timer_id);
197 } 198 }
198 199
199 } // namespace blink 200 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | sky/engine/bindings/dart_callback.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698