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

Unified Diff: services/dart/test/echo.dart

Issue 816113004: Dart: Adds a content handler and a test. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Address comments 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
« no previous file with comments | « services/dart/test/BUILD.gn ('k') | services/dart/test/echo_service.mojom » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/dart/test/echo.dart
diff --git a/services/dart/test/echo.dart b/services/dart/test/echo.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a9dc19041a30a57293f42cb326b628f1380eef81
--- /dev/null
+++ b/services/dart/test/echo.dart
@@ -0,0 +1,49 @@
+#!mojo mojo:dart_content_handler
+
+// 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.
+
+import 'dart:async';
+import 'dart:mojo_application';
+import 'dart:mojo_bindings';
+import 'dart:mojo_core';
+
+import 'package:services/dart/test/echo_service.mojom.dart';
+
+// TODO(zra): Interface implementations that delegate to another implementation
+// will all look the same, more or less. Maybe we should generate them?
+class EchoServiceImpl extends EchoServiceInterface {
+ EchoServiceInterface _delegate;
+
+ EchoServiceImpl(this._delegate, MojoMessagePipeEndpoint endpoint) :
+ super(endpoint);
+
+ echoString(String value) => _delegate.echoString(value);
+}
+
+class EchoApplication extends Application implements EchoServiceInterface {
+ EchoApplication(MojoMessagePipeEndpoint endpoint) : super(endpoint);
+
+ EchoApplication.fromHandle(MojoHandle handle) : super.fromHandle(handle);
+
+ Function interfaceFactoryClosure() {
+ return (endpoint) => new EchoServiceImpl(this, endpoint);
+ }
+
+ echoString(String value) {
+ var response = new EchoServiceEchoStringResponseParams();
+ if (value == 'quit') {
+ close();
+ }
+ response.value = value;
+ return new Future.value(response);
+ }
+}
+
+main(List args) {
+ MojoHandle shellHandle = new MojoHandle(args[0]);
+ String url = args[1];
+ var echoApplication = new EchoApplication.fromHandle(shellHandle);
+ echoApplication.listen();
+}
« no previous file with comments | « services/dart/test/BUILD.gn ('k') | services/dart/test/echo_service.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698