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

Unified Diff: tonic/dart_gc_controller.cc

Issue 1244493002: Wholesale move sky/engine/tonic to tonic (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tonic/dart_gc_controller.h ('k') | tonic/dart_gc_visitor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tonic/dart_gc_controller.cc
diff --git a/tonic/dart_gc_controller.cc b/tonic/dart_gc_controller.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4b3505924641b1e6baa4f7271f9acfb7e7417556
--- /dev/null
+++ b/tonic/dart_gc_controller.cc
@@ -0,0 +1,52 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "tonic/dart_gc_controller.h"
+
+#include "base/trace_event/trace_event.h"
+#include "dart/runtime/include/dart_api.h"
+#include "tonic/dart_gc_context.h"
+#include "tonic/dart_gc_visitor.h"
+#include "tonic/dart_wrappable.h"
+
+namespace blink {
+namespace {
+
+DartGCContext* g_gc_context = nullptr;
+
+DartWrappable* GetWrappable(intptr_t* fields) {
+ return reinterpret_cast<DartWrappable*>(fields[DartWrappable::kPeerIndex]);
+}
+
+void Visit(void* isolate_callback_data,
+ Dart_WeakPersistentHandle handle,
+ intptr_t native_field_count,
+ intptr_t* native_fields) {
+ if (!native_field_count)
+ return;
+ DCHECK(native_field_count == DartWrappable::kNumberOfNativeFields);
+ DartGCVisitor visitor(g_gc_context);
+ GetWrappable(native_fields)->AcceptDartGCVisitor(visitor);
+}
+
+} // namespace
+
+void DartGCPrologue() {
+ TRACE_EVENT_ASYNC_BEGIN0("sky", "DartGC", 0);
+
+ Dart_EnterScope();
+ DCHECK(!g_gc_context);
+ g_gc_context = new DartGCContext();
+ Dart_VisitPrologueWeakHandles(Visit);
+}
+
+void DartGCEpilogue() {
+ delete g_gc_context;
+ g_gc_context = nullptr;
+ Dart_ExitScope();
+
+ TRACE_EVENT_ASYNC_END0("sky", "DartGC", 0);
+}
+
+} // namespace blink
« no previous file with comments | « tonic/dart_gc_controller.h ('k') | tonic/dart_gc_visitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698