| OLD | NEW |
| 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 sharing_mojom; | 5 library sharing_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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 92 |
| 93 dynamic getAllTypeDefinitions([Function responseFactory]) => | 93 dynamic getAllTypeDefinitions([Function responseFactory]) => |
| 94 responseFactory(null); | 94 responseFactory(null); |
| 95 } | 95 } |
| 96 | 96 |
| 97 abstract class SharingService { | 97 abstract class SharingService { |
| 98 static const String serviceName = "mojo::SharingService"; | 98 static const String serviceName = "mojo::SharingService"; |
| 99 void shareText(String text); | 99 void shareText(String text); |
| 100 } | 100 } |
| 101 | 101 |
| 102 | 102 class _SharingServiceProxyControl |
| 103 class _SharingServiceProxyControl extends bindings.ProxyMessageHandler | 103 extends bindings.ProxyMessageHandler |
| 104 implements bindings.ProxyControl { | 104 implements bindings.ProxyControl { |
| 105 _SharingServiceProxyControl.fromEndpoint( | 105 _SharingServiceProxyControl.fromEndpoint( |
| 106 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 106 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
| 107 | 107 |
| 108 _SharingServiceProxyControl.fromHandle( | 108 _SharingServiceProxyControl.fromHandle( |
| 109 core.MojoHandle handle) : super.fromHandle(handle); | 109 core.MojoHandle handle) : super.fromHandle(handle); |
| 110 | 110 |
| 111 _SharingServiceProxyControl.unbound() : super.unbound(); | 111 _SharingServiceProxyControl.unbound() : super.unbound(); |
| 112 | 112 |
| 113 service_describer.ServiceDescription get serviceDescription => | 113 service_describer.ServiceDescription get serviceDescription => |
| 114 new _SharingServiceServiceDescription(); | 114 new _SharingServiceServiceDescription(); |
| 115 | 115 |
| 116 String get serviceName => SharingService.serviceName; | 116 String get serviceName => SharingService.serviceName; |
| 117 | 117 |
| 118 @override | |
| 119 void handleResponse(bindings.ServiceMessage message) { | 118 void handleResponse(bindings.ServiceMessage message) { |
| 120 switch (message.header.type) { | 119 switch (message.header.type) { |
| 121 default: | 120 default: |
| 122 proxyError("Unexpected message type: ${message.header.type}"); | 121 proxyError("Unexpected message type: ${message.header.type}"); |
| 123 close(immediate: true); | 122 close(immediate: true); |
| 124 break; | 123 break; |
| 125 } | 124 } |
| 126 } | 125 } |
| 127 | 126 |
| 128 @override | 127 @override |
| 129 String toString() { | 128 String toString() { |
| 130 var superString = super.toString(); | 129 var superString = super.toString(); |
| 131 return "_SharingServiceProxyControl($superString)"; | 130 return "_SharingServiceProxyControl($superString)"; |
| 132 } | 131 } |
| 133 } | 132 } |
| 134 | 133 |
| 135 | 134 class SharingServiceProxy |
| 136 class SharingServiceProxy extends bindings.Proxy | 135 extends bindings.Proxy |
| 137 implements SharingService { | 136 implements SharingService { |
| 138 SharingServiceProxy.fromEndpoint( | 137 SharingServiceProxy.fromEndpoint( |
| 139 core.MojoMessagePipeEndpoint endpoint) | 138 core.MojoMessagePipeEndpoint endpoint) |
| 140 : super(new _SharingServiceProxyControl.fromEndpoint(endpoint)); | 139 : super(new _SharingServiceProxyControl.fromEndpoint(endpoint)); |
| 141 | 140 |
| 142 SharingServiceProxy.fromHandle(core.MojoHandle handle) | 141 SharingServiceProxy.fromHandle(core.MojoHandle handle) |
| 143 : super(new _SharingServiceProxyControl.fromHandle(handle)); | 142 : super(new _SharingServiceProxyControl.fromHandle(handle)); |
| 144 | 143 |
| 145 SharingServiceProxy.unbound() | 144 SharingServiceProxy.unbound() |
| 146 : super(new _SharingServiceProxyControl.unbound()); | 145 : super(new _SharingServiceProxyControl.unbound()); |
| 147 | 146 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 164 ctrl.proxyError("The Proxy is closed."); | 163 ctrl.proxyError("The Proxy is closed."); |
| 165 return; | 164 return; |
| 166 } | 165 } |
| 167 var params = new _SharingServiceShareTextParams(); | 166 var params = new _SharingServiceShareTextParams(); |
| 168 params.text = text; | 167 params.text = text; |
| 169 ctrl.sendMessage(params, | 168 ctrl.sendMessage(params, |
| 170 _sharingServiceMethodShareTextName); | 169 _sharingServiceMethodShareTextName); |
| 171 } | 170 } |
| 172 } | 171 } |
| 173 | 172 |
| 174 | 173 class _SharingServiceStubControl |
| 175 class SharingServiceStub extends bindings.Stub { | 174 extends bindings.StubMessageHandler |
| 175 implements bindings.StubControl<SharingService> { |
| 176 SharingService _impl; | 176 SharingService _impl; |
| 177 | 177 |
| 178 SharingServiceStub.fromEndpoint( | 178 _SharingServiceStubControl.fromEndpoint( |
| 179 core.MojoMessagePipeEndpoint endpoint, [SharingService impl]) | 179 core.MojoMessagePipeEndpoint endpoint, [SharingService impl]) |
| 180 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 180 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
| 181 _impl = impl; | 181 _impl = impl; |
| 182 } | 182 } |
| 183 | 183 |
| 184 SharingServiceStub.fromHandle( | 184 _SharingServiceStubControl.fromHandle( |
| 185 core.MojoHandle handle, [SharingService impl]) | 185 core.MojoHandle handle, [SharingService impl]) |
| 186 : super.fromHandle(handle, autoBegin: impl != null) { | 186 : super.fromHandle(handle, autoBegin: impl != null) { |
| 187 _impl = impl; | 187 _impl = impl; |
| 188 } | 188 } |
| 189 | 189 |
| 190 SharingServiceStub.unbound([this._impl]) : super.unbound(); | 190 _SharingServiceStubControl.unbound([this._impl]) : super.unbound(); |
| 191 | |
| 192 static SharingServiceStub newFromEndpoint( | |
| 193 core.MojoMessagePipeEndpoint endpoint) { | |
| 194 assert(endpoint.setDescription("For SharingServiceStub")); | |
| 195 return new SharingServiceStub.fromEndpoint(endpoint); | |
| 196 } | |
| 197 | 191 |
| 198 | 192 |
| 199 | 193 |
| 200 dynamic handleMessage(bindings.ServiceMessage message) { | 194 dynamic handleMessage(bindings.ServiceMessage message) { |
| 201 if (bindings.ControlMessageHandler.isControlMessage(message)) { | 195 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
| 202 return bindings.ControlMessageHandler.handleMessage(this, | 196 return bindings.ControlMessageHandler.handleMessage(this, |
| 203 0, | 197 0, |
| 204 message); | 198 message); |
| 205 } | 199 } |
| 206 if (_impl == null) { | 200 if (_impl == null) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 231 } | 225 } |
| 232 | 226 |
| 233 @override | 227 @override |
| 234 void bind(core.MojoMessagePipeEndpoint endpoint) { | 228 void bind(core.MojoMessagePipeEndpoint endpoint) { |
| 235 super.bind(endpoint); | 229 super.bind(endpoint); |
| 236 if (!isOpen && (_impl != null)) { | 230 if (!isOpen && (_impl != null)) { |
| 237 beginHandlingEvents(); | 231 beginHandlingEvents(); |
| 238 } | 232 } |
| 239 } | 233 } |
| 240 | 234 |
| 235 @override |
| 241 String toString() { | 236 String toString() { |
| 242 var superString = super.toString(); | 237 var superString = super.toString(); |
| 243 return "SharingServiceStub($superString)"; | 238 return "_SharingServiceStubControl($superString)"; |
| 244 } | 239 } |
| 245 | 240 |
| 246 int get version => 0; | 241 int get version => 0; |
| 247 | 242 |
| 248 static service_describer.ServiceDescription _cachedServiceDescription; | 243 static service_describer.ServiceDescription _cachedServiceDescription; |
| 249 static service_describer.ServiceDescription get serviceDescription { | 244 static service_describer.ServiceDescription get serviceDescription { |
| 250 if (_cachedServiceDescription == null) { | 245 if (_cachedServiceDescription == null) { |
| 251 _cachedServiceDescription = new _SharingServiceServiceDescription(); | 246 _cachedServiceDescription = new _SharingServiceServiceDescription(); |
| 252 } | 247 } |
| 253 return _cachedServiceDescription; | 248 return _cachedServiceDescription; |
| 254 } | 249 } |
| 255 } | 250 } |
| 256 | 251 |
| 252 class SharingServiceStub |
| 253 extends bindings.Stub<SharingService> |
| 254 implements SharingService { |
| 255 SharingServiceStub.fromEndpoint( |
| 256 core.MojoMessagePipeEndpoint endpoint, [SharingService impl]) |
| 257 : super(new _SharingServiceStubControl.fromEndpoint(endpoint, impl)); |
| 258 |
| 259 SharingServiceStub.fromHandle( |
| 260 core.MojoHandle handle, [SharingService impl]) |
| 261 : super(new _SharingServiceStubControl.fromHandle(handle, impl)); |
| 262 |
| 263 SharingServiceStub.unbound([SharingService impl]) |
| 264 : super(new _SharingServiceStubControl.unbound(impl)); |
| 265 |
| 266 static SharingServiceStub newFromEndpoint( |
| 267 core.MojoMessagePipeEndpoint endpoint) { |
| 268 assert(endpoint.setDescription("For SharingServiceStub")); |
| 269 return new SharingServiceStub.fromEndpoint(endpoint); |
| 270 } |
| 271 |
| 272 static service_describer.ServiceDescription get serviceDescription => |
| 273 _SharingServiceStubControl.serviceDescription; |
| 274 |
| 275 |
| 276 void shareText(String text) { |
| 277 return impl.shareText(text); |
| 278 } |
| 279 } |
| 280 |
| 257 | 281 |
| 258 | 282 |
| OLD | NEW |