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

Side by Side Diff: runtime/bin/eventhandler.cc

Issue 22303002: Auto create ApiLocalScope before calling native functions, this ensures that (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "bin/dartutils.h" 5 #include "bin/dartutils.h"
6 #include "bin/eventhandler.h" 6 #include "bin/eventhandler.h"
7 #include "bin/socket.h" 7 #include "bin/socket.h"
8 #include "bin/thread.h" 8 #include "bin/thread.h"
9 9
10 #include "include/dart_api.h" 10 #include "include/dart_api.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 event_handler = EventHandler::Start(); 82 event_handler = EventHandler::Start();
83 } 83 }
84 84
85 85
86 /* 86 /*
87 * Send data to the EventHandler thread to register for a given instance 87 * Send data to the EventHandler thread to register for a given instance
88 * args[1] a ReceivePort args[2] with a notification event args[3]. args[0] 88 * args[1] a ReceivePort args[2] with a notification event args[3]. args[0]
89 * holds the reference to the dart EventHandler object. 89 * holds the reference to the dart EventHandler object.
90 */ 90 */
91 void FUNCTION_NAME(EventHandler_SendData)(Dart_NativeArguments args) { 91 void FUNCTION_NAME(EventHandler_SendData)(Dart_NativeArguments args) {
92 Dart_EnterScope();
93 Dart_Handle sender = Dart_GetNativeArgument(args, 1); 92 Dart_Handle sender = Dart_GetNativeArgument(args, 1);
94 intptr_t id = kInvalidId; 93 intptr_t id = kInvalidId;
95 if (Dart_IsNull(sender)) { 94 if (Dart_IsNull(sender)) {
96 id = kTimerId; 95 id = kTimerId;
97 } else { 96 } else {
98 Socket::GetSocketIdNativeField(sender, &id); 97 Socket::GetSocketIdNativeField(sender, &id);
99 } 98 }
100 Dart_Handle handle = Dart_GetNativeArgument(args, 2); 99 Dart_Handle handle = Dart_GetNativeArgument(args, 2);
101 Dart_Port dart_port = 100 Dart_Port dart_port =
102 DartUtils::GetIntegerField(handle, DartUtils::kIdFieldName); 101 DartUtils::GetIntegerField(handle, DartUtils::kIdFieldName);
103 int64_t data = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 3)); 102 int64_t data = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 3));
104 { 103 {
105 MutexLocker locker(mutex_); 104 MutexLocker locker(mutex_);
106 // Only send if the event_handler is not NULL. This means that the handler 105 // Only send if the event_handler is not NULL. This means that the handler
107 // shut down, and a message is send later on. 106 // shut down, and a message is send later on.
108 if (event_handler != NULL) { 107 if (event_handler != NULL) {
109 event_handler->SendData(id, dart_port, data); 108 event_handler->SendData(id, dart_port, data);
110 } 109 }
111 } 110 }
112 Dart_ExitScope();
113 } 111 }
114 112
115 } // namespace bin 113 } // namespace bin
116 } // namespace dart 114 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/directory.cc ('k') | runtime/bin/file.cc » ('j') | runtime/vm/ast.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698