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

Unified Diff: sky/engine/bindings2/dart_event_listener.h

Issue 918333002: Add the c++ code part of bindings2/ (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Updated per earlier reviews 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/engine/bindings2/dart_callback.cc ('k') | sky/engine/bindings2/dart_event_listener.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/bindings2/dart_event_listener.h
diff --git a/sky/engine/bindings2/dart_event_listener.h b/sky/engine/bindings2/dart_event_listener.h
new file mode 100644
index 0000000000000000000000000000000000000000..2b3d6fdf867102d9889a4cf287cc9f7de4fa8f1c
--- /dev/null
+++ b/sky/engine/bindings2/dart_event_listener.h
@@ -0,0 +1,64 @@
+// 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.
+
+#ifndef SKY_ENGINE_BINDINGS2_DART_EVENT_LISTENER_H_
+#define SKY_ENGINE_BINDINGS2_DART_EVENT_LISTENER_H_
+
+#include "dart/runtime/include/dart_api.h"
+#include "sky/engine/core/events/EventListener.h"
+#include "sky/engine/wtf/PassRefPtr.h"
+#include "sky/engine/tonic/dart_converter.h"
+
+namespace blink {
+
+class DartEventListener : public EventListener {
+ public:
+ static PassRefPtr<DartEventListener> FromDart(Dart_Handle handle);
+
+ ~DartEventListener() override;
+
+ bool operator==(const EventListener& other) override {
+ return this == &other;
+ }
+ void handleEvent(ExecutionContext*, Event*) override;
+
+ void AcceptDartGCVisitor(DartGCVisitor& visitor) const override;
+
+ private:
+ explicit DartEventListener(Dart_Handle handle);
+
+ static void Finalize(void* isolate_callback_data,
+ Dart_WeakPersistentHandle handle,
+ void* peer);
+
+ base::WeakPtr<DartState> data_state_;
+ Dart_WeakPersistentHandle closure_;
+};
+
+template <>
+struct DartConverter<EventListener*> {
+ static PassRefPtr<EventListener> FromDart(Dart_Handle handle) {
+ return DartEventListener::FromDart(handle);
+ }
+
+ static PassRefPtr<EventListener> FromArguments(Dart_NativeArguments args,
+ int index,
+ Dart_Handle& exception) {
+ return FromDart(Dart_GetNativeArgument(args, index));
+ }
+
+ static PassRefPtr<EventListener> FromArgumentsWithNullCheck(
+ Dart_NativeArguments args,
+ int index,
+ Dart_Handle& exception) {
+ Dart_Handle handle = Dart_GetNativeArgument(args, index);
+ if (Dart_IsNull(handle))
+ return nullptr;
+ return FromDart(handle);
+ }
+};
+
+} // namespace blink
+
+#endif // SKY_ENGINE_BINDINGS2_DART_EVENT_LISTENER_H_
« no previous file with comments | « sky/engine/bindings2/dart_callback.cc ('k') | sky/engine/bindings2/dart_event_listener.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698