Commit e41c1c0b authored by Ian Hickson's avatar Ian Hickson

Split services/ into services/ and foundation/ (#3350)

We're getting back to the point where we have a bunch of foundation APIs
and it's getting confusing having them mixed with services/.
parent e845e8ad
// Copyright 2016 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.
/// Core Flutter framework primitives.
///
/// The features defined in this library are the lowest-level utility
/// classes and functions used by all the other layers of the Flutter
/// framework.
library foundation;
export 'src/foundation/assertions.dart';
export 'src/foundation/binding.dart';
export 'src/foundation/print.dart';
......@@ -48,4 +48,5 @@ export 'src/rendering/table.dart';
export 'src/rendering/view.dart';
export 'src/rendering/viewport.dart';
export 'package:flutter/foundation.dart';
export 'package:vector_math/vector_math_64.dart' show Matrix4;
......@@ -7,13 +7,13 @@
/// For example, this library includes [fetch], which fetches data from the
/// network.
///
/// This library depends only on core Dart libraries as well as the `mojo`,
/// `mojo_services`, and `sky_services` and packages.
/// This library depends only on core Dart libraries, the `mojo`,
/// `mojo_services`, and `sky_services` packages, and the `foundation`
/// Flutter library.
library services;
export 'src/services/activity.dart';
export 'src/services/app_messages.dart';
export 'src/services/assertions.dart';
export 'src/services/asset_bundle.dart';
export 'src/services/binding.dart';
export 'src/services/fetch.dart';
......@@ -21,4 +21,4 @@ export 'src/services/image_cache.dart';
export 'src/services/image_decoder.dart';
export 'src/services/image_resource.dart';
export 'src/services/keyboard.dart';
export 'src/services/print.dart';
export 'src/services/shell.dart';
The rule for packages in this directory is that they can depend on
nothing but core Dart packages. They can't depend on `dart:ui`, they
can't depend on any `package:`, and they can't depend on anything
outside this directory.
// Copyright 2016 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.
/// Base class for mixins that provide singleton services (also known as
/// "bindings").
///
/// To use this class in a mixin, inherit from it and implement
/// [initInstances()]. The mixin is guaranteed to only be constructed once in
/// the lifetime of the app (more precisely, it will assert if constructed twice
/// in checked mode).
///
/// The top-most layer used to write the application will have a
/// concrete class that inherits from BindingBase and uses all the
/// various BindingBase mixins (such as [Services]). For example, the
/// Widgets library in flutter introduces a binding called
/// [WidgetFlutterBinding]. The relevant library defines how to create
/// the binding. It could be implied (for example,
/// [WidgetFlutterBinding] is automatically started from [runApp]), or
/// the application might be required to explicitly call the
/// constructor.
abstract class BindingBase {
BindingBase() {
assert(!_debugInitialized);
initInstances();
assert(_debugInitialized);
}
static bool _debugInitialized = false;
/// The initialization method. Subclasses override this method to hook into
/// the platform and otherwise configure their services. Subclasses must call
/// "super.initInstances()".
///
/// By convention, if the service is to be provided as a singleton, it should
/// be exposed as `MixinClassName.instance`, a static getter that returns
/// `MixinClassName._instance`, a static field that is set by
/// `initInstances()`.
void initInstances() {
assert(() { _debugInitialized = true; return true; });
}
@override
String toString() => '<$runtimeType>';
}
......@@ -5,7 +5,7 @@
import 'dart:typed_data';
import 'dart:ui' as ui show window;
import 'package:flutter/services.dart';
import 'package:flutter/foundation.dart';
import 'package:mojo/bindings.dart' as mojo_bindings;
import 'package:mojo/core.dart' as mojo_core;
import 'package:sky_services/pointer/pointer.mojom.dart';
......
......@@ -4,7 +4,7 @@
import 'dart:collection';
import 'package:flutter/services.dart';
import 'package:flutter/foundation.dart';
import 'events.dart';
......
......@@ -6,13 +6,14 @@ import 'dart:async';
import 'dart:convert';
import 'dart:typed_data';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:mojo_services/mojo/network_service.mojom.dart' as mojom;
import 'package:mojo_services/mojo/url_loader.mojom.dart' as mojom;
import 'package:mojo/core.dart' as mojo;
import 'package:mojo/mojo/http_header.mojom.dart' as mojom;
import 'package:mojo/mojo/url_request.mojom.dart' as mojom;
import 'package:mojo/mojo/url_response.mojom.dart' as mojom;
import 'package:mojo/mojo/http_header.mojom.dart' as mojom;
import 'package:mojo_services/mojo/network_service.mojom.dart' as mojom;
import 'package:mojo_services/mojo/url_loader.mojom.dart' as mojom;
import 'response.dart';
......
......@@ -5,7 +5,7 @@
import 'dart:ui' as ui show Paragraph, ParagraphBuilder, ParagraphStyle, TextBox;
import 'package:flutter/gestures.dart';
import 'package:flutter/services.dart';
import 'package:flutter/foundation.dart';
import 'basic_types.dart';
import 'text_editing.dart';
......
......@@ -4,6 +4,7 @@
import 'dart:ui' as ui show window;
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
......
......@@ -5,10 +5,10 @@
import 'dart:developer';
import 'dart:ui' as ui show ImageFilter, PictureRecorder;
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/painting.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
import 'package:mojo_services/mojo/gfx/composition/scene_token.mojom.dart' as mojom;
import 'package:vector_math/vector_math_64.dart';
......@@ -20,7 +20,7 @@ import 'binding.dart';
export 'package:flutter/gestures.dart' show HitTestEntry, HitTestResult;
export 'package:flutter/painting.dart';
export 'package:flutter/services.dart' show FlutterError, InformationCollector;
export 'package:flutter/foundation.dart' show FlutterError, InformationCollector;
/// Base class for data associated with a [RenderObject] by its parent.
///
......
......@@ -9,7 +9,7 @@ import 'dart:ui' as ui show window;
import 'dart:ui' show VoidCallback;
import 'package:collection/collection.dart';
import 'package:flutter/services.dart';
import 'package:flutter/foundation.dart';
export 'dart:ui' show VoidCallback;
......
......@@ -7,7 +7,7 @@ import 'dart:async';
import 'package:sky_services/activity/activity.mojom.dart';
import 'binding.dart';
import 'shell.dart';
export 'package:sky_services/activity/activity.mojom.dart';
......
......@@ -4,10 +4,11 @@
import 'dart:async';
import 'package:flutter/shell.dart';
import 'package:mojo/core.dart' as core;
import 'package:sky_services/flutter/platform/app_messages.mojom.dart';
import 'shell.dart';
// APIs for exchanging messages with the host application.
ApplicationMessagesProxy _initHostAppMessagesProxy() {
......
......@@ -7,7 +7,6 @@ import 'dart:ui' as ui;
import 'dart:typed_data';
import 'package:flutter/http.dart' as http;
import 'package:mojo/core.dart' as core;
import 'package:mojo_services/mojo/asset_bundle/asset_bundle.mojom.dart';
......@@ -15,7 +14,7 @@ import 'fetch.dart';
import 'image_cache.dart';
import 'image_decoder.dart';
import 'image_resource.dart';
import 'binding.dart';
import 'shell.dart';
abstract class AssetBundle {
ImageResource loadImage(String key);
......
......@@ -2,51 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/shell.dart';
import 'package:flutter/foundation.dart';
export 'package:flutter/shell.dart';
/// Base class for mixins that provide singleton services (also known as
/// "bindings").
///
/// To use this class in a mixin, inherit from it and implement
/// [initInstances()]. The mixin is guaranteed to only be constructed once in
/// the lifetime of the app (more precisely, it will assert if constructed twice
/// in checked mode).
///
/// The top-most layer used to write the application will have a
/// concrete class that inherits from BindingBase and uses all the
/// various BindingBase mixins (such as [Services]). For example, the
/// Widgets library in flutter introduces a binding called
/// [WidgetFlutterBinding]. The relevant library defines how to create
/// the binding. It could be implied (for example,
/// [WidgetFlutterBinding] is automatically started from [runApp]), or
/// the application might be required to explicitly call the
/// constructor.
abstract class BindingBase {
BindingBase() {
assert(!_debugInitialized);
initInstances();
assert(_debugInitialized);
}
static bool _debugInitialized = false;
/// The initialization method. Subclasses override this method to hook into
/// the platform and otherwise configure their services. Subclasses must call
/// "super.initInstances()".
///
/// By convention, if the service is to be provided as a singleton, it should
/// be exposed as `MixinClassName.instance`, a static getter that returns
/// `MixinClassName._instance`, a static field that is set by
/// `initInstances()`.
void initInstances() {
assert(() { _debugInitialized = true; return true; });
}
@override
String toString() => '<$runtimeType>';
}
import 'shell.dart';
abstract class Services extends BindingBase {
@override
......
......@@ -4,12 +4,12 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:mojo/mojo/url_request.mojom.dart' as mojom;
import 'package:mojo/mojo/url_response.mojom.dart' as mojom;
import 'package:mojo_services/mojo/url_loader.mojom.dart' as mojom;
import 'assertions.dart';
import '../http/mojo_client.dart';
import '../http/mojo_client.dart'; // TODO(ianh): clean this up, see https://github.com/flutter/flutter/issues/2889
export 'package:mojo/mojo/url_response.mojom.dart' show UrlResponse;
......
......@@ -5,7 +5,7 @@
import 'dart:async';
import 'dart:ui' as ui show Image;
import 'assertions.dart';
import 'package:flutter/foundation.dart';
/// A [ui.Image] object with its corresponding scale.
///
......
......@@ -6,7 +6,7 @@ import 'dart:async';
import 'package:sky_services/editing/editing.mojom.dart' as mojom;
import 'binding.dart';
import 'shell.dart';
export 'package:sky_services/editing/editing.mojom.dart' show KeyboardType;
......
......@@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// Manages connections with embedder-provided services.
library shell;
import 'dart:ui' as ui;
import 'package:mojo/application.dart';
......
......@@ -9,12 +9,12 @@ import 'dart:developer';
import 'debug.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter/foundation.dart';
import 'package:meta/meta.dart';
export 'dart:ui' show hashValues, hashList;
export 'package:flutter/rendering.dart' show RenderObject, RenderBox, debugPrint;
export 'package:flutter/services.dart' show FlutterError;
export 'package:flutter/foundation.dart' show FlutterError;
// KEYS
......
......@@ -50,4 +50,5 @@ export 'src/widgets/transitions.dart';
export 'src/widgets/unique_widget.dart';
export 'src/widgets/virtual_viewport.dart';
export 'package:flutter/foundation.dart';
export 'package:vector_math/vector_math_64.dart' show Matrix4;
......@@ -4,8 +4,8 @@
import 'dart:ui' as ui;
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/services.dart';
import 'package:mojo/bindings.dart' as mojo_bindings;
import 'package:sky_services/pointer/pointer.mojom.dart';
import 'package:test/test.dart';
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/services.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
class TestGestureFlutterBinding extends BindingBase with Gesturer { }
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/foundation.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
import 'package:test/test.dart';
class TestSchedulerBinding extends BindingBase with Scheduler { }
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/foundation.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
import 'package:test/test.dart';
class TestSchedulerBinding extends BindingBase with Scheduler { }
......
......@@ -4,9 +4,9 @@
import 'dart:ui' as ui show window;
import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:quiver/testing/async.dart';
import 'package:quiver/time.dart';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment