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

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

Issue 1983453002: Dart: Refactor Stubs (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Merge 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 http_server_mojom; 5 library http_server_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/http_connection.mojom.dart' as http_connectio n_mojom; 10 import 'package:mojo_services/mojo/http_connection.mojom.dart' as http_connectio n_mojom;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 dynamic getAllTypeDefinitions([Function responseFactory]) => 106 dynamic getAllTypeDefinitions([Function responseFactory]) =>
107 responseFactory(null); 107 responseFactory(null);
108 } 108 }
109 109
110 abstract class HttpServerDelegate { 110 abstract class HttpServerDelegate {
111 static const String serviceName = null; 111 static const String serviceName = null;
112 void onConnected(Object connection, Object delegate); 112 void onConnected(Object connection, Object delegate);
113 } 113 }
114 114
115 115 class _HttpServerDelegateProxyControl
116 class _HttpServerDelegateProxyControl extends bindings.ProxyMessageHandler 116 extends bindings.ProxyMessageHandler
117 implements bindings.ProxyControl { 117 implements bindings.ProxyControl {
118 _HttpServerDelegateProxyControl.fromEndpoint( 118 _HttpServerDelegateProxyControl.fromEndpoint(
119 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); 119 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint);
120 120
121 _HttpServerDelegateProxyControl.fromHandle( 121 _HttpServerDelegateProxyControl.fromHandle(
122 core.MojoHandle handle) : super.fromHandle(handle); 122 core.MojoHandle handle) : super.fromHandle(handle);
123 123
124 _HttpServerDelegateProxyControl.unbound() : super.unbound(); 124 _HttpServerDelegateProxyControl.unbound() : super.unbound();
125 125
126 service_describer.ServiceDescription get serviceDescription => 126 service_describer.ServiceDescription get serviceDescription =>
127 new _HttpServerDelegateServiceDescription(); 127 new _HttpServerDelegateServiceDescription();
128 128
129 String get serviceName => HttpServerDelegate.serviceName; 129 String get serviceName => HttpServerDelegate.serviceName;
130 130
131 @override
132 void handleResponse(bindings.ServiceMessage message) { 131 void handleResponse(bindings.ServiceMessage message) {
133 switch (message.header.type) { 132 switch (message.header.type) {
134 default: 133 default:
135 proxyError("Unexpected message type: ${message.header.type}"); 134 proxyError("Unexpected message type: ${message.header.type}");
136 close(immediate: true); 135 close(immediate: true);
137 break; 136 break;
138 } 137 }
139 } 138 }
140 139
141 @override 140 @override
142 String toString() { 141 String toString() {
143 var superString = super.toString(); 142 var superString = super.toString();
144 return "_HttpServerDelegateProxyControl($superString)"; 143 return "_HttpServerDelegateProxyControl($superString)";
145 } 144 }
146 } 145 }
147 146
148 147 class HttpServerDelegateProxy
149 class HttpServerDelegateProxy extends bindings.Proxy 148 extends bindings.Proxy
150 implements HttpServerDelegate { 149 implements HttpServerDelegate {
151 HttpServerDelegateProxy.fromEndpoint( 150 HttpServerDelegateProxy.fromEndpoint(
152 core.MojoMessagePipeEndpoint endpoint) 151 core.MojoMessagePipeEndpoint endpoint)
153 : super(new _HttpServerDelegateProxyControl.fromEndpoint(endpoint)); 152 : super(new _HttpServerDelegateProxyControl.fromEndpoint(endpoint));
154 153
155 HttpServerDelegateProxy.fromHandle(core.MojoHandle handle) 154 HttpServerDelegateProxy.fromHandle(core.MojoHandle handle)
156 : super(new _HttpServerDelegateProxyControl.fromHandle(handle)); 155 : super(new _HttpServerDelegateProxyControl.fromHandle(handle));
157 156
158 HttpServerDelegateProxy.unbound() 157 HttpServerDelegateProxy.unbound()
159 : super(new _HttpServerDelegateProxyControl.unbound()); 158 : super(new _HttpServerDelegateProxyControl.unbound());
160 159
(...skipping 17 matching lines...) Expand all
178 return; 177 return;
179 } 178 }
180 var params = new _HttpServerDelegateOnConnectedParams(); 179 var params = new _HttpServerDelegateOnConnectedParams();
181 params.connection = connection; 180 params.connection = connection;
182 params.delegate = delegate; 181 params.delegate = delegate;
183 ctrl.sendMessage(params, 182 ctrl.sendMessage(params,
184 _httpServerDelegateMethodOnConnectedName); 183 _httpServerDelegateMethodOnConnectedName);
185 } 184 }
186 } 185 }
187 186
188 187 class _HttpServerDelegateStubControl
189 class HttpServerDelegateStub extends bindings.Stub { 188 extends bindings.StubMessageHandler
189 implements bindings.StubControl<HttpServerDelegate> {
190 HttpServerDelegate _impl; 190 HttpServerDelegate _impl;
191 191
192 HttpServerDelegateStub.fromEndpoint( 192 _HttpServerDelegateStubControl.fromEndpoint(
193 core.MojoMessagePipeEndpoint endpoint, [HttpServerDelegate impl]) 193 core.MojoMessagePipeEndpoint endpoint, [HttpServerDelegate impl])
194 : super.fromEndpoint(endpoint, autoBegin: impl != null) { 194 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
195 _impl = impl; 195 _impl = impl;
196 } 196 }
197 197
198 HttpServerDelegateStub.fromHandle( 198 _HttpServerDelegateStubControl.fromHandle(
199 core.MojoHandle handle, [HttpServerDelegate impl]) 199 core.MojoHandle handle, [HttpServerDelegate impl])
200 : super.fromHandle(handle, autoBegin: impl != null) { 200 : super.fromHandle(handle, autoBegin: impl != null) {
201 _impl = impl; 201 _impl = impl;
202 } 202 }
203 203
204 HttpServerDelegateStub.unbound([this._impl]) : super.unbound(); 204 _HttpServerDelegateStubControl.unbound([this._impl]) : super.unbound();
205
206 static HttpServerDelegateStub newFromEndpoint(
207 core.MojoMessagePipeEndpoint endpoint) {
208 assert(endpoint.setDescription("For HttpServerDelegateStub"));
209 return new HttpServerDelegateStub.fromEndpoint(endpoint);
210 }
211 205
212 206
213 207
214 dynamic handleMessage(bindings.ServiceMessage message) { 208 dynamic handleMessage(bindings.ServiceMessage message) {
215 if (bindings.ControlMessageHandler.isControlMessage(message)) { 209 if (bindings.ControlMessageHandler.isControlMessage(message)) {
216 return bindings.ControlMessageHandler.handleMessage(this, 210 return bindings.ControlMessageHandler.handleMessage(this,
217 0, 211 0,
218 message); 212 message);
219 } 213 }
220 if (_impl == null) { 214 if (_impl == null) {
(...skipping 24 matching lines...) Expand all
245 } 239 }
246 240
247 @override 241 @override
248 void bind(core.MojoMessagePipeEndpoint endpoint) { 242 void bind(core.MojoMessagePipeEndpoint endpoint) {
249 super.bind(endpoint); 243 super.bind(endpoint);
250 if (!isOpen && (_impl != null)) { 244 if (!isOpen && (_impl != null)) {
251 beginHandlingEvents(); 245 beginHandlingEvents();
252 } 246 }
253 } 247 }
254 248
249 @override
255 String toString() { 250 String toString() {
256 var superString = super.toString(); 251 var superString = super.toString();
257 return "HttpServerDelegateStub($superString)"; 252 return "_HttpServerDelegateStubControl($superString)";
258 } 253 }
259 254
260 int get version => 0; 255 int get version => 0;
261 256
262 static service_describer.ServiceDescription _cachedServiceDescription; 257 static service_describer.ServiceDescription _cachedServiceDescription;
263 static service_describer.ServiceDescription get serviceDescription { 258 static service_describer.ServiceDescription get serviceDescription {
264 if (_cachedServiceDescription == null) { 259 if (_cachedServiceDescription == null) {
265 _cachedServiceDescription = new _HttpServerDelegateServiceDescription(); 260 _cachedServiceDescription = new _HttpServerDelegateServiceDescription();
266 } 261 }
267 return _cachedServiceDescription; 262 return _cachedServiceDescription;
268 } 263 }
269 } 264 }
270 265
266 class HttpServerDelegateStub
267 extends bindings.Stub<HttpServerDelegate>
268 implements HttpServerDelegate {
269 HttpServerDelegateStub.fromEndpoint(
270 core.MojoMessagePipeEndpoint endpoint, [HttpServerDelegate impl])
271 : super(new _HttpServerDelegateStubControl.fromEndpoint(endpoint, impl));
272
273 HttpServerDelegateStub.fromHandle(
274 core.MojoHandle handle, [HttpServerDelegate impl])
275 : super(new _HttpServerDelegateStubControl.fromHandle(handle, impl));
276
277 HttpServerDelegateStub.unbound([HttpServerDelegate impl])
278 : super(new _HttpServerDelegateStubControl.unbound(impl));
279
280 static HttpServerDelegateStub newFromEndpoint(
281 core.MojoMessagePipeEndpoint endpoint) {
282 assert(endpoint.setDescription("For HttpServerDelegateStub"));
283 return new HttpServerDelegateStub.fromEndpoint(endpoint);
284 }
285
286 static service_describer.ServiceDescription get serviceDescription =>
287 _HttpServerDelegateStubControl.serviceDescription;
288
289
290 void onConnected(Object connection, Object delegate) {
291 return impl.onConnected(connection, delegate);
292 }
293 }
294
271 295
272 296
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698