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

Unified Diff: runtime/bin/native_service.cc

Issue 12328037: Add missing files from previous commit (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | « runtime/bin/native_service.h ('k') | sdk/lib/io/file_system_entity.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/native_service.cc
diff --git a/runtime/bin/native_service.cc b/runtime/bin/native_service.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9d4c3e86d728da7fd02f8ac1f9e7fee2865f81ba
--- /dev/null
+++ b/runtime/bin/native_service.cc
@@ -0,0 +1,40 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#include "bin/native_service.h"
+
+#include "platform/globals.h"
+#include "bin/thread.h"
+
+
+NativeService::NativeService(const char* name,
+ Dart_NativeMessageHandler handler,
+ int number_of_ports)
+ : name_(name),
+ handler_(handler),
+ service_ports_size_(number_of_ports),
+ service_ports_index_(0) {
+ service_ports_ = new Dart_Port[service_ports_size_];
+ for (int i = 0; i < service_ports_size_; i++) {
+ service_ports_[i] = ILLEGAL_PORT;
+ }
+}
+
+
+NativeService::~NativeService() {
+ delete[] service_ports_;
+}
+
+
+Dart_Port NativeService::GetServicePort() {
+ MutexLocker lock(&mutex_);
+ Dart_Port result = service_ports_[service_ports_index_];
+ if (result == ILLEGAL_PORT) {
+ result = Dart_NewNativePort(name_, handler_, true);
+ ASSERT(result != ILLEGAL_PORT);
+ service_ports_[service_ports_index_] = result;
+ }
+ service_ports_index_ = (service_ports_index_ + 1) % service_ports_size_;
+ return result;
+}
« no previous file with comments | « runtime/bin/native_service.h ('k') | sdk/lib/io/file_system_entity.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698