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

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

Issue 922893002: Merge the Sky Engine changes from the SkyDart branch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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 | « sky/engine/bindings2/builtin.cc ('k') | sky/engine/bindings2/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/bindings2/builtin_natives.h" 6 #include "sky/engine/bindings2/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/bindings2/builtin.h" 16 #include "sky/engine/bindings2/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_error.h" 21 #include "sky/engine/tonic/dart_error.h"
21 #include "sky/engine/tonic/dart_isolate_scope.h" 22 #include "sky/engine/tonic/dart_isolate_scope.h"
22 #include "sky/engine/tonic/dart_state.h" 23 #include "sky/engine/tonic/dart_state.h"
23 #include "sky/engine/tonic/dart_value.h" 24 #include "sky/engine/tonic/dart_value.h"
24 #include "sky/engine/wtf/text/WTFString.h" 25 #include "sky/engine/wtf/text/WTFString.h"
25 26
26 namespace blink { 27 namespace blink {
27 28
28 #define REGISTER_FUNCTION(name, count) \ 29 #define REGISTER_FUNCTION(name, count) \
29 { "" #name, name, count }, 30 { "" #name, name, count },
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 Dart_Handle getter_name = ToDart(name); 82 Dart_Handle getter_name = ToDart(name);
82 Dart_Handle closure = Dart_Invoke(builtin_library, getter_name, 0, nullptr); 83 Dart_Handle closure = Dart_Invoke(builtin_library, getter_name, 0, nullptr);
83 DART_CHECK_VALID(closure); 84 DART_CHECK_VALID(closure);
84 return closure; 85 return closure;
85 } 86 }
86 87
87 static void InitDartInternal(Dart_Handle builtin_library) { 88 static void InitDartInternal(Dart_Handle builtin_library) {
88 Dart_Handle print = GetClosure(builtin_library, "_getPrintClosure"); 89 Dart_Handle print = GetClosure(builtin_library, "_getPrintClosure");
89 Dart_Handle timer = GetClosure(builtin_library, "_getCreateTimerClosure"); 90 Dart_Handle timer = GetClosure(builtin_library, "_getCreateTimerClosure");
90 91
91 Dart_Handle internal_library = DartBuiltin::LookupLibrary("dart:_internal") 92 Dart_Handle internal_library = DartBuiltin::LookupLibrary("dart:_internal");
92 93
93 DART_CHECK_VALID(Dart_SetField( 94 DART_CHECK_VALID(Dart_SetField(
94 internal_library, ToDart("_printClosure"), print)); 95 internal_library, ToDart("_printClosure"), print));
95 96
96 Dart_Handle vm_hooks_name = ToDart("VMLibraryHooks"); 97 Dart_Handle vm_hooks_name = ToDart("VMLibraryHooks");
97 Dart_Handle vm_hooks = Dart_GetClass(internal_library, vm_hooks_name); 98 Dart_Handle vm_hooks = Dart_GetClass(internal_library, vm_hooks_name);
98 DART_CHECK_VALID(vm_hooks); 99 DART_CHECK_VALID(vm_hooks);
99 Dart_Handle timer_name = ToDart("timerFactory"); 100 Dart_Handle timer_name = ToDart("timerFactory");
100 DART_CHECK_VALID(Dart_SetField(vm_hooks, timer_name, timer)); 101 DART_CHECK_VALID(Dart_SetField(vm_hooks, timer_name, timer));
101 } 102 }
102 103
103 static void InitAsync(Dart_Handle builtin_library) { 104 static void InitAsync(Dart_Handle builtin_library) {
104 Dart_Handle schedule_microtask = 105 Dart_Handle schedule_microtask =
105 GetClosure(builtin_library, "_getScheduleMicrotaskClosure"); 106 GetClosure(builtin_library, "_getScheduleMicrotaskClosure");
106 Dart_Handle internal_library = DartBuiltin::LookupLibrary("dart:async") 107 Dart_Handle async_library = DartBuiltin::LookupLibrary("dart:async");
107 Dart_Handle set_schedule_microtask = ToDart("_setScheduleImmediateClosure"); 108 Dart_Handle set_schedule_microtask = ToDart("_setScheduleImmediateClosure");
108 DART_CHECK_VALID(Dart_Invoke(async_library, set_schedule_microtask, 1, 109 DART_CHECK_VALID(Dart_Invoke(async_library, set_schedule_microtask, 1,
109 &schedule_microtask)); 110 &schedule_microtask));
110 } 111 }
111 112
112 void BuiltinNatives::Init() { 113 void BuiltinNatives::Init() {
113 Dart_Handle builtin = Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); 114 Dart_Handle builtin = Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary);
114 DART_CHECK_VALID(builtin); 115 DART_CHECK_VALID(builtin);
115 InitDartInternal(builtin); 116 InitDartInternal(builtin);
116 InitAsync(builtin); 117 InitAsync(builtin);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 176
176 void Timer_cancel(Dart_NativeArguments args) { 177 void Timer_cancel(Dart_NativeArguments args) {
177 int64_t timer_id = 0; 178 int64_t timer_id = 0;
178 DART_CHECK_VALID(Dart_GetNativeIntegerArgument(args, 0, &timer_id)); 179 DART_CHECK_VALID(Dart_GetNativeIntegerArgument(args, 0, &timer_id));
179 180
180 DOMDartState* state = DOMDartState::Current(); 181 DOMDartState* state = DOMDartState::Current();
181 DOMTimer::removeByID(state->document(), timer_id); 182 DOMTimer::removeByID(state->document(), timer_id);
182 } 183 }
183 184
184 } // namespace blink 185 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/bindings2/builtin.cc ('k') | sky/engine/bindings2/dart_callback.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698