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

Side by Side Diff: mojo/dart/packages/mojo_services/lib/activity/activity.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 activity_mojom; 5 library activity_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 10
(...skipping 1826 matching lines...) Expand 10 before | Expand all | Expand 10 after
1837 impl.requireVersion(requiredVersion); 1837 impl.requireVersion(requiredVersion);
1838 } 1838 }
1839 1839
1840 String toString() { 1840 String toString() {
1841 return "ActivityProxy($impl)"; 1841 return "ActivityProxy($impl)";
1842 } 1842 }
1843 } 1843 }
1844 1844
1845 1845
1846 class ActivityStub extends bindings.Stub { 1846 class ActivityStub extends bindings.Stub {
1847 Activity _impl = null; 1847 Activity _impl;
1848 1848
1849 ActivityStub.fromEndpoint( 1849 ActivityStub.fromEndpoint(
1850 core.MojoMessagePipeEndpoint endpoint, [this._impl]) 1850 core.MojoMessagePipeEndpoint endpoint, [Activity impl])
1851 : super.fromEndpoint(endpoint); 1851 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
1852 _impl = impl;
1853 }
1852 1854
1853 ActivityStub.fromHandle(core.MojoHandle handle, [this._impl]) 1855 ActivityStub.fromHandle(
1854 : super.fromHandle(handle); 1856 core.MojoHandle handle, [Activity impl])
1857 : super.fromHandle(handle, autoBegin: impl != null) {
1858 _impl = impl;
1859 }
1855 1860
1856 ActivityStub.unbound() : super.unbound(); 1861 ActivityStub.unbound() : super.unbound();
1857 1862
1858 static ActivityStub newFromEndpoint( 1863 static ActivityStub newFromEndpoint(
1859 core.MojoMessagePipeEndpoint endpoint) { 1864 core.MojoMessagePipeEndpoint endpoint) {
1860 assert(endpoint.setDescription("For ActivityStub")); 1865 assert(endpoint.setDescription("For ActivityStub"));
1861 return new ActivityStub.fromEndpoint(endpoint); 1866 return new ActivityStub.fromEndpoint(endpoint);
1862 } 1867 }
1863 1868
1864 1869
1865 1870
1866 dynamic handleMessage(bindings.ServiceMessage message) { 1871 dynamic handleMessage(bindings.ServiceMessage message) {
1867 if (bindings.ControlMessageHandler.isControlMessage(message)) { 1872 if (bindings.ControlMessageHandler.isControlMessage(message)) {
1868 return bindings.ControlMessageHandler.handleMessage(this, 1873 return bindings.ControlMessageHandler.handleMessage(this,
1869 0, 1874 0,
1870 message); 1875 message);
1871 } 1876 }
1872 assert(_impl != null); 1877 if (_impl == null) {
1878 throw new core.MojoApiError("$this has no implementation set");
1879 }
1873 switch (message.header.type) { 1880 switch (message.header.type) {
1874 case _activityMethodGetUserFeedbackName: 1881 case _activityMethodGetUserFeedbackName:
1875 var params = _ActivityGetUserFeedbackParams.deserialize( 1882 var params = _ActivityGetUserFeedbackParams.deserialize(
1876 message.payload); 1883 message.payload);
1877 _impl.getUserFeedback(params.userFeedback); 1884 _impl.getUserFeedback(params.userFeedback);
1878 break; 1885 break;
1879 case _activityMethodStartActivityName: 1886 case _activityMethodStartActivityName:
1880 var params = _ActivityStartActivityParams.deserialize( 1887 var params = _ActivityStartActivityParams.deserialize(
1881 message.payload); 1888 message.payload);
1882 _impl.startActivity(params.intent); 1889 _impl.startActivity(params.intent);
(...skipping 18 matching lines...) Expand all
1901 break; 1908 break;
1902 default: 1909 default:
1903 throw new bindings.MojoCodecError("Unexpected message name"); 1910 throw new bindings.MojoCodecError("Unexpected message name");
1904 break; 1911 break;
1905 } 1912 }
1906 return null; 1913 return null;
1907 } 1914 }
1908 1915
1909 Activity get impl => _impl; 1916 Activity get impl => _impl;
1910 set impl(Activity d) { 1917 set impl(Activity d) {
1911 assert(_impl == null); 1918 if (d == null) {
1919 throw new core.MojoApiError("$this: Cannot set a null implementation");
1920 }
1921 if (isBound && (_impl == null)) {
1922 beginHandlingEvents();
1923 }
1912 _impl = d; 1924 _impl = d;
1913 } 1925 }
1914 1926
1927 @override
1928 void bind(core.MojoMessagePipeEndpoint endpoint) {
1929 super.bind(endpoint);
1930 if (!isOpen && (_impl != null)) {
1931 beginHandlingEvents();
1932 }
1933 }
1934
1915 String toString() { 1935 String toString() {
1916 var superString = super.toString(); 1936 var superString = super.toString();
1917 return "ActivityStub($superString)"; 1937 return "ActivityStub($superString)";
1918 } 1938 }
1919 1939
1920 int get version => 0; 1940 int get version => 0;
1921 1941
1922 static service_describer.ServiceDescription _cachedServiceDescription; 1942 static service_describer.ServiceDescription _cachedServiceDescription;
1923 static service_describer.ServiceDescription get serviceDescription { 1943 static service_describer.ServiceDescription get serviceDescription {
1924 if (_cachedServiceDescription == null) { 1944 if (_cachedServiceDescription == null) {
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
2129 impl.requireVersion(requiredVersion); 2149 impl.requireVersion(requiredVersion);
2130 } 2150 }
2131 2151
2132 String toString() { 2152 String toString() {
2133 return "PathServiceProxy($impl)"; 2153 return "PathServiceProxy($impl)";
2134 } 2154 }
2135 } 2155 }
2136 2156
2137 2157
2138 class PathServiceStub extends bindings.Stub { 2158 class PathServiceStub extends bindings.Stub {
2139 PathService _impl = null; 2159 PathService _impl;
2140 2160
2141 PathServiceStub.fromEndpoint( 2161 PathServiceStub.fromEndpoint(
2142 core.MojoMessagePipeEndpoint endpoint, [this._impl]) 2162 core.MojoMessagePipeEndpoint endpoint, [PathService impl])
2143 : super.fromEndpoint(endpoint); 2163 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
2164 _impl = impl;
2165 }
2144 2166
2145 PathServiceStub.fromHandle(core.MojoHandle handle, [this._impl]) 2167 PathServiceStub.fromHandle(
2146 : super.fromHandle(handle); 2168 core.MojoHandle handle, [PathService impl])
2169 : super.fromHandle(handle, autoBegin: impl != null) {
2170 _impl = impl;
2171 }
2147 2172
2148 PathServiceStub.unbound() : super.unbound(); 2173 PathServiceStub.unbound() : super.unbound();
2149 2174
2150 static PathServiceStub newFromEndpoint( 2175 static PathServiceStub newFromEndpoint(
2151 core.MojoMessagePipeEndpoint endpoint) { 2176 core.MojoMessagePipeEndpoint endpoint) {
2152 assert(endpoint.setDescription("For PathServiceStub")); 2177 assert(endpoint.setDescription("For PathServiceStub"));
2153 return new PathServiceStub.fromEndpoint(endpoint); 2178 return new PathServiceStub.fromEndpoint(endpoint);
2154 } 2179 }
2155 2180
2156 2181
(...skipping 12 matching lines...) Expand all
2169 result.path = path; 2194 result.path = path;
2170 return result; 2195 return result;
2171 } 2196 }
2172 2197
2173 dynamic handleMessage(bindings.ServiceMessage message) { 2198 dynamic handleMessage(bindings.ServiceMessage message) {
2174 if (bindings.ControlMessageHandler.isControlMessage(message)) { 2199 if (bindings.ControlMessageHandler.isControlMessage(message)) {
2175 return bindings.ControlMessageHandler.handleMessage(this, 2200 return bindings.ControlMessageHandler.handleMessage(this,
2176 0, 2201 0,
2177 message); 2202 message);
2178 } 2203 }
2179 assert(_impl != null); 2204 if (_impl == null) {
2205 throw new core.MojoApiError("$this has no implementation set");
2206 }
2180 switch (message.header.type) { 2207 switch (message.header.type) {
2181 case _pathServiceMethodGetAppDataDirName: 2208 case _pathServiceMethodGetAppDataDirName:
2182 var response = _impl.getAppDataDir(_pathServiceGetAppDataDirResponsePara msFactory); 2209 var response = _impl.getAppDataDir(_pathServiceGetAppDataDirResponsePara msFactory);
2183 if (response is Future) { 2210 if (response is Future) {
2184 return response.then((response) { 2211 return response.then((response) {
2185 if (response != null) { 2212 if (response != null) {
2186 return buildResponseWithId( 2213 return buildResponseWithId(
2187 response, 2214 response,
2188 _pathServiceMethodGetAppDataDirName, 2215 _pathServiceMethodGetAppDataDirName,
2189 message.header.requestId, 2216 message.header.requestId,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2240 break; 2267 break;
2241 default: 2268 default:
2242 throw new bindings.MojoCodecError("Unexpected message name"); 2269 throw new bindings.MojoCodecError("Unexpected message name");
2243 break; 2270 break;
2244 } 2271 }
2245 return null; 2272 return null;
2246 } 2273 }
2247 2274
2248 PathService get impl => _impl; 2275 PathService get impl => _impl;
2249 set impl(PathService d) { 2276 set impl(PathService d) {
2250 assert(_impl == null); 2277 if (d == null) {
2278 throw new core.MojoApiError("$this: Cannot set a null implementation");
2279 }
2280 if (isBound && (_impl == null)) {
2281 beginHandlingEvents();
2282 }
2251 _impl = d; 2283 _impl = d;
2252 } 2284 }
2253 2285
2286 @override
2287 void bind(core.MojoMessagePipeEndpoint endpoint) {
2288 super.bind(endpoint);
2289 if (!isOpen && (_impl != null)) {
2290 beginHandlingEvents();
2291 }
2292 }
2293
2254 String toString() { 2294 String toString() {
2255 var superString = super.toString(); 2295 var superString = super.toString();
2256 return "PathServiceStub($superString)"; 2296 return "PathServiceStub($superString)";
2257 } 2297 }
2258 2298
2259 int get version => 0; 2299 int get version => 0;
2260 2300
2261 static service_describer.ServiceDescription _cachedServiceDescription; 2301 static service_describer.ServiceDescription _cachedServiceDescription;
2262 static service_describer.ServiceDescription get serviceDescription { 2302 static service_describer.ServiceDescription get serviceDescription {
2263 if (_cachedServiceDescription == null) { 2303 if (_cachedServiceDescription == null) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
2400 impl.requireVersion(requiredVersion); 2440 impl.requireVersion(requiredVersion);
2401 } 2441 }
2402 2442
2403 String toString() { 2443 String toString() {
2404 return "UserFeedbackProxy($impl)"; 2444 return "UserFeedbackProxy($impl)";
2405 } 2445 }
2406 } 2446 }
2407 2447
2408 2448
2409 class UserFeedbackStub extends bindings.Stub { 2449 class UserFeedbackStub extends bindings.Stub {
2410 UserFeedback _impl = null; 2450 UserFeedback _impl;
2411 2451
2412 UserFeedbackStub.fromEndpoint( 2452 UserFeedbackStub.fromEndpoint(
2413 core.MojoMessagePipeEndpoint endpoint, [this._impl]) 2453 core.MojoMessagePipeEndpoint endpoint, [UserFeedback impl])
2414 : super.fromEndpoint(endpoint); 2454 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
2455 _impl = impl;
2456 }
2415 2457
2416 UserFeedbackStub.fromHandle(core.MojoHandle handle, [this._impl]) 2458 UserFeedbackStub.fromHandle(
2417 : super.fromHandle(handle); 2459 core.MojoHandle handle, [UserFeedback impl])
2460 : super.fromHandle(handle, autoBegin: impl != null) {
2461 _impl = impl;
2462 }
2418 2463
2419 UserFeedbackStub.unbound() : super.unbound(); 2464 UserFeedbackStub.unbound() : super.unbound();
2420 2465
2421 static UserFeedbackStub newFromEndpoint( 2466 static UserFeedbackStub newFromEndpoint(
2422 core.MojoMessagePipeEndpoint endpoint) { 2467 core.MojoMessagePipeEndpoint endpoint) {
2423 assert(endpoint.setDescription("For UserFeedbackStub")); 2468 assert(endpoint.setDescription("For UserFeedbackStub"));
2424 return new UserFeedbackStub.fromEndpoint(endpoint); 2469 return new UserFeedbackStub.fromEndpoint(endpoint);
2425 } 2470 }
2426 2471
2427 2472
2428 2473
2429 dynamic handleMessage(bindings.ServiceMessage message) { 2474 dynamic handleMessage(bindings.ServiceMessage message) {
2430 if (bindings.ControlMessageHandler.isControlMessage(message)) { 2475 if (bindings.ControlMessageHandler.isControlMessage(message)) {
2431 return bindings.ControlMessageHandler.handleMessage(this, 2476 return bindings.ControlMessageHandler.handleMessage(this,
2432 0, 2477 0,
2433 message); 2478 message);
2434 } 2479 }
2435 assert(_impl != null); 2480 if (_impl == null) {
2481 throw new core.MojoApiError("$this has no implementation set");
2482 }
2436 switch (message.header.type) { 2483 switch (message.header.type) {
2437 case _userFeedbackMethodPerformHapticFeedbackName: 2484 case _userFeedbackMethodPerformHapticFeedbackName:
2438 var params = _UserFeedbackPerformHapticFeedbackParams.deserialize( 2485 var params = _UserFeedbackPerformHapticFeedbackParams.deserialize(
2439 message.payload); 2486 message.payload);
2440 _impl.performHapticFeedback(params.type); 2487 _impl.performHapticFeedback(params.type);
2441 break; 2488 break;
2442 case _userFeedbackMethodPerformAuralFeedbackName: 2489 case _userFeedbackMethodPerformAuralFeedbackName:
2443 var params = _UserFeedbackPerformAuralFeedbackParams.deserialize( 2490 var params = _UserFeedbackPerformAuralFeedbackParams.deserialize(
2444 message.payload); 2491 message.payload);
2445 _impl.performAuralFeedback(params.type); 2492 _impl.performAuralFeedback(params.type);
2446 break; 2493 break;
2447 default: 2494 default:
2448 throw new bindings.MojoCodecError("Unexpected message name"); 2495 throw new bindings.MojoCodecError("Unexpected message name");
2449 break; 2496 break;
2450 } 2497 }
2451 return null; 2498 return null;
2452 } 2499 }
2453 2500
2454 UserFeedback get impl => _impl; 2501 UserFeedback get impl => _impl;
2455 set impl(UserFeedback d) { 2502 set impl(UserFeedback d) {
2456 assert(_impl == null); 2503 if (d == null) {
2504 throw new core.MojoApiError("$this: Cannot set a null implementation");
2505 }
2506 if (isBound && (_impl == null)) {
2507 beginHandlingEvents();
2508 }
2457 _impl = d; 2509 _impl = d;
2458 } 2510 }
2459 2511
2512 @override
2513 void bind(core.MojoMessagePipeEndpoint endpoint) {
2514 super.bind(endpoint);
2515 if (!isOpen && (_impl != null)) {
2516 beginHandlingEvents();
2517 }
2518 }
2519
2460 String toString() { 2520 String toString() {
2461 var superString = super.toString(); 2521 var superString = super.toString();
2462 return "UserFeedbackStub($superString)"; 2522 return "UserFeedbackStub($superString)";
2463 } 2523 }
2464 2524
2465 int get version => 0; 2525 int get version => 0;
2466 2526
2467 static service_describer.ServiceDescription _cachedServiceDescription; 2527 static service_describer.ServiceDescription _cachedServiceDescription;
2468 static service_describer.ServiceDescription get serviceDescription { 2528 static service_describer.ServiceDescription get serviceDescription {
2469 if (_cachedServiceDescription == null) { 2529 if (_cachedServiceDescription == null) {
2470 _cachedServiceDescription = new _UserFeedbackServiceDescription(); 2530 _cachedServiceDescription = new _UserFeedbackServiceDescription();
2471 } 2531 }
2472 return _cachedServiceDescription; 2532 return _cachedServiceDescription;
2473 } 2533 }
2474 } 2534 }
2475 2535
2476 2536
2477 2537
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698