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

Side by Side Diff: mojo/dart/packages/mojo_services/lib/mojo/tcp_connected_socket.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 tcp_connected_socket_mojom; 5 library tcp_connected_socket_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
11 11
12 12
13 class _TcpConnectedSocketServiceDescription implements service_describer.Service Description { 13 class _TcpConnectedSocketServiceDescription implements service_describer.Service Description {
14 dynamic getTopLevelInterface([Function responseFactory]) => 14 dynamic getTopLevelInterface([Function responseFactory]) =>
15 responseFactory(null); 15 responseFactory(null);
16 16
17 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => 17 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) =>
18 responseFactory(null); 18 responseFactory(null);
19 19
20 dynamic getAllTypeDefinitions([Function responseFactory]) => 20 dynamic getAllTypeDefinitions([Function responseFactory]) =>
21 responseFactory(null); 21 responseFactory(null);
22 } 22 }
23 23
24 abstract class TcpConnectedSocket { 24 abstract class TcpConnectedSocket {
25 static const String serviceName = null; 25 static const String serviceName = null;
26 } 26 }
27 27
28 28 class _TcpConnectedSocketProxyControl
29 class _TcpConnectedSocketProxyControl extends bindings.ProxyMessageHandler 29 extends bindings.ProxyMessageHandler
30 implements bindings.ProxyControl { 30 implements bindings.ProxyControl {
31 _TcpConnectedSocketProxyControl.fromEndpoint( 31 _TcpConnectedSocketProxyControl.fromEndpoint(
32 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); 32 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint);
33 33
34 _TcpConnectedSocketProxyControl.fromHandle( 34 _TcpConnectedSocketProxyControl.fromHandle(
35 core.MojoHandle handle) : super.fromHandle(handle); 35 core.MojoHandle handle) : super.fromHandle(handle);
36 36
37 _TcpConnectedSocketProxyControl.unbound() : super.unbound(); 37 _TcpConnectedSocketProxyControl.unbound() : super.unbound();
38 38
39 service_describer.ServiceDescription get serviceDescription => 39 service_describer.ServiceDescription get serviceDescription =>
40 new _TcpConnectedSocketServiceDescription(); 40 new _TcpConnectedSocketServiceDescription();
41 41
42 String get serviceName => TcpConnectedSocket.serviceName; 42 String get serviceName => TcpConnectedSocket.serviceName;
43 43
44 @override
45 void handleResponse(bindings.ServiceMessage message) { 44 void handleResponse(bindings.ServiceMessage message) {
46 switch (message.header.type) { 45 switch (message.header.type) {
47 default: 46 default:
48 proxyError("Unexpected message type: ${message.header.type}"); 47 proxyError("Unexpected message type: ${message.header.type}");
49 close(immediate: true); 48 close(immediate: true);
50 break; 49 break;
51 } 50 }
52 } 51 }
53 52
54 @override 53 @override
55 String toString() { 54 String toString() {
56 var superString = super.toString(); 55 var superString = super.toString();
57 return "_TcpConnectedSocketProxyControl($superString)"; 56 return "_TcpConnectedSocketProxyControl($superString)";
58 } 57 }
59 } 58 }
60 59
61 60 class TcpConnectedSocketProxy
62 class TcpConnectedSocketProxy extends bindings.Proxy 61 extends bindings.Proxy
63 implements TcpConnectedSocket { 62 implements TcpConnectedSocket {
64 TcpConnectedSocketProxy.fromEndpoint( 63 TcpConnectedSocketProxy.fromEndpoint(
65 core.MojoMessagePipeEndpoint endpoint) 64 core.MojoMessagePipeEndpoint endpoint)
66 : super(new _TcpConnectedSocketProxyControl.fromEndpoint(endpoint)); 65 : super(new _TcpConnectedSocketProxyControl.fromEndpoint(endpoint));
67 66
68 TcpConnectedSocketProxy.fromHandle(core.MojoHandle handle) 67 TcpConnectedSocketProxy.fromHandle(core.MojoHandle handle)
69 : super(new _TcpConnectedSocketProxyControl.fromHandle(handle)); 68 : super(new _TcpConnectedSocketProxyControl.fromHandle(handle));
70 69
71 TcpConnectedSocketProxy.unbound() 70 TcpConnectedSocketProxy.unbound()
72 : super(new _TcpConnectedSocketProxyControl.unbound()); 71 : super(new _TcpConnectedSocketProxyControl.unbound());
73 72
74 static TcpConnectedSocketProxy newFromEndpoint( 73 static TcpConnectedSocketProxy newFromEndpoint(
75 core.MojoMessagePipeEndpoint endpoint) { 74 core.MojoMessagePipeEndpoint endpoint) {
76 assert(endpoint.setDescription("For TcpConnectedSocketProxy")); 75 assert(endpoint.setDescription("For TcpConnectedSocketProxy"));
77 return new TcpConnectedSocketProxy.fromEndpoint(endpoint); 76 return new TcpConnectedSocketProxy.fromEndpoint(endpoint);
78 } 77 }
79 78
80 factory TcpConnectedSocketProxy.connectToService( 79 factory TcpConnectedSocketProxy.connectToService(
81 bindings.ServiceConnector s, String url, [String serviceName]) { 80 bindings.ServiceConnector s, String url, [String serviceName]) {
82 TcpConnectedSocketProxy p = new TcpConnectedSocketProxy.unbound(); 81 TcpConnectedSocketProxy p = new TcpConnectedSocketProxy.unbound();
83 s.connectToService(url, p, serviceName); 82 s.connectToService(url, p, serviceName);
84 return p; 83 return p;
85 } 84 }
86 85
87 86
88 } 87 }
89 88
90 89 class _TcpConnectedSocketStubControl
91 class TcpConnectedSocketStub extends bindings.Stub { 90 extends bindings.StubMessageHandler
91 implements bindings.StubControl<TcpConnectedSocket> {
92 TcpConnectedSocket _impl; 92 TcpConnectedSocket _impl;
93 93
94 TcpConnectedSocketStub.fromEndpoint( 94 _TcpConnectedSocketStubControl.fromEndpoint(
95 core.MojoMessagePipeEndpoint endpoint, [TcpConnectedSocket impl]) 95 core.MojoMessagePipeEndpoint endpoint, [TcpConnectedSocket impl])
96 : super.fromEndpoint(endpoint, autoBegin: impl != null) { 96 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
97 _impl = impl; 97 _impl = impl;
98 } 98 }
99 99
100 TcpConnectedSocketStub.fromHandle( 100 _TcpConnectedSocketStubControl.fromHandle(
101 core.MojoHandle handle, [TcpConnectedSocket impl]) 101 core.MojoHandle handle, [TcpConnectedSocket impl])
102 : super.fromHandle(handle, autoBegin: impl != null) { 102 : super.fromHandle(handle, autoBegin: impl != null) {
103 _impl = impl; 103 _impl = impl;
104 } 104 }
105 105
106 TcpConnectedSocketStub.unbound([this._impl]) : super.unbound(); 106 _TcpConnectedSocketStubControl.unbound([this._impl]) : super.unbound();
107
108 static TcpConnectedSocketStub newFromEndpoint(
109 core.MojoMessagePipeEndpoint endpoint) {
110 assert(endpoint.setDescription("For TcpConnectedSocketStub"));
111 return new TcpConnectedSocketStub.fromEndpoint(endpoint);
112 }
113 107
114 108
115 109
116 dynamic handleMessage(bindings.ServiceMessage message) { 110 dynamic handleMessage(bindings.ServiceMessage message) {
117 if (bindings.ControlMessageHandler.isControlMessage(message)) { 111 if (bindings.ControlMessageHandler.isControlMessage(message)) {
118 return bindings.ControlMessageHandler.handleMessage(this, 112 return bindings.ControlMessageHandler.handleMessage(this,
119 0, 113 0,
120 message); 114 message);
121 } 115 }
122 if (_impl == null) { 116 if (_impl == null) {
(...skipping 19 matching lines...) Expand all
142 } 136 }
143 137
144 @override 138 @override
145 void bind(core.MojoMessagePipeEndpoint endpoint) { 139 void bind(core.MojoMessagePipeEndpoint endpoint) {
146 super.bind(endpoint); 140 super.bind(endpoint);
147 if (!isOpen && (_impl != null)) { 141 if (!isOpen && (_impl != null)) {
148 beginHandlingEvents(); 142 beginHandlingEvents();
149 } 143 }
150 } 144 }
151 145
146 @override
152 String toString() { 147 String toString() {
153 var superString = super.toString(); 148 var superString = super.toString();
154 return "TcpConnectedSocketStub($superString)"; 149 return "_TcpConnectedSocketStubControl($superString)";
155 } 150 }
156 151
157 int get version => 0; 152 int get version => 0;
158 153
159 static service_describer.ServiceDescription _cachedServiceDescription; 154 static service_describer.ServiceDescription _cachedServiceDescription;
160 static service_describer.ServiceDescription get serviceDescription { 155 static service_describer.ServiceDescription get serviceDescription {
161 if (_cachedServiceDescription == null) { 156 if (_cachedServiceDescription == null) {
162 _cachedServiceDescription = new _TcpConnectedSocketServiceDescription(); 157 _cachedServiceDescription = new _TcpConnectedSocketServiceDescription();
163 } 158 }
164 return _cachedServiceDescription; 159 return _cachedServiceDescription;
165 } 160 }
166 } 161 }
167 162
163 class TcpConnectedSocketStub
164 extends bindings.Stub<TcpConnectedSocket>
165 implements TcpConnectedSocket {
166 TcpConnectedSocketStub.fromEndpoint(
167 core.MojoMessagePipeEndpoint endpoint, [TcpConnectedSocket impl])
168 : super(new _TcpConnectedSocketStubControl.fromEndpoint(endpoint, impl));
169
170 TcpConnectedSocketStub.fromHandle(
171 core.MojoHandle handle, [TcpConnectedSocket impl])
172 : super(new _TcpConnectedSocketStubControl.fromHandle(handle, impl));
173
174 TcpConnectedSocketStub.unbound([TcpConnectedSocket impl])
175 : super(new _TcpConnectedSocketStubControl.unbound(impl));
176
177 static TcpConnectedSocketStub newFromEndpoint(
178 core.MojoMessagePipeEndpoint endpoint) {
179 assert(endpoint.setDescription("For TcpConnectedSocketStub"));
180 return new TcpConnectedSocketStub.fromEndpoint(endpoint);
181 }
182
183 static service_describer.ServiceDescription get serviceDescription =>
184 _TcpConnectedSocketStubControl.serviceDescription;
185
186
187 }
188
168 189
169 190
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698