[cleanup] remove intent_handler and lifecycle
Change-Id: I6457c7601315d97a425c233516258a96dcd5fd41
diff --git a/public/lib/intent_handler/dart/BUILD.gn b/public/lib/intent_handler/dart/BUILD.gn
deleted file mode 100644
index 2aa6af3..0000000
--- a/public/lib/intent_handler/dart/BUILD.gn
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright 2018 The Fuchsia 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("//build/dart/dart_library.gni")
-
-dart_library("dart") {
- package_name = "lib.intent_handler.dart"
-
- sdk_category = "partner"
-
- sources = [
- "intent_handler.dart",
- "src/intent_handler_impl.dart",
- ]
-
- deps = [
- "//sdk/fidl/fuchsia.modular",
- "//topaz/public/dart/fidl",
- "//topaz/public/lib/app/dart",
- ]
-}
diff --git a/public/lib/intent_handler/dart/analysis_options.yaml b/public/lib/intent_handler/dart/analysis_options.yaml
deleted file mode 100644
index 54917c0..0000000
--- a/public/lib/intent_handler/dart/analysis_options.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2017 The Fuchsia Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-include: ../../../analysis_options.yaml
diff --git a/public/lib/intent_handler/dart/lib/intent_handler.dart b/public/lib/intent_handler/dart/lib/intent_handler.dart
deleted file mode 100644
index d490d03..0000000
--- a/public/lib/intent_handler/dart/lib/intent_handler.dart
+++ /dev/null
@@ -1,5 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-export 'src/intent_handler_impl.dart';
diff --git a/public/lib/intent_handler/dart/lib/src/intent_handler_impl.dart b/public/lib/intent_handler/dart/lib/src/intent_handler_impl.dart
deleted file mode 100644
index 178cddd..0000000
--- a/public/lib/intent_handler/dart/lib/src/intent_handler_impl.dart
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright 2018 The Fuchsia 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 'package:fidl/fidl.dart';
-import 'package:fidl_fuchsia_modular/fidl.dart' as fidl;
-import 'package:lib.app.dart/app.dart';
-import 'package:lib.app.dart/logging.dart';
-import 'package:meta/meta.dart';
-
-/// Callback for [IntentHandler#handleIntent].
-typedef HandleIntentCallback = void Function(fidl.Intent intent);
-
-/// Impl for [fidl.IntentHandler].
-class IntentHandlerImpl extends fidl.IntentHandler {
- /// Callback for when the system calls [handleIntent].
- final HandleIntentCallback onHandleIntent;
-
- var _intentHandlerBinding = fidl.IntentHandlerBinding();
-
- /// Creates an [fidl.IntentHandler] which calls [onHandleIntent] when a
- /// new intent is received from the framework.
- IntentHandlerImpl({
- @required this.onHandleIntent,
- }) : assert(onHandleIntent != null) {
- _intentHandlerBinding
- ..onBind = _handleBind
- ..onClose = _handleClose
- ..onConnectionError = _handleConnectionError
- ..onUnbind = _handleUnbind;
- }
-
- @override
- void handleIntent(fidl.Intent intent) {
- onHandleIntent(intent);
- }
-
- /// Adds an [fidl.IntentHandler] service to the outgoing services of [startupContext].
- void addService({
- @required StartupContext startupContext,
- }) {
- assert(startupContext != null);
-
- log.fine('starting intent handler');
-
- if (_intentHandlerBinding.isBound) {
- log.warning('Intent handler has already been bound.');
- return;
- }
-
- startupContext.outgoingServices.addServiceForName(
- (InterfaceRequest<fidl.IntentHandler> request) {
- try {
- _intentHandlerBinding = fidl.IntentHandlerBinding()
- ..bind(this, request);
- } on Exception catch (err, stackTrace) {
- log.warning('Intent handler connection died', err, stackTrace);
- }
- },
- fidl.IntentHandler.$serviceName,
- );
- }
-
- void _handleConnectionError() {
- log.fine(
- 'Intent handler connection died: ${_intentHandlerBinding.isBound}');
- }
-
- void _handleBind() {
- log.fine('Intent handler bound');
- }
-
- void _handleUnbind() {
- log.fine('Intent handler unbound');
- }
-
- void _handleClose() {
- log.fine('Intent handler closed');
- }
-}
diff --git a/public/lib/intent_handler/dart/pubspec.yaml b/public/lib/intent_handler/dart/pubspec.yaml
deleted file mode 100644
index 1dffd03..0000000
--- a/public/lib/intent_handler/dart/pubspec.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2018 The Fuchsia Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-name: intent_handler
diff --git a/public/lib/lifecycle/dart/BUILD.gn b/public/lib/lifecycle/dart/BUILD.gn
deleted file mode 100644
index 6f0bb34..0000000
--- a/public/lib/lifecycle/dart/BUILD.gn
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright 2018 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("//build/dart/dart_library.gni")
-
-dart_library("dart") {
- package_name = "lib.lifecycle.dart"
-
- sdk_category = "partner"
-
- sources = [
- "lifecycle.dart",
- "src/lifecycle_host.dart",
- "src/lifecycle_impl.dart",
- ]
-
- deps = [
- "//sdk/fidl/fuchsia.modular",
- "//topaz/public/dart/fidl",
- "//topaz/public/lib/app/dart",
- ]
-}
diff --git a/public/lib/lifecycle/dart/analysis_options.yaml b/public/lib/lifecycle/dart/analysis_options.yaml
deleted file mode 100644
index 54917c0..0000000
--- a/public/lib/lifecycle/dart/analysis_options.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2017 The Fuchsia Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-include: ../../../analysis_options.yaml
diff --git a/public/lib/lifecycle/dart/lib/lifecycle.dart b/public/lib/lifecycle/dart/lib/lifecycle.dart
deleted file mode 100644
index 12693c1..0000000
--- a/public/lib/lifecycle/dart/lib/lifecycle.dart
+++ /dev/null
@@ -1,6 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-export 'src/lifecycle_host.dart';
-export 'src/lifecycle_impl.dart';
diff --git a/public/lib/lifecycle/dart/lib/src/lifecycle_host.dart b/public/lib/lifecycle/dart/lib/src/lifecycle_host.dart
deleted file mode 100644
index d891c66..0000000
--- a/public/lib/lifecycle/dart/lib/src/lifecycle_host.dart
+++ /dev/null
@@ -1,130 +0,0 @@
-// Copyright 2018 The Fuchsia 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 'package:fidl/fidl.dart';
-import 'package:fidl_fuchsia_modular/fidl.dart' as fidl;
-import 'package:lib.app.dart/app.dart';
-import 'package:lib.app.dart/logging.dart';
-import 'package:meta/meta.dart';
-
-import 'lifecycle_impl.dart';
-
-export 'package:lib.app.dart/app.dart' show ServiceProviderImpl;
-
-/// Hosts a [LifecycleImpl] and manages the underlying [binding] connection.
-class LifecycleHost {
- /// The underlying [Binding] that connects the [impl] to client requests.
- final fidl.LifecycleBinding binding = fidl.LifecycleBinding();
-
- /// Callback for when the system starts to shutdown this process.
- final LifecycleTerminateCallback onTerminate;
-
- /// The underlying impl that handles client requests by delegating to
- /// the [onTerminate] callback.
- LifecycleImpl impl;
-
- /// Constructor.
- LifecycleHost({
- @required this.onTerminate,
- }) : assert(onTerminate != null) {
- impl = LifecycleImpl(
- onTerminate: _handleTerminate,
- );
-
- binding
- ..onBind = _handleBind
- ..onClose = _handleClose
- ..onConnectionError = _handleConnectionError
- ..onUnbind = _handleUnbind;
- }
-
- Completer<Null> _addService;
-
- /// Connect this LifecycleHost's impl to the
- /// [StartupContext#outgoingServices].
- Future<Null> addService({
- @required StartupContext startupContext,
- }) {
- assert(startupContext != null);
-
- log.fine('starting lifecycle host');
-
- // Do not create an error by rebinding if, for some reason, this method has been called already.
- if (_addService != null) {
- Exception err =
- Exception('#addService() should only be called once.');
- _addService.completeError(err);
- return _addService.future;
- } else {
- _addService = Completer<Null>();
- }
-
- startupContext.outgoingServices.addServiceForName(
- (InterfaceRequest<fidl.Lifecycle> request) {
- try {
- binding.bind(impl, request);
- } on Exception catch (err, stackTrace) {
- _addService.completeError(err, stackTrace);
- }
-
- // There is no async way to hook into a success path once the lifecycle
- // service has been added. Additionally, errors can occur on the underlying
- // binding at anytime. Use a microtask to check for the future being
- // completed (with an error via _handleConnectionError) and complete
- // successfully if it hasn't.
- scheduleMicrotask(() {
- if (!_addService.isCompleted) {
- _addService.complete(null);
- }
- });
- },
- fidl.Lifecycle.$serviceName,
- );
-
- return _addService.future;
- }
-
- void _handleConnectionError() {
- Exception err = Exception('binding connection failed');
-
- if (_addService != null && !_addService.isCompleted) {
- _addService.completeError(err);
- return;
- }
-
- // NOTE: this should be very a rare case.
- log.warning('binding connection failed outside of async control flow.');
- throw err;
- }
-
- void _handleBind() {
- log.fine('binding ready');
- }
-
- void _handleUnbind() {
- log.fine('binding unbound');
- }
-
- void _handleClose() {
- log.fine('binding closed');
- }
-
- Future<Null> _handleTerminate() async {
- await Future.wait(<Future<Null>>[
- terminate(),
- onTerminate(),
- ]);
- }
-
- /// Closes the underlying binding, usually called as a direct effect of
- /// Lifecycle::terminate (see https://goo.gl/MmZ2dc) being triggered by the
- /// framework.
- Future<Null> terminate() async {
- log.fine('terminate called, closing $binding');
- binding.close();
- return null;
- }
-}
diff --git a/public/lib/lifecycle/dart/lib/src/lifecycle_impl.dart b/public/lib/lifecycle/dart/lib/src/lifecycle_impl.dart
deleted file mode 100644
index 1ec17ea..0000000
--- a/public/lib/lifecycle/dart/lib/src/lifecycle_impl.dart
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2018 The Fuchsia 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 'package:fuchsia/fuchsia.dart' as fuchsia;
-import 'package:fidl_fuchsia_modular/fidl.dart' as fidl;
-import 'package:meta/meta.dart';
-
-/// Callback for [LifecycleImpl#onTerminate].
-typedef LifecycleTerminateCallback = Future<Null> Function();
-
-/// Impl for [fidl.Lifecycle].
-class LifecycleImpl extends fidl.Lifecycle {
- /// Callback for when the system calls [terminate].
- final LifecycleTerminateCallback onTerminate;
-
- /// Constructor.
- LifecycleImpl({
- @required this.onTerminate,
- }) : assert(onTerminate != null);
-
- @override
- Future<Null> terminate() async {
- /// Await async events and errors to ensure a clean shutdown BEFORE exiting
- /// the program.
- await onTerminate();
-
- fuchsia.exit(0);
- }
-}
diff --git a/public/lib/lifecycle/dart/pubspec.yaml b/public/lib/lifecycle/dart/pubspec.yaml
deleted file mode 100644
index 3a3c25e..0000000
--- a/public/lib/lifecycle/dart/pubspec.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2018 The Fuchsia Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-name: lifecycle
\ No newline at end of file