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

Side by Side Diff: mojo/dart/packages/mojo_services/lib/keyboard/keyboard.mojom.dart

Issue 1948003003: Dart: Wait to handle events on a Stub until it makes sense to do it. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Add test Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 library keyboard_mojom; 5 library keyboard_mojom;
6 import 'dart:async'; 6 import 'dart:async';
7 import 'package:mojo/bindings.dart' as bindings; 7 import 'package:mojo/bindings.dart' as bindings;
8 import 'package:mojo/core.dart' as core; 8 import 'package:mojo/core.dart' as core;
9 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic e_describer; 9 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic e_describer;
10 import 'package:mojo_services/mojo/native_viewport_event_dispatcher.mojom.dart' as native_viewport_event_dispatcher_mojom; 10 import 'package:mojo_services/mojo/native_viewport_event_dispatcher.mojom.dart' as native_viewport_event_dispatcher_mojom;
(...skipping 1626 matching lines...) Expand 10 before | Expand all | Expand 10 after
1637 impl.requireVersion(requiredVersion); 1637 impl.requireVersion(requiredVersion);
1638 } 1638 }
1639 1639
1640 String toString() { 1640 String toString() {
1641 return "KeyboardClientProxy($impl)"; 1641 return "KeyboardClientProxy($impl)";
1642 } 1642 }
1643 } 1643 }
1644 1644
1645 1645
1646 class KeyboardClientStub extends bindings.Stub { 1646 class KeyboardClientStub extends bindings.Stub {
1647 KeyboardClient _impl = null; 1647 KeyboardClient _impl;
1648 1648
1649 KeyboardClientStub.fromEndpoint( 1649 KeyboardClientStub.fromEndpoint(
1650 core.MojoMessagePipeEndpoint endpoint, [this._impl]) 1650 core.MojoMessagePipeEndpoint endpoint, [KeyboardClient impl])
1651 : super.fromEndpoint(endpoint); 1651 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
1652 _impl = impl;
1653 }
1652 1654
1653 KeyboardClientStub.fromHandle(core.MojoHandle handle, [this._impl]) 1655 KeyboardClientStub.fromHandle(
1654 : super.fromHandle(handle); 1656 core.MojoHandle handle, [KeyboardClient impl])
1657 : super.fromHandle(handle, autoBegin: impl != null) {
1658 _impl = impl;
1659 }
1655 1660
1656 KeyboardClientStub.unbound() : super.unbound(); 1661 KeyboardClientStub.unbound() : super.unbound();
1657 1662
1658 static KeyboardClientStub newFromEndpoint( 1663 static KeyboardClientStub newFromEndpoint(
1659 core.MojoMessagePipeEndpoint endpoint) { 1664 core.MojoMessagePipeEndpoint endpoint) {
1660 assert(endpoint.setDescription("For KeyboardClientStub")); 1665 assert(endpoint.setDescription("For KeyboardClientStub"));
1661 return new KeyboardClientStub.fromEndpoint(endpoint); 1666 return new KeyboardClientStub.fromEndpoint(endpoint);
1662 } 1667 }
1663 1668
1664 1669
1665 1670
1666 dynamic handleMessage(bindings.ServiceMessage message) { 1671 dynamic handleMessage(bindings.ServiceMessage message) {
1667 if (bindings.ControlMessageHandler.isControlMessage(message)) { 1672 if (bindings.ControlMessageHandler.isControlMessage(message)) {
1668 return bindings.ControlMessageHandler.handleMessage(this, 1673 return bindings.ControlMessageHandler.handleMessage(this,
1669 0, 1674 0,
1670 message); 1675 message);
1671 } 1676 }
1672 assert(_impl != null); 1677 if (_impl == null) {
1678 throw new core.MojoApiError("$this has no implementation set");
1679 }
1673 switch (message.header.type) { 1680 switch (message.header.type) {
1674 case _keyboardClientMethodCommitCompletionName: 1681 case _keyboardClientMethodCommitCompletionName:
1675 var params = _KeyboardClientCommitCompletionParams.deserialize( 1682 var params = _KeyboardClientCommitCompletionParams.deserialize(
1676 message.payload); 1683 message.payload);
1677 _impl.commitCompletion(params.completion); 1684 _impl.commitCompletion(params.completion);
1678 break; 1685 break;
1679 case _keyboardClientMethodCommitCorrectionName: 1686 case _keyboardClientMethodCommitCorrectionName:
1680 var params = _KeyboardClientCommitCorrectionParams.deserialize( 1687 var params = _KeyboardClientCommitCorrectionParams.deserialize(
1681 message.payload); 1688 message.payload);
1682 _impl.commitCorrection(params.correction); 1689 _impl.commitCorrection(params.correction);
(...skipping 30 matching lines...) Expand all
1713 break; 1720 break;
1714 default: 1721 default:
1715 throw new bindings.MojoCodecError("Unexpected message name"); 1722 throw new bindings.MojoCodecError("Unexpected message name");
1716 break; 1723 break;
1717 } 1724 }
1718 return null; 1725 return null;
1719 } 1726 }
1720 1727
1721 KeyboardClient get impl => _impl; 1728 KeyboardClient get impl => _impl;
1722 set impl(KeyboardClient d) { 1729 set impl(KeyboardClient d) {
1723 assert(_impl == null); 1730 if (d == null) {
1731 throw new core.MojoApiError("$this: Cannot set a null implementation");
1732 }
1733 if (isBound && (_impl == null)) {
1734 beginHandlingEvents();
1735 }
1724 _impl = d; 1736 _impl = d;
1725 } 1737 }
1726 1738
1739 @override
1740 void bind(core.MojoMessagePipeEndpoint endpoint) {
1741 super.bind(endpoint);
1742 if (!isOpen && (_impl != null)) {
1743 beginHandlingEvents();
1744 }
1745 }
1746
1727 String toString() { 1747 String toString() {
1728 var superString = super.toString(); 1748 var superString = super.toString();
1729 return "KeyboardClientStub($superString)"; 1749 return "KeyboardClientStub($superString)";
1730 } 1750 }
1731 1751
1732 int get version => 0; 1752 int get version => 0;
1733 1753
1734 static service_describer.ServiceDescription _cachedServiceDescription; 1754 static service_describer.ServiceDescription _cachedServiceDescription;
1735 static service_describer.ServiceDescription get serviceDescription { 1755 static service_describer.ServiceDescription get serviceDescription {
1736 if (_cachedServiceDescription == null) { 1756 if (_cachedServiceDescription == null) {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1906 impl.requireVersion(requiredVersion); 1926 impl.requireVersion(requiredVersion);
1907 } 1927 }
1908 1928
1909 String toString() { 1929 String toString() {
1910 return "KeyboardServiceProxy($impl)"; 1930 return "KeyboardServiceProxy($impl)";
1911 } 1931 }
1912 } 1932 }
1913 1933
1914 1934
1915 class KeyboardServiceStub extends bindings.Stub { 1935 class KeyboardServiceStub extends bindings.Stub {
1916 KeyboardService _impl = null; 1936 KeyboardService _impl;
1917 1937
1918 KeyboardServiceStub.fromEndpoint( 1938 KeyboardServiceStub.fromEndpoint(
1919 core.MojoMessagePipeEndpoint endpoint, [this._impl]) 1939 core.MojoMessagePipeEndpoint endpoint, [KeyboardService impl])
1920 : super.fromEndpoint(endpoint); 1940 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
1941 _impl = impl;
1942 }
1921 1943
1922 KeyboardServiceStub.fromHandle(core.MojoHandle handle, [this._impl]) 1944 KeyboardServiceStub.fromHandle(
1923 : super.fromHandle(handle); 1945 core.MojoHandle handle, [KeyboardService impl])
1946 : super.fromHandle(handle, autoBegin: impl != null) {
1947 _impl = impl;
1948 }
1924 1949
1925 KeyboardServiceStub.unbound() : super.unbound(); 1950 KeyboardServiceStub.unbound() : super.unbound();
1926 1951
1927 static KeyboardServiceStub newFromEndpoint( 1952 static KeyboardServiceStub newFromEndpoint(
1928 core.MojoMessagePipeEndpoint endpoint) { 1953 core.MojoMessagePipeEndpoint endpoint) {
1929 assert(endpoint.setDescription("For KeyboardServiceStub")); 1954 assert(endpoint.setDescription("For KeyboardServiceStub"));
1930 return new KeyboardServiceStub.fromEndpoint(endpoint); 1955 return new KeyboardServiceStub.fromEndpoint(endpoint);
1931 } 1956 }
1932 1957
1933 1958
1934 1959
1935 dynamic handleMessage(bindings.ServiceMessage message) { 1960 dynamic handleMessage(bindings.ServiceMessage message) {
1936 if (bindings.ControlMessageHandler.isControlMessage(message)) { 1961 if (bindings.ControlMessageHandler.isControlMessage(message)) {
1937 return bindings.ControlMessageHandler.handleMessage(this, 1962 return bindings.ControlMessageHandler.handleMessage(this,
1938 0, 1963 0,
1939 message); 1964 message);
1940 } 1965 }
1941 assert(_impl != null); 1966 if (_impl == null) {
1967 throw new core.MojoApiError("$this has no implementation set");
1968 }
1942 switch (message.header.type) { 1969 switch (message.header.type) {
1943 case _keyboardServiceMethodShowName: 1970 case _keyboardServiceMethodShowName:
1944 var params = _KeyboardServiceShowParams.deserialize( 1971 var params = _KeyboardServiceShowParams.deserialize(
1945 message.payload); 1972 message.payload);
1946 _impl.show(params.client, params.type); 1973 _impl.show(params.client, params.type);
1947 break; 1974 break;
1948 case _keyboardServiceMethodShowByRequestName: 1975 case _keyboardServiceMethodShowByRequestName:
1949 _impl.showByRequest(); 1976 _impl.showByRequest();
1950 break; 1977 break;
1951 case _keyboardServiceMethodHideName: 1978 case _keyboardServiceMethodHideName:
(...skipping 11 matching lines...) Expand all
1963 break; 1990 break;
1964 default: 1991 default:
1965 throw new bindings.MojoCodecError("Unexpected message name"); 1992 throw new bindings.MojoCodecError("Unexpected message name");
1966 break; 1993 break;
1967 } 1994 }
1968 return null; 1995 return null;
1969 } 1996 }
1970 1997
1971 KeyboardService get impl => _impl; 1998 KeyboardService get impl => _impl;
1972 set impl(KeyboardService d) { 1999 set impl(KeyboardService d) {
1973 assert(_impl == null); 2000 if (d == null) {
2001 throw new core.MojoApiError("$this: Cannot set a null implementation");
2002 }
2003 if (isBound && (_impl == null)) {
2004 beginHandlingEvents();
2005 }
1974 _impl = d; 2006 _impl = d;
1975 } 2007 }
1976 2008
2009 @override
2010 void bind(core.MojoMessagePipeEndpoint endpoint) {
2011 super.bind(endpoint);
2012 if (!isOpen && (_impl != null)) {
2013 beginHandlingEvents();
2014 }
2015 }
2016
1977 String toString() { 2017 String toString() {
1978 var superString = super.toString(); 2018 var superString = super.toString();
1979 return "KeyboardServiceStub($superString)"; 2019 return "KeyboardServiceStub($superString)";
1980 } 2020 }
1981 2021
1982 int get version => 0; 2022 int get version => 0;
1983 2023
1984 static service_describer.ServiceDescription _cachedServiceDescription; 2024 static service_describer.ServiceDescription _cachedServiceDescription;
1985 static service_describer.ServiceDescription get serviceDescription { 2025 static service_describer.ServiceDescription get serviceDescription {
1986 if (_cachedServiceDescription == null) { 2026 if (_cachedServiceDescription == null) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
2113 impl.requireVersion(requiredVersion); 2153 impl.requireVersion(requiredVersion);
2114 } 2154 }
2115 2155
2116 String toString() { 2156 String toString() {
2117 return "KeyboardServiceFactoryProxy($impl)"; 2157 return "KeyboardServiceFactoryProxy($impl)";
2118 } 2158 }
2119 } 2159 }
2120 2160
2121 2161
2122 class KeyboardServiceFactoryStub extends bindings.Stub { 2162 class KeyboardServiceFactoryStub extends bindings.Stub {
2123 KeyboardServiceFactory _impl = null; 2163 KeyboardServiceFactory _impl;
2124 2164
2125 KeyboardServiceFactoryStub.fromEndpoint( 2165 KeyboardServiceFactoryStub.fromEndpoint(
2126 core.MojoMessagePipeEndpoint endpoint, [this._impl]) 2166 core.MojoMessagePipeEndpoint endpoint, [KeyboardServiceFactory impl])
2127 : super.fromEndpoint(endpoint); 2167 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
2168 _impl = impl;
2169 }
2128 2170
2129 KeyboardServiceFactoryStub.fromHandle(core.MojoHandle handle, [this._impl]) 2171 KeyboardServiceFactoryStub.fromHandle(
2130 : super.fromHandle(handle); 2172 core.MojoHandle handle, [KeyboardServiceFactory impl])
2173 : super.fromHandle(handle, autoBegin: impl != null) {
2174 _impl = impl;
2175 }
2131 2176
2132 KeyboardServiceFactoryStub.unbound() : super.unbound(); 2177 KeyboardServiceFactoryStub.unbound() : super.unbound();
2133 2178
2134 static KeyboardServiceFactoryStub newFromEndpoint( 2179 static KeyboardServiceFactoryStub newFromEndpoint(
2135 core.MojoMessagePipeEndpoint endpoint) { 2180 core.MojoMessagePipeEndpoint endpoint) {
2136 assert(endpoint.setDescription("For KeyboardServiceFactoryStub")); 2181 assert(endpoint.setDescription("For KeyboardServiceFactoryStub"));
2137 return new KeyboardServiceFactoryStub.fromEndpoint(endpoint); 2182 return new KeyboardServiceFactoryStub.fromEndpoint(endpoint);
2138 } 2183 }
2139 2184
2140 2185
2141 2186
2142 dynamic handleMessage(bindings.ServiceMessage message) { 2187 dynamic handleMessage(bindings.ServiceMessage message) {
2143 if (bindings.ControlMessageHandler.isControlMessage(message)) { 2188 if (bindings.ControlMessageHandler.isControlMessage(message)) {
2144 return bindings.ControlMessageHandler.handleMessage(this, 2189 return bindings.ControlMessageHandler.handleMessage(this,
2145 0, 2190 0,
2146 message); 2191 message);
2147 } 2192 }
2148 assert(_impl != null); 2193 if (_impl == null) {
2194 throw new core.MojoApiError("$this has no implementation set");
2195 }
2149 switch (message.header.type) { 2196 switch (message.header.type) {
2150 case _keyboardServiceFactoryMethodCreateKeyboardServiceName: 2197 case _keyboardServiceFactoryMethodCreateKeyboardServiceName:
2151 var params = _KeyboardServiceFactoryCreateKeyboardServiceParams.deserial ize( 2198 var params = _KeyboardServiceFactoryCreateKeyboardServiceParams.deserial ize(
2152 message.payload); 2199 message.payload);
2153 _impl.createKeyboardService(params.keyEventDispatcher, params.serviceReq uest); 2200 _impl.createKeyboardService(params.keyEventDispatcher, params.serviceReq uest);
2154 break; 2201 break;
2155 default: 2202 default:
2156 throw new bindings.MojoCodecError("Unexpected message name"); 2203 throw new bindings.MojoCodecError("Unexpected message name");
2157 break; 2204 break;
2158 } 2205 }
2159 return null; 2206 return null;
2160 } 2207 }
2161 2208
2162 KeyboardServiceFactory get impl => _impl; 2209 KeyboardServiceFactory get impl => _impl;
2163 set impl(KeyboardServiceFactory d) { 2210 set impl(KeyboardServiceFactory d) {
2164 assert(_impl == null); 2211 if (d == null) {
2212 throw new core.MojoApiError("$this: Cannot set a null implementation");
2213 }
2214 if (isBound && (_impl == null)) {
2215 beginHandlingEvents();
2216 }
2165 _impl = d; 2217 _impl = d;
2166 } 2218 }
2167 2219
2220 @override
2221 void bind(core.MojoMessagePipeEndpoint endpoint) {
2222 super.bind(endpoint);
2223 if (!isOpen && (_impl != null)) {
2224 beginHandlingEvents();
2225 }
2226 }
2227
2168 String toString() { 2228 String toString() {
2169 var superString = super.toString(); 2229 var superString = super.toString();
2170 return "KeyboardServiceFactoryStub($superString)"; 2230 return "KeyboardServiceFactoryStub($superString)";
2171 } 2231 }
2172 2232
2173 int get version => 0; 2233 int get version => 0;
2174 2234
2175 static service_describer.ServiceDescription _cachedServiceDescription; 2235 static service_describer.ServiceDescription _cachedServiceDescription;
2176 static service_describer.ServiceDescription get serviceDescription { 2236 static service_describer.ServiceDescription get serviceDescription {
2177 if (_cachedServiceDescription == null) { 2237 if (_cachedServiceDescription == null) {
2178 _cachedServiceDescription = new _KeyboardServiceFactoryServiceDescription( ); 2238 _cachedServiceDescription = new _KeyboardServiceFactoryServiceDescription( );
2179 } 2239 }
2180 return _cachedServiceDescription; 2240 return _cachedServiceDescription;
2181 } 2241 }
2182 } 2242 }
2183 2243
2184 2244
2185 2245
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698