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

Unified Diff: mojo/public/dart/src/service_provider.dart

Issue 816113004: Dart: Adds a content handler and a test. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
Index: mojo/public/dart/src/service_provider.dart
diff --git a/mojo/public/dart/src/service_provider.dart b/mojo/public/dart/src/service_provider.dart
new file mode 100644
index 0000000000000000000000000000000000000000..2ed507106be0c13eb493b3223e8c34eea3e63df2
--- /dev/null
+++ b/mojo/public/dart/src/service_provider.dart
@@ -0,0 +1,30 @@
+// Copyright 2014 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.
+
+part of bindings;
+
+typedef Interface InterfaceFactory(core.MojoMessagePipeEndpoint endpoint);
+
+class ServiceProvider extends service_provider.ServiceProviderInterface {
+ InterfaceFactory _interfaceFactory;
+ List<Interface> _interfaces;
+
+ ServiceProvider(core.MojoMessagePipeEndpoint endpoint,
+ InterfaceFactory interfaceFactory) :
+ _interfaceFactory = interfaceFactory,
+ _interfaces = [],
+ super(endpoint);
+
+ connectToService(String interfaceName, core.MojoHandle pipe) {
+ var endpoint = new core.MojoMessagePipeEndpoint(pipe);
+ var interfaceImpl = _interfaceFactory(endpoint);
+ interfaceImpl.listen();
+ _interfaces.add(interfaceImpl);
+ }
+
+ void close() {
+ _interfaces.forEach((i) => i.close());
+ super.close();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698