OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 RefPtr<DartEventListener> listener = adoptRef(new DartEventListener()); | 65 RefPtr<DartEventListener> listener = adoptRef(new DartEventListener()); |
66 listener->m_isolate = Dart_CurrentIsolate(); | 66 listener->m_isolate = Dart_CurrentIsolate(); |
67 listener->m_listener = Dart_NewPrologueWeakPersistentHandle(closure, listene
r.get(), &weakCallback); | 67 listener->m_listener = Dart_NewPrologueWeakPersistentHandle(closure, listene
r.get(), &weakCallback); |
68 result = Dart_SetPeer(closure, listener.get()); | 68 result = Dart_SetPeer(closure, listener.get()); |
69 ASSERT(!Dart_IsError(result)); | 69 ASSERT(!Dart_IsError(result)); |
70 listener->ref(); | 70 listener->ref(); |
71 return listener.get(); | 71 return listener.get(); |
72 } | 72 } |
73 | 73 |
74 void DartEventListener::weakCallback(Dart_WeakPersistentHandle handle, void* pee
r) | 74 void DartEventListener::weakCallback(Dart_Isolate isolate, Dart_WeakPersistentHa
ndle handle, void* peer) |
75 { | 75 { |
76 DartEventListener* listener = static_cast<DartEventListener*>(peer); | 76 DartEventListener* listener = static_cast<DartEventListener*>(peer); |
77 listener->m_listener = 0; | 77 listener->m_listener = 0; |
78 listener->deref(); | 78 listener->deref(); |
79 } | 79 } |
80 | 80 |
81 void DartEventListener::handleEvent(ExecutionContext* context, Event* event) | 81 void DartEventListener::handleEvent(ExecutionContext* context, Event* event) |
82 { | 82 { |
83 if (!m_listener) | 83 if (!m_listener) |
84 return; | 84 return; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 138 |
139 DartController* dartController = DartController::retrieve(context); | 139 DartController* dartController = DartController::retrieve(context); |
140 if (!dartController) | 140 if (!dartController) |
141 return Dart_NewApiError("Internal error: failed to fetch Dart controller
"); | 141 return Dart_NewApiError("Internal error: failed to fetch Dart controller
"); |
142 | 142 |
143 Dart_Handle parameters[1] = { dartEvent }; | 143 Dart_Handle parameters[1] = { dartEvent }; |
144 return dartController->callFunction(listener, 1, parameters); | 144 return dartController->callFunction(listener, 1, parameters); |
145 } | 145 } |
146 | 146 |
147 } | 147 } |
OLD | NEW |