| OLD | NEW |
| 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/bindings/builtin_natives.h" | 5 #include "sky/engine/bindings/builtin_natives.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 | 10 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 DART_CHECK_VALID(Dart_GetNativeIntegerArgument(args, 0, &milliseconds)); | 203 DART_CHECK_VALID(Dart_GetNativeIntegerArgument(args, 0, &milliseconds)); |
| 204 Dart_Handle closure = Dart_GetNativeArgument(args, 1); | 204 Dart_Handle closure = Dart_GetNativeArgument(args, 1); |
| 205 DART_CHECK_VALID(closure); | 205 DART_CHECK_VALID(closure); |
| 206 CHECK(Dart_IsClosure(closure)); | 206 CHECK(Dart_IsClosure(closure)); |
| 207 bool repeating = false; | 207 bool repeating = false; |
| 208 DART_CHECK_VALID(Dart_GetNativeBooleanArgument(args, 2, &repeating)); | 208 DART_CHECK_VALID(Dart_GetNativeBooleanArgument(args, 2, &repeating)); |
| 209 | 209 |
| 210 DartState* state = DartState::Current(); | 210 DartState* state = DartState::Current(); |
| 211 CHECK(state); | 211 CHECK(state); |
| 212 | 212 |
| 213 OwnPtr<DartTimerHeap::Task> task = adoptPtr(new DartTimerHeap::Task); | 213 std::unique_ptr<DartTimerHeap::Task> task = |
| 214 std::unique_ptr<DartTimerHeap::Task>(new DartTimerHeap::Task); |
| 214 task->closure.Set(state, closure); | 215 task->closure.Set(state, closure); |
| 215 task->delay = base::TimeDelta::FromMilliseconds(milliseconds); | 216 task->delay = base::TimeDelta::FromMilliseconds(milliseconds); |
| 216 task->repeating = repeating; | 217 task->repeating = repeating; |
| 217 | 218 |
| 218 int timer_id = state->timer_heap().Add(task.release()); | 219 int timer_id = state->timer_heap().Add(std::move(task)); |
| 219 Dart_SetIntegerReturnValue(args, timer_id); | 220 Dart_SetIntegerReturnValue(args, timer_id); |
| 220 } | 221 } |
| 221 | 222 |
| 222 void Timer_cancel(Dart_NativeArguments args) { | 223 void Timer_cancel(Dart_NativeArguments args) { |
| 223 int64_t timer_id = 0; | 224 int64_t timer_id = 0; |
| 224 DART_CHECK_VALID(Dart_GetNativeIntegerArgument(args, 0, &timer_id)); | 225 DART_CHECK_VALID(Dart_GetNativeIntegerArgument(args, 0, &timer_id)); |
| 225 | 226 |
| 226 DartState* state = DartState::Current(); | 227 DartState* state = DartState::Current(); |
| 227 CHECK(state); | 228 CHECK(state); |
| 228 state->timer_heap().Remove(timer_id); | 229 state->timer_heap().Remove(timer_id); |
| 229 } | 230 } |
| 230 | 231 |
| 231 } // namespace blink | 232 } // namespace blink |
| OLD | NEW |