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

Unified Diff: runtime/bin/namespace_patch.dart

Issue 3001963002: [dart:io] Namespaces for file IO (Closed)
Patch Set: Fuchsia fix Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/namespace_macos.cc ('k') | runtime/bin/namespace_unsupported.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/namespace_patch.dart
diff --git a/runtime/bin/namespace_patch.dart b/runtime/bin/namespace_patch.dart
new file mode 100644
index 0000000000000000000000000000000000000000..8fc6463b38d35111e5b8032908bf74ec61e66605
--- /dev/null
+++ b/runtime/bin/namespace_patch.dart
@@ -0,0 +1,45 @@
+// Copyright (c) 2017, 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.
+
+class _NamespaceImpl extends NativeFieldWrapperClass1 implements _Namespace {
+ _NamespaceImpl._();
+
+ static _NamespaceImpl _create(_NamespaceImpl namespace, var n)
+ native "Namespace_Create";
+ static int _getPointer(_NamespaceImpl namespace)
+ native "Namespace_GetPointer";
+ static int _getDefault() native "Namespace_GetDefault";
+
+ // If the platform supports "namespaces", this method is called by the
+ // embedder with the platform-specific namespace information.
+ static _NamespaceImpl _cachedNamespace = null;
+ static void _setupNamespace(var namespace) {
+ _cachedNamespace = _create(new _NamespaceImpl._(), namespace);
+ }
+
+ static _NamespaceImpl get _namespace {
+ if (_cachedNamespace == null) {
+ // The embedder has not supplied a namespace before one is needed, so
+ // instead use a safe-ish default value.
+ _cachedNamespace = _create(new _NamespaceImpl._(), _getDefault());
+ }
+ return _cachedNamespace;
+ }
+
+ static int get _namespacePointer => _getPointer(_namespace);
+}
+
+@patch
+class _Namespace {
+ @patch
+ static void _setupNamespace(var namespace) {
+ _NamespaceImpl._setupNamespace(namespace);
+ }
+
+ @patch
+ static _Namespace get _namespace => _NamespaceImpl._namespace;
+
+ @patch
+ static int get _namespacePointer => _NamespaceImpl._namespacePointer;
+}
« no previous file with comments | « runtime/bin/namespace_macos.cc ('k') | runtime/bin/namespace_unsupported.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698