Merge branch 'master' into linux-ime
diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 30f1151..d2391d0 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py
@@ -1063,11 +1063,30 @@ return errors +def _CheckDartBindings(input_api, output_api): + """Check that generated .mojom.dart files are current""" + args = [input_api.python_executable, + 'mojo/dart/tools/presubmit/check_mojom_dart.py', + '--affected-files'] + files = [] + for f in input_api.AffectedFiles(): + files.append(f.LocalPath()) + args.extend(files) + try: + input_api.subprocess.check_output(args) + return [] + except input_api.subprocess.CalledProcessError, error: + return [output_api.PresubmitError( + 'Dart bindings need to be updated.', + long_text=error.output)] + + def CheckChangeOnUpload(input_api, output_api): results = [] results.extend(_CommonChecks(input_api, output_api)) results.extend(_CheckValidHostsInDEPS(input_api, output_api)) results.extend(_CheckJavaStyle(input_api, output_api)) + results.extend(_CheckDartBindings(input_api, output_api)) results.extend( input_api.canned_checks.CheckGNFormatted(input_api, output_api)) return results
diff --git a/base/sha1.h b/base/sha1.h index 998cccb..089381e 100644 --- a/base/sha1.h +++ b/base/sha1.h
@@ -24,6 +24,11 @@ BASE_EXPORT void SHA1HashBytes(const unsigned char* data, size_t len, unsigned char* hash); +// Computes the SHA-1 hash of |file_path| and puts the hash in |hash|. +// |hash| must be kSha1Length bytes long. Returns false on error. +BASE_EXPORT bool SHA1HashFile(const std::string& file_path, + unsigned char* hash); + } // namespace base #endif // BASE_SHA1_H_
diff --git a/base/sha1_portable.cc b/base/sha1_portable.cc index 0b9df83..e653843 100644 --- a/base/sha1_portable.cc +++ b/base/sha1_portable.cc
@@ -4,9 +4,11 @@ #include "base/sha1.h" +#include <stdio.h> #include <string.h> #include "base/basictypes.h" +#include "base/files/scoped_file.h" namespace base { @@ -213,4 +215,27 @@ memcpy(hash, sha.Digest(), SecureHashAlgorithm::kDigestSizeBytes); } +bool SHA1HashFile(const std::string& file_path, unsigned char* hash) { + SecureHashAlgorithm sha; + base::ScopedFILE file(fopen(file_path.c_str(), "rb")); + if (!file) { + LOG(ERROR) << "Could not open file " << file_path; + return false; + } + const size_t kBufferSize = 1 << 16; + scoped_ptr<char[]> buf(new char[kBufferSize]); + size_t len; + while ((len = fread(buf.get(), 1, kBufferSize, file.get())) > 0) + sha.Update(buf.get(), len); + if (ferror(file.get())) { + LOG(ERROR) << "Error reading file " << file_path; + return false; + } + + sha.Final(); + + memcpy(hash, sha.Digest(), SecureHashAlgorithm::kDigestSizeBytes); + return true; +} + } // namespace base
diff --git a/benchmarks/dart_handler_running/BUILD.gn b/benchmarks/dart_handler_running/BUILD.gn index 771adf3..3bb4b43 100644 --- a/benchmarks/dart_handler_running/BUILD.gn +++ b/benchmarks/dart_handler_running/BUILD.gn
@@ -14,7 +14,6 @@ ] deps = [ "//mojo/common/dart", - "//mojo/dart/mojo_services", "//mojo/dart/packages/", "//mojo/public/dart", ]
diff --git a/benchmarks/dart_startup/BUILD.gn b/benchmarks/dart_startup/BUILD.gn index e3acc58..404835c 100644 --- a/benchmarks/dart_startup/BUILD.gn +++ b/benchmarks/dart_startup/BUILD.gn
@@ -14,7 +14,8 @@ ] deps = [ "//mojo/common/dart", - "//mojo/dart/mojo_services", + "//mojo/dart/packages/mojo_services", + "//mojo/dart/packages/mojo", "//mojo/public/dart", ] }
diff --git a/build/config/nacl/config.gni b/build/config/nacl/config.gni index b743910..652c37a 100644 --- a/build/config/nacl/config.gni +++ b/build/config/nacl/config.gni
@@ -7,6 +7,12 @@ # is assumed to be the default one; use this to determine whether Glibc # is being used instead. is_nacl_glibc = false + + # TODO(ncbray): support ASAN once NaCl's GN build is unforked. + # TODO(cstout): support fnl/musl build in nacl + mojo_use_nacl_sfi = is_linux && !is_asan && !is_fnl + mojo_use_nacl_nonsfi = (is_linux || is_android) && !is_asan && !is_fnl + mojo_use_nacl = mojo_use_nacl_sfi || mojo_use_nacl_nonsfi } nacl_toolchain_dir = "//native_client/toolchain/${host_os}_x86"
diff --git a/examples/BUILD.gn b/examples/BUILD.gn index 89e9cfc..1c4a13a 100644 --- a/examples/BUILD.gn +++ b/examples/BUILD.gn
@@ -2,6 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//build/config/nacl/config.gni") import("//build/config/ui.gni") # Collection of examples which are currently capable of being built as pexes. @@ -77,7 +78,7 @@ deps += [ "//examples/python" ] } - if ((is_linux || is_android) && !is_asan) { + if (mojo_use_nacl && (is_linux || is_android) && !is_asan) { deps += [ ":portable_examples(//build/toolchain/nacl:newlib_pnacl)" ] } }
diff --git a/examples/dart/device_info/BUILD.gn b/examples/dart/device_info/BUILD.gn index 7dfb9a0..f4676f5 100644 --- a/examples/dart/device_info/BUILD.gn +++ b/examples/dart/device_info/BUILD.gn
@@ -13,7 +13,8 @@ "pubspec.yaml", ] deps = [ - "//mojo/dart/mojo_services", + "//mojo/dart/packages/mojo", + "//mojo/dart/packages/mojo_services", "//mojo/public/dart", ] }
diff --git a/examples/dart/netcat/BUILD.gn b/examples/dart/netcat/BUILD.gn index 76d3ac3..7c9cdf9 100644 --- a/examples/dart/netcat/BUILD.gn +++ b/examples/dart/netcat/BUILD.gn
@@ -13,7 +13,6 @@ "pubspec.yaml", ] deps = [ - "//mojo/dart/mojo_services", "//mojo/dart/packages/", "//mojo/public/dart", ]
diff --git a/examples/dart/netcat/lib/main.dart b/examples/dart/netcat/lib/main.dart index 4cef6a6..83b47e3 100644 --- a/examples/dart/netcat/lib/main.dart +++ b/examples/dart/netcat/lib/main.dart
@@ -124,11 +124,11 @@ } void _onSocketReceiverEvent(List<int> event) { - var mojoSignals = new MojoHandleSignals(event[1]); + int mojoSignals = event[1]; var shouldShutDown = false; - if (mojoSignals.isReadable) { + if (MojoHandleSignals.isReadable(mojoSignals)) { var numBytesRead = _socketReceiver.read(_readBuffer); - if (_socketReceiver.status.isOk) { + if (_socketReceiver.status == MojoResult.kOk) { assert(numBytesRead > 0); _terminal.ptr .write(_readBuffer.buffer.asUint8List(0, numBytesRead), 0, @@ -140,10 +140,11 @@ } else { shouldShutDown = true; } - } else if (mojoSignals.isPeerClosed) { + } else if (MojoHandleSignals.isPeerClosed(mojoSignals)) { shouldShutDown = true; } else { - throw 'Unexpected handle event: $mojoSignals'; + String signals = MojoHandleSignals.string(mojoSignals); + throw 'Unexpected handle event: $signals'; } if (shouldShutDown) { _shutDown();
diff --git a/examples/dart/wget/BUILD.gn b/examples/dart/wget/BUILD.gn index b07d70d..0902ff3 100644 --- a/examples/dart/wget/BUILD.gn +++ b/examples/dart/wget/BUILD.gn
@@ -13,7 +13,7 @@ "pubspec.yaml", ] deps = [ - "//mojo/dart/mojo_services", + "//mojo/dart/packages/mojo_services", "//mojo/public/dart", ] }
diff --git a/mojo/BUILD.gn b/mojo/BUILD.gn index 23682f4..75ddfa1 100644 --- a/mojo/BUILD.gn +++ b/mojo/BUILD.gn
@@ -2,17 +2,13 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//build/config/nacl/config.gni") import("//build/module_args/mojo.gni") import("//mojo/public/mojo.gni") import("//testing/test.gni") declare_args() { mojo_use_go = false - - # TODO(ncbray): support ASAN once NaCl's GN build is unforked. - # TODO(cstout): support fnl/musl build in nacl - mojo_use_nacl = is_linux && !is_asan && !is_fnl - mojo_use_nacl_nonsfi = (is_linux || is_android) && !is_asan && !is_fnl } group("mojo") { @@ -44,17 +40,19 @@ } if (mojo_use_nacl) { - deps += [ - "//mojo/nacl/sfi:mojo_nacl", - "//mojo/nacl/sfi:mojo_nacl_tests", - ] - } + if (mojo_use_nacl_sfi) { + deps += [ + "//mojo/nacl/sfi:mojo_nacl", + "//mojo/nacl/sfi:mojo_nacl_tests", + ] + } - if (mojo_use_nacl_nonsfi) { - deps += [ - "//mojo/nacl/nonsfi:mojo_nacl_nonsfi", - "//mojo/nacl/nonsfi:mojo_nacl_tests_nonsfi", - ] + if (mojo_use_nacl_nonsfi) { + deps += [ + "//mojo/nacl/nonsfi:mojo_nacl_nonsfi", + "//mojo/nacl/nonsfi:mojo_nacl_tests_nonsfi", + ] + } } }
diff --git a/mojo/common/dart/BUILD.gn b/mojo/common/dart/BUILD.gn index 0b4f724..72f23f2 100644 --- a/mojo/common/dart/BUILD.gn +++ b/mojo/common/dart/BUILD.gn
@@ -12,6 +12,6 @@ ] deps = [ "//mojo/public/dart", - "//mojo/dart/mojo_services", + "//mojo/dart/packages", ] }
diff --git a/mojo/converters/surfaces/tests/surface_unittest.cc b/mojo/converters/surfaces/tests/surface_unittest.cc index 4c16d78..7e0a850 100644 --- a/mojo/converters/surfaces/tests/surface_unittest.cc +++ b/mojo/converters/surfaces/tests/surface_unittest.cc
@@ -72,13 +72,13 @@ QuadPtr mojo_quad = Quad::From<cc::DrawQuad>(*color_quad); ASSERT_FALSE(mojo_quad.is_null()); EXPECT_EQ(Material::SOLID_COLOR, mojo_quad->material); - EXPECT_EQ(Rect::From(rect), mojo_quad->rect); - EXPECT_EQ(Rect::From(opaque_rect), mojo_quad->opaque_rect); - EXPECT_EQ(Rect::From(visible_rect), mojo_quad->visible_rect); + EXPECT_TRUE(Rect::From(rect)->Equals(*mojo_quad->rect)); + EXPECT_TRUE(Rect::From(opaque_rect)->Equals(*mojo_quad->opaque_rect)); + EXPECT_TRUE(Rect::From(visible_rect)->Equals(*mojo_quad->visible_rect)); EXPECT_EQ(needs_blending, mojo_quad->needs_blending); ASSERT_TRUE(mojo_quad->solid_color_quad_state); SolidColorQuadStatePtr& mojo_color_state = mojo_quad->solid_color_quad_state; - EXPECT_EQ(Color::From(arbitrary_color), mojo_color_state->color); + EXPECT_TRUE(Color::From(arbitrary_color)->Equals(*mojo_color_state->color)); EXPECT_EQ(force_anti_aliasing_off, mojo_color_state->force_anti_aliasing_off); } @@ -94,8 +94,8 @@ EXPECT_EQ(Material::SURFACE_CONTENT, mojo_quad->material); ASSERT_TRUE(mojo_quad->surface_quad_state); SurfaceQuadStatePtr& mojo_surface_state = mojo_quad->surface_quad_state; - EXPECT_EQ(SurfaceId::From(arbitrary_id), - mojo_surface_state->surface); + EXPECT_TRUE( + SurfaceId::From(arbitrary_id)->Equals(*mojo_surface_state->surface)); } TEST_F(SurfaceLibQuadTest, TextureQuad) { @@ -130,10 +130,12 @@ TextureQuadStatePtr& mojo_texture_state = mojo_quad->texture_quad_state; EXPECT_EQ(resource_id, mojo_texture_state->resource_id); EXPECT_EQ(premultiplied_alpha, mojo_texture_state->premultiplied_alpha); - EXPECT_EQ(PointF::From(uv_top_left), mojo_texture_state->uv_top_left); - EXPECT_EQ(PointF::From(uv_bottom_right), mojo_texture_state->uv_bottom_right); - EXPECT_EQ(Color::From(background_color), - mojo_texture_state->background_color); + EXPECT_TRUE( + PointF::From(uv_top_left)->Equals(*mojo_texture_state->uv_top_left)); + EXPECT_TRUE(PointF::From(uv_bottom_right) + ->Equals(*mojo_texture_state->uv_bottom_right)); + EXPECT_TRUE(Color::From(background_color) + ->Equals(*mojo_texture_state->background_color)); for (size_t i = 0; i < 4; ++i) { EXPECT_EQ(vertex_opacity[i], mojo_texture_state->vertex_opacity[i]) << i; } @@ -194,11 +196,12 @@ SharedQuadStatePtr mojo_sqs = SharedQuadState::From(*sqs); ASSERT_FALSE(mojo_sqs.is_null()); - EXPECT_EQ(Transform::From(content_to_target_transform), - mojo_sqs->content_to_target_transform); - EXPECT_EQ(Size::From(content_bounds), mojo_sqs->content_bounds); - EXPECT_EQ(Rect::From(visible_content_rect), mojo_sqs->visible_content_rect); - EXPECT_EQ(Rect::From(clip_rect), mojo_sqs->clip_rect); + EXPECT_TRUE(Transform::From(content_to_target_transform) + ->Equals(*mojo_sqs->content_to_target_transform)); + EXPECT_TRUE(Size::From(content_bounds)->Equals(*mojo_sqs->content_bounds)); + EXPECT_TRUE(Rect::From(visible_content_rect) + ->Equals(*mojo_sqs->visible_content_rect)); + EXPECT_TRUE(Rect::From(clip_rect)->Equals(*mojo_sqs->clip_rect)); EXPECT_EQ(is_clipped, mojo_sqs->is_clipped); EXPECT_EQ(opacity, mojo_sqs->opacity); EXPECT_EQ(sorting_context_id, mojo_sqs->sorting_context_id); @@ -287,10 +290,10 @@ PassPtr mojo_pass = Pass::From(*pass); ASSERT_FALSE(mojo_pass.is_null()); EXPECT_EQ(6, mojo_pass->id); - EXPECT_EQ(Rect::From(output_rect), mojo_pass->output_rect); - EXPECT_EQ(Rect::From(damage_rect), mojo_pass->damage_rect); - EXPECT_EQ(Transform::From(transform_to_root_target), - mojo_pass->transform_to_root_target); + EXPECT_TRUE(Rect::From(output_rect)->Equals(*mojo_pass->output_rect)); + EXPECT_TRUE(Rect::From(damage_rect)->Equals(*mojo_pass->damage_rect)); + EXPECT_TRUE(Transform::From(transform_to_root_target) + ->Equals(*mojo_pass->transform_to_root_target)); EXPECT_EQ(has_transparent_background, mojo_pass->has_transparent_background); ASSERT_EQ(1u, mojo_pass->shared_quad_states.size()); ASSERT_EQ(3u, mojo_pass->quads.size()); @@ -416,7 +419,7 @@ EXPECT_EQ(static_cast<ResourceFormat>(format), mojo_resource->format); EXPECT_EQ(filter, mojo_resource->filter); - EXPECT_EQ(Size::From(size), mojo_resource->size); + EXPECT_TRUE(Size::From(size)->Equals(*mojo_resource->size)); EXPECT_EQ(is_repeated, mojo_resource->is_repeated); EXPECT_EQ(is_software, mojo_resource->is_software);
diff --git a/mojo/dart/BUILD.gn b/mojo/dart/BUILD.gn index c91265e..abaa709 100644 --- a/mojo/dart/BUILD.gn +++ b/mojo/dart/BUILD.gn
@@ -6,8 +6,8 @@ deps = [ "//mojo/dart/dart_snapshotter($host_toolchain)", "//mojo/dart/http_load_test", - "//mojo/dart/mojo_services", "//mojo/dart/observatory_test", - "//mojo/dart/mojo_sdk", + "//mojo/dart/packages/mojo_sdk", + "//mojo/dart/packages/mojo_services", ] }
diff --git a/mojo/dart/embedder/io/socket_patch.dart b/mojo/dart/embedder/io/socket_patch.dart index 80b172c..6768216 100644 --- a/mojo/dart/embedder/io/socket_patch.dart +++ b/mojo/dart/embedder/io/socket_patch.dart
@@ -245,18 +245,18 @@ if (_inClosed) { return; } - var signalsWatched = new MojoHandleSignals(event[0]); - var signalsReceived = new MojoHandleSignals(event[1]); + int signalsWatched = event[0]; + int signalsReceived = event[1]; if (_trace) { _tracePrint('<- IN: ${signalsReceived}'); } - if (signalsReceived.isReadable) { + if (MojoHandleSignals.isReadable(signalsReceived)) { if (_trace) { _tracePrint('<- READ'); } _controller.add(RawSocketEvent.READ); } - if (signalsReceived.isPeerClosed) { + if (MojoHandleSignals.isPeerClosed(signalsReceived)) { if (_trace) { _tracePrint('<- READ_CLOSED'); } @@ -271,12 +271,12 @@ if (_outClosed) { return; } - var signalsWatched = new MojoHandleSignals(event[0]); - var signalsReceived = new MojoHandleSignals(event[1]); + int signalsWatched = event[0]; + int signalsReceived = event[1]; if (_trace) { _tracePrint('<- OUT: ${signalsReceived}'); } - if (signalsReceived.isPeerClosed) { + if (MojoHandleSignals.isPeerClosed(signalsReceived)) { if (_trace) { _tracePrint('<- CLOSED'); } @@ -285,7 +285,7 @@ _outClosed = true; return; } - if (signalsReceived.isWritable) { + if (MojoHandleSignals.isWritable(signalsReceived)) { if (_trace) { _tracePrint('<- WRITE'); } @@ -295,17 +295,15 @@ _setupIn() { assert(_pipeInEvents == null); - _pipeInEvents = new MojoEventSubscription(_pipeIn.consumer.handle, - MojoHandleSignals.READABLE + - MojoHandleSignals.PEER_CLOSED); + _pipeInEvents = new MojoEventSubscription( + _pipeIn.consumer.handle, MojoHandleSignals.kPeerClosedReadable); _pipeInEvents.subscribe(_onInputData); } _setupOut() { assert(_pipeOutEvents == null); - _pipeOutEvents = new MojoEventSubscription(_pipeOut.producer.handle, - MojoHandleSignals.WRITABLE + - MojoHandleSignals.PEER_CLOSED); + _pipeOutEvents = new MojoEventSubscription( + _pipeOut.producer.handle, MojoHandleSignals.kPeerClosedWritable); _pipeOutEvents.subscribe(_onOutputData); } @@ -466,23 +464,21 @@ if (subscription == null) { return; } - subscription.enableSignals(MojoHandleSignals.PEER_CLOSED + - MojoHandleSignals.READABLE); + subscription.enableSignals(MojoHandleSignals.kPeerClosedReadable); } static _enableWriteEvents(MojoEventSubscription subscription) { if (subscription == null) { return; } - subscription.enableSignals(MojoHandleSignals.PEER_CLOSED + - MojoHandleSignals.WRITABLE); + subscription.enableSignals(MojoHandleSignals.kPeerClosedWritable); } static _disableEvents(MojoEventSubscription subscription) { if (subscription == null) { return; } - subscription.enableSignals(MojoHandleSignals.PEER_CLOSED); + subscription.enableSignals(MojoHandleSignals.kPeerClosed); } _pause() {
diff --git a/mojo/dart/http_load_test/BUILD.gn b/mojo/dart/http_load_test/BUILD.gn index f1dc274..bd7104e 100644 --- a/mojo/dart/http_load_test/BUILD.gn +++ b/mojo/dart/http_load_test/BUILD.gn
@@ -15,7 +15,6 @@ ] deps = [ "//mojo/dart/packages/", - "//mojo/dart/mojo_services", "//mojo/public/dart", ] }
diff --git a/mojo/dart/mojo_services/BUILD.gn b/mojo/dart/mojo_services/BUILD.gn deleted file mode 100644 index b0c67fe..0000000 --- a/mojo/dart/mojo_services/BUILD.gn +++ /dev/null
@@ -1,19 +0,0 @@ -# Copyright 2015 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import("//mojo/public/dart/rules.gni") -import("//mojo/services/mojo_services.gni") - -dart_pkg("mojo_services") { - sources = [ - "CHANGELOG.md", - "README.md", - "pubspec.yaml", - ] - - deps = [ - "//mojo/public/dart", - "//mojo/services", - ] -}
diff --git a/mojo/dart/packages/BUILD.gn b/mojo/dart/packages/BUILD.gn index ddcbf71..b0a19c1 100644 --- a/mojo/dart/packages/BUILD.gn +++ b/mojo/dart/packages/BUILD.gn
@@ -6,6 +6,8 @@ deps = [ "//mojo/dart/packages/mojo", "//mojo/dart/packages/mojo_apptest", + "//mojo/dart/packages/mojo_sdk", + "//mojo/dart/packages/mojo_services", "//mojo/dart/packages/mojom", ] }
diff --git a/mojo/public/dart/mojo/sdk_ext/lib/mojo/application.mojom.dart b/mojo/dart/packages/mojo/lib/mojo/application.mojom.dart similarity index 100% rename from mojo/public/dart/mojo/sdk_ext/lib/mojo/application.mojom.dart rename to mojo/dart/packages/mojo/lib/mojo/application.mojom.dart
diff --git a/mojo/dart/packages/mojo/lib/mojo/application_connector.mojom.dart b/mojo/dart/packages/mojo/lib/mojo/application_connector.mojom.dart new file mode 100644 index 0000000..6f88cd6 --- /dev/null +++ b/mojo/dart/packages/mojo/lib/mojo/application_connector.mojom.dart
@@ -0,0 +1,356 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library application_connector_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo/mojo/service_provider.mojom.dart' as service_provider_mojom; + + + +class ApplicationConnectorConnectToApplicationParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(32, 0) + ]; + String applicationUrl = null; + Object services = null; + Object exposedServices = null; + + ApplicationConnectorConnectToApplicationParams() : super(kVersions.last.size); + + static ApplicationConnectorConnectToApplicationParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ApplicationConnectorConnectToApplicationParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ApplicationConnectorConnectToApplicationParams result = new ApplicationConnectorConnectToApplicationParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.applicationUrl = decoder0.decodeString(8, false); + } + if (mainDataHeader.version >= 0) { + + result.services = decoder0.decodeInterfaceRequest(16, true, service_provider_mojom.ServiceProviderStub.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.exposedServices = decoder0.decodeServiceInterface(20, true, service_provider_mojom.ServiceProviderProxy.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(applicationUrl, 8, false); + + encoder0.encodeInterfaceRequest(services, 16, true); + + encoder0.encodeInterface(exposedServices, 20, true); + } + + String toString() { + return "ApplicationConnectorConnectToApplicationParams(" + "applicationUrl: $applicationUrl" ", " + "services: $services" ", " + "exposedServices: $exposedServices" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class ApplicationConnectorDuplicateParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + Object applicationConnectorRequest = null; + + ApplicationConnectorDuplicateParams() : super(kVersions.last.size); + + static ApplicationConnectorDuplicateParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ApplicationConnectorDuplicateParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ApplicationConnectorDuplicateParams result = new ApplicationConnectorDuplicateParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.applicationConnectorRequest = decoder0.decodeInterfaceRequest(8, false, ApplicationConnectorStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterfaceRequest(applicationConnectorRequest, 8, false); + } + + String toString() { + return "ApplicationConnectorDuplicateParams(" + "applicationConnectorRequest: $applicationConnectorRequest" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + +const int kApplicationConnector_connectToApplication_name = 0; +const int kApplicationConnector_duplicate_name = 1; + +const String ApplicationConnectorName = + 'mojo::ApplicationConnector'; + +abstract class ApplicationConnector { + void connectToApplication(String applicationUrl, Object services, Object exposedServices); + void duplicate(Object applicationConnectorRequest); + +} + + +class ApplicationConnectorProxyImpl extends bindings.Proxy { + ApplicationConnectorProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + ApplicationConnectorProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + ApplicationConnectorProxyImpl.unbound() : super.unbound(); + + static ApplicationConnectorProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ApplicationConnectorProxyImpl")); + return new ApplicationConnectorProxyImpl.fromEndpoint(endpoint); + } + + String get name => ApplicationConnectorName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "ApplicationConnectorProxyImpl($superString)"; + } +} + + +class _ApplicationConnectorProxyCalls implements ApplicationConnector { + ApplicationConnectorProxyImpl _proxyImpl; + + _ApplicationConnectorProxyCalls(this._proxyImpl); + void connectToApplication(String applicationUrl, Object services, Object exposedServices) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new ApplicationConnectorConnectToApplicationParams(); + params.applicationUrl = applicationUrl; + params.services = services; + params.exposedServices = exposedServices; + _proxyImpl.sendMessage(params, kApplicationConnector_connectToApplication_name); + } + + void duplicate(Object applicationConnectorRequest) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new ApplicationConnectorDuplicateParams(); + params.applicationConnectorRequest = applicationConnectorRequest; + _proxyImpl.sendMessage(params, kApplicationConnector_duplicate_name); + } + +} + + +class ApplicationConnectorProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + ApplicationConnector ptr; + final String name = ApplicationConnectorName; + + ApplicationConnectorProxy(ApplicationConnectorProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _ApplicationConnectorProxyCalls(proxyImpl); + + ApplicationConnectorProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new ApplicationConnectorProxyImpl.fromEndpoint(endpoint) { + ptr = new _ApplicationConnectorProxyCalls(impl); + } + + ApplicationConnectorProxy.fromHandle(core.MojoHandle handle) : + impl = new ApplicationConnectorProxyImpl.fromHandle(handle) { + ptr = new _ApplicationConnectorProxyCalls(impl); + } + + ApplicationConnectorProxy.unbound() : + impl = new ApplicationConnectorProxyImpl.unbound() { + ptr = new _ApplicationConnectorProxyCalls(impl); + } + + factory ApplicationConnectorProxy.connectToService( + bindings.ServiceConnector s, String url) { + ApplicationConnectorProxy p = new ApplicationConnectorProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static ApplicationConnectorProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ApplicationConnectorProxy")); + return new ApplicationConnectorProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "ApplicationConnectorProxy($impl)"; + } +} + + +class ApplicationConnectorStub extends bindings.Stub { + ApplicationConnector _impl = null; + + ApplicationConnectorStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + ApplicationConnectorStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + ApplicationConnectorStub.unbound() : super.unbound(); + + static ApplicationConnectorStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ApplicationConnectorStub")); + return new ApplicationConnectorStub.fromEndpoint(endpoint); + } + + static const String name = ApplicationConnectorName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kApplicationConnector_connectToApplication_name: + var params = ApplicationConnectorConnectToApplicationParams.deserialize( + message.payload); + _impl.connectToApplication(params.applicationUrl, params.services, params.exposedServices); + break; + case kApplicationConnector_duplicate_name: + var params = ApplicationConnectorDuplicateParams.deserialize( + message.payload); + _impl.duplicate(params.applicationConnectorRequest); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + ApplicationConnector get impl => _impl; + set impl(ApplicationConnector d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "ApplicationConnectorStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/public/dart/mojo/sdk_ext/lib/mojo/http_header.mojom.dart b/mojo/dart/packages/mojo/lib/mojo/http_header.mojom.dart similarity index 100% rename from mojo/public/dart/mojo/sdk_ext/lib/mojo/http_header.mojom.dart rename to mojo/dart/packages/mojo/lib/mojo/http_header.mojom.dart
diff --git a/mojo/public/dart/mojo/sdk_ext/lib/mojo/interface_control_messages.mojom.dart b/mojo/dart/packages/mojo/lib/mojo/interface_control_messages.mojom.dart similarity index 100% rename from mojo/public/dart/mojo/sdk_ext/lib/mojo/interface_control_messages.mojom.dart rename to mojo/dart/packages/mojo/lib/mojo/interface_control_messages.mojom.dart
diff --git a/mojo/public/dart/mojo/sdk_ext/lib/mojo/network_error.mojom.dart b/mojo/dart/packages/mojo/lib/mojo/network_error.mojom.dart similarity index 100% rename from mojo/public/dart/mojo/sdk_ext/lib/mojo/network_error.mojom.dart rename to mojo/dart/packages/mojo/lib/mojo/network_error.mojom.dart
diff --git a/mojo/public/dart/mojo/sdk_ext/lib/mojo/service_provider.mojom.dart b/mojo/dart/packages/mojo/lib/mojo/service_provider.mojom.dart similarity index 100% rename from mojo/public/dart/mojo/sdk_ext/lib/mojo/service_provider.mojom.dart rename to mojo/dart/packages/mojo/lib/mojo/service_provider.mojom.dart
diff --git a/mojo/public/dart/mojo/sdk_ext/lib/mojo/shell.mojom.dart b/mojo/dart/packages/mojo/lib/mojo/shell.mojom.dart similarity index 70% rename from mojo/public/dart/mojo/sdk_ext/lib/mojo/shell.mojom.dart rename to mojo/dart/packages/mojo/lib/mojo/shell.mojom.dart index 60d7ab5..8fb8135 100644 --- a/mojo/public/dart/mojo/sdk_ext/lib/mojo/shell.mojom.dart +++ b/mojo/dart/packages/mojo/lib/mojo/shell.mojom.dart
@@ -8,6 +8,7 @@ import 'package:mojo/bindings.dart' as bindings; import 'package:mojo/core.dart' as core; +import 'package:mojo/mojo/application_connector.mojom.dart' as application_connector_mojom; import 'package:mojo/mojo/service_provider.mojom.dart' as service_provider_mojom; @@ -93,13 +94,81 @@ } } + +class ShellCreateApplicationConnectorParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + Object applicationConnectorRequest = null; + + ShellCreateApplicationConnectorParams() : super(kVersions.last.size); + + static ShellCreateApplicationConnectorParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ShellCreateApplicationConnectorParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ShellCreateApplicationConnectorParams result = new ShellCreateApplicationConnectorParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.applicationConnectorRequest = decoder0.decodeInterfaceRequest(8, false, application_connector_mojom.ApplicationConnectorStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterfaceRequest(applicationConnectorRequest, 8, false); + } + + String toString() { + return "ShellCreateApplicationConnectorParams(" + "applicationConnectorRequest: $applicationConnectorRequest" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + const int kShell_connectToApplication_name = 0; +const int kShell_createApplicationConnector_name = 1; const String ShellName = 'mojo::Shell'; abstract class Shell { void connectToApplication(String applicationUrl, Object services, Object exposedServices); + void createApplicationConnector(Object applicationConnectorRequest); } @@ -153,6 +222,16 @@ _proxyImpl.sendMessage(params, kShell_connectToApplication_name); } + void createApplicationConnector(Object applicationConnectorRequest) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new ShellCreateApplicationConnectorParams(); + params.applicationConnectorRequest = applicationConnectorRequest; + _proxyImpl.sendMessage(params, kShell_createApplicationConnector_name); + } + } @@ -249,6 +328,11 @@ message.payload); _impl.connectToApplication(params.applicationUrl, params.services, params.exposedServices); break; + case kShell_createApplicationConnector_name: + var params = ShellCreateApplicationConnectorParams.deserialize( + message.payload); + _impl.createApplicationConnector(params.applicationConnectorRequest); + break; default: throw new bindings.MojoCodecError("Unexpected message name"); break;
diff --git a/mojo/public/dart/mojo/sdk_ext/lib/mojo/url_request.mojom.dart b/mojo/dart/packages/mojo/lib/mojo/url_request.mojom.dart similarity index 100% rename from mojo/public/dart/mojo/sdk_ext/lib/mojo/url_request.mojom.dart rename to mojo/dart/packages/mojo/lib/mojo/url_request.mojom.dart
diff --git a/mojo/public/dart/mojo/sdk_ext/lib/mojo/url_response.mojom.dart b/mojo/dart/packages/mojo/lib/mojo/url_response.mojom.dart similarity index 100% rename from mojo/public/dart/mojo/sdk_ext/lib/mojo/url_response.mojom.dart rename to mojo/dart/packages/mojo/lib/mojo/url_response.mojom.dart
diff --git a/mojo/dart/packages/mojo/lib/src/buffer.dart b/mojo/dart/packages/mojo/lib/src/buffer.dart index 5e153be..c218845 100644 --- a/mojo/dart/packages/mojo/lib/src/buffer.dart +++ b/mojo/dart/packages/mojo/lib/src/buffer.dart
@@ -10,11 +10,11 @@ static const int MAP_FLAG_NONE = 0; MojoHandle handle; - MojoResult status; ByteData mapping; + int status; MojoSharedBuffer(this.handle, - [this.status = MojoResult.OK, this.mapping = null]); + [this.status = MojoResult.kOk, this.mapping = null]); factory MojoSharedBuffer.create(int numBytes, [int flags = 0]) { List result = MojoSharedBufferNatives.Create(numBytes, flags); @@ -22,13 +22,12 @@ return null; } assert((result is List) && (result.length == 2)); - var r = new MojoResult(result[0]); - if (!r.isOk) { + if (result[0] != MojoResult.kOk) { return null; } MojoSharedBuffer buf = - new MojoSharedBuffer(new MojoHandle(result[1]), r, null); + new MojoSharedBuffer(new MojoHandle(result[1]), result[0], null); return buf; } @@ -38,47 +37,46 @@ return null; } assert((result is List) && (result.length == 2)); - var r = new MojoResult(result[0]); - if (!r.isOk) { + if (result[0] != MojoResult.kOk) { return null; } MojoSharedBuffer dupe = - new MojoSharedBuffer(new MojoHandle(result[1]), r, null); + new MojoSharedBuffer(new MojoHandle(result[1]), result[0], null); return dupe; } - MojoResult close() { + int close() { if (handle == null) { - status = MojoResult.INVALID_ARGUMENT; + status = MojoResult.kInvalidArgument; return status; } - MojoResult r = handle.close(); + int r = handle.close(); status = r; mapping = null; return status; } - MojoResult map(int offset, int numBytes, [int flags = 0]) { + int map(int offset, int numBytes, [int flags = 0]) { if (handle == null) { - status = MojoResult.INVALID_ARGUMENT; + status = MojoResult.kInvalidArgument; return status; } List result = MojoSharedBufferNatives.Map(this, handle.h, offset, numBytes, flags); if (result == null) { - status = MojoResult.INVALID_ARGUMENT; + status = MojoResult.kInvalidArgument; return status; } assert((result is List) && (result.length == 2)); - status = new MojoResult(result[0]); + status = result[0]; mapping = result[1]; return status; } - MojoResult unmap() { + int unmap() { int r = MojoSharedBufferNatives.Unmap(mapping); - status = new MojoResult(r); + status = r; mapping = null; return status; }
diff --git a/mojo/dart/packages/mojo/lib/src/data_pipe.dart b/mojo/dart/packages/mojo/lib/src/data_pipe.dart index 884bbcb..e5a5d1f 100644 --- a/mojo/dart/packages/mojo/lib/src/data_pipe.dart +++ b/mojo/dart/packages/mojo/lib/src/data_pipe.dart
@@ -8,16 +8,16 @@ static const int FLAG_NONE = 0; static const int FLAG_ALL_OR_NONE = 1 << 0; - MojoHandle handle; - MojoResult status; final int elementBytes; + MojoHandle handle; + int status; MojoDataPipeProducer(this.handle, - [this.status = MojoResult.OK, this.elementBytes = 1]); + [this.status = MojoResult.kOk, this.elementBytes = 1]); int write(ByteData data, [int numBytes = -1, int flags = 0]) { if (handle == null) { - status = MojoResult.INVALID_ARGUMENT; + status = MojoResult.kInvalidArgument; return 0; } @@ -25,44 +25,45 @@ List result = MojoDataPipeNatives.MojoWriteData(handle.h, data, data_numBytes, flags); if (result == null) { - status = MojoResult.INVALID_ARGUMENT; + status = MojoResult.kInvalidArgument; return 0; } assert((result is List) && (result.length == 2)); - status = new MojoResult(result[0]); + status = result[0]; return result[1]; } ByteData beginWrite(int bufferBytes, [int flags = 0]) { if (handle == null) { - status = MojoResult.INVALID_ARGUMENT; + status = MojoResult.kInvalidArgument; return null; } List result = MojoDataPipeNatives.MojoBeginWriteData(handle.h, bufferBytes, flags); if (result == null) { - status = MojoResult.INVALID_ARGUMENT; + status = MojoResult.kInvalidArgument; return null; } assert((result is List) && (result.length == 2)); - status = new MojoResult(result[0]); + status = result[0]; return result[1]; } - MojoResult endWrite(int bytesWritten) { + int endWrite(int bytesWritten) { if (handle == null) { - status = MojoResult.INVALID_ARGUMENT; + status = MojoResult.kInvalidArgument; return status; } int result = MojoDataPipeNatives.MojoEndWriteData(handle.h, bytesWritten); - status = new MojoResult(result); + status = result; return status; } - String toString() => "MojoDataPipeProducer(handle: $handle, status: $status)"; + String toString() => "MojoDataPipeProducer(handle: $handle, " + "status: ${MojoResult.string(status)})"; } class MojoDataPipeConsumer { @@ -73,15 +74,15 @@ static const int FLAG_PEEK = 1 << 3; MojoHandle handle; - MojoResult status; final int elementBytes; + int status; MojoDataPipeConsumer(this.handle, - [this.status = MojoResult.OK, this.elementBytes = 1]); + [this.status = MojoResult.kOk, this.elementBytes = 1]); int read(ByteData data, [int numBytes = -1, int flags = 0]) { if (handle == null) { - status = MojoResult.INVALID_ARGUMENT; + status = MojoResult.kInvalidArgument; return 0; } @@ -89,46 +90,47 @@ List result = MojoDataPipeNatives.MojoReadData(handle.h, data, data_numBytes, flags); if (result == null) { - status = MojoResult.INVALID_ARGUMENT; + status = MojoResult.kInvalidArgument; return 0; } assert((result is List) && (result.length == 2)); - status = new MojoResult(result[0]); + status = result[0]; return result[1]; } ByteData beginRead([int bufferBytes = 0, int flags = 0]) { if (handle == null) { - status = MojoResult.INVALID_ARGUMENT; + status = MojoResult.kInvalidArgument; return null; } List result = MojoDataPipeNatives.MojoBeginReadData(handle.h, bufferBytes, flags); if (result == null) { - status = MojoResult.INVALID_ARGUMENT; + status = MojoResult.kInvalidArgument; return null; } assert((result is List) && (result.length == 2)); - status = new MojoResult(result[0]); + status = result[0]; return result[1]; } - MojoResult endRead(int bytesRead) { + int endRead(int bytesRead) { if (handle == null) { - status = MojoResult.INVALID_ARGUMENT; + status = MojoResult.kInvalidArgument; return status; } int result = MojoDataPipeNatives.MojoEndReadData(handle.h, bytesRead); - status = new MojoResult(result); + status = result; return status; } int query() => read(null, 0, FLAG_QUERY); - String toString() => "MojoDataPipeConsumer(" - "handle: $handle, status: $status, available: ${query()})"; + String toString() => "MojoDataPipeConsumer(handle: $handle, " + "status: ${MojoResult.string(status)}, " + "available: ${query()})"; } class MojoDataPipe { @@ -138,16 +140,14 @@ MojoDataPipeProducer producer; MojoDataPipeConsumer consumer; - MojoResult status; + int status; - MojoDataPipe._internal() { - producer = null; - consumer = null; - status = MojoResult.OK; - } + MojoDataPipe._internal() : status = MojoResult.kOk; - factory MojoDataPipe([int elementBytes = DEFAULT_ELEMENT_SIZE, - int capacityBytes = DEFAULT_CAPACITY, int flags = FLAG_NONE]) { + factory MojoDataPipe( + [int elementBytes = DEFAULT_ELEMENT_SIZE, + int capacityBytes = DEFAULT_CAPACITY, + int flags = FLAG_NONE]) { List result = MojoDataPipeNatives.MojoCreateDataPipe( elementBytes, capacityBytes, flags); if (result == null) { @@ -157,11 +157,11 @@ MojoHandle producerHandle = new MojoHandle(result[1]); MojoHandle consumerHandle = new MojoHandle(result[2]); MojoDataPipe pipe = new MojoDataPipe._internal(); - pipe.producer = new MojoDataPipeProducer( - producerHandle, new MojoResult(result[0]), elementBytes); - pipe.consumer = new MojoDataPipeConsumer( - consumerHandle, new MojoResult(result[0]), elementBytes); - pipe.status = new MojoResult(result[0]); + pipe.producer = + new MojoDataPipeProducer(producerHandle, result[0], elementBytes); + pipe.consumer = + new MojoDataPipeConsumer(consumerHandle, result[0], elementBytes); + pipe.status = result[0]; return pipe; } }
diff --git a/mojo/dart/packages/mojo/lib/src/drain_data.dart b/mojo/dart/packages/mojo/lib/src/drain_data.dart index dc630bf..380d84e 100644 --- a/mojo/dart/packages/mojo/lib/src/drain_data.dart +++ b/mojo/dart/packages/mojo/lib/src/drain_data.dart
@@ -19,10 +19,10 @@ ByteData _copy(ByteData byteData) => new ByteData.view( new Uint8List.fromList(byteData.buffer.asUint8List()).buffer); - MojoResult _doRead() { + int _doRead() { ByteData thisRead = _consumer.beginRead(); if (thisRead == null) { - throw 'Data pipe beginRead failed: ${_consumer.status}'; + throw 'Data pipe beginRead failed: ${_consumer}'; } _dataList.add(_copy(thisRead)); _dataSize += thisRead.lengthInBytes; @@ -44,22 +44,23 @@ Future<ByteData> drain() { var completer = new Completer(); _eventSubscription.subscribe((List<int> event) { - var mojoSignals = new MojoHandleSignals(event[1]); - if (mojoSignals.isReadable) { - var result = _doRead(); - if (!result.isOk) { + int mojoSignals = event[1]; + if (MojoHandleSignals.isReadable(mojoSignals)) { + int result = _doRead(); + if (result != MojoResult.kOk) { _eventSubscription.close(); _eventSubscription = null; completer.complete(_concatData()); } else { _eventSubscription.enableReadEvents(); } - } else if (mojoSignals.isPeerClosed) { + } else if (MojoHandleSignals.isPeerClosed(mojoSignals)) { _eventSubscription.close(); _eventSubscription = null; completer.complete(_concatData()); } else { - throw 'Unexpected handle event: $mojoSignals'; + String signals = MojoHandleSignals.string(mojoSignals); + throw 'Unexpected handle event: $signals'; } }); return completer.future;
diff --git a/mojo/dart/packages/mojo/lib/src/event_stream.dart b/mojo/dart/packages/mojo/lib/src/event_stream.dart index 74694c9..9db8393 100644 --- a/mojo/dart/packages/mojo/lib/src/event_stream.dart +++ b/mojo/dart/packages/mojo/lib/src/event_stream.dart
@@ -17,19 +17,18 @@ RawReceivePort _receivePort; // The signals on this handle that we're interested in. - MojoHandleSignals _signals; + int _signals; // Whether subscribe() has been called. bool _isSubscribed; MojoEventSubscription(MojoHandle handle, - [MojoHandleSignals signals = MojoHandleSignals.PEER_CLOSED_READABLE]) + [int signals = MojoHandleSignals.kPeerClosedReadable]) : _handle = handle, _signals = signals, _isSubscribed = false { if (!MojoHandle.registerFinalizer(this)) { - throw new MojoInternalError( - "Failed to register the MojoHandle."); + throw new MojoInternalError("Failed to register the MojoHandle."); } } @@ -42,8 +41,8 @@ _receivePort = new RawReceivePort(handler); _sendPort = _receivePort.sendPort; - if (_signals.value != MojoHandleSignals.kNone) { - int res = MojoHandleWatcher.add(_handle.h, _sendPort, _signals.value); + if (_signals != MojoHandleSignals.kNone) { + int res = MojoHandleWatcher.add(_handle.h, _sendPort, _signals); if (res != MojoResult.kOk) { throw new MojoInternalError("MojoHandleWatcher add failed: $res"); } @@ -52,26 +51,26 @@ _isSubscribed = true; } - bool enableSignals(MojoHandleSignals signals) { + bool enableSignals(int signals) { _signals = signals; if (_isSubscribed) { - return MojoHandleWatcher.add(_handle.h, _sendPort, signals.value) == + return MojoHandleWatcher.add(_handle.h, _sendPort, _signals) == MojoResult.kOk; } return false; } bool enableReadEvents() => - enableSignals(MojoHandleSignals.PEER_CLOSED_READABLE); - bool enableWriteEvents() => enableSignals(MojoHandleSignals.WRITABLE); - bool enableAllEvents() => enableSignals(MojoHandleSignals.READWRITE); + enableSignals(MojoHandleSignals.kPeerClosedReadable); + bool enableWriteEvents() => enableSignals(MojoHandleSignals.kWritable); + bool enableAllEvents() => enableSignals(MojoHandleSignals.kReadWrite); Future _close({bool immediate: false, bool local: false}) { if (_handle != null) { if (_isSubscribed && !local) { return _handleWatcherClose(immediate: immediate).then((result) { // If the handle watcher is gone, then close the handle ourselves. - if (!result.isOk) { + if (result != MojoResult.kOk) { _localClose(); } }); @@ -90,7 +89,7 @@ _receivePort.close(); _receivePort = null; } - return new MojoResult(r); + return r; }); } @@ -105,7 +104,7 @@ bool get readyRead => _handle.readyRead; bool get readyWrite => _handle.readyWrite; - MojoHandleSignals get signals => _signals; + int get signals => _signals; String toString() => "$_handle"; } @@ -196,18 +195,18 @@ // immediately. return; } - var signalsWatched = new MojoHandleSignals(event[0]); - var signalsReceived = new MojoHandleSignals(event[1]); + int signalsWatched = event[0]; + int signalsReceived = event[1]; _isInHandler = true; - if (signalsReceived.isReadable) { + if (MojoHandleSignals.isReadable(signalsReceived)) { assert(_eventSubscription.readyRead); handleRead(); } - if (signalsReceived.isWritable) { + if (MojoHandleSignals.isWritable(signalsReceived)) { assert(_eventSubscription.readyWrite); handleWrite(); } - _isPeerClosed = signalsReceived.isPeerClosed || + _isPeerClosed = MojoHandleSignals.isPeerClosed(signalsReceived) || !_eventSubscription.enableSignals(signalsWatched); _isInHandler = false; if (_isPeerClosed) {
diff --git a/mojo/dart/packages/mojo/lib/src/fill_data.dart b/mojo/dart/packages/mojo/lib/src/fill_data.dart index c139a7c..0fa5ec6 100644 --- a/mojo/dart/packages/mojo/lib/src/fill_data.dart +++ b/mojo/dart/packages/mojo/lib/src/fill_data.dart
@@ -15,12 +15,13 @@ _dataPosition = 0; } - MojoResult _doWrite() { + int _doWrite() { ByteData view = new ByteData.view( _data.buffer, _dataPosition, _data.lengthInBytes - _dataPosition); int written = _producer.write(view); - if (!_producer.status.isOk) { - throw 'Data pipe beginWrite failed: ${_producer.status}'; + if (_producer.status != MojoResult.kOk) { + throw 'Data pipe beginWrite failed: ' + '${MojoResult.string(_producer.status)}'; } _dataPosition += written; return _producer.status; @@ -29,18 +30,20 @@ void fill() { _eventSubscription.enableWriteEvents(); _eventSubscription.subscribe((List<int> event) { - var mojoSignals = new MojoHandleSignals(event[1]); - if (mojoSignals.isWritable) { - MojoResult result = _doWrite(); - if (_dataPosition >= _data.lengthInBytes || !result.isOk) { + int mojoSignals = event[1]; + if (MojoHandleSignals.isWritable(mojoSignals)) { + int result = _doWrite(); + if ((_dataPosition >= _data.lengthInBytes) || + (result != MojoResult.kOk)) { _eventSubscription.close(); _eventSubscription = null; } - } else if (mojoSignals.isPeerClosed) { + } else if (MojoHandleSignals.isPeerClosed(mojoSignals)) { _eventSubscription.close(); _eventSubscription = null; } else { - throw 'Unexpected handle event: $mojoSignals'; + String signals = MojoHandleSignals.string(mojoSignals); + throw 'Unexpected handle event: $signals'; } }); }
diff --git a/mojo/dart/packages/mojo/lib/src/handle.dart b/mojo/dart/packages/mojo/lib/src/handle.dart index ef6078c..77c605f 100644 --- a/mojo/dart/packages/mojo/lib/src/handle.dart +++ b/mojo/dart/packages/mojo/lib/src/handle.dart
@@ -19,11 +19,11 @@ MojoHandle.invalid() : this._internal(INVALID); - MojoResult close() { + int close() { MojoHandleNatives.removeOpenHandle(_h); int result = MojoHandleNatives.close(_h); _h = INVALID; - return new MojoResult(result); + return result; } MojoHandle pass() { @@ -36,18 +36,18 @@ var state = result[1] != null ? new MojoHandleSignalsState(result[1][0], result[1][1]) : null; - return new MojoWaitResult(new MojoResult(result[0]), state); + return new MojoWaitResult(result[0], state); } - bool _ready(MojoHandleSignals signal) { - MojoWaitResult mwr = wait(signal.value, 0); + bool _ready(int signal) { + MojoWaitResult mwr = wait(signal, 0); switch (mwr.result) { - case MojoResult.OK: + case MojoResult.kOk: return true; - case MojoResult.DEADLINE_EXCEEDED: - case MojoResult.CANCELLED: - case MojoResult.INVALID_ARGUMENT: - case MojoResult.FAILED_PRECONDITION: + case MojoResult.kDeadlineExceeded: + case MojoResult.kCancelled: + case MojoResult.kInvalidArgument: + case MojoResult.kFailedPrecondition: return false; default: // Should be unreachable. @@ -55,8 +55,8 @@ } } - bool get readyRead => _ready(MojoHandleSignals.PEER_CLOSED_READABLE); - bool get readyWrite => _ready(MojoHandleSignals.WRITABLE); + bool get readyRead => _ready(MojoHandleSignals.kPeerClosedReadable); + bool get readyWrite => _ready(MojoHandleSignals.kWritable); bool get isValid => (_h != INVALID); String toString() { @@ -77,12 +77,13 @@ List states = result[2] != null ? result[2].map((l) => new MojoHandleSignalsState(l[0], l[1])).toList() : null; - return new MojoWaitManyResult(new MojoResult(result[0]), result[1], states); + return new MojoWaitManyResult(result[0], result[1], states); } static bool registerFinalizer(MojoEventSubscription eventSubscription) { return MojoHandleNatives.registerFinalizer( - eventSubscription, eventSubscription._handle.h) == MojoResult.kOk; + eventSubscription, eventSubscription._handle.h) == + MojoResult.kOk; } static bool reportLeakedHandles() => MojoHandleNatives.reportOpenHandles();
diff --git a/mojo/dart/packages/mojo/lib/src/message_pipe.dart b/mojo/dart/packages/mojo/lib/src/message_pipe.dart index 9317be4..3472f5d 100644 --- a/mojo/dart/packages/mojo/lib/src/message_pipe.dart +++ b/mojo/dart/packages/mojo/lib/src/message_pipe.dart
@@ -5,17 +5,18 @@ part of core; class MojoMessagePipeReadResult { - final MojoResult status; + final int status; final int bytesRead; final int handlesRead; MojoMessagePipeReadResult(this.status, this.bytesRead, this.handlesRead); MojoMessagePipeReadResult.fromList(List<int> resultList) - : this(new MojoResult(resultList[0]), resultList[1], resultList[2]); + : this(resultList[0], resultList[1], resultList[2]); String toString() { return "MojoMessagePipeReadResult(" - "status: $status, bytesRead: $bytesRead, handlesRead: $handlesRead)"; + "status: ${MojoResult.string(status)}, bytesRead: $bytesRead, " + "handlesRead: $handlesRead)"; } } @@ -24,7 +25,7 @@ List<MojoHandle> _handles; - MojoResult get status => new MojoResult(_result[0]); + int get status => _result[0]; ByteData get data => _result[1]; List<MojoHandle> get handles => _handles; int get dataLength => _result[3]; @@ -47,7 +48,7 @@ String toString() { return "MojoMessagePipeQueryAndReadState(" - "status: $status, dataLength: $dataLength, " + "status: ${MojoResult.string(status)}, dataLength: $dataLength, " "handlesLength: $handlesLength)"; } } @@ -60,14 +61,16 @@ static final _queryAndReadState = new MojoMessagePipeQueryAndReadState(); MojoHandle handle; - MojoResult status; + int status; MojoMessagePipeEndpoint(this.handle); - MojoResult write(ByteData data, + bool get ok => status == MojoResult.kOk; + + int write(ByteData data, [int numBytes = -1, List<MojoHandle> handles = null, int flags = 0]) { if (handle == null) { - status = MojoResult.INVALID_ARGUMENT; + status = MojoResult.kInvalidArgument; return status; } @@ -76,7 +79,7 @@ // If numBytes has the default value, use the full length of the data. int dataNumBytes = (numBytes == -1) ? dataLengthInBytes : numBytes; if (dataNumBytes > dataLengthInBytes) { - status = MojoResult.INVALID_ARGUMENT; + status = MojoResult.kInvalidArgument; return status; } @@ -85,17 +88,15 @@ (handles != null) ? handles.map((h) => h.h).toList() : null; // Do the call. - int result = MojoMessagePipeNatives.MojoWriteMessage( + status = MojoMessagePipeNatives.MojoWriteMessage( handle.h, data, dataNumBytes, mojoHandles, flags); - - status = new MojoResult(result); return status; } MojoMessagePipeReadResult read(ByteData data, [int numBytes = -1, List<MojoHandle> handles = null, int flags = 0]) { if (handle == null) { - status = MojoResult.INVALID_ARGUMENT; + status = MojoResult.kInvalidArgument; return null; } @@ -106,7 +107,7 @@ } else { dataNumBytes = (numBytes == -1) ? data.lengthInBytes : numBytes; if (dataNumBytes > data.lengthInBytes) { - status = MojoResult.INVALID_ARGUMENT; + status = MojoResult.kInvalidArgument; return null; } } @@ -124,7 +125,7 @@ handle.h, data, dataNumBytes, mojoHandles, flags); if (result == null) { - status = MojoResult.INVALID_ARGUMENT; + status = MojoResult.kInvalidArgument; return null; } @@ -152,7 +153,7 @@ /// isolate. MojoMessagePipeQueryAndReadState queryAndRead([int flags = 0]) { if (handle == null) { - status = MojoResult.INVALID_ARGUMENT; + status = MojoResult.kInvalidArgument; return null; } @@ -166,20 +167,17 @@ handle = null; } - String toString() => - "MojoMessagePipeEndpoint(handle: $handle, status: $status)"; + String toString() => "MojoMessagePipeEndpoint(handle: $handle, " + "status: ${MojoResult.string(status)})"; } class MojoMessagePipe { static const int FLAG_NONE = 0; List<MojoMessagePipeEndpoint> endpoints; - MojoResult status; + int status; - MojoMessagePipe._() { - endpoints = null; - status = MojoResult.OK; - } + MojoMessagePipe._() : status = MojoResult.kOk; factory MojoMessagePipe([int flags = FLAG_NONE]) { List result = MojoMessagePipeNatives.MojoCreateMessagePipe(flags); @@ -194,7 +192,7 @@ pipe.endpoints = new List(2); pipe.endpoints[0] = new MojoMessagePipeEndpoint(end1); pipe.endpoints[1] = new MojoMessagePipeEndpoint(end2); - pipe.status = new MojoResult(result[0]); + pipe.status = result[0]; return pipe; } }
diff --git a/mojo/dart/packages/mojo/lib/src/proxy.dart b/mojo/dart/packages/mojo/lib/src/proxy.dart index 72ef13d..7bf4f15 100644 --- a/mojo/dart/packages/mojo/lib/src/proxy.dart +++ b/mojo/dart/packages/mojo/lib/src/proxy.dart
@@ -86,7 +86,7 @@ var serviceMessage = message.serializeWithHeader(header); endpoint.write(serviceMessage.buffer, serviceMessage.buffer.lengthInBytes, serviceMessage.handles); - if (!endpoint.status.isOk) { + if (endpoint.status != core.MojoResult.kOk) { proxyError("Write to message pipe endpoint failed."); } } @@ -109,11 +109,11 @@ endpoint.write(serviceMessage.buffer, serviceMessage.buffer.lengthInBytes, serviceMessage.handles); - if (endpoint.status.isOk) { + if (endpoint.status == core.MojoResult.kOk) { _completerMap[id] = completer; _pendingCount++; } else { - proxyError("Write to message pipe endpoint failed."); + proxyError("Write to message pipe endpoint failed: ${endpoint}"); } return completer.future; }
diff --git a/mojo/dart/packages/mojo/lib/src/stub.dart b/mojo/dart/packages/mojo/lib/src/stub.dart index dce1038..ea09ae3 100644 --- a/mojo/dart/packages/mojo/lib/src/stub.dart +++ b/mojo/dart/packages/mojo/lib/src/stub.dart
@@ -69,7 +69,8 @@ // FailedPrecondition is only used to indicate that the other end of // the pipe has been closed. We can ignore the close here and wait for // the PeerClosed signal on the event stream. - assert(endpoint.status.isOk || endpoint.status.isFailedPrecondition); + assert((endpoint.status == core.MojoResult.kOk) || + (endpoint.status == core.MojoResult.kFailedPrecondition)); if (_isClosing && (_outstandingResponseFutures == 0)) { // This was the final response future for which we needed to send // a response. It is safe to close.
diff --git a/mojo/dart/packages/mojo/lib/src/types.dart b/mojo/dart/packages/mojo/lib/src/types.dart index bd6b642..7b189c6 100644 --- a/mojo/dart/packages/mojo/lib/src/types.dart +++ b/mojo/dart/packages/mojo/lib/src/types.dart
@@ -24,72 +24,9 @@ static const int kBusy = 16; static const int kShouldWait = 17; - static const OK = const MojoResult._(kOk); - static const CANCELLED = const MojoResult._(kCancelled); - static const UNKNOWN = const MojoResult._(kUnknown); - static const INVALID_ARGUMENT = const MojoResult._(kInvalidArgument); - static const DEADLINE_EXCEEDED = const MojoResult._(kDeadlineExceeded); - static const NOT_FOUND = const MojoResult._(kNotFound); - static const ALREADY_EXISTS = const MojoResult._(kAlreadyExists); - static const PERMISSION_DENIED = const MojoResult._(kPermissionDenied); - static const RESOURCE_EXHAUSTED = const MojoResult._(kResourceExhausted); - static const FAILED_PRECONDITION = const MojoResult._(kFailedPrecondition); - static const ABORTED = const MojoResult._(kAborted); - static const OUT_OF_RANGE = const MojoResult._(kOutOfRange); - static const UNIMPLEMENTED = const MojoResult._(kUnimplemented); - static const INTERNAL = const MojoResult._(kInternal); - static const UNAVAILABLE = const MojoResult._(kUnavailable); - static const DATA_LOSS = const MojoResult._(kDataLoss); - static const BUSY = const MojoResult._(kBusy); - static const SHOULD_WAIT = const MojoResult._(kShouldWait); + MojoResult._(); - static const _values = const <MojoResult>[ - OK, - CANCELLED, - UNKNOWN, - INVALID_ARGUMENT, - DEADLINE_EXCEEDED, - NOT_FOUND, - ALREADY_EXISTS, - PERMISSION_DENIED, - RESOURCE_EXHAUSTED, - FAILED_PRECONDITION, - ABORTED, - OUT_OF_RANGE, - UNIMPLEMENTED, - INTERNAL, - UNAVAILABLE, - DATA_LOSS, - BUSY, - SHOULD_WAIT, - ]; - - final int value; - - const MojoResult._(this.value); - - factory MojoResult(int value) => _values[value]; - - bool get isOk => (this == OK); - bool get isCancelled => (this == CANCELLED); - bool get isUnknown => (this == UNKNOWN); - bool get isInvalidArgument => (this == INVALID_ARGUMENT); - bool get isDeadlineExceeded => (this == DEADLINE_EXCEEDED); - bool get isNotFound => (this == NOT_FOUND); - bool get isAlreadExists => (this == ALREADY_EXISTS); - bool get isPermissionDenied => (this == PERMISSION_DENIED); - bool get isResourceExhausted => (this == RESOURCE_EXHAUSTED); - bool get isFailedPrecondition => (this == FAILED_PRECONDITION); - bool get isAborted => (this == ABORTED); - bool get isOutOfRange => (this == OUT_OF_RANGE); - bool get isUnimplemented => (this == UNIMPLEMENTED); - bool get isInternal => (this == INTERNAL); - bool get isUnavailable => (this == UNAVAILABLE); - bool get isDataLoss => (this == DATA_LOSS); - bool get isBusy => (this == BUSY); - bool get isShouldWait => (this == SHOULD_WAIT); - - String toString() { + static String string(int value) { switch (value) { case kOk: return "OK"; @@ -144,61 +81,31 @@ static const int kAll = 0x7; static const int kBitfieldSize = 3; - static const NONE = const MojoHandleSignals._(kNone); - static const READABLE = const MojoHandleSignals._(kReadable); - static const WRITABLE = const MojoHandleSignals._(kWritable); - static const PEER_CLOSED = const MojoHandleSignals._(kPeerClosed); - static const PEER_CLOSED_READABLE = - const MojoHandleSignals._(kPeerClosedReadable); - static const READWRITE = const MojoHandleSignals._(kReadWrite); - static const PEER_CLOSED_WRITABLE = - const MojoHandleSignals._(kPeerClosedWritable); - static const ALL = const MojoHandleSignals._(kAll); + MojoHandleSignals._(); - static const _values = const <MojoHandleSignals>[ - NONE, // 0 - READABLE, // 1 - WRITABLE, // 2 - READWRITE, // 3 - PEER_CLOSED, // 4 - PEER_CLOSED_READABLE, // 5 - PEER_CLOSED_WRITABLE, // 6 - ALL, // 7 - ]; + static bool isNone(int v) => v == 0; + static bool isReadable(int v) => (v & kReadable) == kReadable; + static bool isWritable(int v) => (v & kWritable) == kWritable; + static bool isReadWrite(int v) => (v & kReadWrite) == kReadWrite; + static bool isPeerClosed(int v) => (v & kPeerClosed) == kPeerClosed; + static bool isPeerClosedReadable(int v) => + (v & kPeerClosedReadable) == kPeerClosedReadable; + static bool isPeerClosedWritable(int v) => + (v & kPeerClosedWritable) == kPeerClosedWritable; + static bool isAll(int v) => (v & kAll) == kAll; + static bool isValid(int v) => (v & kAll) == v; - final int value; - - const MojoHandleSignals._(this.value); - - factory MojoHandleSignals(int value) => _values[value]; - - bool get isNone => (this == NONE); - bool get isReadable => (value & kReadable) == kReadable; - bool get isWritable => (value & kWritable) == kWritable; - bool get isPeerClosed => (value & kPeerClosed) == kPeerClosed; - bool get isReadWrite => (value & kReadWrite) == kReadWrite; - bool get isAll => (this == ALL); - bool get isValid => (value & kAll) == value; - - MojoHandleSignals operator +(MojoHandleSignals other) { - return new MojoHandleSignals(value | other.value); - } - - MojoHandleSignals operator -(MojoHandleSignals other) { - return new MojoHandleSignals(value & ~other.value); - } - - String toString() { - if (isNone) { + static String string(int value) { + if (value == kNone) { return "(None)"; } - if (!isValid) { + if (!isValid(value)) { return "(INVALID)"; } List<String> signals = []; - if (isReadable) signals.add("Readable"); - if (isWritable) signals.add("Writable"); - if (isPeerClosed) signals.add("PeerClosed"); + if (value == kReadable) signals.add("Readable"); + if (value == kWritable) signals.add("Writable"); + if (value == kPeerClosed) signals.add("PeerClosed"); return "(" + signals.join(", ") + ")"; } } @@ -207,25 +114,31 @@ MojoHandleSignalsState(this.satisfied_signals, this.satisfiable_signals); final int satisfied_signals; final int satisfiable_signals; - String toString() => (new MojoHandleSignals(satisfied_signals)).toString(); + String toString() => MojoHandleSignals.string(satisfied_signals); } class MojoWaitResult { MojoWaitResult(this.result, this.state); - final MojoResult result; + final int result; MojoHandleSignalsState state; - String toString() => "MojoWaitResult(result: $result, state: $state)"; + String toString() { + String r = MojoResult.string(result); + return "MojoWaitResult(result: $r, state: $state)"; + } } class MojoWaitManyResult { MojoWaitManyResult(this.result, this.index, this.states); - final MojoResult result; + final int result; final int index; List<MojoHandleSignalsState> states; bool get isIndexValid => (this.index != null); bool get areSignalStatesValid => (this.states != null); - String toString() => - "MojoWaitManyResult(" "result: $result, idx: $index, state: ${states[index]})"; + String toString() { + String r = MojoResult.string(result); + return "MojoWaitManyResult(result: $r, idx: $index, " + "state: ${states[index]})"; + } }
diff --git a/mojo/dart/packages/mojo/lib/src/union.dart b/mojo/dart/packages/mojo/lib/src/union.dart index ce5e4d7..87e72e7 100644 --- a/mojo/dart/packages/mojo/lib/src/union.dart +++ b/mojo/dart/packages/mojo/lib/src/union.dart
@@ -8,8 +8,7 @@ void encode(Encoder encoder, int offset); } -class UnionError { -} +class UnionError {} class UnsetUnionTagError extends UnionError { final curTag; @@ -18,7 +17,7 @@ UnsetUnionTagError(this.curTag, this.requestedTag); String toString() { - return "Tried to read unset union member: {{requestedTag}} " - "current member: {{curTag}}."; + return "Tried to read unset union member: $requestedTag " + "current member: $curTag."; } }
diff --git a/mojo/dart/packages/mojo/sources.gni b/mojo/dart/packages/mojo/sources.gni index 057a93b..3e43e3a 100644 --- a/mojo/dart/packages/mojo/sources.gni +++ b/mojo/dart/packages/mojo/sources.gni
@@ -10,6 +10,18 @@ "lib/core.dart", ] +package_mojo_bindings = [ + "lib/mojo/application_connector.mojom.dart", + "lib/mojo/interface_control_messages.mojom.dart", + "lib/mojo/shell.mojom.dart", + "lib/mojo/application.mojom.dart", + "lib/mojo/network_error.mojom.dart", + "lib/mojo/url_request.mojom.dart", + "lib/mojo/http_header.mojom.dart", + "lib/mojo/service_provider.mojom.dart", + "lib/mojo/url_response.mojom.dart", +] + package_mojo_sources = [ "lib/src/application_connection.dart", "lib/src/application.dart", @@ -30,4 +42,4 @@ "lib/src/types.dart", "lib/src/union.dart", "lib/src/utils.dart", - ] + package_mojo_entrypoints + ] + package_mojo_entrypoints + package_mojo_bindings
diff --git a/mojo/dart/mojo_sdk/BUILD.gn b/mojo/dart/packages/mojo_sdk/BUILD.gn similarity index 100% rename from mojo/dart/mojo_sdk/BUILD.gn rename to mojo/dart/packages/mojo_sdk/BUILD.gn
diff --git a/mojo/dart/mojo_sdk/CHANGELOG.md b/mojo/dart/packages/mojo_sdk/CHANGELOG.md similarity index 100% rename from mojo/dart/mojo_sdk/CHANGELOG.md rename to mojo/dart/packages/mojo_sdk/CHANGELOG.md
diff --git a/mojo/dart/mojo_sdk/README.md b/mojo/dart/packages/mojo_sdk/README.md similarity index 100% rename from mojo/dart/mojo_sdk/README.md rename to mojo/dart/packages/mojo_sdk/README.md
diff --git a/mojo/dart/mojo_sdk/pubspec.yaml b/mojo/dart/packages/mojo_sdk/pubspec.yaml similarity index 100% rename from mojo/dart/mojo_sdk/pubspec.yaml rename to mojo/dart/packages/mojo_sdk/pubspec.yaml
diff --git a/mojo/dart/packages/mojo_services/BUILD.gn b/mojo/dart/packages/mojo_services/BUILD.gn new file mode 100644 index 0000000..2a3b602 --- /dev/null +++ b/mojo/dart/packages/mojo_services/BUILD.gn
@@ -0,0 +1,99 @@ +# Copyright 2015 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//mojo/public/dart/rules.gni") +import("//mojo/services/mojo_services.gni") + +# TODO(johnmccutchan): Automate this. +# for i in `find lib/|grep mojom.dart`;do echo \"$i\",;done +bindings_sources = [ + "lib/mojo/gpu.mojom.dart", + "lib/mojo/clipboard.mojom.dart", + "lib/mojo/view_manager_constants.mojom.dart", + "lib/mojo/quads.mojom.dart", + "lib/mojo/navigation.mojom.dart", + "lib/mojo/display.mojom.dart", + "lib/mojo/authenticating_url_loader_interceptor_meta_factory.mojom.dart", + "lib/mojo/window_manager_internal.mojom.dart", + "lib/mojo/url_loader.mojom.dart", + "lib/mojo/content_handler.mojom.dart", + "lib/mojo/window_manager.mojom.dart", + "lib/mojo/geocoder.mojom.dart", + "lib/mojo/host_resolver.mojom.dart", + "lib/mojo/command_buffer.mojom.dart", + "lib/mojo/http_server.mojom.dart", + "lib/mojo/files/file.mojom.dart", + "lib/mojo/files/ioctl_terminal.mojom.dart", + "lib/mojo/files/directory.mojom.dart", + "lib/mojo/files/files.mojom.dart", + "lib/mojo/files/types.mojom.dart", + "lib/mojo/files/ioctl.mojom.dart", + "lib/mojo/asset_bundle/asset_bundle.mojom.dart", + "lib/mojo/net_address.mojom.dart", + "lib/mojo/ui/view_provider.mojom.dart", + "lib/mojo/ui/views.mojom.dart", + "lib/mojo/ui/view_trees.mojom.dart", + "lib/mojo/ui/layouts.mojom.dart", + "lib/mojo/ui/view_manager.mojom.dart", + "lib/mojo/web_socket.mojom.dart", + "lib/mojo/url_loader_interceptor.mojom.dart", + "lib/mojo/viewport_parameter_listener.mojom.dart", + "lib/mojo/location.mojom.dart", + "lib/mojo/service_registry.mojom.dart", + "lib/mojo/network_service.mojom.dart", + "lib/mojo/http_message.mojom.dart", + "lib/mojo/cookie_store.mojom.dart", + "lib/mojo/input_events.mojom.dart", + "lib/mojo/udp_socket.mojom.dart", + "lib/mojo/http_connection.mojom.dart", + "lib/mojo/native_viewport.mojom.dart", + "lib/mojo/tcp_connected_socket.mojom.dart", + "lib/mojo/input_key_codes.mojom.dart", + "lib/mojo/sharing.mojom.dart", + "lib/mojo/gpu_capabilities.mojom.dart", + "lib/mojo/context_provider.mojom.dart", + "lib/mojo/animations.mojom.dart", + "lib/mojo/surface_id.mojom.dart", + "lib/mojo/tcp_server_socket.mojom.dart", + "lib/mojo/view_manager.mojom.dart", + "lib/mojo/url_response_disk_cache.mojom.dart", + "lib/mojo/terminal/terminal.mojom.dart", + "lib/mojo/terminal/terminal_client.mojom.dart", + "lib/mojo/geometry.mojom.dart", + "lib/mojo/tcp_bound_socket.mojom.dart", + "lib/mojo/input_event_constants.mojom.dart", + "lib/mojo/surfaces.mojom.dart", + "lib/mojo/device_info.mojom.dart", + "lib/mojo/camera.mojom.dart", + "lib/mojo/location_service.mojom.dart", + "lib/contacts/contacts.mojom.dart", + "lib/authentication/authentication.mojom.dart", + "lib/tracing/tracing.mojom.dart", + "lib/input/input.mojom.dart", + "lib/prediction/prediction.mojom.dart", + "lib/nfc/nfc.mojom.dart", + "lib/native_support/process.mojom.dart", + "lib/speech_recognizer/speech_recognizer.mojom.dart", + "lib/http_server/http_server.mojom.dart", + "lib/http_server/http_request.mojom.dart", + "lib/http_server/http_server_factory.mojom.dart", + "lib/http_server/http_response.mojom.dart", + "lib/keyboard/keyboard.mojom.dart", + "lib/notifications/notifications.mojom.dart", + "lib/icu_data/icu_data.mojom.dart", + "lib/sensors/sensors.mojom.dart", +] + +dart_pkg("mojo_services") { + sources = [ + "CHANGELOG.md", + "README.md", + "pubspec.yaml", + ] + bindings_sources + + deps = [ + "//mojo/public/dart", + "//mojo/services", + ] +}
diff --git a/mojo/dart/mojo_services/CHANGELOG.md b/mojo/dart/packages/mojo_services/CHANGELOG.md similarity index 100% rename from mojo/dart/mojo_services/CHANGELOG.md rename to mojo/dart/packages/mojo_services/CHANGELOG.md
diff --git a/mojo/dart/mojo_services/README.md b/mojo/dart/packages/mojo_services/README.md similarity index 100% rename from mojo/dart/mojo_services/README.md rename to mojo/dart/packages/mojo_services/README.md
diff --git a/mojo/dart/packages/mojo_services/lib/authentication/authentication.mojom.dart b/mojo/dart/packages/mojo_services/lib/authentication/authentication.mojom.dart new file mode 100644 index 0000000..c709bf2 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/authentication/authentication.mojom.dart
@@ -0,0 +1,685 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library authentication_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; + + + +class AuthenticationServiceSelectAccountParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + bool returnLastSelected = false; + + AuthenticationServiceSelectAccountParams() : super(kVersions.last.size); + + static AuthenticationServiceSelectAccountParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static AuthenticationServiceSelectAccountParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + AuthenticationServiceSelectAccountParams result = new AuthenticationServiceSelectAccountParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.returnLastSelected = decoder0.decodeBool(8, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeBool(returnLastSelected, 8, 0); + } + + String toString() { + return "AuthenticationServiceSelectAccountParams(" + "returnLastSelected: $returnLastSelected" ")"; + } + + Map toJson() { + Map map = new Map(); + map["returnLastSelected"] = returnLastSelected; + return map; + } +} + + +class AuthenticationServiceSelectAccountResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + String username = null; + String error = null; + + AuthenticationServiceSelectAccountResponseParams() : super(kVersions.last.size); + + static AuthenticationServiceSelectAccountResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static AuthenticationServiceSelectAccountResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + AuthenticationServiceSelectAccountResponseParams result = new AuthenticationServiceSelectAccountResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.username = decoder0.decodeString(8, true); + } + if (mainDataHeader.version >= 0) { + + result.error = decoder0.decodeString(16, true); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(username, 8, true); + + encoder0.encodeString(error, 16, true); + } + + String toString() { + return "AuthenticationServiceSelectAccountResponseParams(" + "username: $username" ", " + "error: $error" ")"; + } + + Map toJson() { + Map map = new Map(); + map["username"] = username; + map["error"] = error; + return map; + } +} + + +class AuthenticationServiceGetOAuth2TokenParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + String username = null; + List<String> scopes = null; + + AuthenticationServiceGetOAuth2TokenParams() : super(kVersions.last.size); + + static AuthenticationServiceGetOAuth2TokenParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static AuthenticationServiceGetOAuth2TokenParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + AuthenticationServiceGetOAuth2TokenParams result = new AuthenticationServiceGetOAuth2TokenParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.username = decoder0.decodeString(8, false); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.scopes = new List<String>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + result.scopes[i1] = decoder1.decodeString(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + } + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(username, 8, false); + + if (scopes == null) { + encoder0.encodeNullPointer(16, false); + } else { + var encoder1 = encoder0.encodePointerArray(scopes.length, 16, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < scopes.length; ++i0) { + + encoder1.encodeString(scopes[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + } + + String toString() { + return "AuthenticationServiceGetOAuth2TokenParams(" + "username: $username" ", " + "scopes: $scopes" ")"; + } + + Map toJson() { + Map map = new Map(); + map["username"] = username; + map["scopes"] = scopes; + return map; + } +} + + +class AuthenticationServiceGetOAuth2TokenResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + String token = null; + String error = null; + + AuthenticationServiceGetOAuth2TokenResponseParams() : super(kVersions.last.size); + + static AuthenticationServiceGetOAuth2TokenResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static AuthenticationServiceGetOAuth2TokenResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + AuthenticationServiceGetOAuth2TokenResponseParams result = new AuthenticationServiceGetOAuth2TokenResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.token = decoder0.decodeString(8, true); + } + if (mainDataHeader.version >= 0) { + + result.error = decoder0.decodeString(16, true); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(token, 8, true); + + encoder0.encodeString(error, 16, true); + } + + String toString() { + return "AuthenticationServiceGetOAuth2TokenResponseParams(" + "token: $token" ", " + "error: $error" ")"; + } + + Map toJson() { + Map map = new Map(); + map["token"] = token; + map["error"] = error; + return map; + } +} + + +class AuthenticationServiceClearOAuth2TokenParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + String token = null; + + AuthenticationServiceClearOAuth2TokenParams() : super(kVersions.last.size); + + static AuthenticationServiceClearOAuth2TokenParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static AuthenticationServiceClearOAuth2TokenParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + AuthenticationServiceClearOAuth2TokenParams result = new AuthenticationServiceClearOAuth2TokenParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.token = decoder0.decodeString(8, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(token, 8, false); + } + + String toString() { + return "AuthenticationServiceClearOAuth2TokenParams(" + "token: $token" ")"; + } + + Map toJson() { + Map map = new Map(); + map["token"] = token; + return map; + } +} + +const int kAuthenticationService_selectAccount_name = 0; +const int kAuthenticationService_getOAuth2Token_name = 1; +const int kAuthenticationService_clearOAuth2Token_name = 2; + +const String AuthenticationServiceName = + 'authentication::AuthenticationService'; + +abstract class AuthenticationService { + dynamic selectAccount(bool returnLastSelected,[Function responseFactory = null]); + dynamic getOAuth2Token(String username,List<String> scopes,[Function responseFactory = null]); + void clearOAuth2Token(String token); + +} + + +class AuthenticationServiceProxyImpl extends bindings.Proxy { + AuthenticationServiceProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + AuthenticationServiceProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + AuthenticationServiceProxyImpl.unbound() : super.unbound(); + + static AuthenticationServiceProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For AuthenticationServiceProxyImpl")); + return new AuthenticationServiceProxyImpl.fromEndpoint(endpoint); + } + + String get name => AuthenticationServiceName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kAuthenticationService_selectAccount_name: + var r = AuthenticationServiceSelectAccountResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kAuthenticationService_getOAuth2Token_name: + var r = AuthenticationServiceGetOAuth2TokenResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "AuthenticationServiceProxyImpl($superString)"; + } +} + + +class _AuthenticationServiceProxyCalls implements AuthenticationService { + AuthenticationServiceProxyImpl _proxyImpl; + + _AuthenticationServiceProxyCalls(this._proxyImpl); + dynamic selectAccount(bool returnLastSelected,[Function responseFactory = null]) { + var params = new AuthenticationServiceSelectAccountParams(); + params.returnLastSelected = returnLastSelected; + return _proxyImpl.sendMessageWithRequestId( + params, + kAuthenticationService_selectAccount_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic getOAuth2Token(String username,List<String> scopes,[Function responseFactory = null]) { + var params = new AuthenticationServiceGetOAuth2TokenParams(); + params.username = username; + params.scopes = scopes; + return _proxyImpl.sendMessageWithRequestId( + params, + kAuthenticationService_getOAuth2Token_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + void clearOAuth2Token(String token) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new AuthenticationServiceClearOAuth2TokenParams(); + params.token = token; + _proxyImpl.sendMessage(params, kAuthenticationService_clearOAuth2Token_name); + } + +} + + +class AuthenticationServiceProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + AuthenticationService ptr; + final String name = AuthenticationServiceName; + + AuthenticationServiceProxy(AuthenticationServiceProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _AuthenticationServiceProxyCalls(proxyImpl); + + AuthenticationServiceProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new AuthenticationServiceProxyImpl.fromEndpoint(endpoint) { + ptr = new _AuthenticationServiceProxyCalls(impl); + } + + AuthenticationServiceProxy.fromHandle(core.MojoHandle handle) : + impl = new AuthenticationServiceProxyImpl.fromHandle(handle) { + ptr = new _AuthenticationServiceProxyCalls(impl); + } + + AuthenticationServiceProxy.unbound() : + impl = new AuthenticationServiceProxyImpl.unbound() { + ptr = new _AuthenticationServiceProxyCalls(impl); + } + + factory AuthenticationServiceProxy.connectToService( + bindings.ServiceConnector s, String url) { + AuthenticationServiceProxy p = new AuthenticationServiceProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static AuthenticationServiceProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For AuthenticationServiceProxy")); + return new AuthenticationServiceProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "AuthenticationServiceProxy($impl)"; + } +} + + +class AuthenticationServiceStub extends bindings.Stub { + AuthenticationService _impl = null; + + AuthenticationServiceStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + AuthenticationServiceStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + AuthenticationServiceStub.unbound() : super.unbound(); + + static AuthenticationServiceStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For AuthenticationServiceStub")); + return new AuthenticationServiceStub.fromEndpoint(endpoint); + } + + static const String name = AuthenticationServiceName; + + + AuthenticationServiceSelectAccountResponseParams _AuthenticationServiceSelectAccountResponseParamsFactory(String username, String error) { + var result = new AuthenticationServiceSelectAccountResponseParams(); + result.username = username; + result.error = error; + return result; + } + AuthenticationServiceGetOAuth2TokenResponseParams _AuthenticationServiceGetOAuth2TokenResponseParamsFactory(String token, String error) { + var result = new AuthenticationServiceGetOAuth2TokenResponseParams(); + result.token = token; + result.error = error; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kAuthenticationService_selectAccount_name: + var params = AuthenticationServiceSelectAccountParams.deserialize( + message.payload); + var response = _impl.selectAccount(params.returnLastSelected,_AuthenticationServiceSelectAccountResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kAuthenticationService_selectAccount_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kAuthenticationService_selectAccount_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kAuthenticationService_getOAuth2Token_name: + var params = AuthenticationServiceGetOAuth2TokenParams.deserialize( + message.payload); + var response = _impl.getOAuth2Token(params.username,params.scopes,_AuthenticationServiceGetOAuth2TokenResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kAuthenticationService_getOAuth2Token_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kAuthenticationService_getOAuth2Token_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kAuthenticationService_clearOAuth2Token_name: + var params = AuthenticationServiceClearOAuth2TokenParams.deserialize( + message.payload); + _impl.clearOAuth2Token(params.token); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + AuthenticationService get impl => _impl; + set impl(AuthenticationService d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "AuthenticationServiceStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/contacts/contacts.mojom.dart b/mojo/dart/packages/mojo_services/lib/contacts/contacts.mojom.dart new file mode 100644 index 0000000..d8f44ee --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/contacts/contacts.mojom.dart
@@ -0,0 +1,1078 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library contacts_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; + + + +class Contact extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int id = 0; + String name = null; + + Contact() : super(kVersions.last.size); + + static Contact deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static Contact decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + Contact result = new Contact(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.id = decoder0.decodeInt64(8); + } + if (mainDataHeader.version >= 0) { + + result.name = decoder0.decodeString(16, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt64(id, 8); + + encoder0.encodeString(name, 16, false); + } + + String toString() { + return "Contact(" + "id: $id" ", " + "name: $name" ")"; + } + + Map toJson() { + Map map = new Map(); + map["id"] = id; + map["name"] = name; + return map; + } +} + + +class ContactsServiceGetCountParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + String filter = null; + + ContactsServiceGetCountParams() : super(kVersions.last.size); + + static ContactsServiceGetCountParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ContactsServiceGetCountParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ContactsServiceGetCountParams result = new ContactsServiceGetCountParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.filter = decoder0.decodeString(8, true); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(filter, 8, true); + } + + String toString() { + return "ContactsServiceGetCountParams(" + "filter: $filter" ")"; + } + + Map toJson() { + Map map = new Map(); + map["filter"] = filter; + return map; + } +} + + +class ContactsServiceGetCountResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int count = 0; + + ContactsServiceGetCountResponseParams() : super(kVersions.last.size); + + static ContactsServiceGetCountResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ContactsServiceGetCountResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ContactsServiceGetCountResponseParams result = new ContactsServiceGetCountResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.count = decoder0.decodeUint64(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint64(count, 8); + } + + String toString() { + return "ContactsServiceGetCountResponseParams(" + "count: $count" ")"; + } + + Map toJson() { + Map map = new Map(); + map["count"] = count; + return map; + } +} + + +class ContactsServiceGetParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + String filter = null; + int offset = 0; + int limit = 0; + + ContactsServiceGetParams() : super(kVersions.last.size); + + static ContactsServiceGetParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ContactsServiceGetParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ContactsServiceGetParams result = new ContactsServiceGetParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.filter = decoder0.decodeString(8, true); + } + if (mainDataHeader.version >= 0) { + + result.offset = decoder0.decodeUint32(16); + } + if (mainDataHeader.version >= 0) { + + result.limit = decoder0.decodeUint32(20); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(filter, 8, true); + + encoder0.encodeUint32(offset, 16); + + encoder0.encodeUint32(limit, 20); + } + + String toString() { + return "ContactsServiceGetParams(" + "filter: $filter" ", " + "offset: $offset" ", " + "limit: $limit" ")"; + } + + Map toJson() { + Map map = new Map(); + map["filter"] = filter; + map["offset"] = offset; + map["limit"] = limit; + return map; + } +} + + +class ContactsServiceGetResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + List<Contact> contacts = null; + + ContactsServiceGetResponseParams() : super(kVersions.last.size); + + static ContactsServiceGetResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ContactsServiceGetResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ContactsServiceGetResponseParams result = new ContactsServiceGetResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.contacts = new List<Contact>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + var decoder2 = decoder1.decodePointer(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + result.contacts[i1] = Contact.decode(decoder2); + } + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + if (contacts == null) { + encoder0.encodeNullPointer(8, false); + } else { + var encoder1 = encoder0.encodePointerArray(contacts.length, 8, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < contacts.length; ++i0) { + + encoder1.encodeStruct(contacts[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + } + + String toString() { + return "ContactsServiceGetResponseParams(" + "contacts: $contacts" ")"; + } + + Map toJson() { + Map map = new Map(); + map["contacts"] = contacts; + return map; + } +} + + +class ContactsServiceGetEmailsParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int id = 0; + + ContactsServiceGetEmailsParams() : super(kVersions.last.size); + + static ContactsServiceGetEmailsParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ContactsServiceGetEmailsParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ContactsServiceGetEmailsParams result = new ContactsServiceGetEmailsParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.id = decoder0.decodeInt64(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt64(id, 8); + } + + String toString() { + return "ContactsServiceGetEmailsParams(" + "id: $id" ")"; + } + + Map toJson() { + Map map = new Map(); + map["id"] = id; + return map; + } +} + + +class ContactsServiceGetEmailsResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + List<String> emails = null; + + ContactsServiceGetEmailsResponseParams() : super(kVersions.last.size); + + static ContactsServiceGetEmailsResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ContactsServiceGetEmailsResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ContactsServiceGetEmailsResponseParams result = new ContactsServiceGetEmailsResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.emails = new List<String>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + result.emails[i1] = decoder1.decodeString(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + } + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + if (emails == null) { + encoder0.encodeNullPointer(8, false); + } else { + var encoder1 = encoder0.encodePointerArray(emails.length, 8, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < emails.length; ++i0) { + + encoder1.encodeString(emails[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + } + + String toString() { + return "ContactsServiceGetEmailsResponseParams(" + "emails: $emails" ")"; + } + + Map toJson() { + Map map = new Map(); + map["emails"] = emails; + return map; + } +} + + +class ContactsServiceGetPhotoParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int id = 0; + bool highResolution = false; + + ContactsServiceGetPhotoParams() : super(kVersions.last.size); + + static ContactsServiceGetPhotoParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ContactsServiceGetPhotoParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ContactsServiceGetPhotoParams result = new ContactsServiceGetPhotoParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.id = decoder0.decodeInt64(8); + } + if (mainDataHeader.version >= 0) { + + result.highResolution = decoder0.decodeBool(16, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt64(id, 8); + + encoder0.encodeBool(highResolution, 16, 0); + } + + String toString() { + return "ContactsServiceGetPhotoParams(" + "id: $id" ", " + "highResolution: $highResolution" ")"; + } + + Map toJson() { + Map map = new Map(); + map["id"] = id; + map["highResolution"] = highResolution; + return map; + } +} + + +class ContactsServiceGetPhotoResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + String photoUrl = null; + + ContactsServiceGetPhotoResponseParams() : super(kVersions.last.size); + + static ContactsServiceGetPhotoResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ContactsServiceGetPhotoResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ContactsServiceGetPhotoResponseParams result = new ContactsServiceGetPhotoResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.photoUrl = decoder0.decodeString(8, true); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(photoUrl, 8, true); + } + + String toString() { + return "ContactsServiceGetPhotoResponseParams(" + "photoUrl: $photoUrl" ")"; + } + + Map toJson() { + Map map = new Map(); + map["photoUrl"] = photoUrl; + return map; + } +} + +const int kContactsService_getCount_name = 0; +const int kContactsService_get_name = 1; +const int kContactsService_getEmails_name = 2; +const int kContactsService_getPhoto_name = 3; + +const String ContactsServiceName = + 'contacts::ContactsService'; + +abstract class ContactsService { + dynamic getCount(String filter,[Function responseFactory = null]); + dynamic get(String filter,int offset,int limit,[Function responseFactory = null]); + dynamic getEmails(int id,[Function responseFactory = null]); + dynamic getPhoto(int id,bool highResolution,[Function responseFactory = null]); + +} + + +class ContactsServiceProxyImpl extends bindings.Proxy { + ContactsServiceProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + ContactsServiceProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + ContactsServiceProxyImpl.unbound() : super.unbound(); + + static ContactsServiceProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ContactsServiceProxyImpl")); + return new ContactsServiceProxyImpl.fromEndpoint(endpoint); + } + + String get name => ContactsServiceName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kContactsService_getCount_name: + var r = ContactsServiceGetCountResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kContactsService_get_name: + var r = ContactsServiceGetResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kContactsService_getEmails_name: + var r = ContactsServiceGetEmailsResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kContactsService_getPhoto_name: + var r = ContactsServiceGetPhotoResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "ContactsServiceProxyImpl($superString)"; + } +} + + +class _ContactsServiceProxyCalls implements ContactsService { + ContactsServiceProxyImpl _proxyImpl; + + _ContactsServiceProxyCalls(this._proxyImpl); + dynamic getCount(String filter,[Function responseFactory = null]) { + var params = new ContactsServiceGetCountParams(); + params.filter = filter; + return _proxyImpl.sendMessageWithRequestId( + params, + kContactsService_getCount_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic get(String filter,int offset,int limit,[Function responseFactory = null]) { + var params = new ContactsServiceGetParams(); + params.filter = filter; + params.offset = offset; + params.limit = limit; + return _proxyImpl.sendMessageWithRequestId( + params, + kContactsService_get_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic getEmails(int id,[Function responseFactory = null]) { + var params = new ContactsServiceGetEmailsParams(); + params.id = id; + return _proxyImpl.sendMessageWithRequestId( + params, + kContactsService_getEmails_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic getPhoto(int id,bool highResolution,[Function responseFactory = null]) { + var params = new ContactsServiceGetPhotoParams(); + params.id = id; + params.highResolution = highResolution; + return _proxyImpl.sendMessageWithRequestId( + params, + kContactsService_getPhoto_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class ContactsServiceProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + ContactsService ptr; + final String name = ContactsServiceName; + + ContactsServiceProxy(ContactsServiceProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _ContactsServiceProxyCalls(proxyImpl); + + ContactsServiceProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new ContactsServiceProxyImpl.fromEndpoint(endpoint) { + ptr = new _ContactsServiceProxyCalls(impl); + } + + ContactsServiceProxy.fromHandle(core.MojoHandle handle) : + impl = new ContactsServiceProxyImpl.fromHandle(handle) { + ptr = new _ContactsServiceProxyCalls(impl); + } + + ContactsServiceProxy.unbound() : + impl = new ContactsServiceProxyImpl.unbound() { + ptr = new _ContactsServiceProxyCalls(impl); + } + + factory ContactsServiceProxy.connectToService( + bindings.ServiceConnector s, String url) { + ContactsServiceProxy p = new ContactsServiceProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static ContactsServiceProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ContactsServiceProxy")); + return new ContactsServiceProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "ContactsServiceProxy($impl)"; + } +} + + +class ContactsServiceStub extends bindings.Stub { + ContactsService _impl = null; + + ContactsServiceStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + ContactsServiceStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + ContactsServiceStub.unbound() : super.unbound(); + + static ContactsServiceStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ContactsServiceStub")); + return new ContactsServiceStub.fromEndpoint(endpoint); + } + + static const String name = ContactsServiceName; + + + ContactsServiceGetCountResponseParams _ContactsServiceGetCountResponseParamsFactory(int count) { + var result = new ContactsServiceGetCountResponseParams(); + result.count = count; + return result; + } + ContactsServiceGetResponseParams _ContactsServiceGetResponseParamsFactory(List<Contact> contacts) { + var result = new ContactsServiceGetResponseParams(); + result.contacts = contacts; + return result; + } + ContactsServiceGetEmailsResponseParams _ContactsServiceGetEmailsResponseParamsFactory(List<String> emails) { + var result = new ContactsServiceGetEmailsResponseParams(); + result.emails = emails; + return result; + } + ContactsServiceGetPhotoResponseParams _ContactsServiceGetPhotoResponseParamsFactory(String photoUrl) { + var result = new ContactsServiceGetPhotoResponseParams(); + result.photoUrl = photoUrl; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kContactsService_getCount_name: + var params = ContactsServiceGetCountParams.deserialize( + message.payload); + var response = _impl.getCount(params.filter,_ContactsServiceGetCountResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kContactsService_getCount_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kContactsService_getCount_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kContactsService_get_name: + var params = ContactsServiceGetParams.deserialize( + message.payload); + var response = _impl.get(params.filter,params.offset,params.limit,_ContactsServiceGetResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kContactsService_get_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kContactsService_get_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kContactsService_getEmails_name: + var params = ContactsServiceGetEmailsParams.deserialize( + message.payload); + var response = _impl.getEmails(params.id,_ContactsServiceGetEmailsResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kContactsService_getEmails_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kContactsService_getEmails_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kContactsService_getPhoto_name: + var params = ContactsServiceGetPhotoParams.deserialize( + message.payload); + var response = _impl.getPhoto(params.id,params.highResolution,_ContactsServiceGetPhotoResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kContactsService_getPhoto_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kContactsService_getPhoto_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + ContactsService get impl => _impl; + set impl(ContactsService d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "ContactsServiceStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/http_server/http_request.mojom.dart b/mojo/dart/packages/mojo_services/lib/http_server/http_request.mojom.dart new file mode 100644 index 0000000..e3f54b2 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/http_server/http_request.mojom.dart
@@ -0,0 +1,159 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library http_request_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; + + + +class HttpRequest extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(40, 0) + ]; + String relativeUrl = null; + String method = "GET"; + Map<String, String> headers = null; + core.MojoDataPipeConsumer body = null; + + HttpRequest() : super(kVersions.last.size); + + static HttpRequest deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static HttpRequest decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + HttpRequest result = new HttpRequest(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.relativeUrl = decoder0.decodeString(8, false); + } + if (mainDataHeader.version >= 0) { + + result.method = decoder0.decodeString(16, false); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(24, true); + if (decoder1 == null) { + result.headers = null; + } else { + decoder1.decodeDataHeaderForMap(); + List<String> keys0; + List<String> values0; + { + + var decoder2 = decoder1.decodePointer(bindings.ArrayDataHeader.kHeaderSize, false); + { + var si2 = decoder2.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + keys0 = new List<String>(si2.numElements); + for (int i2 = 0; i2 < si2.numElements; ++i2) { + + keys0[i2] = decoder2.decodeString(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i2, false); + } + } + } + { + + var decoder2 = decoder1.decodePointer(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize, false); + { + var si2 = decoder2.decodeDataHeaderForPointerArray(keys0.length); + values0 = new List<String>(si2.numElements); + for (int i2 = 0; i2 < si2.numElements; ++i2) { + + values0[i2] = decoder2.decodeString(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i2, false); + } + } + } + result.headers = new Map<String, String>.fromIterables( + keys0, values0); + } + } + if (mainDataHeader.version >= 0) { + + result.body = decoder0.decodeConsumerHandle(32, true); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(relativeUrl, 8, false); + + encoder0.encodeString(method, 16, false); + + if (headers == null) { + encoder0.encodeNullPointer(24, true); + } else { + var encoder1 = encoder0.encoderForMap(24); + int size0 = headers.length; + var keys0 = headers.keys.toList(); + var values0 = headers.values.toList(); + + { + var encoder2 = encoder1.encodePointerArray(keys0.length, bindings.ArrayDataHeader.kHeaderSize, bindings.kUnspecifiedArrayLength); + for (int i1 = 0; i1 < keys0.length; ++i1) { + + encoder2.encodeString(keys0[i1], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + } + } + + { + var encoder2 = encoder1.encodePointerArray(values0.length, bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize, bindings.kUnspecifiedArrayLength); + for (int i1 = 0; i1 < values0.length; ++i1) { + + encoder2.encodeString(values0[i1], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + } + } + } + + encoder0.encodeConsumerHandle(body, 32, true); + } + + String toString() { + return "HttpRequest(" + "relativeUrl: $relativeUrl" ", " + "method: $method" ", " + "headers: $headers" ", " + "body: $body" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/http_server/http_response.mojom.dart b/mojo/dart/packages/mojo_services/lib/http_server/http_response.mojom.dart new file mode 100644 index 0000000..a532a86 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/http_server/http_response.mojom.dart
@@ -0,0 +1,167 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library http_response_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; + + + +class HttpResponse extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(40, 0) + ]; + int statusCode = 200; + core.MojoDataPipeConsumer body = null; + int contentLength = 0; + String contentType = "text/html; charset=utf-8"; + Map<String, String> customHeaders = null; + + HttpResponse() : super(kVersions.last.size); + + static HttpResponse deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static HttpResponse decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + HttpResponse result = new HttpResponse(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.statusCode = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + result.body = decoder0.decodeConsumerHandle(12, true); + } + if (mainDataHeader.version >= 0) { + + result.contentLength = decoder0.decodeInt64(16); + } + if (mainDataHeader.version >= 0) { + + result.contentType = decoder0.decodeString(24, false); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(32, true); + if (decoder1 == null) { + result.customHeaders = null; + } else { + decoder1.decodeDataHeaderForMap(); + List<String> keys0; + List<String> values0; + { + + var decoder2 = decoder1.decodePointer(bindings.ArrayDataHeader.kHeaderSize, false); + { + var si2 = decoder2.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + keys0 = new List<String>(si2.numElements); + for (int i2 = 0; i2 < si2.numElements; ++i2) { + + keys0[i2] = decoder2.decodeString(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i2, false); + } + } + } + { + + var decoder2 = decoder1.decodePointer(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize, false); + { + var si2 = decoder2.decodeDataHeaderForPointerArray(keys0.length); + values0 = new List<String>(si2.numElements); + for (int i2 = 0; i2 < si2.numElements; ++i2) { + + values0[i2] = decoder2.decodeString(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i2, false); + } + } + } + result.customHeaders = new Map<String, String>.fromIterables( + keys0, values0); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(statusCode, 8); + + encoder0.encodeConsumerHandle(body, 12, true); + + encoder0.encodeInt64(contentLength, 16); + + encoder0.encodeString(contentType, 24, false); + + if (customHeaders == null) { + encoder0.encodeNullPointer(32, true); + } else { + var encoder1 = encoder0.encoderForMap(32); + int size0 = customHeaders.length; + var keys0 = customHeaders.keys.toList(); + var values0 = customHeaders.values.toList(); + + { + var encoder2 = encoder1.encodePointerArray(keys0.length, bindings.ArrayDataHeader.kHeaderSize, bindings.kUnspecifiedArrayLength); + for (int i1 = 0; i1 < keys0.length; ++i1) { + + encoder2.encodeString(keys0[i1], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + } + } + + { + var encoder2 = encoder1.encodePointerArray(values0.length, bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize, bindings.kUnspecifiedArrayLength); + for (int i1 = 0; i1 < values0.length; ++i1) { + + encoder2.encodeString(values0[i1], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + } + } + } + } + + String toString() { + return "HttpResponse(" + "statusCode: $statusCode" ", " + "body: $body" ", " + "contentLength: $contentLength" ", " + "contentType: $contentType" ", " + "customHeaders: $customHeaders" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/http_server/http_server.mojom.dart b/mojo/dart/packages/mojo_services/lib/http_server/http_server.mojom.dart new file mode 100644 index 0000000..8cec930 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/http_server/http_server.mojom.dart
@@ -0,0 +1,905 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library http_server_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo_services/http_server/http_request.mojom.dart' as http_request_mojom; +import 'package:mojo_services/http_server/http_response.mojom.dart' as http_response_mojom; + + + +class HttpServerSetHandlerParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + String pattern = null; + Object handler = null; + + HttpServerSetHandlerParams() : super(kVersions.last.size); + + static HttpServerSetHandlerParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static HttpServerSetHandlerParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + HttpServerSetHandlerParams result = new HttpServerSetHandlerParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.pattern = decoder0.decodeString(8, false); + } + if (mainDataHeader.version >= 0) { + + result.handler = decoder0.decodeServiceInterface(16, false, HttpHandlerProxy.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(pattern, 8, false); + + encoder0.encodeInterface(handler, 16, false); + } + + String toString() { + return "HttpServerSetHandlerParams(" + "pattern: $pattern" ", " + "handler: $handler" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class HttpServerSetHandlerResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + bool success = false; + + HttpServerSetHandlerResponseParams() : super(kVersions.last.size); + + static HttpServerSetHandlerResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static HttpServerSetHandlerResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + HttpServerSetHandlerResponseParams result = new HttpServerSetHandlerResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.success = decoder0.decodeBool(8, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeBool(success, 8, 0); + } + + String toString() { + return "HttpServerSetHandlerResponseParams(" + "success: $success" ")"; + } + + Map toJson() { + Map map = new Map(); + map["success"] = success; + return map; + } +} + + +class HttpServerGetPortParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + HttpServerGetPortParams() : super(kVersions.last.size); + + static HttpServerGetPortParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static HttpServerGetPortParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + HttpServerGetPortParams result = new HttpServerGetPortParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "HttpServerGetPortParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class HttpServerGetPortResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int port = 0; + + HttpServerGetPortResponseParams() : super(kVersions.last.size); + + static HttpServerGetPortResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static HttpServerGetPortResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + HttpServerGetPortResponseParams result = new HttpServerGetPortResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.port = decoder0.decodeUint16(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint16(port, 8); + } + + String toString() { + return "HttpServerGetPortResponseParams(" + "port: $port" ")"; + } + + Map toJson() { + Map map = new Map(); + map["port"] = port; + return map; + } +} + + +class HttpHandlerHandleRequestParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + http_request_mojom.HttpRequest request = null; + + HttpHandlerHandleRequestParams() : super(kVersions.last.size); + + static HttpHandlerHandleRequestParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static HttpHandlerHandleRequestParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + HttpHandlerHandleRequestParams result = new HttpHandlerHandleRequestParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.request = http_request_mojom.HttpRequest.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(request, 8, false); + } + + String toString() { + return "HttpHandlerHandleRequestParams(" + "request: $request" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class HttpHandlerHandleRequestResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + http_response_mojom.HttpResponse response = null; + + HttpHandlerHandleRequestResponseParams() : super(kVersions.last.size); + + static HttpHandlerHandleRequestResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static HttpHandlerHandleRequestResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + HttpHandlerHandleRequestResponseParams result = new HttpHandlerHandleRequestResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.response = http_response_mojom.HttpResponse.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(response, 8, false); + } + + String toString() { + return "HttpHandlerHandleRequestResponseParams(" + "response: $response" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + +const int kHttpServer_setHandler_name = 0; +const int kHttpServer_getPort_name = 1; + +const String HttpServerName = + 'http_server::HttpServer'; + +abstract class HttpServer { + dynamic setHandler(String pattern,Object handler,[Function responseFactory = null]); + dynamic getPort([Function responseFactory = null]); + +} + + +class HttpServerProxyImpl extends bindings.Proxy { + HttpServerProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + HttpServerProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + HttpServerProxyImpl.unbound() : super.unbound(); + + static HttpServerProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For HttpServerProxyImpl")); + return new HttpServerProxyImpl.fromEndpoint(endpoint); + } + + String get name => HttpServerName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kHttpServer_setHandler_name: + var r = HttpServerSetHandlerResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kHttpServer_getPort_name: + var r = HttpServerGetPortResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "HttpServerProxyImpl($superString)"; + } +} + + +class _HttpServerProxyCalls implements HttpServer { + HttpServerProxyImpl _proxyImpl; + + _HttpServerProxyCalls(this._proxyImpl); + dynamic setHandler(String pattern,Object handler,[Function responseFactory = null]) { + var params = new HttpServerSetHandlerParams(); + params.pattern = pattern; + params.handler = handler; + return _proxyImpl.sendMessageWithRequestId( + params, + kHttpServer_setHandler_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic getPort([Function responseFactory = null]) { + var params = new HttpServerGetPortParams(); + return _proxyImpl.sendMessageWithRequestId( + params, + kHttpServer_getPort_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class HttpServerProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + HttpServer ptr; + final String name = HttpServerName; + + HttpServerProxy(HttpServerProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _HttpServerProxyCalls(proxyImpl); + + HttpServerProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new HttpServerProxyImpl.fromEndpoint(endpoint) { + ptr = new _HttpServerProxyCalls(impl); + } + + HttpServerProxy.fromHandle(core.MojoHandle handle) : + impl = new HttpServerProxyImpl.fromHandle(handle) { + ptr = new _HttpServerProxyCalls(impl); + } + + HttpServerProxy.unbound() : + impl = new HttpServerProxyImpl.unbound() { + ptr = new _HttpServerProxyCalls(impl); + } + + factory HttpServerProxy.connectToService( + bindings.ServiceConnector s, String url) { + HttpServerProxy p = new HttpServerProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static HttpServerProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For HttpServerProxy")); + return new HttpServerProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "HttpServerProxy($impl)"; + } +} + + +class HttpServerStub extends bindings.Stub { + HttpServer _impl = null; + + HttpServerStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + HttpServerStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + HttpServerStub.unbound() : super.unbound(); + + static HttpServerStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For HttpServerStub")); + return new HttpServerStub.fromEndpoint(endpoint); + } + + static const String name = HttpServerName; + + + HttpServerSetHandlerResponseParams _HttpServerSetHandlerResponseParamsFactory(bool success) { + var result = new HttpServerSetHandlerResponseParams(); + result.success = success; + return result; + } + HttpServerGetPortResponseParams _HttpServerGetPortResponseParamsFactory(int port) { + var result = new HttpServerGetPortResponseParams(); + result.port = port; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kHttpServer_setHandler_name: + var params = HttpServerSetHandlerParams.deserialize( + message.payload); + var response = _impl.setHandler(params.pattern,params.handler,_HttpServerSetHandlerResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kHttpServer_setHandler_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kHttpServer_setHandler_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kHttpServer_getPort_name: + var params = HttpServerGetPortParams.deserialize( + message.payload); + var response = _impl.getPort(_HttpServerGetPortResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kHttpServer_getPort_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kHttpServer_getPort_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + HttpServer get impl => _impl; + set impl(HttpServer d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "HttpServerStub($superString)"; + } + + int get version => 0; +} + +const int kHttpHandler_handleRequest_name = 0; + +const String HttpHandlerName = + 'http_server::HttpHandler'; + +abstract class HttpHandler { + dynamic handleRequest(http_request_mojom.HttpRequest request,[Function responseFactory = null]); + +} + + +class HttpHandlerProxyImpl extends bindings.Proxy { + HttpHandlerProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + HttpHandlerProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + HttpHandlerProxyImpl.unbound() : super.unbound(); + + static HttpHandlerProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For HttpHandlerProxyImpl")); + return new HttpHandlerProxyImpl.fromEndpoint(endpoint); + } + + String get name => HttpHandlerName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kHttpHandler_handleRequest_name: + var r = HttpHandlerHandleRequestResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "HttpHandlerProxyImpl($superString)"; + } +} + + +class _HttpHandlerProxyCalls implements HttpHandler { + HttpHandlerProxyImpl _proxyImpl; + + _HttpHandlerProxyCalls(this._proxyImpl); + dynamic handleRequest(http_request_mojom.HttpRequest request,[Function responseFactory = null]) { + var params = new HttpHandlerHandleRequestParams(); + params.request = request; + return _proxyImpl.sendMessageWithRequestId( + params, + kHttpHandler_handleRequest_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class HttpHandlerProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + HttpHandler ptr; + final String name = HttpHandlerName; + + HttpHandlerProxy(HttpHandlerProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _HttpHandlerProxyCalls(proxyImpl); + + HttpHandlerProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new HttpHandlerProxyImpl.fromEndpoint(endpoint) { + ptr = new _HttpHandlerProxyCalls(impl); + } + + HttpHandlerProxy.fromHandle(core.MojoHandle handle) : + impl = new HttpHandlerProxyImpl.fromHandle(handle) { + ptr = new _HttpHandlerProxyCalls(impl); + } + + HttpHandlerProxy.unbound() : + impl = new HttpHandlerProxyImpl.unbound() { + ptr = new _HttpHandlerProxyCalls(impl); + } + + factory HttpHandlerProxy.connectToService( + bindings.ServiceConnector s, String url) { + HttpHandlerProxy p = new HttpHandlerProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static HttpHandlerProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For HttpHandlerProxy")); + return new HttpHandlerProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "HttpHandlerProxy($impl)"; + } +} + + +class HttpHandlerStub extends bindings.Stub { + HttpHandler _impl = null; + + HttpHandlerStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + HttpHandlerStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + HttpHandlerStub.unbound() : super.unbound(); + + static HttpHandlerStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For HttpHandlerStub")); + return new HttpHandlerStub.fromEndpoint(endpoint); + } + + static const String name = HttpHandlerName; + + + HttpHandlerHandleRequestResponseParams _HttpHandlerHandleRequestResponseParamsFactory(http_response_mojom.HttpResponse response) { + var result = new HttpHandlerHandleRequestResponseParams(); + result.response = response; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kHttpHandler_handleRequest_name: + var params = HttpHandlerHandleRequestParams.deserialize( + message.payload); + var response = _impl.handleRequest(params.request,_HttpHandlerHandleRequestResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kHttpHandler_handleRequest_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kHttpHandler_handleRequest_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + HttpHandler get impl => _impl; + set impl(HttpHandler d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "HttpHandlerStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/http_server/http_server_factory.mojom.dart b/mojo/dart/packages/mojo_services/lib/http_server/http_server_factory.mojom.dart new file mode 100644 index 0000000..22cbf0c --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/http_server/http_server_factory.mojom.dart
@@ -0,0 +1,266 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library http_server_factory_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo_services/http_server/http_server.mojom.dart' as http_server_mojom; +import 'package:mojo_services/mojo/net_address.mojom.dart' as net_address_mojom; + + + +class HttpServerFactoryCreateHttpServerParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + Object serverRequest = null; + net_address_mojom.NetAddress localAddress = null; + + HttpServerFactoryCreateHttpServerParams() : super(kVersions.last.size); + + static HttpServerFactoryCreateHttpServerParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static HttpServerFactoryCreateHttpServerParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + HttpServerFactoryCreateHttpServerParams result = new HttpServerFactoryCreateHttpServerParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.serverRequest = decoder0.decodeInterfaceRequest(8, false, http_server_mojom.HttpServerStub.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, true); + result.localAddress = net_address_mojom.NetAddress.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterfaceRequest(serverRequest, 8, false); + + encoder0.encodeStruct(localAddress, 16, true); + } + + String toString() { + return "HttpServerFactoryCreateHttpServerParams(" + "serverRequest: $serverRequest" ", " + "localAddress: $localAddress" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + +const int kHttpServerFactory_createHttpServer_name = 0; + +const String HttpServerFactoryName = + 'http_server::HttpServerFactory'; + +abstract class HttpServerFactory { + void createHttpServer(Object serverRequest, net_address_mojom.NetAddress localAddress); + +} + + +class HttpServerFactoryProxyImpl extends bindings.Proxy { + HttpServerFactoryProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + HttpServerFactoryProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + HttpServerFactoryProxyImpl.unbound() : super.unbound(); + + static HttpServerFactoryProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For HttpServerFactoryProxyImpl")); + return new HttpServerFactoryProxyImpl.fromEndpoint(endpoint); + } + + String get name => HttpServerFactoryName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "HttpServerFactoryProxyImpl($superString)"; + } +} + + +class _HttpServerFactoryProxyCalls implements HttpServerFactory { + HttpServerFactoryProxyImpl _proxyImpl; + + _HttpServerFactoryProxyCalls(this._proxyImpl); + void createHttpServer(Object serverRequest, net_address_mojom.NetAddress localAddress) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new HttpServerFactoryCreateHttpServerParams(); + params.serverRequest = serverRequest; + params.localAddress = localAddress; + _proxyImpl.sendMessage(params, kHttpServerFactory_createHttpServer_name); + } + +} + + +class HttpServerFactoryProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + HttpServerFactory ptr; + final String name = HttpServerFactoryName; + + HttpServerFactoryProxy(HttpServerFactoryProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _HttpServerFactoryProxyCalls(proxyImpl); + + HttpServerFactoryProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new HttpServerFactoryProxyImpl.fromEndpoint(endpoint) { + ptr = new _HttpServerFactoryProxyCalls(impl); + } + + HttpServerFactoryProxy.fromHandle(core.MojoHandle handle) : + impl = new HttpServerFactoryProxyImpl.fromHandle(handle) { + ptr = new _HttpServerFactoryProxyCalls(impl); + } + + HttpServerFactoryProxy.unbound() : + impl = new HttpServerFactoryProxyImpl.unbound() { + ptr = new _HttpServerFactoryProxyCalls(impl); + } + + factory HttpServerFactoryProxy.connectToService( + bindings.ServiceConnector s, String url) { + HttpServerFactoryProxy p = new HttpServerFactoryProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static HttpServerFactoryProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For HttpServerFactoryProxy")); + return new HttpServerFactoryProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "HttpServerFactoryProxy($impl)"; + } +} + + +class HttpServerFactoryStub extends bindings.Stub { + HttpServerFactory _impl = null; + + HttpServerFactoryStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + HttpServerFactoryStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + HttpServerFactoryStub.unbound() : super.unbound(); + + static HttpServerFactoryStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For HttpServerFactoryStub")); + return new HttpServerFactoryStub.fromEndpoint(endpoint); + } + + static const String name = HttpServerFactoryName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kHttpServerFactory_createHttpServer_name: + var params = HttpServerFactoryCreateHttpServerParams.deserialize( + message.payload); + _impl.createHttpServer(params.serverRequest, params.localAddress); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + HttpServerFactory get impl => _impl; + set impl(HttpServerFactory d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "HttpServerFactoryStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/icu_data/icu_data.mojom.dart b/mojo/dart/packages/mojo_services/lib/icu_data/icu_data.mojom.dart new file mode 100644 index 0000000..36a8e08 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/icu_data/icu_data.mojom.dart
@@ -0,0 +1,362 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library icu_data_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; + + + +class IcuDataMapParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + String sha1hash = null; + + IcuDataMapParams() : super(kVersions.last.size); + + static IcuDataMapParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static IcuDataMapParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + IcuDataMapParams result = new IcuDataMapParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.sha1hash = decoder0.decodeString(8, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(sha1hash, 8, false); + } + + String toString() { + return "IcuDataMapParams(" + "sha1hash: $sha1hash" ")"; + } + + Map toJson() { + Map map = new Map(); + map["sha1hash"] = sha1hash; + return map; + } +} + + +class IcuDataMapResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + core.MojoSharedBuffer icuData = null; + + IcuDataMapResponseParams() : super(kVersions.last.size); + + static IcuDataMapResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static IcuDataMapResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + IcuDataMapResponseParams result = new IcuDataMapResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.icuData = decoder0.decodeSharedBufferHandle(8, true); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeSharedBufferHandle(icuData, 8, true); + } + + String toString() { + return "IcuDataMapResponseParams(" + "icuData: $icuData" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + +const int kIcuData_map_name = 0; + +const String IcuDataName = + 'icu_data::ICUData'; + +abstract class IcuData { + dynamic map(String sha1hash,[Function responseFactory = null]); + +} + + +class IcuDataProxyImpl extends bindings.Proxy { + IcuDataProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + IcuDataProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + IcuDataProxyImpl.unbound() : super.unbound(); + + static IcuDataProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For IcuDataProxyImpl")); + return new IcuDataProxyImpl.fromEndpoint(endpoint); + } + + String get name => IcuDataName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kIcuData_map_name: + var r = IcuDataMapResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "IcuDataProxyImpl($superString)"; + } +} + + +class _IcuDataProxyCalls implements IcuData { + IcuDataProxyImpl _proxyImpl; + + _IcuDataProxyCalls(this._proxyImpl); + dynamic map(String sha1hash,[Function responseFactory = null]) { + var params = new IcuDataMapParams(); + params.sha1hash = sha1hash; + return _proxyImpl.sendMessageWithRequestId( + params, + kIcuData_map_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class IcuDataProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + IcuData ptr; + final String name = IcuDataName; + + IcuDataProxy(IcuDataProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _IcuDataProxyCalls(proxyImpl); + + IcuDataProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new IcuDataProxyImpl.fromEndpoint(endpoint) { + ptr = new _IcuDataProxyCalls(impl); + } + + IcuDataProxy.fromHandle(core.MojoHandle handle) : + impl = new IcuDataProxyImpl.fromHandle(handle) { + ptr = new _IcuDataProxyCalls(impl); + } + + IcuDataProxy.unbound() : + impl = new IcuDataProxyImpl.unbound() { + ptr = new _IcuDataProxyCalls(impl); + } + + factory IcuDataProxy.connectToService( + bindings.ServiceConnector s, String url) { + IcuDataProxy p = new IcuDataProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static IcuDataProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For IcuDataProxy")); + return new IcuDataProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "IcuDataProxy($impl)"; + } +} + + +class IcuDataStub extends bindings.Stub { + IcuData _impl = null; + + IcuDataStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + IcuDataStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + IcuDataStub.unbound() : super.unbound(); + + static IcuDataStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For IcuDataStub")); + return new IcuDataStub.fromEndpoint(endpoint); + } + + static const String name = IcuDataName; + + + IcuDataMapResponseParams _IcuDataMapResponseParamsFactory(core.MojoSharedBuffer icuData) { + var result = new IcuDataMapResponseParams(); + result.icuData = icuData; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kIcuData_map_name: + var params = IcuDataMapParams.deserialize( + message.payload); + var response = _impl.map(params.sha1hash,_IcuDataMapResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kIcuData_map_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kIcuData_map_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + IcuData get impl => _impl; + set impl(IcuData d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "IcuDataStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/input/input.mojom.dart b/mojo/dart/packages/mojo_services/lib/input/input.mojom.dart new file mode 100644 index 0000000..7ba4a92 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/input/input.mojom.dart
@@ -0,0 +1,584 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library input_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; + + + +class InputClientOnBackButtonParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + InputClientOnBackButtonParams() : super(kVersions.last.size); + + static InputClientOnBackButtonParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static InputClientOnBackButtonParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + InputClientOnBackButtonParams result = new InputClientOnBackButtonParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "InputClientOnBackButtonParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class InputClientOnBackButtonResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + InputClientOnBackButtonResponseParams() : super(kVersions.last.size); + + static InputClientOnBackButtonResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static InputClientOnBackButtonResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + InputClientOnBackButtonResponseParams result = new InputClientOnBackButtonResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "InputClientOnBackButtonResponseParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class InputServiceSetClientParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + Object client = null; + + InputServiceSetClientParams() : super(kVersions.last.size); + + static InputServiceSetClientParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static InputServiceSetClientParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + InputServiceSetClientParams result = new InputServiceSetClientParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.client = decoder0.decodeServiceInterface(8, false, InputClientProxy.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterface(client, 8, false); + } + + String toString() { + return "InputServiceSetClientParams(" + "client: $client" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + +const int kInputClient_onBackButton_name = 0; + +const String InputClientName = + 'input::InputClient'; + +abstract class InputClient { + dynamic onBackButton([Function responseFactory = null]); + +} + + +class InputClientProxyImpl extends bindings.Proxy { + InputClientProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + InputClientProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + InputClientProxyImpl.unbound() : super.unbound(); + + static InputClientProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For InputClientProxyImpl")); + return new InputClientProxyImpl.fromEndpoint(endpoint); + } + + String get name => InputClientName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kInputClient_onBackButton_name: + var r = InputClientOnBackButtonResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "InputClientProxyImpl($superString)"; + } +} + + +class _InputClientProxyCalls implements InputClient { + InputClientProxyImpl _proxyImpl; + + _InputClientProxyCalls(this._proxyImpl); + dynamic onBackButton([Function responseFactory = null]) { + var params = new InputClientOnBackButtonParams(); + return _proxyImpl.sendMessageWithRequestId( + params, + kInputClient_onBackButton_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class InputClientProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + InputClient ptr; + final String name = InputClientName; + + InputClientProxy(InputClientProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _InputClientProxyCalls(proxyImpl); + + InputClientProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new InputClientProxyImpl.fromEndpoint(endpoint) { + ptr = new _InputClientProxyCalls(impl); + } + + InputClientProxy.fromHandle(core.MojoHandle handle) : + impl = new InputClientProxyImpl.fromHandle(handle) { + ptr = new _InputClientProxyCalls(impl); + } + + InputClientProxy.unbound() : + impl = new InputClientProxyImpl.unbound() { + ptr = new _InputClientProxyCalls(impl); + } + + factory InputClientProxy.connectToService( + bindings.ServiceConnector s, String url) { + InputClientProxy p = new InputClientProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static InputClientProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For InputClientProxy")); + return new InputClientProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "InputClientProxy($impl)"; + } +} + + +class InputClientStub extends bindings.Stub { + InputClient _impl = null; + + InputClientStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + InputClientStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + InputClientStub.unbound() : super.unbound(); + + static InputClientStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For InputClientStub")); + return new InputClientStub.fromEndpoint(endpoint); + } + + static const String name = InputClientName; + + + InputClientOnBackButtonResponseParams _InputClientOnBackButtonResponseParamsFactory() { + var result = new InputClientOnBackButtonResponseParams(); + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kInputClient_onBackButton_name: + var params = InputClientOnBackButtonParams.deserialize( + message.payload); + var response = _impl.onBackButton(_InputClientOnBackButtonResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kInputClient_onBackButton_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kInputClient_onBackButton_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + InputClient get impl => _impl; + set impl(InputClient d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "InputClientStub($superString)"; + } + + int get version => 0; +} + +const int kInputService_setClient_name = 0; + +const String InputServiceName = + 'input::InputService'; + +abstract class InputService { + void setClient(Object client); + +} + + +class InputServiceProxyImpl extends bindings.Proxy { + InputServiceProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + InputServiceProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + InputServiceProxyImpl.unbound() : super.unbound(); + + static InputServiceProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For InputServiceProxyImpl")); + return new InputServiceProxyImpl.fromEndpoint(endpoint); + } + + String get name => InputServiceName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "InputServiceProxyImpl($superString)"; + } +} + + +class _InputServiceProxyCalls implements InputService { + InputServiceProxyImpl _proxyImpl; + + _InputServiceProxyCalls(this._proxyImpl); + void setClient(Object client) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new InputServiceSetClientParams(); + params.client = client; + _proxyImpl.sendMessage(params, kInputService_setClient_name); + } + +} + + +class InputServiceProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + InputService ptr; + final String name = InputServiceName; + + InputServiceProxy(InputServiceProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _InputServiceProxyCalls(proxyImpl); + + InputServiceProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new InputServiceProxyImpl.fromEndpoint(endpoint) { + ptr = new _InputServiceProxyCalls(impl); + } + + InputServiceProxy.fromHandle(core.MojoHandle handle) : + impl = new InputServiceProxyImpl.fromHandle(handle) { + ptr = new _InputServiceProxyCalls(impl); + } + + InputServiceProxy.unbound() : + impl = new InputServiceProxyImpl.unbound() { + ptr = new _InputServiceProxyCalls(impl); + } + + factory InputServiceProxy.connectToService( + bindings.ServiceConnector s, String url) { + InputServiceProxy p = new InputServiceProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static InputServiceProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For InputServiceProxy")); + return new InputServiceProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "InputServiceProxy($impl)"; + } +} + + +class InputServiceStub extends bindings.Stub { + InputService _impl = null; + + InputServiceStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + InputServiceStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + InputServiceStub.unbound() : super.unbound(); + + static InputServiceStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For InputServiceStub")); + return new InputServiceStub.fromEndpoint(endpoint); + } + + static const String name = InputServiceName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kInputService_setClient_name: + var params = InputServiceSetClientParams.deserialize( + message.payload); + _impl.setClient(params.client); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + InputService get impl => _impl; + set impl(InputService d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "InputServiceStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/keyboard/keyboard.mojom.dart b/mojo/dart/packages/mojo_services/lib/keyboard/keyboard.mojom.dart new file mode 100644 index 0000000..7e7f67d --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/keyboard/keyboard.mojom.dart
@@ -0,0 +1,1763 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library keyboard_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +class SubmitAction extends bindings.MojoEnum { + static const DONE = const SubmitAction._(0); + + const SubmitAction._(int v) : super(v); + + static const Map<String, SubmitAction> valuesMap = const { + "DONE": DONE, + }; + static const List<SubmitAction> values = const [ + DONE, + ]; + + static SubmitAction valueOf(String name) => valuesMap[name]; + + factory SubmitAction(int v) { + switch (v) { + case 0: + return DONE; + default: + return null; + } + } + + static SubmitAction decode(bindings.Decoder decoder0, int offset) { + int v = decoder0.decodeUint32(offset); + SubmitAction result = new SubmitAction(v); + if (result == null) { + throw new bindings.MojoCodecError( + 'Bad value $v for enum SubmitAction.'); + } + return result; + } + + String toString() { + switch(this) { + case DONE: + return 'SubmitAction.DONE'; + } + } + + int toJson() => value; +} +class KeyboardType extends bindings.MojoEnum { + static const TEXT = const KeyboardType._(0); + static const NUMBER = const KeyboardType._(1); + static const PHONE = const KeyboardType._(2); + static const DATETIME = const KeyboardType._(3); + + const KeyboardType._(int v) : super(v); + + static const Map<String, KeyboardType> valuesMap = const { + "TEXT": TEXT, + "NUMBER": NUMBER, + "PHONE": PHONE, + "DATETIME": DATETIME, + }; + static const List<KeyboardType> values = const [ + TEXT, + NUMBER, + PHONE, + DATETIME, + ]; + + static KeyboardType valueOf(String name) => valuesMap[name]; + + factory KeyboardType(int v) { + switch (v) { + case 0: + return TEXT; + case 1: + return NUMBER; + case 2: + return PHONE; + case 3: + return DATETIME; + default: + return null; + } + } + + static KeyboardType decode(bindings.Decoder decoder0, int offset) { + int v = decoder0.decodeUint32(offset); + KeyboardType result = new KeyboardType(v); + if (result == null) { + throw new bindings.MojoCodecError( + 'Bad value $v for enum KeyboardType.'); + } + return result; + } + + String toString() { + switch(this) { + case TEXT: + return 'KeyboardType.TEXT'; + case NUMBER: + return 'KeyboardType.NUMBER'; + case PHONE: + return 'KeyboardType.PHONE'; + case DATETIME: + return 'KeyboardType.DATETIME'; + } + } + + int toJson() => value; +} + + + +class CompletionData extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(40, 0) + ]; + int id = 0; + int position = 0; + String text = null; + String label = null; + + CompletionData() : super(kVersions.last.size); + + static CompletionData deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CompletionData decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CompletionData result = new CompletionData(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.id = decoder0.decodeInt64(8); + } + if (mainDataHeader.version >= 0) { + + result.position = decoder0.decodeInt32(16); + } + if (mainDataHeader.version >= 0) { + + result.text = decoder0.decodeString(24, false); + } + if (mainDataHeader.version >= 0) { + + result.label = decoder0.decodeString(32, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt64(id, 8); + + encoder0.encodeInt32(position, 16); + + encoder0.encodeString(text, 24, false); + + encoder0.encodeString(label, 32, false); + } + + String toString() { + return "CompletionData(" + "id: $id" ", " + "position: $position" ", " + "text: $text" ", " + "label: $label" ")"; + } + + Map toJson() { + Map map = new Map(); + map["id"] = id; + map["position"] = position; + map["text"] = text; + map["label"] = label; + return map; + } +} + + +class CorrectionData extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(32, 0) + ]; + int offset = 0; + String oldText = null; + String newText = null; + + CorrectionData() : super(kVersions.last.size); + + static CorrectionData deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CorrectionData decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CorrectionData result = new CorrectionData(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.offset = decoder0.decodeInt32(8); + } + if (mainDataHeader.version >= 0) { + + result.oldText = decoder0.decodeString(16, false); + } + if (mainDataHeader.version >= 0) { + + result.newText = decoder0.decodeString(24, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt32(offset, 8); + + encoder0.encodeString(oldText, 16, false); + + encoder0.encodeString(newText, 24, false); + } + + String toString() { + return "CorrectionData(" + "offset: $offset" ", " + "oldText: $oldText" ", " + "newText: $newText" ")"; + } + + Map toJson() { + Map map = new Map(); + map["offset"] = offset; + map["oldText"] = oldText; + map["newText"] = newText; + return map; + } +} + + +class KeyboardClientCommitCompletionParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + CompletionData completion = null; + + KeyboardClientCommitCompletionParams() : super(kVersions.last.size); + + static KeyboardClientCommitCompletionParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static KeyboardClientCommitCompletionParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + KeyboardClientCommitCompletionParams result = new KeyboardClientCommitCompletionParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.completion = CompletionData.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(completion, 8, false); + } + + String toString() { + return "KeyboardClientCommitCompletionParams(" + "completion: $completion" ")"; + } + + Map toJson() { + Map map = new Map(); + map["completion"] = completion; + return map; + } +} + + +class KeyboardClientCommitCorrectionParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + CorrectionData correction = null; + + KeyboardClientCommitCorrectionParams() : super(kVersions.last.size); + + static KeyboardClientCommitCorrectionParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static KeyboardClientCommitCorrectionParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + KeyboardClientCommitCorrectionParams result = new KeyboardClientCommitCorrectionParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.correction = CorrectionData.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(correction, 8, false); + } + + String toString() { + return "KeyboardClientCommitCorrectionParams(" + "correction: $correction" ")"; + } + + Map toJson() { + Map map = new Map(); + map["correction"] = correction; + return map; + } +} + + +class KeyboardClientCommitTextParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + String text = null; + int newCursorPosition = 0; + + KeyboardClientCommitTextParams() : super(kVersions.last.size); + + static KeyboardClientCommitTextParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static KeyboardClientCommitTextParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + KeyboardClientCommitTextParams result = new KeyboardClientCommitTextParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.text = decoder0.decodeString(8, false); + } + if (mainDataHeader.version >= 0) { + + result.newCursorPosition = decoder0.decodeInt32(16); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(text, 8, false); + + encoder0.encodeInt32(newCursorPosition, 16); + } + + String toString() { + return "KeyboardClientCommitTextParams(" + "text: $text" ", " + "newCursorPosition: $newCursorPosition" ")"; + } + + Map toJson() { + Map map = new Map(); + map["text"] = text; + map["newCursorPosition"] = newCursorPosition; + return map; + } +} + + +class KeyboardClientDeleteSurroundingTextParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int beforeLength = 0; + int afterLength = 0; + + KeyboardClientDeleteSurroundingTextParams() : super(kVersions.last.size); + + static KeyboardClientDeleteSurroundingTextParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static KeyboardClientDeleteSurroundingTextParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + KeyboardClientDeleteSurroundingTextParams result = new KeyboardClientDeleteSurroundingTextParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.beforeLength = decoder0.decodeInt32(8); + } + if (mainDataHeader.version >= 0) { + + result.afterLength = decoder0.decodeInt32(12); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt32(beforeLength, 8); + + encoder0.encodeInt32(afterLength, 12); + } + + String toString() { + return "KeyboardClientDeleteSurroundingTextParams(" + "beforeLength: $beforeLength" ", " + "afterLength: $afterLength" ")"; + } + + Map toJson() { + Map map = new Map(); + map["beforeLength"] = beforeLength; + map["afterLength"] = afterLength; + return map; + } +} + + +class KeyboardClientSetComposingRegionParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int start = 0; + int end = 0; + + KeyboardClientSetComposingRegionParams() : super(kVersions.last.size); + + static KeyboardClientSetComposingRegionParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static KeyboardClientSetComposingRegionParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + KeyboardClientSetComposingRegionParams result = new KeyboardClientSetComposingRegionParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.start = decoder0.decodeInt32(8); + } + if (mainDataHeader.version >= 0) { + + result.end = decoder0.decodeInt32(12); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt32(start, 8); + + encoder0.encodeInt32(end, 12); + } + + String toString() { + return "KeyboardClientSetComposingRegionParams(" + "start: $start" ", " + "end: $end" ")"; + } + + Map toJson() { + Map map = new Map(); + map["start"] = start; + map["end"] = end; + return map; + } +} + + +class KeyboardClientSetComposingTextParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + String text = null; + int newCursorPosition = 0; + + KeyboardClientSetComposingTextParams() : super(kVersions.last.size); + + static KeyboardClientSetComposingTextParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static KeyboardClientSetComposingTextParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + KeyboardClientSetComposingTextParams result = new KeyboardClientSetComposingTextParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.text = decoder0.decodeString(8, false); + } + if (mainDataHeader.version >= 0) { + + result.newCursorPosition = decoder0.decodeInt32(16); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(text, 8, false); + + encoder0.encodeInt32(newCursorPosition, 16); + } + + String toString() { + return "KeyboardClientSetComposingTextParams(" + "text: $text" ", " + "newCursorPosition: $newCursorPosition" ")"; + } + + Map toJson() { + Map map = new Map(); + map["text"] = text; + map["newCursorPosition"] = newCursorPosition; + return map; + } +} + + +class KeyboardClientSetSelectionParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int start = 0; + int end = 0; + + KeyboardClientSetSelectionParams() : super(kVersions.last.size); + + static KeyboardClientSetSelectionParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static KeyboardClientSetSelectionParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + KeyboardClientSetSelectionParams result = new KeyboardClientSetSelectionParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.start = decoder0.decodeInt32(8); + } + if (mainDataHeader.version >= 0) { + + result.end = decoder0.decodeInt32(12); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt32(start, 8); + + encoder0.encodeInt32(end, 12); + } + + String toString() { + return "KeyboardClientSetSelectionParams(" + "start: $start" ", " + "end: $end" ")"; + } + + Map toJson() { + Map map = new Map(); + map["start"] = start; + map["end"] = end; + return map; + } +} + + +class KeyboardClientSubmitParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + SubmitAction action = null; + + KeyboardClientSubmitParams() : super(kVersions.last.size); + + static KeyboardClientSubmitParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static KeyboardClientSubmitParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + KeyboardClientSubmitParams result = new KeyboardClientSubmitParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.action = SubmitAction.decode(decoder0, 8); + if (result.action == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable SubmitAction.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(action, 8); + } + + String toString() { + return "KeyboardClientSubmitParams(" + "action: $action" ")"; + } + + Map toJson() { + Map map = new Map(); + map["action"] = action; + return map; + } +} + + +class KeyboardServiceShowParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + Object client = null; + KeyboardType type = null; + + KeyboardServiceShowParams() : super(kVersions.last.size); + + static KeyboardServiceShowParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static KeyboardServiceShowParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + KeyboardServiceShowParams result = new KeyboardServiceShowParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.client = decoder0.decodeServiceInterface(8, false, KeyboardClientProxy.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.type = KeyboardType.decode(decoder0, 16); + if (result.type == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable KeyboardType.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterface(client, 8, false); + + encoder0.encodeEnum(type, 16); + } + + String toString() { + return "KeyboardServiceShowParams(" + "client: $client" ", " + "type: $type" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class KeyboardServiceShowByRequestParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + KeyboardServiceShowByRequestParams() : super(kVersions.last.size); + + static KeyboardServiceShowByRequestParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static KeyboardServiceShowByRequestParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + KeyboardServiceShowByRequestParams result = new KeyboardServiceShowByRequestParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "KeyboardServiceShowByRequestParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class KeyboardServiceHideParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + KeyboardServiceHideParams() : super(kVersions.last.size); + + static KeyboardServiceHideParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static KeyboardServiceHideParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + KeyboardServiceHideParams result = new KeyboardServiceHideParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "KeyboardServiceHideParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class KeyboardServiceSetTextParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + String text = null; + + KeyboardServiceSetTextParams() : super(kVersions.last.size); + + static KeyboardServiceSetTextParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static KeyboardServiceSetTextParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + KeyboardServiceSetTextParams result = new KeyboardServiceSetTextParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.text = decoder0.decodeString(8, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(text, 8, false); + } + + String toString() { + return "KeyboardServiceSetTextParams(" + "text: $text" ")"; + } + + Map toJson() { + Map map = new Map(); + map["text"] = text; + return map; + } +} + + +class KeyboardServiceSetSelectionParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int start = 0; + int end = 0; + + KeyboardServiceSetSelectionParams() : super(kVersions.last.size); + + static KeyboardServiceSetSelectionParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static KeyboardServiceSetSelectionParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + KeyboardServiceSetSelectionParams result = new KeyboardServiceSetSelectionParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.start = decoder0.decodeInt32(8); + } + if (mainDataHeader.version >= 0) { + + result.end = decoder0.decodeInt32(12); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt32(start, 8); + + encoder0.encodeInt32(end, 12); + } + + String toString() { + return "KeyboardServiceSetSelectionParams(" + "start: $start" ", " + "end: $end" ")"; + } + + Map toJson() { + Map map = new Map(); + map["start"] = start; + map["end"] = end; + return map; + } +} + +const int kKeyboardClient_commitCompletion_name = 0; +const int kKeyboardClient_commitCorrection_name = 1; +const int kKeyboardClient_commitText_name = 2; +const int kKeyboardClient_deleteSurroundingText_name = 3; +const int kKeyboardClient_setComposingRegion_name = 4; +const int kKeyboardClient_setComposingText_name = 5; +const int kKeyboardClient_setSelection_name = 6; +const int kKeyboardClient_submit_name = 7; + +const String KeyboardClientName = + 'keyboard::KeyboardClient'; + +abstract class KeyboardClient { + void commitCompletion(CompletionData completion); + void commitCorrection(CorrectionData correction); + void commitText(String text, int newCursorPosition); + void deleteSurroundingText(int beforeLength, int afterLength); + void setComposingRegion(int start, int end); + void setComposingText(String text, int newCursorPosition); + void setSelection(int start, int end); + void submit(SubmitAction action); + +} + + +class KeyboardClientProxyImpl extends bindings.Proxy { + KeyboardClientProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + KeyboardClientProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + KeyboardClientProxyImpl.unbound() : super.unbound(); + + static KeyboardClientProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For KeyboardClientProxyImpl")); + return new KeyboardClientProxyImpl.fromEndpoint(endpoint); + } + + String get name => KeyboardClientName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "KeyboardClientProxyImpl($superString)"; + } +} + + +class _KeyboardClientProxyCalls implements KeyboardClient { + KeyboardClientProxyImpl _proxyImpl; + + _KeyboardClientProxyCalls(this._proxyImpl); + void commitCompletion(CompletionData completion) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new KeyboardClientCommitCompletionParams(); + params.completion = completion; + _proxyImpl.sendMessage(params, kKeyboardClient_commitCompletion_name); + } + + void commitCorrection(CorrectionData correction) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new KeyboardClientCommitCorrectionParams(); + params.correction = correction; + _proxyImpl.sendMessage(params, kKeyboardClient_commitCorrection_name); + } + + void commitText(String text, int newCursorPosition) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new KeyboardClientCommitTextParams(); + params.text = text; + params.newCursorPosition = newCursorPosition; + _proxyImpl.sendMessage(params, kKeyboardClient_commitText_name); + } + + void deleteSurroundingText(int beforeLength, int afterLength) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new KeyboardClientDeleteSurroundingTextParams(); + params.beforeLength = beforeLength; + params.afterLength = afterLength; + _proxyImpl.sendMessage(params, kKeyboardClient_deleteSurroundingText_name); + } + + void setComposingRegion(int start, int end) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new KeyboardClientSetComposingRegionParams(); + params.start = start; + params.end = end; + _proxyImpl.sendMessage(params, kKeyboardClient_setComposingRegion_name); + } + + void setComposingText(String text, int newCursorPosition) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new KeyboardClientSetComposingTextParams(); + params.text = text; + params.newCursorPosition = newCursorPosition; + _proxyImpl.sendMessage(params, kKeyboardClient_setComposingText_name); + } + + void setSelection(int start, int end) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new KeyboardClientSetSelectionParams(); + params.start = start; + params.end = end; + _proxyImpl.sendMessage(params, kKeyboardClient_setSelection_name); + } + + void submit(SubmitAction action) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new KeyboardClientSubmitParams(); + params.action = action; + _proxyImpl.sendMessage(params, kKeyboardClient_submit_name); + } + +} + + +class KeyboardClientProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + KeyboardClient ptr; + final String name = KeyboardClientName; + + KeyboardClientProxy(KeyboardClientProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _KeyboardClientProxyCalls(proxyImpl); + + KeyboardClientProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new KeyboardClientProxyImpl.fromEndpoint(endpoint) { + ptr = new _KeyboardClientProxyCalls(impl); + } + + KeyboardClientProxy.fromHandle(core.MojoHandle handle) : + impl = new KeyboardClientProxyImpl.fromHandle(handle) { + ptr = new _KeyboardClientProxyCalls(impl); + } + + KeyboardClientProxy.unbound() : + impl = new KeyboardClientProxyImpl.unbound() { + ptr = new _KeyboardClientProxyCalls(impl); + } + + factory KeyboardClientProxy.connectToService( + bindings.ServiceConnector s, String url) { + KeyboardClientProxy p = new KeyboardClientProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static KeyboardClientProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For KeyboardClientProxy")); + return new KeyboardClientProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "KeyboardClientProxy($impl)"; + } +} + + +class KeyboardClientStub extends bindings.Stub { + KeyboardClient _impl = null; + + KeyboardClientStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + KeyboardClientStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + KeyboardClientStub.unbound() : super.unbound(); + + static KeyboardClientStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For KeyboardClientStub")); + return new KeyboardClientStub.fromEndpoint(endpoint); + } + + static const String name = KeyboardClientName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kKeyboardClient_commitCompletion_name: + var params = KeyboardClientCommitCompletionParams.deserialize( + message.payload); + _impl.commitCompletion(params.completion); + break; + case kKeyboardClient_commitCorrection_name: + var params = KeyboardClientCommitCorrectionParams.deserialize( + message.payload); + _impl.commitCorrection(params.correction); + break; + case kKeyboardClient_commitText_name: + var params = KeyboardClientCommitTextParams.deserialize( + message.payload); + _impl.commitText(params.text, params.newCursorPosition); + break; + case kKeyboardClient_deleteSurroundingText_name: + var params = KeyboardClientDeleteSurroundingTextParams.deserialize( + message.payload); + _impl.deleteSurroundingText(params.beforeLength, params.afterLength); + break; + case kKeyboardClient_setComposingRegion_name: + var params = KeyboardClientSetComposingRegionParams.deserialize( + message.payload); + _impl.setComposingRegion(params.start, params.end); + break; + case kKeyboardClient_setComposingText_name: + var params = KeyboardClientSetComposingTextParams.deserialize( + message.payload); + _impl.setComposingText(params.text, params.newCursorPosition); + break; + case kKeyboardClient_setSelection_name: + var params = KeyboardClientSetSelectionParams.deserialize( + message.payload); + _impl.setSelection(params.start, params.end); + break; + case kKeyboardClient_submit_name: + var params = KeyboardClientSubmitParams.deserialize( + message.payload); + _impl.submit(params.action); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + KeyboardClient get impl => _impl; + set impl(KeyboardClient d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "KeyboardClientStub($superString)"; + } + + int get version => 0; +} + +const int kKeyboardService_show_name = 0; +const int kKeyboardService_showByRequest_name = 1; +const int kKeyboardService_hide_name = 2; +const int kKeyboardService_setText_name = 3; +const int kKeyboardService_setSelection_name = 4; + +const String KeyboardServiceName = + 'keyboard::KeyboardService'; + +abstract class KeyboardService { + void show(Object client, KeyboardType type); + void showByRequest(); + void hide(); + void setText(String text); + void setSelection(int start, int end); + +} + + +class KeyboardServiceProxyImpl extends bindings.Proxy { + KeyboardServiceProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + KeyboardServiceProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + KeyboardServiceProxyImpl.unbound() : super.unbound(); + + static KeyboardServiceProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For KeyboardServiceProxyImpl")); + return new KeyboardServiceProxyImpl.fromEndpoint(endpoint); + } + + String get name => KeyboardServiceName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "KeyboardServiceProxyImpl($superString)"; + } +} + + +class _KeyboardServiceProxyCalls implements KeyboardService { + KeyboardServiceProxyImpl _proxyImpl; + + _KeyboardServiceProxyCalls(this._proxyImpl); + void show(Object client, KeyboardType type) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new KeyboardServiceShowParams(); + params.client = client; + params.type = type; + _proxyImpl.sendMessage(params, kKeyboardService_show_name); + } + + void showByRequest() { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new KeyboardServiceShowByRequestParams(); + _proxyImpl.sendMessage(params, kKeyboardService_showByRequest_name); + } + + void hide() { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new KeyboardServiceHideParams(); + _proxyImpl.sendMessage(params, kKeyboardService_hide_name); + } + + void setText(String text) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new KeyboardServiceSetTextParams(); + params.text = text; + _proxyImpl.sendMessage(params, kKeyboardService_setText_name); + } + + void setSelection(int start, int end) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new KeyboardServiceSetSelectionParams(); + params.start = start; + params.end = end; + _proxyImpl.sendMessage(params, kKeyboardService_setSelection_name); + } + +} + + +class KeyboardServiceProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + KeyboardService ptr; + final String name = KeyboardServiceName; + + KeyboardServiceProxy(KeyboardServiceProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _KeyboardServiceProxyCalls(proxyImpl); + + KeyboardServiceProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new KeyboardServiceProxyImpl.fromEndpoint(endpoint) { + ptr = new _KeyboardServiceProxyCalls(impl); + } + + KeyboardServiceProxy.fromHandle(core.MojoHandle handle) : + impl = new KeyboardServiceProxyImpl.fromHandle(handle) { + ptr = new _KeyboardServiceProxyCalls(impl); + } + + KeyboardServiceProxy.unbound() : + impl = new KeyboardServiceProxyImpl.unbound() { + ptr = new _KeyboardServiceProxyCalls(impl); + } + + factory KeyboardServiceProxy.connectToService( + bindings.ServiceConnector s, String url) { + KeyboardServiceProxy p = new KeyboardServiceProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static KeyboardServiceProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For KeyboardServiceProxy")); + return new KeyboardServiceProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "KeyboardServiceProxy($impl)"; + } +} + + +class KeyboardServiceStub extends bindings.Stub { + KeyboardService _impl = null; + + KeyboardServiceStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + KeyboardServiceStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + KeyboardServiceStub.unbound() : super.unbound(); + + static KeyboardServiceStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For KeyboardServiceStub")); + return new KeyboardServiceStub.fromEndpoint(endpoint); + } + + static const String name = KeyboardServiceName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kKeyboardService_show_name: + var params = KeyboardServiceShowParams.deserialize( + message.payload); + _impl.show(params.client, params.type); + break; + case kKeyboardService_showByRequest_name: + var params = KeyboardServiceShowByRequestParams.deserialize( + message.payload); + _impl.showByRequest(); + break; + case kKeyboardService_hide_name: + var params = KeyboardServiceHideParams.deserialize( + message.payload); + _impl.hide(); + break; + case kKeyboardService_setText_name: + var params = KeyboardServiceSetTextParams.deserialize( + message.payload); + _impl.setText(params.text); + break; + case kKeyboardService_setSelection_name: + var params = KeyboardServiceSetSelectionParams.deserialize( + message.payload); + _impl.setSelection(params.start, params.end); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + KeyboardService get impl => _impl; + set impl(KeyboardService d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "KeyboardServiceStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/animations.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/animations.mojom.dart new file mode 100644 index 0000000..7ae0808 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/animations.mojom.dart
@@ -0,0 +1,509 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library animations_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo_services/mojo/geometry.mojom.dart' as geometry_mojom; +class AnimationTweenType extends bindings.MojoEnum { + static const LINEAR = const AnimationTweenType._(0); + static const EASE_IN = const AnimationTweenType._(1); + static const EASE_OUT = const AnimationTweenType._(2); + static const EASE_IN_OUT = const AnimationTweenType._(3); + + const AnimationTweenType._(int v) : super(v); + + static const Map<String, AnimationTweenType> valuesMap = const { + "LINEAR": LINEAR, + "EASE_IN": EASE_IN, + "EASE_OUT": EASE_OUT, + "EASE_IN_OUT": EASE_IN_OUT, + }; + static const List<AnimationTweenType> values = const [ + LINEAR, + EASE_IN, + EASE_OUT, + EASE_IN_OUT, + ]; + + static AnimationTweenType valueOf(String name) => valuesMap[name]; + + factory AnimationTweenType(int v) { + switch (v) { + case 0: + return LINEAR; + case 1: + return EASE_IN; + case 2: + return EASE_OUT; + case 3: + return EASE_IN_OUT; + default: + return null; + } + } + + static AnimationTweenType decode(bindings.Decoder decoder0, int offset) { + int v = decoder0.decodeUint32(offset); + AnimationTweenType result = new AnimationTweenType(v); + if (result == null) { + throw new bindings.MojoCodecError( + 'Bad value $v for enum AnimationTweenType.'); + } + return result; + } + + String toString() { + switch(this) { + case LINEAR: + return 'AnimationTweenType.LINEAR'; + case EASE_IN: + return 'AnimationTweenType.EASE_IN'; + case EASE_OUT: + return 'AnimationTweenType.EASE_OUT'; + case EASE_IN_OUT: + return 'AnimationTweenType.EASE_IN_OUT'; + } + } + + int toJson() => value; +} +class AnimationProperty extends bindings.MojoEnum { + static const NONE = const AnimationProperty._(0); + static const OPACITY = const AnimationProperty._(1); + static const TRANSFORM = const AnimationProperty._(2); + + const AnimationProperty._(int v) : super(v); + + static const Map<String, AnimationProperty> valuesMap = const { + "NONE": NONE, + "OPACITY": OPACITY, + "TRANSFORM": TRANSFORM, + }; + static const List<AnimationProperty> values = const [ + NONE, + OPACITY, + TRANSFORM, + ]; + + static AnimationProperty valueOf(String name) => valuesMap[name]; + + factory AnimationProperty(int v) { + switch (v) { + case 0: + return NONE; + case 1: + return OPACITY; + case 2: + return TRANSFORM; + default: + return null; + } + } + + static AnimationProperty decode(bindings.Decoder decoder0, int offset) { + int v = decoder0.decodeUint32(offset); + AnimationProperty result = new AnimationProperty(v); + if (result == null) { + throw new bindings.MojoCodecError( + 'Bad value $v for enum AnimationProperty.'); + } + return result; + } + + String toString() { + switch(this) { + case NONE: + return 'AnimationProperty.NONE'; + case OPACITY: + return 'AnimationProperty.OPACITY'; + case TRANSFORM: + return 'AnimationProperty.TRANSFORM'; + } + } + + int toJson() => value; +} + + + +class AnimationValue extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + double floatValue = 0.0; + geometry_mojom.Transform transform = null; + + AnimationValue() : super(kVersions.last.size); + + static AnimationValue deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static AnimationValue decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + AnimationValue result = new AnimationValue(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.floatValue = decoder0.decodeFloat(8); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + result.transform = geometry_mojom.Transform.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeFloat(floatValue, 8); + + encoder0.encodeStruct(transform, 16, false); + } + + String toString() { + return "AnimationValue(" + "floatValue: $floatValue" ", " + "transform: $transform" ")"; + } + + Map toJson() { + Map map = new Map(); + map["floatValue"] = floatValue; + map["transform"] = transform; + return map; + } +} + + +class AnimationElement extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(40, 0) + ]; + AnimationProperty property = null; + AnimationTweenType tweenType = null; + int duration = 0; + AnimationValue startValue = null; + AnimationValue targetValue = null; + + AnimationElement() : super(kVersions.last.size); + + static AnimationElement deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static AnimationElement decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + AnimationElement result = new AnimationElement(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.property = AnimationProperty.decode(decoder0, 8); + if (result.property == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable AnimationProperty.'); + } + } + if (mainDataHeader.version >= 0) { + + result.tweenType = AnimationTweenType.decode(decoder0, 12); + if (result.tweenType == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable AnimationTweenType.'); + } + } + if (mainDataHeader.version >= 0) { + + result.duration = decoder0.decodeInt64(16); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(24, true); + result.startValue = AnimationValue.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(32, true); + result.targetValue = AnimationValue.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(property, 8); + + encoder0.encodeEnum(tweenType, 12); + + encoder0.encodeInt64(duration, 16); + + encoder0.encodeStruct(startValue, 24, true); + + encoder0.encodeStruct(targetValue, 32, true); + } + + String toString() { + return "AnimationElement(" + "property: $property" ", " + "tweenType: $tweenType" ", " + "duration: $duration" ", " + "startValue: $startValue" ", " + "targetValue: $targetValue" ")"; + } + + Map toJson() { + Map map = new Map(); + map["property"] = property; + map["tweenType"] = tweenType; + map["duration"] = duration; + map["startValue"] = startValue; + map["targetValue"] = targetValue; + return map; + } +} + + +class AnimationSequence extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int cycleCount = 0; + List<AnimationElement> elements = null; + + AnimationSequence() : super(kVersions.last.size); + + static AnimationSequence deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static AnimationSequence decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + AnimationSequence result = new AnimationSequence(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.cycleCount = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.elements = new List<AnimationElement>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + var decoder2 = decoder1.decodePointer(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + result.elements[i1] = AnimationElement.decode(decoder2); + } + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(cycleCount, 8); + + if (elements == null) { + encoder0.encodeNullPointer(16, false); + } else { + var encoder1 = encoder0.encodePointerArray(elements.length, 16, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < elements.length; ++i0) { + + encoder1.encodeStruct(elements[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + } + + String toString() { + return "AnimationSequence(" + "cycleCount: $cycleCount" ", " + "elements: $elements" ")"; + } + + Map toJson() { + Map map = new Map(); + map["cycleCount"] = cycleCount; + map["elements"] = elements; + return map; + } +} + + +class AnimationGroup extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int viewId = 0; + List<AnimationSequence> sequences = null; + + AnimationGroup() : super(kVersions.last.size); + + static AnimationGroup deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static AnimationGroup decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + AnimationGroup result = new AnimationGroup(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.viewId = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.sequences = new List<AnimationSequence>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + var decoder2 = decoder1.decodePointer(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + result.sequences[i1] = AnimationSequence.decode(decoder2); + } + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(viewId, 8); + + if (sequences == null) { + encoder0.encodeNullPointer(16, false); + } else { + var encoder1 = encoder0.encodePointerArray(sequences.length, 16, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < sequences.length; ++i0) { + + encoder1.encodeStruct(sequences[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + } + + String toString() { + return "AnimationGroup(" + "viewId: $viewId" ", " + "sequences: $sequences" ")"; + } + + Map toJson() { + Map map = new Map(); + map["viewId"] = viewId; + map["sequences"] = sequences; + return map; + } +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/asset_bundle/asset_bundle.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/asset_bundle/asset_bundle.mojom.dart new file mode 100644 index 0000000..0a62c2d --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/asset_bundle/asset_bundle.mojom.dart
@@ -0,0 +1,612 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library asset_bundle_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; + + + +class AssetBundleGetAsStreamParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + String assetName = null; + + AssetBundleGetAsStreamParams() : super(kVersions.last.size); + + static AssetBundleGetAsStreamParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static AssetBundleGetAsStreamParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + AssetBundleGetAsStreamParams result = new AssetBundleGetAsStreamParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.assetName = decoder0.decodeString(8, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(assetName, 8, false); + } + + String toString() { + return "AssetBundleGetAsStreamParams(" + "assetName: $assetName" ")"; + } + + Map toJson() { + Map map = new Map(); + map["assetName"] = assetName; + return map; + } +} + + +class AssetBundleGetAsStreamResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + core.MojoDataPipeConsumer assetData = null; + + AssetBundleGetAsStreamResponseParams() : super(kVersions.last.size); + + static AssetBundleGetAsStreamResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static AssetBundleGetAsStreamResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + AssetBundleGetAsStreamResponseParams result = new AssetBundleGetAsStreamResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.assetData = decoder0.decodeConsumerHandle(8, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeConsumerHandle(assetData, 8, false); + } + + String toString() { + return "AssetBundleGetAsStreamResponseParams(" + "assetData: $assetData" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class AssetUnpackerUnpackZipStreamParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + core.MojoDataPipeConsumer zippedAssets = null; + Object assetBundle = null; + + AssetUnpackerUnpackZipStreamParams() : super(kVersions.last.size); + + static AssetUnpackerUnpackZipStreamParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static AssetUnpackerUnpackZipStreamParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + AssetUnpackerUnpackZipStreamParams result = new AssetUnpackerUnpackZipStreamParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.zippedAssets = decoder0.decodeConsumerHandle(8, false); + } + if (mainDataHeader.version >= 0) { + + result.assetBundle = decoder0.decodeInterfaceRequest(12, false, AssetBundleStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeConsumerHandle(zippedAssets, 8, false); + + encoder0.encodeInterfaceRequest(assetBundle, 12, false); + } + + String toString() { + return "AssetUnpackerUnpackZipStreamParams(" + "zippedAssets: $zippedAssets" ", " + "assetBundle: $assetBundle" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + +const int kAssetBundle_getAsStream_name = 0; + +const String AssetBundleName = + 'mojo::asset_bundle::AssetBundle'; + +abstract class AssetBundle { + dynamic getAsStream(String assetName,[Function responseFactory = null]); + +} + + +class AssetBundleProxyImpl extends bindings.Proxy { + AssetBundleProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + AssetBundleProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + AssetBundleProxyImpl.unbound() : super.unbound(); + + static AssetBundleProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For AssetBundleProxyImpl")); + return new AssetBundleProxyImpl.fromEndpoint(endpoint); + } + + String get name => AssetBundleName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kAssetBundle_getAsStream_name: + var r = AssetBundleGetAsStreamResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "AssetBundleProxyImpl($superString)"; + } +} + + +class _AssetBundleProxyCalls implements AssetBundle { + AssetBundleProxyImpl _proxyImpl; + + _AssetBundleProxyCalls(this._proxyImpl); + dynamic getAsStream(String assetName,[Function responseFactory = null]) { + var params = new AssetBundleGetAsStreamParams(); + params.assetName = assetName; + return _proxyImpl.sendMessageWithRequestId( + params, + kAssetBundle_getAsStream_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class AssetBundleProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + AssetBundle ptr; + final String name = AssetBundleName; + + AssetBundleProxy(AssetBundleProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _AssetBundleProxyCalls(proxyImpl); + + AssetBundleProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new AssetBundleProxyImpl.fromEndpoint(endpoint) { + ptr = new _AssetBundleProxyCalls(impl); + } + + AssetBundleProxy.fromHandle(core.MojoHandle handle) : + impl = new AssetBundleProxyImpl.fromHandle(handle) { + ptr = new _AssetBundleProxyCalls(impl); + } + + AssetBundleProxy.unbound() : + impl = new AssetBundleProxyImpl.unbound() { + ptr = new _AssetBundleProxyCalls(impl); + } + + factory AssetBundleProxy.connectToService( + bindings.ServiceConnector s, String url) { + AssetBundleProxy p = new AssetBundleProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static AssetBundleProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For AssetBundleProxy")); + return new AssetBundleProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "AssetBundleProxy($impl)"; + } +} + + +class AssetBundleStub extends bindings.Stub { + AssetBundle _impl = null; + + AssetBundleStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + AssetBundleStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + AssetBundleStub.unbound() : super.unbound(); + + static AssetBundleStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For AssetBundleStub")); + return new AssetBundleStub.fromEndpoint(endpoint); + } + + static const String name = AssetBundleName; + + + AssetBundleGetAsStreamResponseParams _AssetBundleGetAsStreamResponseParamsFactory(core.MojoDataPipeConsumer assetData) { + var result = new AssetBundleGetAsStreamResponseParams(); + result.assetData = assetData; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kAssetBundle_getAsStream_name: + var params = AssetBundleGetAsStreamParams.deserialize( + message.payload); + var response = _impl.getAsStream(params.assetName,_AssetBundleGetAsStreamResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kAssetBundle_getAsStream_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kAssetBundle_getAsStream_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + AssetBundle get impl => _impl; + set impl(AssetBundle d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "AssetBundleStub($superString)"; + } + + int get version => 0; +} + +const int kAssetUnpacker_unpackZipStream_name = 0; + +const String AssetUnpackerName = + 'mojo::asset_bundle::AssetUnpacker'; + +abstract class AssetUnpacker { + void unpackZipStream(core.MojoDataPipeConsumer zippedAssets, Object assetBundle); + +} + + +class AssetUnpackerProxyImpl extends bindings.Proxy { + AssetUnpackerProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + AssetUnpackerProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + AssetUnpackerProxyImpl.unbound() : super.unbound(); + + static AssetUnpackerProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For AssetUnpackerProxyImpl")); + return new AssetUnpackerProxyImpl.fromEndpoint(endpoint); + } + + String get name => AssetUnpackerName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "AssetUnpackerProxyImpl($superString)"; + } +} + + +class _AssetUnpackerProxyCalls implements AssetUnpacker { + AssetUnpackerProxyImpl _proxyImpl; + + _AssetUnpackerProxyCalls(this._proxyImpl); + void unpackZipStream(core.MojoDataPipeConsumer zippedAssets, Object assetBundle) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new AssetUnpackerUnpackZipStreamParams(); + params.zippedAssets = zippedAssets; + params.assetBundle = assetBundle; + _proxyImpl.sendMessage(params, kAssetUnpacker_unpackZipStream_name); + } + +} + + +class AssetUnpackerProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + AssetUnpacker ptr; + final String name = AssetUnpackerName; + + AssetUnpackerProxy(AssetUnpackerProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _AssetUnpackerProxyCalls(proxyImpl); + + AssetUnpackerProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new AssetUnpackerProxyImpl.fromEndpoint(endpoint) { + ptr = new _AssetUnpackerProxyCalls(impl); + } + + AssetUnpackerProxy.fromHandle(core.MojoHandle handle) : + impl = new AssetUnpackerProxyImpl.fromHandle(handle) { + ptr = new _AssetUnpackerProxyCalls(impl); + } + + AssetUnpackerProxy.unbound() : + impl = new AssetUnpackerProxyImpl.unbound() { + ptr = new _AssetUnpackerProxyCalls(impl); + } + + factory AssetUnpackerProxy.connectToService( + bindings.ServiceConnector s, String url) { + AssetUnpackerProxy p = new AssetUnpackerProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static AssetUnpackerProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For AssetUnpackerProxy")); + return new AssetUnpackerProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "AssetUnpackerProxy($impl)"; + } +} + + +class AssetUnpackerStub extends bindings.Stub { + AssetUnpacker _impl = null; + + AssetUnpackerStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + AssetUnpackerStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + AssetUnpackerStub.unbound() : super.unbound(); + + static AssetUnpackerStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For AssetUnpackerStub")); + return new AssetUnpackerStub.fromEndpoint(endpoint); + } + + static const String name = AssetUnpackerName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kAssetUnpacker_unpackZipStream_name: + var params = AssetUnpackerUnpackZipStreamParams.deserialize( + message.payload); + _impl.unpackZipStream(params.zippedAssets, params.assetBundle); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + AssetUnpacker get impl => _impl; + set impl(AssetUnpacker d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "AssetUnpackerStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/authenticating_url_loader_interceptor_meta_factory.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/authenticating_url_loader_interceptor_meta_factory.mojom.dart new file mode 100644 index 0000000..167a6f5 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/authenticating_url_loader_interceptor_meta_factory.mojom.dart
@@ -0,0 +1,265 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library authenticating_url_loader_interceptor_meta_factory_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo_services/authentication/authentication.mojom.dart' as authentication_mojom; +import 'package:mojo_services/mojo/url_loader_interceptor.mojom.dart' as url_loader_interceptor_mojom; + + + +class AuthenticatingUrlLoaderInterceptorMetaFactoryCreateUrlLoaderInterceptorFactoryParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + Object factoryRequest = null; + Object authenticationService = null; + + AuthenticatingUrlLoaderInterceptorMetaFactoryCreateUrlLoaderInterceptorFactoryParams() : super(kVersions.last.size); + + static AuthenticatingUrlLoaderInterceptorMetaFactoryCreateUrlLoaderInterceptorFactoryParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static AuthenticatingUrlLoaderInterceptorMetaFactoryCreateUrlLoaderInterceptorFactoryParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + AuthenticatingUrlLoaderInterceptorMetaFactoryCreateUrlLoaderInterceptorFactoryParams result = new AuthenticatingUrlLoaderInterceptorMetaFactoryCreateUrlLoaderInterceptorFactoryParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.factoryRequest = decoder0.decodeInterfaceRequest(8, false, url_loader_interceptor_mojom.UrlLoaderInterceptorFactoryStub.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.authenticationService = decoder0.decodeServiceInterface(12, false, authentication_mojom.AuthenticationServiceProxy.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterfaceRequest(factoryRequest, 8, false); + + encoder0.encodeInterface(authenticationService, 12, false); + } + + String toString() { + return "AuthenticatingUrlLoaderInterceptorMetaFactoryCreateUrlLoaderInterceptorFactoryParams(" + "factoryRequest: $factoryRequest" ", " + "authenticationService: $authenticationService" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + +const int kAuthenticatingUrlLoaderInterceptorMetaFactory_createUrlLoaderInterceptorFactory_name = 0; + +const String AuthenticatingUrlLoaderInterceptorMetaFactoryName = + 'mojo::AuthenticatingURLLoaderInterceptorMetaFactory'; + +abstract class AuthenticatingUrlLoaderInterceptorMetaFactory { + void createUrlLoaderInterceptorFactory(Object factoryRequest, Object authenticationService); + +} + + +class AuthenticatingUrlLoaderInterceptorMetaFactoryProxyImpl extends bindings.Proxy { + AuthenticatingUrlLoaderInterceptorMetaFactoryProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + AuthenticatingUrlLoaderInterceptorMetaFactoryProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + AuthenticatingUrlLoaderInterceptorMetaFactoryProxyImpl.unbound() : super.unbound(); + + static AuthenticatingUrlLoaderInterceptorMetaFactoryProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For AuthenticatingUrlLoaderInterceptorMetaFactoryProxyImpl")); + return new AuthenticatingUrlLoaderInterceptorMetaFactoryProxyImpl.fromEndpoint(endpoint); + } + + String get name => AuthenticatingUrlLoaderInterceptorMetaFactoryName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "AuthenticatingUrlLoaderInterceptorMetaFactoryProxyImpl($superString)"; + } +} + + +class _AuthenticatingUrlLoaderInterceptorMetaFactoryProxyCalls implements AuthenticatingUrlLoaderInterceptorMetaFactory { + AuthenticatingUrlLoaderInterceptorMetaFactoryProxyImpl _proxyImpl; + + _AuthenticatingUrlLoaderInterceptorMetaFactoryProxyCalls(this._proxyImpl); + void createUrlLoaderInterceptorFactory(Object factoryRequest, Object authenticationService) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new AuthenticatingUrlLoaderInterceptorMetaFactoryCreateUrlLoaderInterceptorFactoryParams(); + params.factoryRequest = factoryRequest; + params.authenticationService = authenticationService; + _proxyImpl.sendMessage(params, kAuthenticatingUrlLoaderInterceptorMetaFactory_createUrlLoaderInterceptorFactory_name); + } + +} + + +class AuthenticatingUrlLoaderInterceptorMetaFactoryProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + AuthenticatingUrlLoaderInterceptorMetaFactory ptr; + final String name = AuthenticatingUrlLoaderInterceptorMetaFactoryName; + + AuthenticatingUrlLoaderInterceptorMetaFactoryProxy(AuthenticatingUrlLoaderInterceptorMetaFactoryProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _AuthenticatingUrlLoaderInterceptorMetaFactoryProxyCalls(proxyImpl); + + AuthenticatingUrlLoaderInterceptorMetaFactoryProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new AuthenticatingUrlLoaderInterceptorMetaFactoryProxyImpl.fromEndpoint(endpoint) { + ptr = new _AuthenticatingUrlLoaderInterceptorMetaFactoryProxyCalls(impl); + } + + AuthenticatingUrlLoaderInterceptorMetaFactoryProxy.fromHandle(core.MojoHandle handle) : + impl = new AuthenticatingUrlLoaderInterceptorMetaFactoryProxyImpl.fromHandle(handle) { + ptr = new _AuthenticatingUrlLoaderInterceptorMetaFactoryProxyCalls(impl); + } + + AuthenticatingUrlLoaderInterceptorMetaFactoryProxy.unbound() : + impl = new AuthenticatingUrlLoaderInterceptorMetaFactoryProxyImpl.unbound() { + ptr = new _AuthenticatingUrlLoaderInterceptorMetaFactoryProxyCalls(impl); + } + + factory AuthenticatingUrlLoaderInterceptorMetaFactoryProxy.connectToService( + bindings.ServiceConnector s, String url) { + AuthenticatingUrlLoaderInterceptorMetaFactoryProxy p = new AuthenticatingUrlLoaderInterceptorMetaFactoryProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static AuthenticatingUrlLoaderInterceptorMetaFactoryProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For AuthenticatingUrlLoaderInterceptorMetaFactoryProxy")); + return new AuthenticatingUrlLoaderInterceptorMetaFactoryProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "AuthenticatingUrlLoaderInterceptorMetaFactoryProxy($impl)"; + } +} + + +class AuthenticatingUrlLoaderInterceptorMetaFactoryStub extends bindings.Stub { + AuthenticatingUrlLoaderInterceptorMetaFactory _impl = null; + + AuthenticatingUrlLoaderInterceptorMetaFactoryStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + AuthenticatingUrlLoaderInterceptorMetaFactoryStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + AuthenticatingUrlLoaderInterceptorMetaFactoryStub.unbound() : super.unbound(); + + static AuthenticatingUrlLoaderInterceptorMetaFactoryStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For AuthenticatingUrlLoaderInterceptorMetaFactoryStub")); + return new AuthenticatingUrlLoaderInterceptorMetaFactoryStub.fromEndpoint(endpoint); + } + + static const String name = AuthenticatingUrlLoaderInterceptorMetaFactoryName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kAuthenticatingUrlLoaderInterceptorMetaFactory_createUrlLoaderInterceptorFactory_name: + var params = AuthenticatingUrlLoaderInterceptorMetaFactoryCreateUrlLoaderInterceptorFactoryParams.deserialize( + message.payload); + _impl.createUrlLoaderInterceptorFactory(params.factoryRequest, params.authenticationService); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + AuthenticatingUrlLoaderInterceptorMetaFactory get impl => _impl; + set impl(AuthenticatingUrlLoaderInterceptorMetaFactory d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "AuthenticatingUrlLoaderInterceptorMetaFactoryStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/camera.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/camera.mojom.dart new file mode 100644 index 0000000..1f7b328 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/camera.mojom.dart
@@ -0,0 +1,1032 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library camera_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; + + + +class Photo extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + String uniqueId = null; + core.MojoDataPipeConsumer content = null; + + Photo() : super(kVersions.last.size); + + static Photo deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static Photo decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + Photo result = new Photo(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.uniqueId = decoder0.decodeString(8, false); + } + if (mainDataHeader.version >= 0) { + + result.content = decoder0.decodeConsumerHandle(16, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(uniqueId, 8, false); + + encoder0.encodeConsumerHandle(content, 16, false); + } + + String toString() { + return "Photo(" + "uniqueId: $uniqueId" ", " + "content: $content" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class CameraRollServiceUpdateParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + CameraRollServiceUpdateParams() : super(kVersions.last.size); + + static CameraRollServiceUpdateParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CameraRollServiceUpdateParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CameraRollServiceUpdateParams result = new CameraRollServiceUpdateParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "CameraRollServiceUpdateParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class CameraRollServiceGetCountParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + CameraRollServiceGetCountParams() : super(kVersions.last.size); + + static CameraRollServiceGetCountParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CameraRollServiceGetCountParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CameraRollServiceGetCountParams result = new CameraRollServiceGetCountParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "CameraRollServiceGetCountParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class CameraRollServiceGetCountResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int numPhotos = 0; + + CameraRollServiceGetCountResponseParams() : super(kVersions.last.size); + + static CameraRollServiceGetCountResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CameraRollServiceGetCountResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CameraRollServiceGetCountResponseParams result = new CameraRollServiceGetCountResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.numPhotos = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(numPhotos, 8); + } + + String toString() { + return "CameraRollServiceGetCountResponseParams(" + "numPhotos: $numPhotos" ")"; + } + + Map toJson() { + Map map = new Map(); + map["numPhotos"] = numPhotos; + return map; + } +} + + +class CameraRollServiceGetPhotoParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int index = 0; + + CameraRollServiceGetPhotoParams() : super(kVersions.last.size); + + static CameraRollServiceGetPhotoParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CameraRollServiceGetPhotoParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CameraRollServiceGetPhotoParams result = new CameraRollServiceGetPhotoParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.index = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(index, 8); + } + + String toString() { + return "CameraRollServiceGetPhotoParams(" + "index: $index" ")"; + } + + Map toJson() { + Map map = new Map(); + map["index"] = index; + return map; + } +} + + +class CameraRollServiceGetPhotoResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + Photo photo = null; + + CameraRollServiceGetPhotoResponseParams() : super(kVersions.last.size); + + static CameraRollServiceGetPhotoResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CameraRollServiceGetPhotoResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CameraRollServiceGetPhotoResponseParams result = new CameraRollServiceGetPhotoResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, true); + result.photo = Photo.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(photo, 8, true); + } + + String toString() { + return "CameraRollServiceGetPhotoResponseParams(" + "photo: $photo" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class CameraServiceGetLatestFrameParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + CameraServiceGetLatestFrameParams() : super(kVersions.last.size); + + static CameraServiceGetLatestFrameParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CameraServiceGetLatestFrameParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CameraServiceGetLatestFrameParams result = new CameraServiceGetLatestFrameParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "CameraServiceGetLatestFrameParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class CameraServiceGetLatestFrameResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + core.MojoDataPipeConsumer content = null; + + CameraServiceGetLatestFrameResponseParams() : super(kVersions.last.size); + + static CameraServiceGetLatestFrameResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CameraServiceGetLatestFrameResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CameraServiceGetLatestFrameResponseParams result = new CameraServiceGetLatestFrameResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.content = decoder0.decodeConsumerHandle(8, true); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeConsumerHandle(content, 8, true); + } + + String toString() { + return "CameraServiceGetLatestFrameResponseParams(" + "content: $content" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + +const int kCameraRollService_update_name = 0; +const int kCameraRollService_getCount_name = 1; +const int kCameraRollService_getPhoto_name = 2; + +const String CameraRollServiceName = + 'mojo::CameraRollService'; + +abstract class CameraRollService { + void update(); + dynamic getCount([Function responseFactory = null]); + dynamic getPhoto(int index,[Function responseFactory = null]); + +} + + +class CameraRollServiceProxyImpl extends bindings.Proxy { + CameraRollServiceProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + CameraRollServiceProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + CameraRollServiceProxyImpl.unbound() : super.unbound(); + + static CameraRollServiceProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For CameraRollServiceProxyImpl")); + return new CameraRollServiceProxyImpl.fromEndpoint(endpoint); + } + + String get name => CameraRollServiceName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kCameraRollService_getCount_name: + var r = CameraRollServiceGetCountResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kCameraRollService_getPhoto_name: + var r = CameraRollServiceGetPhotoResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "CameraRollServiceProxyImpl($superString)"; + } +} + + +class _CameraRollServiceProxyCalls implements CameraRollService { + CameraRollServiceProxyImpl _proxyImpl; + + _CameraRollServiceProxyCalls(this._proxyImpl); + void update() { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new CameraRollServiceUpdateParams(); + _proxyImpl.sendMessage(params, kCameraRollService_update_name); + } + + dynamic getCount([Function responseFactory = null]) { + var params = new CameraRollServiceGetCountParams(); + return _proxyImpl.sendMessageWithRequestId( + params, + kCameraRollService_getCount_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic getPhoto(int index,[Function responseFactory = null]) { + var params = new CameraRollServiceGetPhotoParams(); + params.index = index; + return _proxyImpl.sendMessageWithRequestId( + params, + kCameraRollService_getPhoto_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class CameraRollServiceProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + CameraRollService ptr; + final String name = CameraRollServiceName; + + CameraRollServiceProxy(CameraRollServiceProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _CameraRollServiceProxyCalls(proxyImpl); + + CameraRollServiceProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new CameraRollServiceProxyImpl.fromEndpoint(endpoint) { + ptr = new _CameraRollServiceProxyCalls(impl); + } + + CameraRollServiceProxy.fromHandle(core.MojoHandle handle) : + impl = new CameraRollServiceProxyImpl.fromHandle(handle) { + ptr = new _CameraRollServiceProxyCalls(impl); + } + + CameraRollServiceProxy.unbound() : + impl = new CameraRollServiceProxyImpl.unbound() { + ptr = new _CameraRollServiceProxyCalls(impl); + } + + factory CameraRollServiceProxy.connectToService( + bindings.ServiceConnector s, String url) { + CameraRollServiceProxy p = new CameraRollServiceProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static CameraRollServiceProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For CameraRollServiceProxy")); + return new CameraRollServiceProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "CameraRollServiceProxy($impl)"; + } +} + + +class CameraRollServiceStub extends bindings.Stub { + CameraRollService _impl = null; + + CameraRollServiceStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + CameraRollServiceStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + CameraRollServiceStub.unbound() : super.unbound(); + + static CameraRollServiceStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For CameraRollServiceStub")); + return new CameraRollServiceStub.fromEndpoint(endpoint); + } + + static const String name = CameraRollServiceName; + + + CameraRollServiceGetCountResponseParams _CameraRollServiceGetCountResponseParamsFactory(int numPhotos) { + var result = new CameraRollServiceGetCountResponseParams(); + result.numPhotos = numPhotos; + return result; + } + CameraRollServiceGetPhotoResponseParams _CameraRollServiceGetPhotoResponseParamsFactory(Photo photo) { + var result = new CameraRollServiceGetPhotoResponseParams(); + result.photo = photo; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kCameraRollService_update_name: + var params = CameraRollServiceUpdateParams.deserialize( + message.payload); + _impl.update(); + break; + case kCameraRollService_getCount_name: + var params = CameraRollServiceGetCountParams.deserialize( + message.payload); + var response = _impl.getCount(_CameraRollServiceGetCountResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kCameraRollService_getCount_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kCameraRollService_getCount_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kCameraRollService_getPhoto_name: + var params = CameraRollServiceGetPhotoParams.deserialize( + message.payload); + var response = _impl.getPhoto(params.index,_CameraRollServiceGetPhotoResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kCameraRollService_getPhoto_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kCameraRollService_getPhoto_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + CameraRollService get impl => _impl; + set impl(CameraRollService d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "CameraRollServiceStub($superString)"; + } + + int get version => 0; +} + +const int kCameraService_getLatestFrame_name = 0; + +const String CameraServiceName = + 'mojo::CameraService'; + +abstract class CameraService { + dynamic getLatestFrame([Function responseFactory = null]); + +} + + +class CameraServiceProxyImpl extends bindings.Proxy { + CameraServiceProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + CameraServiceProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + CameraServiceProxyImpl.unbound() : super.unbound(); + + static CameraServiceProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For CameraServiceProxyImpl")); + return new CameraServiceProxyImpl.fromEndpoint(endpoint); + } + + String get name => CameraServiceName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kCameraService_getLatestFrame_name: + var r = CameraServiceGetLatestFrameResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "CameraServiceProxyImpl($superString)"; + } +} + + +class _CameraServiceProxyCalls implements CameraService { + CameraServiceProxyImpl _proxyImpl; + + _CameraServiceProxyCalls(this._proxyImpl); + dynamic getLatestFrame([Function responseFactory = null]) { + var params = new CameraServiceGetLatestFrameParams(); + return _proxyImpl.sendMessageWithRequestId( + params, + kCameraService_getLatestFrame_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class CameraServiceProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + CameraService ptr; + final String name = CameraServiceName; + + CameraServiceProxy(CameraServiceProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _CameraServiceProxyCalls(proxyImpl); + + CameraServiceProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new CameraServiceProxyImpl.fromEndpoint(endpoint) { + ptr = new _CameraServiceProxyCalls(impl); + } + + CameraServiceProxy.fromHandle(core.MojoHandle handle) : + impl = new CameraServiceProxyImpl.fromHandle(handle) { + ptr = new _CameraServiceProxyCalls(impl); + } + + CameraServiceProxy.unbound() : + impl = new CameraServiceProxyImpl.unbound() { + ptr = new _CameraServiceProxyCalls(impl); + } + + factory CameraServiceProxy.connectToService( + bindings.ServiceConnector s, String url) { + CameraServiceProxy p = new CameraServiceProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static CameraServiceProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For CameraServiceProxy")); + return new CameraServiceProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "CameraServiceProxy($impl)"; + } +} + + +class CameraServiceStub extends bindings.Stub { + CameraService _impl = null; + + CameraServiceStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + CameraServiceStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + CameraServiceStub.unbound() : super.unbound(); + + static CameraServiceStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For CameraServiceStub")); + return new CameraServiceStub.fromEndpoint(endpoint); + } + + static const String name = CameraServiceName; + + + CameraServiceGetLatestFrameResponseParams _CameraServiceGetLatestFrameResponseParamsFactory(core.MojoDataPipeConsumer content) { + var result = new CameraServiceGetLatestFrameResponseParams(); + result.content = content; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kCameraService_getLatestFrame_name: + var params = CameraServiceGetLatestFrameParams.deserialize( + message.payload); + var response = _impl.getLatestFrame(_CameraServiceGetLatestFrameResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kCameraService_getLatestFrame_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kCameraService_getLatestFrame_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + CameraService get impl => _impl; + set impl(CameraService d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "CameraServiceStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/clipboard.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/clipboard.mojom.dart new file mode 100644 index 0000000..c915407 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/clipboard.mojom.dart
@@ -0,0 +1,998 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library clipboard_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; + + + +class ClipboardGetSequenceNumberParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + ClipboardType clipboardType = null; + + ClipboardGetSequenceNumberParams() : super(kVersions.last.size); + + static ClipboardGetSequenceNumberParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ClipboardGetSequenceNumberParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ClipboardGetSequenceNumberParams result = new ClipboardGetSequenceNumberParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.clipboardType = ClipboardType.decode(decoder0, 8); + if (result.clipboardType == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable ClipboardType.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(clipboardType, 8); + } + + String toString() { + return "ClipboardGetSequenceNumberParams(" + "clipboardType: $clipboardType" ")"; + } + + Map toJson() { + Map map = new Map(); + map["clipboardType"] = clipboardType; + return map; + } +} + + +class ClipboardGetSequenceNumberResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int sequence = 0; + + ClipboardGetSequenceNumberResponseParams() : super(kVersions.last.size); + + static ClipboardGetSequenceNumberResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ClipboardGetSequenceNumberResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ClipboardGetSequenceNumberResponseParams result = new ClipboardGetSequenceNumberResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.sequence = decoder0.decodeUint64(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint64(sequence, 8); + } + + String toString() { + return "ClipboardGetSequenceNumberResponseParams(" + "sequence: $sequence" ")"; + } + + Map toJson() { + Map map = new Map(); + map["sequence"] = sequence; + return map; + } +} + + +class ClipboardGetAvailableMimeTypesParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + ClipboardType clipboardTypes = null; + + ClipboardGetAvailableMimeTypesParams() : super(kVersions.last.size); + + static ClipboardGetAvailableMimeTypesParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ClipboardGetAvailableMimeTypesParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ClipboardGetAvailableMimeTypesParams result = new ClipboardGetAvailableMimeTypesParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.clipboardTypes = ClipboardType.decode(decoder0, 8); + if (result.clipboardTypes == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable ClipboardType.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(clipboardTypes, 8); + } + + String toString() { + return "ClipboardGetAvailableMimeTypesParams(" + "clipboardTypes: $clipboardTypes" ")"; + } + + Map toJson() { + Map map = new Map(); + map["clipboardTypes"] = clipboardTypes; + return map; + } +} + + +class ClipboardGetAvailableMimeTypesResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + List<String> types = null; + + ClipboardGetAvailableMimeTypesResponseParams() : super(kVersions.last.size); + + static ClipboardGetAvailableMimeTypesResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ClipboardGetAvailableMimeTypesResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ClipboardGetAvailableMimeTypesResponseParams result = new ClipboardGetAvailableMimeTypesResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.types = new List<String>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + result.types[i1] = decoder1.decodeString(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + } + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + if (types == null) { + encoder0.encodeNullPointer(8, false); + } else { + var encoder1 = encoder0.encodePointerArray(types.length, 8, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < types.length; ++i0) { + + encoder1.encodeString(types[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + } + + String toString() { + return "ClipboardGetAvailableMimeTypesResponseParams(" + "types: $types" ")"; + } + + Map toJson() { + Map map = new Map(); + map["types"] = types; + return map; + } +} + + +class ClipboardReadMimeTypeParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + ClipboardType clipboardType = null; + String mimeType = null; + + ClipboardReadMimeTypeParams() : super(kVersions.last.size); + + static ClipboardReadMimeTypeParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ClipboardReadMimeTypeParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ClipboardReadMimeTypeParams result = new ClipboardReadMimeTypeParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.clipboardType = ClipboardType.decode(decoder0, 8); + if (result.clipboardType == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable ClipboardType.'); + } + } + if (mainDataHeader.version >= 0) { + + result.mimeType = decoder0.decodeString(16, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(clipboardType, 8); + + encoder0.encodeString(mimeType, 16, false); + } + + String toString() { + return "ClipboardReadMimeTypeParams(" + "clipboardType: $clipboardType" ", " + "mimeType: $mimeType" ")"; + } + + Map toJson() { + Map map = new Map(); + map["clipboardType"] = clipboardType; + map["mimeType"] = mimeType; + return map; + } +} + + +class ClipboardReadMimeTypeResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + List<int> data = null; + + ClipboardReadMimeTypeResponseParams() : super(kVersions.last.size); + + static ClipboardReadMimeTypeResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ClipboardReadMimeTypeResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ClipboardReadMimeTypeResponseParams result = new ClipboardReadMimeTypeResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.data = decoder0.decodeUint8Array(8, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint8Array(data, 8, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + } + + String toString() { + return "ClipboardReadMimeTypeResponseParams(" + "data: $data" ")"; + } + + Map toJson() { + Map map = new Map(); + map["data"] = data; + return map; + } +} + + +class ClipboardWriteClipboardDataParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + ClipboardType clipboardType = null; + Map<String, List<int>> data = null; + + ClipboardWriteClipboardDataParams() : super(kVersions.last.size); + + static ClipboardWriteClipboardDataParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ClipboardWriteClipboardDataParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ClipboardWriteClipboardDataParams result = new ClipboardWriteClipboardDataParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.clipboardType = ClipboardType.decode(decoder0, 8); + if (result.clipboardType == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable ClipboardType.'); + } + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, true); + if (decoder1 == null) { + result.data = null; + } else { + decoder1.decodeDataHeaderForMap(); + List<String> keys0; + List<List<int>> values0; + { + + var decoder2 = decoder1.decodePointer(bindings.ArrayDataHeader.kHeaderSize, false); + { + var si2 = decoder2.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + keys0 = new List<String>(si2.numElements); + for (int i2 = 0; i2 < si2.numElements; ++i2) { + + keys0[i2] = decoder2.decodeString(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i2, false); + } + } + } + { + + var decoder2 = decoder1.decodePointer(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize, false); + { + var si2 = decoder2.decodeDataHeaderForPointerArray(keys0.length); + values0 = new List<List<int>>(si2.numElements); + for (int i2 = 0; i2 < si2.numElements; ++i2) { + + values0[i2] = decoder2.decodeUint8Array(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i2, bindings.kNothingNullable, bindings.kUnspecifiedArrayLength); + } + } + } + result.data = new Map<String, List<int>>.fromIterables( + keys0, values0); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(clipboardType, 8); + + if (data == null) { + encoder0.encodeNullPointer(16, true); + } else { + var encoder1 = encoder0.encoderForMap(16); + int size0 = data.length; + var keys0 = data.keys.toList(); + var values0 = data.values.toList(); + + { + var encoder2 = encoder1.encodePointerArray(keys0.length, bindings.ArrayDataHeader.kHeaderSize, bindings.kUnspecifiedArrayLength); + for (int i1 = 0; i1 < keys0.length; ++i1) { + + encoder2.encodeString(keys0[i1], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + } + } + + { + var encoder2 = encoder1.encodePointerArray(values0.length, bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize, bindings.kUnspecifiedArrayLength); + for (int i1 = 0; i1 < values0.length; ++i1) { + + encoder2.encodeUint8Array(values0[i1], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, bindings.kNothingNullable, bindings.kUnspecifiedArrayLength); + } + } + } + } + + String toString() { + return "ClipboardWriteClipboardDataParams(" + "clipboardType: $clipboardType" ", " + "data: $data" ")"; + } + + Map toJson() { + Map map = new Map(); + map["clipboardType"] = clipboardType; + map["data"] = data; + return map; + } +} + +const int kClipboard_getSequenceNumber_name = 0; +const int kClipboard_getAvailableMimeTypes_name = 1; +const int kClipboard_readMimeType_name = 2; +const int kClipboard_writeClipboardData_name = 3; + +const String ClipboardName = + 'mojo::Clipboard'; + class ClipboardType extends bindings.MojoEnum { + static const COPY_PASTE = const ClipboardType._(0); + static const SELECTION = const ClipboardType._(1); + static const DRAG = const ClipboardType._(2); + + const ClipboardType._(int v) : super(v); + + static const Map<String, ClipboardType> valuesMap = const { + "COPY_PASTE": COPY_PASTE, + "SELECTION": SELECTION, + "DRAG": DRAG, + }; + static const List<ClipboardType> values = const [ + COPY_PASTE, + SELECTION, + DRAG, + ]; + + static ClipboardType valueOf(String name) => valuesMap[name]; + + factory ClipboardType(int v) { + switch (v) { + case 0: + return COPY_PASTE; + case 1: + return SELECTION; + case 2: + return DRAG; + default: + return null; + } + } + + static ClipboardType decode(bindings.Decoder decoder0, int offset) { + int v = decoder0.decodeUint32(offset); + ClipboardType result = new ClipboardType(v); + if (result == null) { + throw new bindings.MojoCodecError( + 'Bad value $v for enum ClipboardType.'); + } + return result; + } + + String toString() { + switch(this) { + case COPY_PASTE: + return 'ClipboardType.COPY_PASTE'; + case SELECTION: + return 'ClipboardType.SELECTION'; + case DRAG: + return 'ClipboardType.DRAG'; + } + } + + int toJson() => value; +} + +abstract class Clipboard { + dynamic getSequenceNumber(ClipboardType clipboardType,[Function responseFactory = null]); + dynamic getAvailableMimeTypes(ClipboardType clipboardTypes,[Function responseFactory = null]); + dynamic readMimeType(ClipboardType clipboardType,String mimeType,[Function responseFactory = null]); + void writeClipboardData(ClipboardType clipboardType, Map<String, List<int>> data); + + static const MIME_TYPE_TEXT = "text/plain"; + static const MIME_TYPE_HTML = "text/html"; + static const MIME_TYPE_URL = "text/url"; +} + + +class ClipboardProxyImpl extends bindings.Proxy { + ClipboardProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + ClipboardProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + ClipboardProxyImpl.unbound() : super.unbound(); + + static ClipboardProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ClipboardProxyImpl")); + return new ClipboardProxyImpl.fromEndpoint(endpoint); + } + + String get name => ClipboardName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kClipboard_getSequenceNumber_name: + var r = ClipboardGetSequenceNumberResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kClipboard_getAvailableMimeTypes_name: + var r = ClipboardGetAvailableMimeTypesResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kClipboard_readMimeType_name: + var r = ClipboardReadMimeTypeResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "ClipboardProxyImpl($superString)"; + } +} + + +class _ClipboardProxyCalls implements Clipboard { + ClipboardProxyImpl _proxyImpl; + + _ClipboardProxyCalls(this._proxyImpl); + dynamic getSequenceNumber(ClipboardType clipboardType,[Function responseFactory = null]) { + var params = new ClipboardGetSequenceNumberParams(); + params.clipboardType = clipboardType; + return _proxyImpl.sendMessageWithRequestId( + params, + kClipboard_getSequenceNumber_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic getAvailableMimeTypes(ClipboardType clipboardTypes,[Function responseFactory = null]) { + var params = new ClipboardGetAvailableMimeTypesParams(); + params.clipboardTypes = clipboardTypes; + return _proxyImpl.sendMessageWithRequestId( + params, + kClipboard_getAvailableMimeTypes_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic readMimeType(ClipboardType clipboardType,String mimeType,[Function responseFactory = null]) { + var params = new ClipboardReadMimeTypeParams(); + params.clipboardType = clipboardType; + params.mimeType = mimeType; + return _proxyImpl.sendMessageWithRequestId( + params, + kClipboard_readMimeType_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + void writeClipboardData(ClipboardType clipboardType, Map<String, List<int>> data) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new ClipboardWriteClipboardDataParams(); + params.clipboardType = clipboardType; + params.data = data; + _proxyImpl.sendMessage(params, kClipboard_writeClipboardData_name); + } + +} + + +class ClipboardProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + Clipboard ptr; + final String name = ClipboardName; + + ClipboardProxy(ClipboardProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _ClipboardProxyCalls(proxyImpl); + + ClipboardProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new ClipboardProxyImpl.fromEndpoint(endpoint) { + ptr = new _ClipboardProxyCalls(impl); + } + + ClipboardProxy.fromHandle(core.MojoHandle handle) : + impl = new ClipboardProxyImpl.fromHandle(handle) { + ptr = new _ClipboardProxyCalls(impl); + } + + ClipboardProxy.unbound() : + impl = new ClipboardProxyImpl.unbound() { + ptr = new _ClipboardProxyCalls(impl); + } + + factory ClipboardProxy.connectToService( + bindings.ServiceConnector s, String url) { + ClipboardProxy p = new ClipboardProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static ClipboardProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ClipboardProxy")); + return new ClipboardProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "ClipboardProxy($impl)"; + } +} + + +class ClipboardStub extends bindings.Stub { + Clipboard _impl = null; + + ClipboardStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + ClipboardStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + ClipboardStub.unbound() : super.unbound(); + + static ClipboardStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ClipboardStub")); + return new ClipboardStub.fromEndpoint(endpoint); + } + + static const String name = ClipboardName; + + + ClipboardGetSequenceNumberResponseParams _ClipboardGetSequenceNumberResponseParamsFactory(int sequence) { + var result = new ClipboardGetSequenceNumberResponseParams(); + result.sequence = sequence; + return result; + } + ClipboardGetAvailableMimeTypesResponseParams _ClipboardGetAvailableMimeTypesResponseParamsFactory(List<String> types) { + var result = new ClipboardGetAvailableMimeTypesResponseParams(); + result.types = types; + return result; + } + ClipboardReadMimeTypeResponseParams _ClipboardReadMimeTypeResponseParamsFactory(List<int> data) { + var result = new ClipboardReadMimeTypeResponseParams(); + result.data = data; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kClipboard_getSequenceNumber_name: + var params = ClipboardGetSequenceNumberParams.deserialize( + message.payload); + var response = _impl.getSequenceNumber(params.clipboardType,_ClipboardGetSequenceNumberResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kClipboard_getSequenceNumber_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kClipboard_getSequenceNumber_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kClipboard_getAvailableMimeTypes_name: + var params = ClipboardGetAvailableMimeTypesParams.deserialize( + message.payload); + var response = _impl.getAvailableMimeTypes(params.clipboardTypes,_ClipboardGetAvailableMimeTypesResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kClipboard_getAvailableMimeTypes_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kClipboard_getAvailableMimeTypes_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kClipboard_readMimeType_name: + var params = ClipboardReadMimeTypeParams.deserialize( + message.payload); + var response = _impl.readMimeType(params.clipboardType,params.mimeType,_ClipboardReadMimeTypeResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kClipboard_readMimeType_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kClipboard_readMimeType_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kClipboard_writeClipboardData_name: + var params = ClipboardWriteClipboardDataParams.deserialize( + message.payload); + _impl.writeClipboardData(params.clipboardType, params.data); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + Clipboard get impl => _impl; + set impl(Clipboard d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "ClipboardStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/command_buffer.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/command_buffer.mojom.dart new file mode 100644 index 0000000..f35bc12 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/command_buffer.mojom.dart
@@ -0,0 +1,2002 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library command_buffer_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo_services/mojo/gpu_capabilities.mojom.dart' as gpu_capabilities_mojom; + + + +class CommandBufferState extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(40, 0) + ]; + int numEntries = 0; + int getOffset = 0; + int putOffset = 0; + int token = 0; + int error = 0; + int contextLostReason = 0; + int generation = 0; + + CommandBufferState() : super(kVersions.last.size); + + static CommandBufferState deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CommandBufferState decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CommandBufferState result = new CommandBufferState(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.numEntries = decoder0.decodeInt32(8); + } + if (mainDataHeader.version >= 0) { + + result.getOffset = decoder0.decodeInt32(12); + } + if (mainDataHeader.version >= 0) { + + result.putOffset = decoder0.decodeInt32(16); + } + if (mainDataHeader.version >= 0) { + + result.token = decoder0.decodeInt32(20); + } + if (mainDataHeader.version >= 0) { + + result.error = decoder0.decodeInt32(24); + } + if (mainDataHeader.version >= 0) { + + result.contextLostReason = decoder0.decodeInt32(28); + } + if (mainDataHeader.version >= 0) { + + result.generation = decoder0.decodeUint32(32); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt32(numEntries, 8); + + encoder0.encodeInt32(getOffset, 12); + + encoder0.encodeInt32(putOffset, 16); + + encoder0.encodeInt32(token, 20); + + encoder0.encodeInt32(error, 24); + + encoder0.encodeInt32(contextLostReason, 28); + + encoder0.encodeUint32(generation, 32); + } + + String toString() { + return "CommandBufferState(" + "numEntries: $numEntries" ", " + "getOffset: $getOffset" ", " + "putOffset: $putOffset" ", " + "token: $token" ", " + "error: $error" ", " + "contextLostReason: $contextLostReason" ", " + "generation: $generation" ")"; + } + + Map toJson() { + Map map = new Map(); + map["numEntries"] = numEntries; + map["getOffset"] = getOffset; + map["putOffset"] = putOffset; + map["token"] = token; + map["error"] = error; + map["contextLostReason"] = contextLostReason; + map["generation"] = generation; + return map; + } +} + + +class CommandBufferSyncClientDidInitializeParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + bool success = false; + gpu_capabilities_mojom.GpuCapabilities capabilities = null; + + CommandBufferSyncClientDidInitializeParams() : super(kVersions.last.size); + + static CommandBufferSyncClientDidInitializeParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CommandBufferSyncClientDidInitializeParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CommandBufferSyncClientDidInitializeParams result = new CommandBufferSyncClientDidInitializeParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.success = decoder0.decodeBool(8, 0); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + result.capabilities = gpu_capabilities_mojom.GpuCapabilities.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeBool(success, 8, 0); + + encoder0.encodeStruct(capabilities, 16, false); + } + + String toString() { + return "CommandBufferSyncClientDidInitializeParams(" + "success: $success" ", " + "capabilities: $capabilities" ")"; + } + + Map toJson() { + Map map = new Map(); + map["success"] = success; + map["capabilities"] = capabilities; + return map; + } +} + + +class CommandBufferSyncClientDidMakeProgressParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + CommandBufferState state = null; + + CommandBufferSyncClientDidMakeProgressParams() : super(kVersions.last.size); + + static CommandBufferSyncClientDidMakeProgressParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CommandBufferSyncClientDidMakeProgressParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CommandBufferSyncClientDidMakeProgressParams result = new CommandBufferSyncClientDidMakeProgressParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.state = CommandBufferState.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(state, 8, false); + } + + String toString() { + return "CommandBufferSyncClientDidMakeProgressParams(" + "state: $state" ")"; + } + + Map toJson() { + Map map = new Map(); + map["state"] = state; + return map; + } +} + + +class CommandBufferSyncPointClientDidInsertSyncPointParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int syncPoint = 0; + + CommandBufferSyncPointClientDidInsertSyncPointParams() : super(kVersions.last.size); + + static CommandBufferSyncPointClientDidInsertSyncPointParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CommandBufferSyncPointClientDidInsertSyncPointParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CommandBufferSyncPointClientDidInsertSyncPointParams result = new CommandBufferSyncPointClientDidInsertSyncPointParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.syncPoint = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(syncPoint, 8); + } + + String toString() { + return "CommandBufferSyncPointClientDidInsertSyncPointParams(" + "syncPoint: $syncPoint" ")"; + } + + Map toJson() { + Map map = new Map(); + map["syncPoint"] = syncPoint; + return map; + } +} + + +class CommandBufferLostContextObserverDidLoseContextParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int contextLostReason = 0; + + CommandBufferLostContextObserverDidLoseContextParams() : super(kVersions.last.size); + + static CommandBufferLostContextObserverDidLoseContextParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CommandBufferLostContextObserverDidLoseContextParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CommandBufferLostContextObserverDidLoseContextParams result = new CommandBufferLostContextObserverDidLoseContextParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.contextLostReason = decoder0.decodeInt32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt32(contextLostReason, 8); + } + + String toString() { + return "CommandBufferLostContextObserverDidLoseContextParams(" + "contextLostReason: $contextLostReason" ")"; + } + + Map toJson() { + Map map = new Map(); + map["contextLostReason"] = contextLostReason; + return map; + } +} + + +class CommandBufferInitializeParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(40, 0) + ]; + Object syncClient = null; + Object syncPointClient = null; + Object lostObserver = null; + core.MojoSharedBuffer sharedState = null; + + CommandBufferInitializeParams() : super(kVersions.last.size); + + static CommandBufferInitializeParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CommandBufferInitializeParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CommandBufferInitializeParams result = new CommandBufferInitializeParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.syncClient = decoder0.decodeServiceInterface(8, false, CommandBufferSyncClientProxy.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.syncPointClient = decoder0.decodeServiceInterface(16, false, CommandBufferSyncPointClientProxy.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.lostObserver = decoder0.decodeServiceInterface(24, false, CommandBufferLostContextObserverProxy.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.sharedState = decoder0.decodeSharedBufferHandle(32, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterface(syncClient, 8, false); + + encoder0.encodeInterface(syncPointClient, 16, false); + + encoder0.encodeInterface(lostObserver, 24, false); + + encoder0.encodeSharedBufferHandle(sharedState, 32, false); + } + + String toString() { + return "CommandBufferInitializeParams(" + "syncClient: $syncClient" ", " + "syncPointClient: $syncPointClient" ", " + "lostObserver: $lostObserver" ", " + "sharedState: $sharedState" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class CommandBufferSetGetBufferParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int buffer = 0; + + CommandBufferSetGetBufferParams() : super(kVersions.last.size); + + static CommandBufferSetGetBufferParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CommandBufferSetGetBufferParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CommandBufferSetGetBufferParams result = new CommandBufferSetGetBufferParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.buffer = decoder0.decodeInt32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt32(buffer, 8); + } + + String toString() { + return "CommandBufferSetGetBufferParams(" + "buffer: $buffer" ")"; + } + + Map toJson() { + Map map = new Map(); + map["buffer"] = buffer; + return map; + } +} + + +class CommandBufferFlushParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int putOffset = 0; + + CommandBufferFlushParams() : super(kVersions.last.size); + + static CommandBufferFlushParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CommandBufferFlushParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CommandBufferFlushParams result = new CommandBufferFlushParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.putOffset = decoder0.decodeInt32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt32(putOffset, 8); + } + + String toString() { + return "CommandBufferFlushParams(" + "putOffset: $putOffset" ")"; + } + + Map toJson() { + Map map = new Map(); + map["putOffset"] = putOffset; + return map; + } +} + + +class CommandBufferMakeProgressParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int lastGetOffset = 0; + + CommandBufferMakeProgressParams() : super(kVersions.last.size); + + static CommandBufferMakeProgressParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CommandBufferMakeProgressParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CommandBufferMakeProgressParams result = new CommandBufferMakeProgressParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.lastGetOffset = decoder0.decodeInt32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt32(lastGetOffset, 8); + } + + String toString() { + return "CommandBufferMakeProgressParams(" + "lastGetOffset: $lastGetOffset" ")"; + } + + Map toJson() { + Map map = new Map(); + map["lastGetOffset"] = lastGetOffset; + return map; + } +} + + +class CommandBufferRegisterTransferBufferParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int id = 0; + core.MojoSharedBuffer transferBuffer = null; + int size = 0; + + CommandBufferRegisterTransferBufferParams() : super(kVersions.last.size); + + static CommandBufferRegisterTransferBufferParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CommandBufferRegisterTransferBufferParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CommandBufferRegisterTransferBufferParams result = new CommandBufferRegisterTransferBufferParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.id = decoder0.decodeInt32(8); + } + if (mainDataHeader.version >= 0) { + + result.transferBuffer = decoder0.decodeSharedBufferHandle(12, false); + } + if (mainDataHeader.version >= 0) { + + result.size = decoder0.decodeUint32(16); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt32(id, 8); + + encoder0.encodeSharedBufferHandle(transferBuffer, 12, false); + + encoder0.encodeUint32(size, 16); + } + + String toString() { + return "CommandBufferRegisterTransferBufferParams(" + "id: $id" ", " + "transferBuffer: $transferBuffer" ", " + "size: $size" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class CommandBufferDestroyTransferBufferParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int id = 0; + + CommandBufferDestroyTransferBufferParams() : super(kVersions.last.size); + + static CommandBufferDestroyTransferBufferParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CommandBufferDestroyTransferBufferParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CommandBufferDestroyTransferBufferParams result = new CommandBufferDestroyTransferBufferParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.id = decoder0.decodeInt32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt32(id, 8); + } + + String toString() { + return "CommandBufferDestroyTransferBufferParams(" + "id: $id" ")"; + } + + Map toJson() { + Map map = new Map(); + map["id"] = id; + return map; + } +} + + +class CommandBufferInsertSyncPointParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + bool retire = false; + + CommandBufferInsertSyncPointParams() : super(kVersions.last.size); + + static CommandBufferInsertSyncPointParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CommandBufferInsertSyncPointParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CommandBufferInsertSyncPointParams result = new CommandBufferInsertSyncPointParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.retire = decoder0.decodeBool(8, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeBool(retire, 8, 0); + } + + String toString() { + return "CommandBufferInsertSyncPointParams(" + "retire: $retire" ")"; + } + + Map toJson() { + Map map = new Map(); + map["retire"] = retire; + return map; + } +} + + +class CommandBufferRetireSyncPointParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int syncPoint = 0; + + CommandBufferRetireSyncPointParams() : super(kVersions.last.size); + + static CommandBufferRetireSyncPointParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CommandBufferRetireSyncPointParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CommandBufferRetireSyncPointParams result = new CommandBufferRetireSyncPointParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.syncPoint = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(syncPoint, 8); + } + + String toString() { + return "CommandBufferRetireSyncPointParams(" + "syncPoint: $syncPoint" ")"; + } + + Map toJson() { + Map map = new Map(); + map["syncPoint"] = syncPoint; + return map; + } +} + + +class CommandBufferEchoParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + CommandBufferEchoParams() : super(kVersions.last.size); + + static CommandBufferEchoParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CommandBufferEchoParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CommandBufferEchoParams result = new CommandBufferEchoParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "CommandBufferEchoParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class CommandBufferEchoResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + CommandBufferEchoResponseParams() : super(kVersions.last.size); + + static CommandBufferEchoResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CommandBufferEchoResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CommandBufferEchoResponseParams result = new CommandBufferEchoResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "CommandBufferEchoResponseParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + +const int kCommandBufferSyncClient_didInitialize_name = 0; +const int kCommandBufferSyncClient_didMakeProgress_name = 1; + +const String CommandBufferSyncClientName = + 'mojo::CommandBufferSyncClient'; + +abstract class CommandBufferSyncClient { + void didInitialize(bool success, gpu_capabilities_mojom.GpuCapabilities capabilities); + void didMakeProgress(CommandBufferState state); + +} + + +class CommandBufferSyncClientProxyImpl extends bindings.Proxy { + CommandBufferSyncClientProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + CommandBufferSyncClientProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + CommandBufferSyncClientProxyImpl.unbound() : super.unbound(); + + static CommandBufferSyncClientProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For CommandBufferSyncClientProxyImpl")); + return new CommandBufferSyncClientProxyImpl.fromEndpoint(endpoint); + } + + String get name => CommandBufferSyncClientName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "CommandBufferSyncClientProxyImpl($superString)"; + } +} + + +class _CommandBufferSyncClientProxyCalls implements CommandBufferSyncClient { + CommandBufferSyncClientProxyImpl _proxyImpl; + + _CommandBufferSyncClientProxyCalls(this._proxyImpl); + void didInitialize(bool success, gpu_capabilities_mojom.GpuCapabilities capabilities) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new CommandBufferSyncClientDidInitializeParams(); + params.success = success; + params.capabilities = capabilities; + _proxyImpl.sendMessage(params, kCommandBufferSyncClient_didInitialize_name); + } + + void didMakeProgress(CommandBufferState state) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new CommandBufferSyncClientDidMakeProgressParams(); + params.state = state; + _proxyImpl.sendMessage(params, kCommandBufferSyncClient_didMakeProgress_name); + } + +} + + +class CommandBufferSyncClientProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + CommandBufferSyncClient ptr; + final String name = CommandBufferSyncClientName; + + CommandBufferSyncClientProxy(CommandBufferSyncClientProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _CommandBufferSyncClientProxyCalls(proxyImpl); + + CommandBufferSyncClientProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new CommandBufferSyncClientProxyImpl.fromEndpoint(endpoint) { + ptr = new _CommandBufferSyncClientProxyCalls(impl); + } + + CommandBufferSyncClientProxy.fromHandle(core.MojoHandle handle) : + impl = new CommandBufferSyncClientProxyImpl.fromHandle(handle) { + ptr = new _CommandBufferSyncClientProxyCalls(impl); + } + + CommandBufferSyncClientProxy.unbound() : + impl = new CommandBufferSyncClientProxyImpl.unbound() { + ptr = new _CommandBufferSyncClientProxyCalls(impl); + } + + factory CommandBufferSyncClientProxy.connectToService( + bindings.ServiceConnector s, String url) { + CommandBufferSyncClientProxy p = new CommandBufferSyncClientProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static CommandBufferSyncClientProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For CommandBufferSyncClientProxy")); + return new CommandBufferSyncClientProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "CommandBufferSyncClientProxy($impl)"; + } +} + + +class CommandBufferSyncClientStub extends bindings.Stub { + CommandBufferSyncClient _impl = null; + + CommandBufferSyncClientStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + CommandBufferSyncClientStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + CommandBufferSyncClientStub.unbound() : super.unbound(); + + static CommandBufferSyncClientStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For CommandBufferSyncClientStub")); + return new CommandBufferSyncClientStub.fromEndpoint(endpoint); + } + + static const String name = CommandBufferSyncClientName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kCommandBufferSyncClient_didInitialize_name: + var params = CommandBufferSyncClientDidInitializeParams.deserialize( + message.payload); + _impl.didInitialize(params.success, params.capabilities); + break; + case kCommandBufferSyncClient_didMakeProgress_name: + var params = CommandBufferSyncClientDidMakeProgressParams.deserialize( + message.payload); + _impl.didMakeProgress(params.state); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + CommandBufferSyncClient get impl => _impl; + set impl(CommandBufferSyncClient d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "CommandBufferSyncClientStub($superString)"; + } + + int get version => 0; +} + +const int kCommandBufferSyncPointClient_didInsertSyncPoint_name = 0; + +const String CommandBufferSyncPointClientName = + 'mojo::CommandBufferSyncPointClient'; + +abstract class CommandBufferSyncPointClient { + void didInsertSyncPoint(int syncPoint); + +} + + +class CommandBufferSyncPointClientProxyImpl extends bindings.Proxy { + CommandBufferSyncPointClientProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + CommandBufferSyncPointClientProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + CommandBufferSyncPointClientProxyImpl.unbound() : super.unbound(); + + static CommandBufferSyncPointClientProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For CommandBufferSyncPointClientProxyImpl")); + return new CommandBufferSyncPointClientProxyImpl.fromEndpoint(endpoint); + } + + String get name => CommandBufferSyncPointClientName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "CommandBufferSyncPointClientProxyImpl($superString)"; + } +} + + +class _CommandBufferSyncPointClientProxyCalls implements CommandBufferSyncPointClient { + CommandBufferSyncPointClientProxyImpl _proxyImpl; + + _CommandBufferSyncPointClientProxyCalls(this._proxyImpl); + void didInsertSyncPoint(int syncPoint) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new CommandBufferSyncPointClientDidInsertSyncPointParams(); + params.syncPoint = syncPoint; + _proxyImpl.sendMessage(params, kCommandBufferSyncPointClient_didInsertSyncPoint_name); + } + +} + + +class CommandBufferSyncPointClientProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + CommandBufferSyncPointClient ptr; + final String name = CommandBufferSyncPointClientName; + + CommandBufferSyncPointClientProxy(CommandBufferSyncPointClientProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _CommandBufferSyncPointClientProxyCalls(proxyImpl); + + CommandBufferSyncPointClientProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new CommandBufferSyncPointClientProxyImpl.fromEndpoint(endpoint) { + ptr = new _CommandBufferSyncPointClientProxyCalls(impl); + } + + CommandBufferSyncPointClientProxy.fromHandle(core.MojoHandle handle) : + impl = new CommandBufferSyncPointClientProxyImpl.fromHandle(handle) { + ptr = new _CommandBufferSyncPointClientProxyCalls(impl); + } + + CommandBufferSyncPointClientProxy.unbound() : + impl = new CommandBufferSyncPointClientProxyImpl.unbound() { + ptr = new _CommandBufferSyncPointClientProxyCalls(impl); + } + + factory CommandBufferSyncPointClientProxy.connectToService( + bindings.ServiceConnector s, String url) { + CommandBufferSyncPointClientProxy p = new CommandBufferSyncPointClientProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static CommandBufferSyncPointClientProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For CommandBufferSyncPointClientProxy")); + return new CommandBufferSyncPointClientProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "CommandBufferSyncPointClientProxy($impl)"; + } +} + + +class CommandBufferSyncPointClientStub extends bindings.Stub { + CommandBufferSyncPointClient _impl = null; + + CommandBufferSyncPointClientStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + CommandBufferSyncPointClientStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + CommandBufferSyncPointClientStub.unbound() : super.unbound(); + + static CommandBufferSyncPointClientStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For CommandBufferSyncPointClientStub")); + return new CommandBufferSyncPointClientStub.fromEndpoint(endpoint); + } + + static const String name = CommandBufferSyncPointClientName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kCommandBufferSyncPointClient_didInsertSyncPoint_name: + var params = CommandBufferSyncPointClientDidInsertSyncPointParams.deserialize( + message.payload); + _impl.didInsertSyncPoint(params.syncPoint); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + CommandBufferSyncPointClient get impl => _impl; + set impl(CommandBufferSyncPointClient d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "CommandBufferSyncPointClientStub($superString)"; + } + + int get version => 0; +} + +const int kCommandBufferLostContextObserver_didLoseContext_name = 0; + +const String CommandBufferLostContextObserverName = + 'mojo::CommandBufferLostContextObserver'; + +abstract class CommandBufferLostContextObserver { + void didLoseContext(int contextLostReason); + +} + + +class CommandBufferLostContextObserverProxyImpl extends bindings.Proxy { + CommandBufferLostContextObserverProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + CommandBufferLostContextObserverProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + CommandBufferLostContextObserverProxyImpl.unbound() : super.unbound(); + + static CommandBufferLostContextObserverProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For CommandBufferLostContextObserverProxyImpl")); + return new CommandBufferLostContextObserverProxyImpl.fromEndpoint(endpoint); + } + + String get name => CommandBufferLostContextObserverName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "CommandBufferLostContextObserverProxyImpl($superString)"; + } +} + + +class _CommandBufferLostContextObserverProxyCalls implements CommandBufferLostContextObserver { + CommandBufferLostContextObserverProxyImpl _proxyImpl; + + _CommandBufferLostContextObserverProxyCalls(this._proxyImpl); + void didLoseContext(int contextLostReason) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new CommandBufferLostContextObserverDidLoseContextParams(); + params.contextLostReason = contextLostReason; + _proxyImpl.sendMessage(params, kCommandBufferLostContextObserver_didLoseContext_name); + } + +} + + +class CommandBufferLostContextObserverProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + CommandBufferLostContextObserver ptr; + final String name = CommandBufferLostContextObserverName; + + CommandBufferLostContextObserverProxy(CommandBufferLostContextObserverProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _CommandBufferLostContextObserverProxyCalls(proxyImpl); + + CommandBufferLostContextObserverProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new CommandBufferLostContextObserverProxyImpl.fromEndpoint(endpoint) { + ptr = new _CommandBufferLostContextObserverProxyCalls(impl); + } + + CommandBufferLostContextObserverProxy.fromHandle(core.MojoHandle handle) : + impl = new CommandBufferLostContextObserverProxyImpl.fromHandle(handle) { + ptr = new _CommandBufferLostContextObserverProxyCalls(impl); + } + + CommandBufferLostContextObserverProxy.unbound() : + impl = new CommandBufferLostContextObserverProxyImpl.unbound() { + ptr = new _CommandBufferLostContextObserverProxyCalls(impl); + } + + factory CommandBufferLostContextObserverProxy.connectToService( + bindings.ServiceConnector s, String url) { + CommandBufferLostContextObserverProxy p = new CommandBufferLostContextObserverProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static CommandBufferLostContextObserverProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For CommandBufferLostContextObserverProxy")); + return new CommandBufferLostContextObserverProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "CommandBufferLostContextObserverProxy($impl)"; + } +} + + +class CommandBufferLostContextObserverStub extends bindings.Stub { + CommandBufferLostContextObserver _impl = null; + + CommandBufferLostContextObserverStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + CommandBufferLostContextObserverStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + CommandBufferLostContextObserverStub.unbound() : super.unbound(); + + static CommandBufferLostContextObserverStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For CommandBufferLostContextObserverStub")); + return new CommandBufferLostContextObserverStub.fromEndpoint(endpoint); + } + + static const String name = CommandBufferLostContextObserverName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kCommandBufferLostContextObserver_didLoseContext_name: + var params = CommandBufferLostContextObserverDidLoseContextParams.deserialize( + message.payload); + _impl.didLoseContext(params.contextLostReason); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + CommandBufferLostContextObserver get impl => _impl; + set impl(CommandBufferLostContextObserver d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "CommandBufferLostContextObserverStub($superString)"; + } + + int get version => 0; +} + +const int kCommandBuffer_initialize_name = 0; +const int kCommandBuffer_setGetBuffer_name = 1; +const int kCommandBuffer_flush_name = 2; +const int kCommandBuffer_makeProgress_name = 3; +const int kCommandBuffer_registerTransferBuffer_name = 4; +const int kCommandBuffer_destroyTransferBuffer_name = 5; +const int kCommandBuffer_insertSyncPoint_name = 6; +const int kCommandBuffer_retireSyncPoint_name = 7; +const int kCommandBuffer_echo_name = 8; + +const String CommandBufferName = + 'mojo::CommandBuffer'; + +abstract class CommandBuffer { + void initialize(Object syncClient, Object syncPointClient, Object lostObserver, core.MojoSharedBuffer sharedState); + void setGetBuffer(int buffer); + void flush(int putOffset); + void makeProgress(int lastGetOffset); + void registerTransferBuffer(int id, core.MojoSharedBuffer transferBuffer, int size); + void destroyTransferBuffer(int id); + void insertSyncPoint(bool retire); + void retireSyncPoint(int syncPoint); + dynamic echo([Function responseFactory = null]); + +} + + +class CommandBufferProxyImpl extends bindings.Proxy { + CommandBufferProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + CommandBufferProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + CommandBufferProxyImpl.unbound() : super.unbound(); + + static CommandBufferProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For CommandBufferProxyImpl")); + return new CommandBufferProxyImpl.fromEndpoint(endpoint); + } + + String get name => CommandBufferName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kCommandBuffer_echo_name: + var r = CommandBufferEchoResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "CommandBufferProxyImpl($superString)"; + } +} + + +class _CommandBufferProxyCalls implements CommandBuffer { + CommandBufferProxyImpl _proxyImpl; + + _CommandBufferProxyCalls(this._proxyImpl); + void initialize(Object syncClient, Object syncPointClient, Object lostObserver, core.MojoSharedBuffer sharedState) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new CommandBufferInitializeParams(); + params.syncClient = syncClient; + params.syncPointClient = syncPointClient; + params.lostObserver = lostObserver; + params.sharedState = sharedState; + _proxyImpl.sendMessage(params, kCommandBuffer_initialize_name); + } + + void setGetBuffer(int buffer) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new CommandBufferSetGetBufferParams(); + params.buffer = buffer; + _proxyImpl.sendMessage(params, kCommandBuffer_setGetBuffer_name); + } + + void flush(int putOffset) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new CommandBufferFlushParams(); + params.putOffset = putOffset; + _proxyImpl.sendMessage(params, kCommandBuffer_flush_name); + } + + void makeProgress(int lastGetOffset) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new CommandBufferMakeProgressParams(); + params.lastGetOffset = lastGetOffset; + _proxyImpl.sendMessage(params, kCommandBuffer_makeProgress_name); + } + + void registerTransferBuffer(int id, core.MojoSharedBuffer transferBuffer, int size) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new CommandBufferRegisterTransferBufferParams(); + params.id = id; + params.transferBuffer = transferBuffer; + params.size = size; + _proxyImpl.sendMessage(params, kCommandBuffer_registerTransferBuffer_name); + } + + void destroyTransferBuffer(int id) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new CommandBufferDestroyTransferBufferParams(); + params.id = id; + _proxyImpl.sendMessage(params, kCommandBuffer_destroyTransferBuffer_name); + } + + void insertSyncPoint(bool retire) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new CommandBufferInsertSyncPointParams(); + params.retire = retire; + _proxyImpl.sendMessage(params, kCommandBuffer_insertSyncPoint_name); + } + + void retireSyncPoint(int syncPoint) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new CommandBufferRetireSyncPointParams(); + params.syncPoint = syncPoint; + _proxyImpl.sendMessage(params, kCommandBuffer_retireSyncPoint_name); + } + + dynamic echo([Function responseFactory = null]) { + var params = new CommandBufferEchoParams(); + return _proxyImpl.sendMessageWithRequestId( + params, + kCommandBuffer_echo_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class CommandBufferProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + CommandBuffer ptr; + final String name = CommandBufferName; + + CommandBufferProxy(CommandBufferProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _CommandBufferProxyCalls(proxyImpl); + + CommandBufferProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new CommandBufferProxyImpl.fromEndpoint(endpoint) { + ptr = new _CommandBufferProxyCalls(impl); + } + + CommandBufferProxy.fromHandle(core.MojoHandle handle) : + impl = new CommandBufferProxyImpl.fromHandle(handle) { + ptr = new _CommandBufferProxyCalls(impl); + } + + CommandBufferProxy.unbound() : + impl = new CommandBufferProxyImpl.unbound() { + ptr = new _CommandBufferProxyCalls(impl); + } + + factory CommandBufferProxy.connectToService( + bindings.ServiceConnector s, String url) { + CommandBufferProxy p = new CommandBufferProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static CommandBufferProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For CommandBufferProxy")); + return new CommandBufferProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "CommandBufferProxy($impl)"; + } +} + + +class CommandBufferStub extends bindings.Stub { + CommandBuffer _impl = null; + + CommandBufferStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + CommandBufferStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + CommandBufferStub.unbound() : super.unbound(); + + static CommandBufferStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For CommandBufferStub")); + return new CommandBufferStub.fromEndpoint(endpoint); + } + + static const String name = CommandBufferName; + + + CommandBufferEchoResponseParams _CommandBufferEchoResponseParamsFactory() { + var result = new CommandBufferEchoResponseParams(); + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kCommandBuffer_initialize_name: + var params = CommandBufferInitializeParams.deserialize( + message.payload); + _impl.initialize(params.syncClient, params.syncPointClient, params.lostObserver, params.sharedState); + break; + case kCommandBuffer_setGetBuffer_name: + var params = CommandBufferSetGetBufferParams.deserialize( + message.payload); + _impl.setGetBuffer(params.buffer); + break; + case kCommandBuffer_flush_name: + var params = CommandBufferFlushParams.deserialize( + message.payload); + _impl.flush(params.putOffset); + break; + case kCommandBuffer_makeProgress_name: + var params = CommandBufferMakeProgressParams.deserialize( + message.payload); + _impl.makeProgress(params.lastGetOffset); + break; + case kCommandBuffer_registerTransferBuffer_name: + var params = CommandBufferRegisterTransferBufferParams.deserialize( + message.payload); + _impl.registerTransferBuffer(params.id, params.transferBuffer, params.size); + break; + case kCommandBuffer_destroyTransferBuffer_name: + var params = CommandBufferDestroyTransferBufferParams.deserialize( + message.payload); + _impl.destroyTransferBuffer(params.id); + break; + case kCommandBuffer_insertSyncPoint_name: + var params = CommandBufferInsertSyncPointParams.deserialize( + message.payload); + _impl.insertSyncPoint(params.retire); + break; + case kCommandBuffer_retireSyncPoint_name: + var params = CommandBufferRetireSyncPointParams.deserialize( + message.payload); + _impl.retireSyncPoint(params.syncPoint); + break; + case kCommandBuffer_echo_name: + var params = CommandBufferEchoParams.deserialize( + message.payload); + var response = _impl.echo(_CommandBufferEchoResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kCommandBuffer_echo_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kCommandBuffer_echo_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + CommandBuffer get impl => _impl; + set impl(CommandBuffer d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "CommandBufferStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/content_handler.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/content_handler.mojom.dart new file mode 100644 index 0000000..3dd3ffd --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/content_handler.mojom.dart
@@ -0,0 +1,266 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library content_handler_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo/mojo/application.mojom.dart' as application_mojom; +import 'package:mojo/mojo/url_response.mojom.dart' as url_response_mojom; + + + +class ContentHandlerStartApplicationParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + Object application = null; + url_response_mojom.UrlResponse response = null; + + ContentHandlerStartApplicationParams() : super(kVersions.last.size); + + static ContentHandlerStartApplicationParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ContentHandlerStartApplicationParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ContentHandlerStartApplicationParams result = new ContentHandlerStartApplicationParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.application = decoder0.decodeInterfaceRequest(8, false, application_mojom.ApplicationStub.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + result.response = url_response_mojom.UrlResponse.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterfaceRequest(application, 8, false); + + encoder0.encodeStruct(response, 16, false); + } + + String toString() { + return "ContentHandlerStartApplicationParams(" + "application: $application" ", " + "response: $response" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + +const int kContentHandler_startApplication_name = 0; + +const String ContentHandlerName = + 'mojo::ContentHandler'; + +abstract class ContentHandler { + void startApplication(Object application, url_response_mojom.UrlResponse response); + +} + + +class ContentHandlerProxyImpl extends bindings.Proxy { + ContentHandlerProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + ContentHandlerProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + ContentHandlerProxyImpl.unbound() : super.unbound(); + + static ContentHandlerProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ContentHandlerProxyImpl")); + return new ContentHandlerProxyImpl.fromEndpoint(endpoint); + } + + String get name => ContentHandlerName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "ContentHandlerProxyImpl($superString)"; + } +} + + +class _ContentHandlerProxyCalls implements ContentHandler { + ContentHandlerProxyImpl _proxyImpl; + + _ContentHandlerProxyCalls(this._proxyImpl); + void startApplication(Object application, url_response_mojom.UrlResponse response) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new ContentHandlerStartApplicationParams(); + params.application = application; + params.response = response; + _proxyImpl.sendMessage(params, kContentHandler_startApplication_name); + } + +} + + +class ContentHandlerProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + ContentHandler ptr; + final String name = ContentHandlerName; + + ContentHandlerProxy(ContentHandlerProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _ContentHandlerProxyCalls(proxyImpl); + + ContentHandlerProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new ContentHandlerProxyImpl.fromEndpoint(endpoint) { + ptr = new _ContentHandlerProxyCalls(impl); + } + + ContentHandlerProxy.fromHandle(core.MojoHandle handle) : + impl = new ContentHandlerProxyImpl.fromHandle(handle) { + ptr = new _ContentHandlerProxyCalls(impl); + } + + ContentHandlerProxy.unbound() : + impl = new ContentHandlerProxyImpl.unbound() { + ptr = new _ContentHandlerProxyCalls(impl); + } + + factory ContentHandlerProxy.connectToService( + bindings.ServiceConnector s, String url) { + ContentHandlerProxy p = new ContentHandlerProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static ContentHandlerProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ContentHandlerProxy")); + return new ContentHandlerProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "ContentHandlerProxy($impl)"; + } +} + + +class ContentHandlerStub extends bindings.Stub { + ContentHandler _impl = null; + + ContentHandlerStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + ContentHandlerStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + ContentHandlerStub.unbound() : super.unbound(); + + static ContentHandlerStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ContentHandlerStub")); + return new ContentHandlerStub.fromEndpoint(endpoint); + } + + static const String name = ContentHandlerName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kContentHandler_startApplication_name: + var params = ContentHandlerStartApplicationParams.deserialize( + message.payload); + _impl.startApplication(params.application, params.response); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + ContentHandler get impl => _impl; + set impl(ContentHandler d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "ContentHandlerStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/context_provider.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/context_provider.mojom.dart new file mode 100644 index 0000000..f5c2554 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/context_provider.mojom.dart
@@ -0,0 +1,363 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library context_provider_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo_services/mojo/command_buffer.mojom.dart' as command_buffer_mojom; +import 'package:mojo_services/mojo/viewport_parameter_listener.mojom.dart' as viewport_parameter_listener_mojom; + + + +class ContextProviderCreateParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + Object viewportParameterListener = null; + + ContextProviderCreateParams() : super(kVersions.last.size); + + static ContextProviderCreateParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ContextProviderCreateParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ContextProviderCreateParams result = new ContextProviderCreateParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.viewportParameterListener = decoder0.decodeServiceInterface(8, true, viewport_parameter_listener_mojom.ViewportParameterListenerProxy.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterface(viewportParameterListener, 8, true); + } + + String toString() { + return "ContextProviderCreateParams(" + "viewportParameterListener: $viewportParameterListener" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class ContextProviderCreateResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + Object gles2Client = null; + + ContextProviderCreateResponseParams() : super(kVersions.last.size); + + static ContextProviderCreateResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ContextProviderCreateResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ContextProviderCreateResponseParams result = new ContextProviderCreateResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.gles2Client = decoder0.decodeServiceInterface(8, true, command_buffer_mojom.CommandBufferProxy.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterface(gles2Client, 8, true); + } + + String toString() { + return "ContextProviderCreateResponseParams(" + "gles2Client: $gles2Client" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + +const int kContextProvider_create_name = 0; + +const String ContextProviderName = + 'mojo::ContextProvider'; + +abstract class ContextProvider { + dynamic create(Object viewportParameterListener,[Function responseFactory = null]); + +} + + +class ContextProviderProxyImpl extends bindings.Proxy { + ContextProviderProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + ContextProviderProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + ContextProviderProxyImpl.unbound() : super.unbound(); + + static ContextProviderProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ContextProviderProxyImpl")); + return new ContextProviderProxyImpl.fromEndpoint(endpoint); + } + + String get name => ContextProviderName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kContextProvider_create_name: + var r = ContextProviderCreateResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "ContextProviderProxyImpl($superString)"; + } +} + + +class _ContextProviderProxyCalls implements ContextProvider { + ContextProviderProxyImpl _proxyImpl; + + _ContextProviderProxyCalls(this._proxyImpl); + dynamic create(Object viewportParameterListener,[Function responseFactory = null]) { + var params = new ContextProviderCreateParams(); + params.viewportParameterListener = viewportParameterListener; + return _proxyImpl.sendMessageWithRequestId( + params, + kContextProvider_create_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class ContextProviderProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + ContextProvider ptr; + final String name = ContextProviderName; + + ContextProviderProxy(ContextProviderProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _ContextProviderProxyCalls(proxyImpl); + + ContextProviderProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new ContextProviderProxyImpl.fromEndpoint(endpoint) { + ptr = new _ContextProviderProxyCalls(impl); + } + + ContextProviderProxy.fromHandle(core.MojoHandle handle) : + impl = new ContextProviderProxyImpl.fromHandle(handle) { + ptr = new _ContextProviderProxyCalls(impl); + } + + ContextProviderProxy.unbound() : + impl = new ContextProviderProxyImpl.unbound() { + ptr = new _ContextProviderProxyCalls(impl); + } + + factory ContextProviderProxy.connectToService( + bindings.ServiceConnector s, String url) { + ContextProviderProxy p = new ContextProviderProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static ContextProviderProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ContextProviderProxy")); + return new ContextProviderProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "ContextProviderProxy($impl)"; + } +} + + +class ContextProviderStub extends bindings.Stub { + ContextProvider _impl = null; + + ContextProviderStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + ContextProviderStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + ContextProviderStub.unbound() : super.unbound(); + + static ContextProviderStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ContextProviderStub")); + return new ContextProviderStub.fromEndpoint(endpoint); + } + + static const String name = ContextProviderName; + + + ContextProviderCreateResponseParams _ContextProviderCreateResponseParamsFactory(Object gles2Client) { + var result = new ContextProviderCreateResponseParams(); + result.gles2Client = gles2Client; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kContextProvider_create_name: + var params = ContextProviderCreateParams.deserialize( + message.payload); + var response = _impl.create(params.viewportParameterListener,_ContextProviderCreateResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kContextProvider_create_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kContextProvider_create_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + ContextProvider get impl => _impl; + set impl(ContextProvider d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "ContextProviderStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/cookie_store.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/cookie_store.mojom.dart new file mode 100644 index 0000000..5b0aaa8 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/cookie_store.mojom.dart
@@ -0,0 +1,565 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library cookie_store_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; + + + +class CookieStoreGetParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + String url = null; + + CookieStoreGetParams() : super(kVersions.last.size); + + static CookieStoreGetParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CookieStoreGetParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CookieStoreGetParams result = new CookieStoreGetParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.url = decoder0.decodeString(8, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(url, 8, false); + } + + String toString() { + return "CookieStoreGetParams(" + "url: $url" ")"; + } + + Map toJson() { + Map map = new Map(); + map["url"] = url; + return map; + } +} + + +class CookieStoreGetResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + String cookies = null; + + CookieStoreGetResponseParams() : super(kVersions.last.size); + + static CookieStoreGetResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CookieStoreGetResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CookieStoreGetResponseParams result = new CookieStoreGetResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.cookies = decoder0.decodeString(8, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(cookies, 8, false); + } + + String toString() { + return "CookieStoreGetResponseParams(" + "cookies: $cookies" ")"; + } + + Map toJson() { + Map map = new Map(); + map["cookies"] = cookies; + return map; + } +} + + +class CookieStoreSetParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + String url = null; + String cookie = null; + + CookieStoreSetParams() : super(kVersions.last.size); + + static CookieStoreSetParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CookieStoreSetParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CookieStoreSetParams result = new CookieStoreSetParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.url = decoder0.decodeString(8, false); + } + if (mainDataHeader.version >= 0) { + + result.cookie = decoder0.decodeString(16, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(url, 8, false); + + encoder0.encodeString(cookie, 16, false); + } + + String toString() { + return "CookieStoreSetParams(" + "url: $url" ", " + "cookie: $cookie" ")"; + } + + Map toJson() { + Map map = new Map(); + map["url"] = url; + map["cookie"] = cookie; + return map; + } +} + + +class CookieStoreSetResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + bool success = false; + + CookieStoreSetResponseParams() : super(kVersions.last.size); + + static CookieStoreSetResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CookieStoreSetResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CookieStoreSetResponseParams result = new CookieStoreSetResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.success = decoder0.decodeBool(8, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeBool(success, 8, 0); + } + + String toString() { + return "CookieStoreSetResponseParams(" + "success: $success" ")"; + } + + Map toJson() { + Map map = new Map(); + map["success"] = success; + return map; + } +} + +const int kCookieStore_get_name = 0; +const int kCookieStore_set_name = 1; + +const String CookieStoreName = + 'mojo::CookieStore'; + +abstract class CookieStore { + dynamic get(String url,[Function responseFactory = null]); + dynamic set(String url,String cookie,[Function responseFactory = null]); + +} + + +class CookieStoreProxyImpl extends bindings.Proxy { + CookieStoreProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + CookieStoreProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + CookieStoreProxyImpl.unbound() : super.unbound(); + + static CookieStoreProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For CookieStoreProxyImpl")); + return new CookieStoreProxyImpl.fromEndpoint(endpoint); + } + + String get name => CookieStoreName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kCookieStore_get_name: + var r = CookieStoreGetResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kCookieStore_set_name: + var r = CookieStoreSetResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "CookieStoreProxyImpl($superString)"; + } +} + + +class _CookieStoreProxyCalls implements CookieStore { + CookieStoreProxyImpl _proxyImpl; + + _CookieStoreProxyCalls(this._proxyImpl); + dynamic get(String url,[Function responseFactory = null]) { + var params = new CookieStoreGetParams(); + params.url = url; + return _proxyImpl.sendMessageWithRequestId( + params, + kCookieStore_get_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic set(String url,String cookie,[Function responseFactory = null]) { + var params = new CookieStoreSetParams(); + params.url = url; + params.cookie = cookie; + return _proxyImpl.sendMessageWithRequestId( + params, + kCookieStore_set_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class CookieStoreProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + CookieStore ptr; + final String name = CookieStoreName; + + CookieStoreProxy(CookieStoreProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _CookieStoreProxyCalls(proxyImpl); + + CookieStoreProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new CookieStoreProxyImpl.fromEndpoint(endpoint) { + ptr = new _CookieStoreProxyCalls(impl); + } + + CookieStoreProxy.fromHandle(core.MojoHandle handle) : + impl = new CookieStoreProxyImpl.fromHandle(handle) { + ptr = new _CookieStoreProxyCalls(impl); + } + + CookieStoreProxy.unbound() : + impl = new CookieStoreProxyImpl.unbound() { + ptr = new _CookieStoreProxyCalls(impl); + } + + factory CookieStoreProxy.connectToService( + bindings.ServiceConnector s, String url) { + CookieStoreProxy p = new CookieStoreProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static CookieStoreProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For CookieStoreProxy")); + return new CookieStoreProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "CookieStoreProxy($impl)"; + } +} + + +class CookieStoreStub extends bindings.Stub { + CookieStore _impl = null; + + CookieStoreStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + CookieStoreStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + CookieStoreStub.unbound() : super.unbound(); + + static CookieStoreStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For CookieStoreStub")); + return new CookieStoreStub.fromEndpoint(endpoint); + } + + static const String name = CookieStoreName; + + + CookieStoreGetResponseParams _CookieStoreGetResponseParamsFactory(String cookies) { + var result = new CookieStoreGetResponseParams(); + result.cookies = cookies; + return result; + } + CookieStoreSetResponseParams _CookieStoreSetResponseParamsFactory(bool success) { + var result = new CookieStoreSetResponseParams(); + result.success = success; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kCookieStore_get_name: + var params = CookieStoreGetParams.deserialize( + message.payload); + var response = _impl.get(params.url,_CookieStoreGetResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kCookieStore_get_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kCookieStore_get_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kCookieStore_set_name: + var params = CookieStoreSetParams.deserialize( + message.payload); + var response = _impl.set(params.url,params.cookie,_CookieStoreSetResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kCookieStore_set_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kCookieStore_set_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + CookieStore get impl => _impl; + set impl(CookieStore d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "CookieStoreStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/device_info.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/device_info.mojom.dart new file mode 100644 index 0000000..2908053 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/device_info.mojom.dart
@@ -0,0 +1,441 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library device_info_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; + + + +class DeviceInfoGetDeviceTypeParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + DeviceInfoGetDeviceTypeParams() : super(kVersions.last.size); + + static DeviceInfoGetDeviceTypeParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static DeviceInfoGetDeviceTypeParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + DeviceInfoGetDeviceTypeParams result = new DeviceInfoGetDeviceTypeParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "DeviceInfoGetDeviceTypeParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class DeviceInfoGetDeviceTypeResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + DeviceInfoDeviceType deviceType = null; + + DeviceInfoGetDeviceTypeResponseParams() : super(kVersions.last.size); + + static DeviceInfoGetDeviceTypeResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static DeviceInfoGetDeviceTypeResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + DeviceInfoGetDeviceTypeResponseParams result = new DeviceInfoGetDeviceTypeResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.deviceType = DeviceInfoDeviceType.decode(decoder0, 8); + if (result.deviceType == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable DeviceInfoDeviceType.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(deviceType, 8); + } + + String toString() { + return "DeviceInfoGetDeviceTypeResponseParams(" + "deviceType: $deviceType" ")"; + } + + Map toJson() { + Map map = new Map(); + map["deviceType"] = deviceType; + return map; + } +} + +const int kDeviceInfo_getDeviceType_name = 0; + +const String DeviceInfoName = + 'mojo::DeviceInfo'; + class DeviceInfoDeviceType extends bindings.MojoEnum { + static const UNKNOWN = const DeviceInfoDeviceType._(0); + static const HEADLESS = const DeviceInfoDeviceType._(1); + static const WATCH = const DeviceInfoDeviceType._(2); + static const PHONE = const DeviceInfoDeviceType._(3); + static const TABLET = const DeviceInfoDeviceType._(4); + static const DESKTOP = const DeviceInfoDeviceType._(5); + static const TV = const DeviceInfoDeviceType._(6); + + const DeviceInfoDeviceType._(int v) : super(v); + + static const Map<String, DeviceInfoDeviceType> valuesMap = const { + "UNKNOWN": UNKNOWN, + "HEADLESS": HEADLESS, + "WATCH": WATCH, + "PHONE": PHONE, + "TABLET": TABLET, + "DESKTOP": DESKTOP, + "TV": TV, + }; + static const List<DeviceInfoDeviceType> values = const [ + UNKNOWN, + HEADLESS, + WATCH, + PHONE, + TABLET, + DESKTOP, + TV, + ]; + + static DeviceInfoDeviceType valueOf(String name) => valuesMap[name]; + + factory DeviceInfoDeviceType(int v) { + switch (v) { + case 0: + return UNKNOWN; + case 1: + return HEADLESS; + case 2: + return WATCH; + case 3: + return PHONE; + case 4: + return TABLET; + case 5: + return DESKTOP; + case 6: + return TV; + default: + return null; + } + } + + static DeviceInfoDeviceType decode(bindings.Decoder decoder0, int offset) { + int v = decoder0.decodeUint32(offset); + DeviceInfoDeviceType result = new DeviceInfoDeviceType(v); + if (result == null) { + throw new bindings.MojoCodecError( + 'Bad value $v for enum DeviceInfoDeviceType.'); + } + return result; + } + + String toString() { + switch(this) { + case UNKNOWN: + return 'DeviceInfoDeviceType.UNKNOWN'; + case HEADLESS: + return 'DeviceInfoDeviceType.HEADLESS'; + case WATCH: + return 'DeviceInfoDeviceType.WATCH'; + case PHONE: + return 'DeviceInfoDeviceType.PHONE'; + case TABLET: + return 'DeviceInfoDeviceType.TABLET'; + case DESKTOP: + return 'DeviceInfoDeviceType.DESKTOP'; + case TV: + return 'DeviceInfoDeviceType.TV'; + } + } + + int toJson() => value; +} + +abstract class DeviceInfo { + dynamic getDeviceType([Function responseFactory = null]); + +} + + +class DeviceInfoProxyImpl extends bindings.Proxy { + DeviceInfoProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + DeviceInfoProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + DeviceInfoProxyImpl.unbound() : super.unbound(); + + static DeviceInfoProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For DeviceInfoProxyImpl")); + return new DeviceInfoProxyImpl.fromEndpoint(endpoint); + } + + String get name => DeviceInfoName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kDeviceInfo_getDeviceType_name: + var r = DeviceInfoGetDeviceTypeResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "DeviceInfoProxyImpl($superString)"; + } +} + + +class _DeviceInfoProxyCalls implements DeviceInfo { + DeviceInfoProxyImpl _proxyImpl; + + _DeviceInfoProxyCalls(this._proxyImpl); + dynamic getDeviceType([Function responseFactory = null]) { + var params = new DeviceInfoGetDeviceTypeParams(); + return _proxyImpl.sendMessageWithRequestId( + params, + kDeviceInfo_getDeviceType_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class DeviceInfoProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + DeviceInfo ptr; + final String name = DeviceInfoName; + + DeviceInfoProxy(DeviceInfoProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _DeviceInfoProxyCalls(proxyImpl); + + DeviceInfoProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new DeviceInfoProxyImpl.fromEndpoint(endpoint) { + ptr = new _DeviceInfoProxyCalls(impl); + } + + DeviceInfoProxy.fromHandle(core.MojoHandle handle) : + impl = new DeviceInfoProxyImpl.fromHandle(handle) { + ptr = new _DeviceInfoProxyCalls(impl); + } + + DeviceInfoProxy.unbound() : + impl = new DeviceInfoProxyImpl.unbound() { + ptr = new _DeviceInfoProxyCalls(impl); + } + + factory DeviceInfoProxy.connectToService( + bindings.ServiceConnector s, String url) { + DeviceInfoProxy p = new DeviceInfoProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static DeviceInfoProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For DeviceInfoProxy")); + return new DeviceInfoProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "DeviceInfoProxy($impl)"; + } +} + + +class DeviceInfoStub extends bindings.Stub { + DeviceInfo _impl = null; + + DeviceInfoStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + DeviceInfoStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + DeviceInfoStub.unbound() : super.unbound(); + + static DeviceInfoStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For DeviceInfoStub")); + return new DeviceInfoStub.fromEndpoint(endpoint); + } + + static const String name = DeviceInfoName; + + + DeviceInfoGetDeviceTypeResponseParams _DeviceInfoGetDeviceTypeResponseParamsFactory(DeviceInfoDeviceType deviceType) { + var result = new DeviceInfoGetDeviceTypeResponseParams(); + result.deviceType = deviceType; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kDeviceInfo_getDeviceType_name: + var params = DeviceInfoGetDeviceTypeParams.deserialize( + message.payload); + var response = _impl.getDeviceType(_DeviceInfoGetDeviceTypeResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kDeviceInfo_getDeviceType_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kDeviceInfo_getDeviceType_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + DeviceInfo get impl => _impl; + set impl(DeviceInfo d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "DeviceInfoStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/display.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/display.mojom.dart new file mode 100644 index 0000000..23e5359 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/display.mojom.dart
@@ -0,0 +1,616 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library display_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo_services/mojo/context_provider.mojom.dart' as context_provider_mojom; +import 'package:mojo_services/mojo/viewport_parameter_listener.mojom.dart' as viewport_parameter_listener_mojom; +import 'package:mojo_services/mojo/surfaces.mojom.dart' as surfaces_mojom; + + + +class DisplaySubmitFrameParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + surfaces_mojom.Frame frame = null; + + DisplaySubmitFrameParams() : super(kVersions.last.size); + + static DisplaySubmitFrameParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static DisplaySubmitFrameParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + DisplaySubmitFrameParams result = new DisplaySubmitFrameParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.frame = surfaces_mojom.Frame.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(frame, 8, false); + } + + String toString() { + return "DisplaySubmitFrameParams(" + "frame: $frame" ")"; + } + + Map toJson() { + Map map = new Map(); + map["frame"] = frame; + return map; + } +} + + +class DisplaySubmitFrameResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + DisplaySubmitFrameResponseParams() : super(kVersions.last.size); + + static DisplaySubmitFrameResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static DisplaySubmitFrameResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + DisplaySubmitFrameResponseParams result = new DisplaySubmitFrameResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "DisplaySubmitFrameResponseParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class DisplayFactoryCreateParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(32, 0) + ]; + Object contextProvider = null; + Object returner = null; + Object displayRequest = null; + + DisplayFactoryCreateParams() : super(kVersions.last.size); + + static DisplayFactoryCreateParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static DisplayFactoryCreateParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + DisplayFactoryCreateParams result = new DisplayFactoryCreateParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.contextProvider = decoder0.decodeServiceInterface(8, false, context_provider_mojom.ContextProviderProxy.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.returner = decoder0.decodeServiceInterface(16, true, surfaces_mojom.ResourceReturnerProxy.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.displayRequest = decoder0.decodeInterfaceRequest(24, false, DisplayStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterface(contextProvider, 8, false); + + encoder0.encodeInterface(returner, 16, true); + + encoder0.encodeInterfaceRequest(displayRequest, 24, false); + } + + String toString() { + return "DisplayFactoryCreateParams(" + "contextProvider: $contextProvider" ", " + "returner: $returner" ", " + "displayRequest: $displayRequest" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + +const int kDisplay_submitFrame_name = 0; + +const String DisplayName = + 'mojo::Display'; + +abstract class Display { + dynamic submitFrame(surfaces_mojom.Frame frame,[Function responseFactory = null]); + +} + + +class DisplayProxyImpl extends bindings.Proxy { + DisplayProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + DisplayProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + DisplayProxyImpl.unbound() : super.unbound(); + + static DisplayProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For DisplayProxyImpl")); + return new DisplayProxyImpl.fromEndpoint(endpoint); + } + + String get name => DisplayName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kDisplay_submitFrame_name: + var r = DisplaySubmitFrameResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "DisplayProxyImpl($superString)"; + } +} + + +class _DisplayProxyCalls implements Display { + DisplayProxyImpl _proxyImpl; + + _DisplayProxyCalls(this._proxyImpl); + dynamic submitFrame(surfaces_mojom.Frame frame,[Function responseFactory = null]) { + var params = new DisplaySubmitFrameParams(); + params.frame = frame; + return _proxyImpl.sendMessageWithRequestId( + params, + kDisplay_submitFrame_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class DisplayProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + Display ptr; + final String name = DisplayName; + + DisplayProxy(DisplayProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _DisplayProxyCalls(proxyImpl); + + DisplayProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new DisplayProxyImpl.fromEndpoint(endpoint) { + ptr = new _DisplayProxyCalls(impl); + } + + DisplayProxy.fromHandle(core.MojoHandle handle) : + impl = new DisplayProxyImpl.fromHandle(handle) { + ptr = new _DisplayProxyCalls(impl); + } + + DisplayProxy.unbound() : + impl = new DisplayProxyImpl.unbound() { + ptr = new _DisplayProxyCalls(impl); + } + + factory DisplayProxy.connectToService( + bindings.ServiceConnector s, String url) { + DisplayProxy p = new DisplayProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static DisplayProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For DisplayProxy")); + return new DisplayProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "DisplayProxy($impl)"; + } +} + + +class DisplayStub extends bindings.Stub { + Display _impl = null; + + DisplayStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + DisplayStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + DisplayStub.unbound() : super.unbound(); + + static DisplayStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For DisplayStub")); + return new DisplayStub.fromEndpoint(endpoint); + } + + static const String name = DisplayName; + + + DisplaySubmitFrameResponseParams _DisplaySubmitFrameResponseParamsFactory() { + var result = new DisplaySubmitFrameResponseParams(); + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kDisplay_submitFrame_name: + var params = DisplaySubmitFrameParams.deserialize( + message.payload); + var response = _impl.submitFrame(params.frame,_DisplaySubmitFrameResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kDisplay_submitFrame_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kDisplay_submitFrame_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + Display get impl => _impl; + set impl(Display d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "DisplayStub($superString)"; + } + + int get version => 0; +} + +const int kDisplayFactory_create_name = 0; + +const String DisplayFactoryName = + 'mojo::DisplayFactory'; + +abstract class DisplayFactory { + void create(Object contextProvider, Object returner, Object displayRequest); + +} + + +class DisplayFactoryProxyImpl extends bindings.Proxy { + DisplayFactoryProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + DisplayFactoryProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + DisplayFactoryProxyImpl.unbound() : super.unbound(); + + static DisplayFactoryProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For DisplayFactoryProxyImpl")); + return new DisplayFactoryProxyImpl.fromEndpoint(endpoint); + } + + String get name => DisplayFactoryName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "DisplayFactoryProxyImpl($superString)"; + } +} + + +class _DisplayFactoryProxyCalls implements DisplayFactory { + DisplayFactoryProxyImpl _proxyImpl; + + _DisplayFactoryProxyCalls(this._proxyImpl); + void create(Object contextProvider, Object returner, Object displayRequest) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new DisplayFactoryCreateParams(); + params.contextProvider = contextProvider; + params.returner = returner; + params.displayRequest = displayRequest; + _proxyImpl.sendMessage(params, kDisplayFactory_create_name); + } + +} + + +class DisplayFactoryProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + DisplayFactory ptr; + final String name = DisplayFactoryName; + + DisplayFactoryProxy(DisplayFactoryProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _DisplayFactoryProxyCalls(proxyImpl); + + DisplayFactoryProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new DisplayFactoryProxyImpl.fromEndpoint(endpoint) { + ptr = new _DisplayFactoryProxyCalls(impl); + } + + DisplayFactoryProxy.fromHandle(core.MojoHandle handle) : + impl = new DisplayFactoryProxyImpl.fromHandle(handle) { + ptr = new _DisplayFactoryProxyCalls(impl); + } + + DisplayFactoryProxy.unbound() : + impl = new DisplayFactoryProxyImpl.unbound() { + ptr = new _DisplayFactoryProxyCalls(impl); + } + + factory DisplayFactoryProxy.connectToService( + bindings.ServiceConnector s, String url) { + DisplayFactoryProxy p = new DisplayFactoryProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static DisplayFactoryProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For DisplayFactoryProxy")); + return new DisplayFactoryProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "DisplayFactoryProxy($impl)"; + } +} + + +class DisplayFactoryStub extends bindings.Stub { + DisplayFactory _impl = null; + + DisplayFactoryStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + DisplayFactoryStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + DisplayFactoryStub.unbound() : super.unbound(); + + static DisplayFactoryStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For DisplayFactoryStub")); + return new DisplayFactoryStub.fromEndpoint(endpoint); + } + + static const String name = DisplayFactoryName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kDisplayFactory_create_name: + var params = DisplayFactoryCreateParams.deserialize( + message.payload); + _impl.create(params.contextProvider, params.returner, params.displayRequest); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + DisplayFactory get impl => _impl; + set impl(DisplayFactory d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "DisplayFactoryStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/files/directory.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/files/directory.mojom.dart new file mode 100644 index 0000000..bdf481a --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/files/directory.mojom.dart
@@ -0,0 +1,1631 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library directory_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo_services/mojo/files/file.mojom.dart' as file_mojom; +import 'package:mojo_services/mojo/files/types.mojom.dart' as types_mojom; + + + +class DirectoryReadParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + DirectoryReadParams() : super(kVersions.last.size); + + static DirectoryReadParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static DirectoryReadParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + DirectoryReadParams result = new DirectoryReadParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "DirectoryReadParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class DirectoryReadResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + types_mojom.Error error = null; + List<types_mojom.DirectoryEntry> directoryContents = null; + + DirectoryReadResponseParams() : super(kVersions.last.size); + + static DirectoryReadResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static DirectoryReadResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + DirectoryReadResponseParams result = new DirectoryReadResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, true); + if (decoder1 == null) { + result.directoryContents = null; + } else { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.directoryContents = new List<types_mojom.DirectoryEntry>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + var decoder2 = decoder1.decodePointer(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + result.directoryContents[i1] = types_mojom.DirectoryEntry.decode(decoder2); + } + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + + if (directoryContents == null) { + encoder0.encodeNullPointer(16, true); + } else { + var encoder1 = encoder0.encodePointerArray(directoryContents.length, 16, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < directoryContents.length; ++i0) { + + encoder1.encodeStruct(directoryContents[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + } + + String toString() { + return "DirectoryReadResponseParams(" + "error: $error" ", " + "directoryContents: $directoryContents" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + map["directoryContents"] = directoryContents; + return map; + } +} + + +class DirectoryStatParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + DirectoryStatParams() : super(kVersions.last.size); + + static DirectoryStatParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static DirectoryStatParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + DirectoryStatParams result = new DirectoryStatParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "DirectoryStatParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class DirectoryStatResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + types_mojom.Error error = null; + types_mojom.FileInformation fileInformation = null; + + DirectoryStatResponseParams() : super(kVersions.last.size); + + static DirectoryStatResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static DirectoryStatResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + DirectoryStatResponseParams result = new DirectoryStatResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, true); + result.fileInformation = types_mojom.FileInformation.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + + encoder0.encodeStruct(fileInformation, 16, true); + } + + String toString() { + return "DirectoryStatResponseParams(" + "error: $error" ", " + "fileInformation: $fileInformation" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + map["fileInformation"] = fileInformation; + return map; + } +} + + +class DirectoryTouchParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + types_mojom.TimespecOrNow atime = null; + types_mojom.TimespecOrNow mtime = null; + + DirectoryTouchParams() : super(kVersions.last.size); + + static DirectoryTouchParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static DirectoryTouchParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + DirectoryTouchParams result = new DirectoryTouchParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, true); + result.atime = types_mojom.TimespecOrNow.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, true); + result.mtime = types_mojom.TimespecOrNow.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(atime, 8, true); + + encoder0.encodeStruct(mtime, 16, true); + } + + String toString() { + return "DirectoryTouchParams(" + "atime: $atime" ", " + "mtime: $mtime" ")"; + } + + Map toJson() { + Map map = new Map(); + map["atime"] = atime; + map["mtime"] = mtime; + return map; + } +} + + +class DirectoryTouchResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + types_mojom.Error error = null; + + DirectoryTouchResponseParams() : super(kVersions.last.size); + + static DirectoryTouchResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static DirectoryTouchResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + DirectoryTouchResponseParams result = new DirectoryTouchResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + } + + String toString() { + return "DirectoryTouchResponseParams(" + "error: $error" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + return map; + } +} + + +class DirectoryOpenFileParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + String path = null; + Object file = null; + int openFlags = 0; + + DirectoryOpenFileParams() : super(kVersions.last.size); + + static DirectoryOpenFileParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static DirectoryOpenFileParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + DirectoryOpenFileParams result = new DirectoryOpenFileParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.path = decoder0.decodeString(8, false); + } + if (mainDataHeader.version >= 0) { + + result.file = decoder0.decodeInterfaceRequest(16, true, file_mojom.FileStub.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.openFlags = decoder0.decodeUint32(20); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(path, 8, false); + + encoder0.encodeInterfaceRequest(file, 16, true); + + encoder0.encodeUint32(openFlags, 20); + } + + String toString() { + return "DirectoryOpenFileParams(" + "path: $path" ", " + "file: $file" ", " + "openFlags: $openFlags" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class DirectoryOpenFileResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + types_mojom.Error error = null; + + DirectoryOpenFileResponseParams() : super(kVersions.last.size); + + static DirectoryOpenFileResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static DirectoryOpenFileResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + DirectoryOpenFileResponseParams result = new DirectoryOpenFileResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + } + + String toString() { + return "DirectoryOpenFileResponseParams(" + "error: $error" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + return map; + } +} + + +class DirectoryOpenDirectoryParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + String path = null; + Object directory = null; + int openFlags = 0; + + DirectoryOpenDirectoryParams() : super(kVersions.last.size); + + static DirectoryOpenDirectoryParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static DirectoryOpenDirectoryParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + DirectoryOpenDirectoryParams result = new DirectoryOpenDirectoryParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.path = decoder0.decodeString(8, false); + } + if (mainDataHeader.version >= 0) { + + result.directory = decoder0.decodeInterfaceRequest(16, true, DirectoryStub.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.openFlags = decoder0.decodeUint32(20); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(path, 8, false); + + encoder0.encodeInterfaceRequest(directory, 16, true); + + encoder0.encodeUint32(openFlags, 20); + } + + String toString() { + return "DirectoryOpenDirectoryParams(" + "path: $path" ", " + "directory: $directory" ", " + "openFlags: $openFlags" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class DirectoryOpenDirectoryResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + types_mojom.Error error = null; + + DirectoryOpenDirectoryResponseParams() : super(kVersions.last.size); + + static DirectoryOpenDirectoryResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static DirectoryOpenDirectoryResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + DirectoryOpenDirectoryResponseParams result = new DirectoryOpenDirectoryResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + } + + String toString() { + return "DirectoryOpenDirectoryResponseParams(" + "error: $error" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + return map; + } +} + + +class DirectoryRenameParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + String path = null; + String newPath = null; + + DirectoryRenameParams() : super(kVersions.last.size); + + static DirectoryRenameParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static DirectoryRenameParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + DirectoryRenameParams result = new DirectoryRenameParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.path = decoder0.decodeString(8, false); + } + if (mainDataHeader.version >= 0) { + + result.newPath = decoder0.decodeString(16, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(path, 8, false); + + encoder0.encodeString(newPath, 16, false); + } + + String toString() { + return "DirectoryRenameParams(" + "path: $path" ", " + "newPath: $newPath" ")"; + } + + Map toJson() { + Map map = new Map(); + map["path"] = path; + map["newPath"] = newPath; + return map; + } +} + + +class DirectoryRenameResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + types_mojom.Error error = null; + + DirectoryRenameResponseParams() : super(kVersions.last.size); + + static DirectoryRenameResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static DirectoryRenameResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + DirectoryRenameResponseParams result = new DirectoryRenameResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + } + + String toString() { + return "DirectoryRenameResponseParams(" + "error: $error" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + return map; + } +} + + +class DirectoryDeleteParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + String path = null; + int deleteFlags = 0; + + DirectoryDeleteParams() : super(kVersions.last.size); + + static DirectoryDeleteParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static DirectoryDeleteParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + DirectoryDeleteParams result = new DirectoryDeleteParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.path = decoder0.decodeString(8, false); + } + if (mainDataHeader.version >= 0) { + + result.deleteFlags = decoder0.decodeUint32(16); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(path, 8, false); + + encoder0.encodeUint32(deleteFlags, 16); + } + + String toString() { + return "DirectoryDeleteParams(" + "path: $path" ", " + "deleteFlags: $deleteFlags" ")"; + } + + Map toJson() { + Map map = new Map(); + map["path"] = path; + map["deleteFlags"] = deleteFlags; + return map; + } +} + + +class DirectoryDeleteResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + types_mojom.Error error = null; + + DirectoryDeleteResponseParams() : super(kVersions.last.size); + + static DirectoryDeleteResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static DirectoryDeleteResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + DirectoryDeleteResponseParams result = new DirectoryDeleteResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + } + + String toString() { + return "DirectoryDeleteResponseParams(" + "error: $error" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + return map; + } +} + +const int kDirectory_read_name = 0; +const int kDirectory_stat_name = 1; +const int kDirectory_touch_name = 2; +const int kDirectory_openFile_name = 3; +const int kDirectory_openDirectory_name = 4; +const int kDirectory_rename_name = 5; +const int kDirectory_delete_name = 6; + +const String DirectoryName = + 'mojo::files::Directory'; + +abstract class Directory { + dynamic read([Function responseFactory = null]); + dynamic stat([Function responseFactory = null]); + dynamic touch(types_mojom.TimespecOrNow atime,types_mojom.TimespecOrNow mtime,[Function responseFactory = null]); + dynamic openFile(String path,Object file,int openFlags,[Function responseFactory = null]); + dynamic openDirectory(String path,Object directory,int openFlags,[Function responseFactory = null]); + dynamic rename(String path,String newPath,[Function responseFactory = null]); + dynamic delete(String path,int deleteFlags,[Function responseFactory = null]); + +} + + +class DirectoryProxyImpl extends bindings.Proxy { + DirectoryProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + DirectoryProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + DirectoryProxyImpl.unbound() : super.unbound(); + + static DirectoryProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For DirectoryProxyImpl")); + return new DirectoryProxyImpl.fromEndpoint(endpoint); + } + + String get name => DirectoryName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kDirectory_read_name: + var r = DirectoryReadResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kDirectory_stat_name: + var r = DirectoryStatResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kDirectory_touch_name: + var r = DirectoryTouchResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kDirectory_openFile_name: + var r = DirectoryOpenFileResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kDirectory_openDirectory_name: + var r = DirectoryOpenDirectoryResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kDirectory_rename_name: + var r = DirectoryRenameResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kDirectory_delete_name: + var r = DirectoryDeleteResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "DirectoryProxyImpl($superString)"; + } +} + + +class _DirectoryProxyCalls implements Directory { + DirectoryProxyImpl _proxyImpl; + + _DirectoryProxyCalls(this._proxyImpl); + dynamic read([Function responseFactory = null]) { + var params = new DirectoryReadParams(); + return _proxyImpl.sendMessageWithRequestId( + params, + kDirectory_read_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic stat([Function responseFactory = null]) { + var params = new DirectoryStatParams(); + return _proxyImpl.sendMessageWithRequestId( + params, + kDirectory_stat_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic touch(types_mojom.TimespecOrNow atime,types_mojom.TimespecOrNow mtime,[Function responseFactory = null]) { + var params = new DirectoryTouchParams(); + params.atime = atime; + params.mtime = mtime; + return _proxyImpl.sendMessageWithRequestId( + params, + kDirectory_touch_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic openFile(String path,Object file,int openFlags,[Function responseFactory = null]) { + var params = new DirectoryOpenFileParams(); + params.path = path; + params.file = file; + params.openFlags = openFlags; + return _proxyImpl.sendMessageWithRequestId( + params, + kDirectory_openFile_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic openDirectory(String path,Object directory,int openFlags,[Function responseFactory = null]) { + var params = new DirectoryOpenDirectoryParams(); + params.path = path; + params.directory = directory; + params.openFlags = openFlags; + return _proxyImpl.sendMessageWithRequestId( + params, + kDirectory_openDirectory_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic rename(String path,String newPath,[Function responseFactory = null]) { + var params = new DirectoryRenameParams(); + params.path = path; + params.newPath = newPath; + return _proxyImpl.sendMessageWithRequestId( + params, + kDirectory_rename_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic delete(String path,int deleteFlags,[Function responseFactory = null]) { + var params = new DirectoryDeleteParams(); + params.path = path; + params.deleteFlags = deleteFlags; + return _proxyImpl.sendMessageWithRequestId( + params, + kDirectory_delete_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class DirectoryProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + Directory ptr; + final String name = DirectoryName; + + DirectoryProxy(DirectoryProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _DirectoryProxyCalls(proxyImpl); + + DirectoryProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new DirectoryProxyImpl.fromEndpoint(endpoint) { + ptr = new _DirectoryProxyCalls(impl); + } + + DirectoryProxy.fromHandle(core.MojoHandle handle) : + impl = new DirectoryProxyImpl.fromHandle(handle) { + ptr = new _DirectoryProxyCalls(impl); + } + + DirectoryProxy.unbound() : + impl = new DirectoryProxyImpl.unbound() { + ptr = new _DirectoryProxyCalls(impl); + } + + factory DirectoryProxy.connectToService( + bindings.ServiceConnector s, String url) { + DirectoryProxy p = new DirectoryProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static DirectoryProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For DirectoryProxy")); + return new DirectoryProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "DirectoryProxy($impl)"; + } +} + + +class DirectoryStub extends bindings.Stub { + Directory _impl = null; + + DirectoryStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + DirectoryStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + DirectoryStub.unbound() : super.unbound(); + + static DirectoryStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For DirectoryStub")); + return new DirectoryStub.fromEndpoint(endpoint); + } + + static const String name = DirectoryName; + + + DirectoryReadResponseParams _DirectoryReadResponseParamsFactory(types_mojom.Error error, List<types_mojom.DirectoryEntry> directoryContents) { + var result = new DirectoryReadResponseParams(); + result.error = error; + result.directoryContents = directoryContents; + return result; + } + DirectoryStatResponseParams _DirectoryStatResponseParamsFactory(types_mojom.Error error, types_mojom.FileInformation fileInformation) { + var result = new DirectoryStatResponseParams(); + result.error = error; + result.fileInformation = fileInformation; + return result; + } + DirectoryTouchResponseParams _DirectoryTouchResponseParamsFactory(types_mojom.Error error) { + var result = new DirectoryTouchResponseParams(); + result.error = error; + return result; + } + DirectoryOpenFileResponseParams _DirectoryOpenFileResponseParamsFactory(types_mojom.Error error) { + var result = new DirectoryOpenFileResponseParams(); + result.error = error; + return result; + } + DirectoryOpenDirectoryResponseParams _DirectoryOpenDirectoryResponseParamsFactory(types_mojom.Error error) { + var result = new DirectoryOpenDirectoryResponseParams(); + result.error = error; + return result; + } + DirectoryRenameResponseParams _DirectoryRenameResponseParamsFactory(types_mojom.Error error) { + var result = new DirectoryRenameResponseParams(); + result.error = error; + return result; + } + DirectoryDeleteResponseParams _DirectoryDeleteResponseParamsFactory(types_mojom.Error error) { + var result = new DirectoryDeleteResponseParams(); + result.error = error; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kDirectory_read_name: + var params = DirectoryReadParams.deserialize( + message.payload); + var response = _impl.read(_DirectoryReadResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kDirectory_read_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kDirectory_read_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kDirectory_stat_name: + var params = DirectoryStatParams.deserialize( + message.payload); + var response = _impl.stat(_DirectoryStatResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kDirectory_stat_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kDirectory_stat_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kDirectory_touch_name: + var params = DirectoryTouchParams.deserialize( + message.payload); + var response = _impl.touch(params.atime,params.mtime,_DirectoryTouchResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kDirectory_touch_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kDirectory_touch_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kDirectory_openFile_name: + var params = DirectoryOpenFileParams.deserialize( + message.payload); + var response = _impl.openFile(params.path,params.file,params.openFlags,_DirectoryOpenFileResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kDirectory_openFile_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kDirectory_openFile_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kDirectory_openDirectory_name: + var params = DirectoryOpenDirectoryParams.deserialize( + message.payload); + var response = _impl.openDirectory(params.path,params.directory,params.openFlags,_DirectoryOpenDirectoryResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kDirectory_openDirectory_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kDirectory_openDirectory_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kDirectory_rename_name: + var params = DirectoryRenameParams.deserialize( + message.payload); + var response = _impl.rename(params.path,params.newPath,_DirectoryRenameResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kDirectory_rename_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kDirectory_rename_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kDirectory_delete_name: + var params = DirectoryDeleteParams.deserialize( + message.payload); + var response = _impl.delete(params.path,params.deleteFlags,_DirectoryDeleteResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kDirectory_delete_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kDirectory_delete_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + Directory get impl => _impl; + set impl(Directory d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "DirectoryStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/files/file.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/files/file.mojom.dart new file mode 100644 index 0000000..b62a2eb --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/files/file.mojom.dart
@@ -0,0 +1,3087 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library file_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo_services/mojo/files/types.mojom.dart' as types_mojom; + + + +class FileCloseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + FileCloseParams() : super(kVersions.last.size); + + static FileCloseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileCloseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileCloseParams result = new FileCloseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "FileCloseParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class FileCloseResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + types_mojom.Error err = null; + + FileCloseResponseParams() : super(kVersions.last.size); + + static FileCloseResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileCloseResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileCloseResponseParams result = new FileCloseResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.err = types_mojom.Error.decode(decoder0, 8); + if (result.err == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(err, 8); + } + + String toString() { + return "FileCloseResponseParams(" + "err: $err" ")"; + } + + Map toJson() { + Map map = new Map(); + map["err"] = err; + return map; + } +} + + +class FileReadParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int numBytesToRead = 0; + types_mojom.Whence whence = null; + int offset = 0; + + FileReadParams() : super(kVersions.last.size); + + static FileReadParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileReadParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileReadParams result = new FileReadParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.numBytesToRead = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + result.whence = types_mojom.Whence.decode(decoder0, 12); + if (result.whence == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Whence.'); + } + } + if (mainDataHeader.version >= 0) { + + result.offset = decoder0.decodeInt64(16); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(numBytesToRead, 8); + + encoder0.encodeEnum(whence, 12); + + encoder0.encodeInt64(offset, 16); + } + + String toString() { + return "FileReadParams(" + "numBytesToRead: $numBytesToRead" ", " + "whence: $whence" ", " + "offset: $offset" ")"; + } + + Map toJson() { + Map map = new Map(); + map["numBytesToRead"] = numBytesToRead; + map["whence"] = whence; + map["offset"] = offset; + return map; + } +} + + +class FileReadResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + types_mojom.Error error = null; + List<int> bytesRead = null; + + FileReadResponseParams() : super(kVersions.last.size); + + static FileReadResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileReadResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileReadResponseParams result = new FileReadResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + if (mainDataHeader.version >= 0) { + + result.bytesRead = decoder0.decodeUint8Array(16, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + + encoder0.encodeUint8Array(bytesRead, 16, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + } + + String toString() { + return "FileReadResponseParams(" + "error: $error" ", " + "bytesRead: $bytesRead" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + map["bytesRead"] = bytesRead; + return map; + } +} + + +class FileWriteParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(32, 0) + ]; + List<int> bytesToWrite = null; + int offset = 0; + types_mojom.Whence whence = null; + + FileWriteParams() : super(kVersions.last.size); + + static FileWriteParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileWriteParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileWriteParams result = new FileWriteParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.bytesToWrite = decoder0.decodeUint8Array(8, bindings.kNothingNullable, bindings.kUnspecifiedArrayLength); + } + if (mainDataHeader.version >= 0) { + + result.offset = decoder0.decodeInt64(16); + } + if (mainDataHeader.version >= 0) { + + result.whence = types_mojom.Whence.decode(decoder0, 24); + if (result.whence == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Whence.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint8Array(bytesToWrite, 8, bindings.kNothingNullable, bindings.kUnspecifiedArrayLength); + + encoder0.encodeInt64(offset, 16); + + encoder0.encodeEnum(whence, 24); + } + + String toString() { + return "FileWriteParams(" + "bytesToWrite: $bytesToWrite" ", " + "offset: $offset" ", " + "whence: $whence" ")"; + } + + Map toJson() { + Map map = new Map(); + map["bytesToWrite"] = bytesToWrite; + map["offset"] = offset; + map["whence"] = whence; + return map; + } +} + + +class FileWriteResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + types_mojom.Error error = null; + int numBytesWritten = 0; + + FileWriteResponseParams() : super(kVersions.last.size); + + static FileWriteResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileWriteResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileWriteResponseParams result = new FileWriteResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + if (mainDataHeader.version >= 0) { + + result.numBytesWritten = decoder0.decodeUint32(12); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + + encoder0.encodeUint32(numBytesWritten, 12); + } + + String toString() { + return "FileWriteResponseParams(" + "error: $error" ", " + "numBytesWritten: $numBytesWritten" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + map["numBytesWritten"] = numBytesWritten; + return map; + } +} + + +class FileReadToStreamParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(32, 0) + ]; + core.MojoDataPipeProducer source = null; + types_mojom.Whence whence = null; + int offset = 0; + int numBytesToRead = 0; + + FileReadToStreamParams() : super(kVersions.last.size); + + static FileReadToStreamParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileReadToStreamParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileReadToStreamParams result = new FileReadToStreamParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.source = decoder0.decodeProducerHandle(8, false); + } + if (mainDataHeader.version >= 0) { + + result.whence = types_mojom.Whence.decode(decoder0, 12); + if (result.whence == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Whence.'); + } + } + if (mainDataHeader.version >= 0) { + + result.offset = decoder0.decodeInt64(16); + } + if (mainDataHeader.version >= 0) { + + result.numBytesToRead = decoder0.decodeInt64(24); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeProducerHandle(source, 8, false); + + encoder0.encodeEnum(whence, 12); + + encoder0.encodeInt64(offset, 16); + + encoder0.encodeInt64(numBytesToRead, 24); + } + + String toString() { + return "FileReadToStreamParams(" + "source: $source" ", " + "whence: $whence" ", " + "offset: $offset" ", " + "numBytesToRead: $numBytesToRead" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class FileReadToStreamResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + types_mojom.Error error = null; + + FileReadToStreamResponseParams() : super(kVersions.last.size); + + static FileReadToStreamResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileReadToStreamResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileReadToStreamResponseParams result = new FileReadToStreamResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + } + + String toString() { + return "FileReadToStreamResponseParams(" + "error: $error" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + return map; + } +} + + +class FileWriteFromStreamParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + core.MojoDataPipeConsumer sink = null; + types_mojom.Whence whence = null; + int offset = 0; + + FileWriteFromStreamParams() : super(kVersions.last.size); + + static FileWriteFromStreamParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileWriteFromStreamParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileWriteFromStreamParams result = new FileWriteFromStreamParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.sink = decoder0.decodeConsumerHandle(8, false); + } + if (mainDataHeader.version >= 0) { + + result.whence = types_mojom.Whence.decode(decoder0, 12); + if (result.whence == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Whence.'); + } + } + if (mainDataHeader.version >= 0) { + + result.offset = decoder0.decodeInt64(16); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeConsumerHandle(sink, 8, false); + + encoder0.encodeEnum(whence, 12); + + encoder0.encodeInt64(offset, 16); + } + + String toString() { + return "FileWriteFromStreamParams(" + "sink: $sink" ", " + "whence: $whence" ", " + "offset: $offset" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class FileWriteFromStreamResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + types_mojom.Error error = null; + + FileWriteFromStreamResponseParams() : super(kVersions.last.size); + + static FileWriteFromStreamResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileWriteFromStreamResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileWriteFromStreamResponseParams result = new FileWriteFromStreamResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + } + + String toString() { + return "FileWriteFromStreamResponseParams(" + "error: $error" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + return map; + } +} + + +class FileTellParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + FileTellParams() : super(kVersions.last.size); + + static FileTellParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileTellParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileTellParams result = new FileTellParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "FileTellParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class FileTellResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + types_mojom.Error error = null; + int position = 0; + + FileTellResponseParams() : super(kVersions.last.size); + + static FileTellResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileTellResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileTellResponseParams result = new FileTellResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + if (mainDataHeader.version >= 0) { + + result.position = decoder0.decodeInt64(16); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + + encoder0.encodeInt64(position, 16); + } + + String toString() { + return "FileTellResponseParams(" + "error: $error" ", " + "position: $position" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + map["position"] = position; + return map; + } +} + + +class FileSeekParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int offset = 0; + types_mojom.Whence whence = null; + + FileSeekParams() : super(kVersions.last.size); + + static FileSeekParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileSeekParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileSeekParams result = new FileSeekParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.offset = decoder0.decodeInt64(8); + } + if (mainDataHeader.version >= 0) { + + result.whence = types_mojom.Whence.decode(decoder0, 16); + if (result.whence == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Whence.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt64(offset, 8); + + encoder0.encodeEnum(whence, 16); + } + + String toString() { + return "FileSeekParams(" + "offset: $offset" ", " + "whence: $whence" ")"; + } + + Map toJson() { + Map map = new Map(); + map["offset"] = offset; + map["whence"] = whence; + return map; + } +} + + +class FileSeekResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + types_mojom.Error error = null; + int position = 0; + + FileSeekResponseParams() : super(kVersions.last.size); + + static FileSeekResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileSeekResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileSeekResponseParams result = new FileSeekResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + if (mainDataHeader.version >= 0) { + + result.position = decoder0.decodeInt64(16); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + + encoder0.encodeInt64(position, 16); + } + + String toString() { + return "FileSeekResponseParams(" + "error: $error" ", " + "position: $position" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + map["position"] = position; + return map; + } +} + + +class FileStatParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + FileStatParams() : super(kVersions.last.size); + + static FileStatParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileStatParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileStatParams result = new FileStatParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "FileStatParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class FileStatResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + types_mojom.Error error = null; + types_mojom.FileInformation fileInformation = null; + + FileStatResponseParams() : super(kVersions.last.size); + + static FileStatResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileStatResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileStatResponseParams result = new FileStatResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, true); + result.fileInformation = types_mojom.FileInformation.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + + encoder0.encodeStruct(fileInformation, 16, true); + } + + String toString() { + return "FileStatResponseParams(" + "error: $error" ", " + "fileInformation: $fileInformation" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + map["fileInformation"] = fileInformation; + return map; + } +} + + +class FileTruncateParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int size = 0; + + FileTruncateParams() : super(kVersions.last.size); + + static FileTruncateParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileTruncateParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileTruncateParams result = new FileTruncateParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.size = decoder0.decodeInt64(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt64(size, 8); + } + + String toString() { + return "FileTruncateParams(" + "size: $size" ")"; + } + + Map toJson() { + Map map = new Map(); + map["size"] = size; + return map; + } +} + + +class FileTruncateResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + types_mojom.Error error = null; + + FileTruncateResponseParams() : super(kVersions.last.size); + + static FileTruncateResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileTruncateResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileTruncateResponseParams result = new FileTruncateResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + } + + String toString() { + return "FileTruncateResponseParams(" + "error: $error" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + return map; + } +} + + +class FileTouchParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + types_mojom.TimespecOrNow atime = null; + types_mojom.TimespecOrNow mtime = null; + + FileTouchParams() : super(kVersions.last.size); + + static FileTouchParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileTouchParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileTouchParams result = new FileTouchParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, true); + result.atime = types_mojom.TimespecOrNow.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, true); + result.mtime = types_mojom.TimespecOrNow.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(atime, 8, true); + + encoder0.encodeStruct(mtime, 16, true); + } + + String toString() { + return "FileTouchParams(" + "atime: $atime" ", " + "mtime: $mtime" ")"; + } + + Map toJson() { + Map map = new Map(); + map["atime"] = atime; + map["mtime"] = mtime; + return map; + } +} + + +class FileTouchResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + types_mojom.Error error = null; + + FileTouchResponseParams() : super(kVersions.last.size); + + static FileTouchResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileTouchResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileTouchResponseParams result = new FileTouchResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + } + + String toString() { + return "FileTouchResponseParams(" + "error: $error" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + return map; + } +} + + +class FileDupParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + Object file = null; + + FileDupParams() : super(kVersions.last.size); + + static FileDupParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileDupParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileDupParams result = new FileDupParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.file = decoder0.decodeInterfaceRequest(8, false, FileStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterfaceRequest(file, 8, false); + } + + String toString() { + return "FileDupParams(" + "file: $file" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class FileDupResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + types_mojom.Error error = null; + + FileDupResponseParams() : super(kVersions.last.size); + + static FileDupResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileDupResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileDupResponseParams result = new FileDupResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + } + + String toString() { + return "FileDupResponseParams(" + "error: $error" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + return map; + } +} + + +class FileReopenParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + Object file = null; + int openFlags = 0; + + FileReopenParams() : super(kVersions.last.size); + + static FileReopenParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileReopenParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileReopenParams result = new FileReopenParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.file = decoder0.decodeInterfaceRequest(8, false, FileStub.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.openFlags = decoder0.decodeUint32(12); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterfaceRequest(file, 8, false); + + encoder0.encodeUint32(openFlags, 12); + } + + String toString() { + return "FileReopenParams(" + "file: $file" ", " + "openFlags: $openFlags" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class FileReopenResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + types_mojom.Error error = null; + + FileReopenResponseParams() : super(kVersions.last.size); + + static FileReopenResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileReopenResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileReopenResponseParams result = new FileReopenResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + } + + String toString() { + return "FileReopenResponseParams(" + "error: $error" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + return map; + } +} + + +class FileAsBufferParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + FileAsBufferParams() : super(kVersions.last.size); + + static FileAsBufferParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileAsBufferParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileAsBufferParams result = new FileAsBufferParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "FileAsBufferParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class FileAsBufferResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + types_mojom.Error error = null; + core.MojoSharedBuffer buffer = null; + + FileAsBufferResponseParams() : super(kVersions.last.size); + + static FileAsBufferResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileAsBufferResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileAsBufferResponseParams result = new FileAsBufferResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + if (mainDataHeader.version >= 0) { + + result.buffer = decoder0.decodeSharedBufferHandle(12, true); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + + encoder0.encodeSharedBufferHandle(buffer, 12, true); + } + + String toString() { + return "FileAsBufferResponseParams(" + "error: $error" ", " + "buffer: $buffer" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class FileIoctlParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int request = 0; + List<int> inValues = null; + + FileIoctlParams() : super(kVersions.last.size); + + static FileIoctlParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileIoctlParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileIoctlParams result = new FileIoctlParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.request = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + result.inValues = decoder0.decodeUint32Array(16, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(request, 8); + + encoder0.encodeUint32Array(inValues, 16, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + } + + String toString() { + return "FileIoctlParams(" + "request: $request" ", " + "inValues: $inValues" ")"; + } + + Map toJson() { + Map map = new Map(); + map["request"] = request; + map["inValues"] = inValues; + return map; + } +} + + +class FileIoctlResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + types_mojom.Error error = null; + List<int> outValues = null; + + FileIoctlResponseParams() : super(kVersions.last.size); + + static FileIoctlResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileIoctlResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileIoctlResponseParams result = new FileIoctlResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + if (mainDataHeader.version >= 0) { + + result.outValues = decoder0.decodeUint32Array(16, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + + encoder0.encodeUint32Array(outValues, 16, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + } + + String toString() { + return "FileIoctlResponseParams(" + "error: $error" ", " + "outValues: $outValues" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + map["outValues"] = outValues; + return map; + } +} + +const int kFile_close_name = 0; +const int kFile_read_name = 1; +const int kFile_write_name = 2; +const int kFile_readToStream_name = 3; +const int kFile_writeFromStream_name = 4; +const int kFile_tell_name = 5; +const int kFile_seek_name = 6; +const int kFile_stat_name = 7; +const int kFile_truncate_name = 8; +const int kFile_touch_name = 9; +const int kFile_dup_name = 10; +const int kFile_reopen_name = 11; +const int kFile_asBuffer_name = 12; +const int kFile_ioctl_name = 13; + +const String FileName = + 'mojo::files::File'; + +abstract class File { + dynamic close([Function responseFactory = null]); + dynamic read(int numBytesToRead,int offset,types_mojom.Whence whence,[Function responseFactory = null]); + dynamic write(List<int> bytesToWrite,int offset,types_mojom.Whence whence,[Function responseFactory = null]); + dynamic readToStream(core.MojoDataPipeProducer source,int offset,types_mojom.Whence whence,int numBytesToRead,[Function responseFactory = null]); + dynamic writeFromStream(core.MojoDataPipeConsumer sink,int offset,types_mojom.Whence whence,[Function responseFactory = null]); + dynamic tell([Function responseFactory = null]); + dynamic seek(int offset,types_mojom.Whence whence,[Function responseFactory = null]); + dynamic stat([Function responseFactory = null]); + dynamic truncate(int size,[Function responseFactory = null]); + dynamic touch(types_mojom.TimespecOrNow atime,types_mojom.TimespecOrNow mtime,[Function responseFactory = null]); + dynamic dup(Object file,[Function responseFactory = null]); + dynamic reopen(Object file,int openFlags,[Function responseFactory = null]); + dynamic asBuffer([Function responseFactory = null]); + dynamic ioctl(int request,List<int> inValues,[Function responseFactory = null]); + +} + + +class FileProxyImpl extends bindings.Proxy { + FileProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + FileProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + FileProxyImpl.unbound() : super.unbound(); + + static FileProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For FileProxyImpl")); + return new FileProxyImpl.fromEndpoint(endpoint); + } + + String get name => FileName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kFile_close_name: + var r = FileCloseResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kFile_read_name: + var r = FileReadResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kFile_write_name: + var r = FileWriteResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kFile_readToStream_name: + var r = FileReadToStreamResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kFile_writeFromStream_name: + var r = FileWriteFromStreamResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kFile_tell_name: + var r = FileTellResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kFile_seek_name: + var r = FileSeekResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kFile_stat_name: + var r = FileStatResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kFile_truncate_name: + var r = FileTruncateResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kFile_touch_name: + var r = FileTouchResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kFile_dup_name: + var r = FileDupResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kFile_reopen_name: + var r = FileReopenResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kFile_asBuffer_name: + var r = FileAsBufferResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kFile_ioctl_name: + var r = FileIoctlResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "FileProxyImpl($superString)"; + } +} + + +class _FileProxyCalls implements File { + FileProxyImpl _proxyImpl; + + _FileProxyCalls(this._proxyImpl); + dynamic close([Function responseFactory = null]) { + var params = new FileCloseParams(); + return _proxyImpl.sendMessageWithRequestId( + params, + kFile_close_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic read(int numBytesToRead,int offset,types_mojom.Whence whence,[Function responseFactory = null]) { + var params = new FileReadParams(); + params.numBytesToRead = numBytesToRead; + params.offset = offset; + params.whence = whence; + return _proxyImpl.sendMessageWithRequestId( + params, + kFile_read_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic write(List<int> bytesToWrite,int offset,types_mojom.Whence whence,[Function responseFactory = null]) { + var params = new FileWriteParams(); + params.bytesToWrite = bytesToWrite; + params.offset = offset; + params.whence = whence; + return _proxyImpl.sendMessageWithRequestId( + params, + kFile_write_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic readToStream(core.MojoDataPipeProducer source,int offset,types_mojom.Whence whence,int numBytesToRead,[Function responseFactory = null]) { + var params = new FileReadToStreamParams(); + params.source = source; + params.offset = offset; + params.whence = whence; + params.numBytesToRead = numBytesToRead; + return _proxyImpl.sendMessageWithRequestId( + params, + kFile_readToStream_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic writeFromStream(core.MojoDataPipeConsumer sink,int offset,types_mojom.Whence whence,[Function responseFactory = null]) { + var params = new FileWriteFromStreamParams(); + params.sink = sink; + params.offset = offset; + params.whence = whence; + return _proxyImpl.sendMessageWithRequestId( + params, + kFile_writeFromStream_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic tell([Function responseFactory = null]) { + var params = new FileTellParams(); + return _proxyImpl.sendMessageWithRequestId( + params, + kFile_tell_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic seek(int offset,types_mojom.Whence whence,[Function responseFactory = null]) { + var params = new FileSeekParams(); + params.offset = offset; + params.whence = whence; + return _proxyImpl.sendMessageWithRequestId( + params, + kFile_seek_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic stat([Function responseFactory = null]) { + var params = new FileStatParams(); + return _proxyImpl.sendMessageWithRequestId( + params, + kFile_stat_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic truncate(int size,[Function responseFactory = null]) { + var params = new FileTruncateParams(); + params.size = size; + return _proxyImpl.sendMessageWithRequestId( + params, + kFile_truncate_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic touch(types_mojom.TimespecOrNow atime,types_mojom.TimespecOrNow mtime,[Function responseFactory = null]) { + var params = new FileTouchParams(); + params.atime = atime; + params.mtime = mtime; + return _proxyImpl.sendMessageWithRequestId( + params, + kFile_touch_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic dup(Object file,[Function responseFactory = null]) { + var params = new FileDupParams(); + params.file = file; + return _proxyImpl.sendMessageWithRequestId( + params, + kFile_dup_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic reopen(Object file,int openFlags,[Function responseFactory = null]) { + var params = new FileReopenParams(); + params.file = file; + params.openFlags = openFlags; + return _proxyImpl.sendMessageWithRequestId( + params, + kFile_reopen_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic asBuffer([Function responseFactory = null]) { + var params = new FileAsBufferParams(); + return _proxyImpl.sendMessageWithRequestId( + params, + kFile_asBuffer_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic ioctl(int request,List<int> inValues,[Function responseFactory = null]) { + var params = new FileIoctlParams(); + params.request = request; + params.inValues = inValues; + return _proxyImpl.sendMessageWithRequestId( + params, + kFile_ioctl_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class FileProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + File ptr; + final String name = FileName; + + FileProxy(FileProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _FileProxyCalls(proxyImpl); + + FileProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new FileProxyImpl.fromEndpoint(endpoint) { + ptr = new _FileProxyCalls(impl); + } + + FileProxy.fromHandle(core.MojoHandle handle) : + impl = new FileProxyImpl.fromHandle(handle) { + ptr = new _FileProxyCalls(impl); + } + + FileProxy.unbound() : + impl = new FileProxyImpl.unbound() { + ptr = new _FileProxyCalls(impl); + } + + factory FileProxy.connectToService( + bindings.ServiceConnector s, String url) { + FileProxy p = new FileProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static FileProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For FileProxy")); + return new FileProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "FileProxy($impl)"; + } +} + + +class FileStub extends bindings.Stub { + File _impl = null; + + FileStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + FileStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + FileStub.unbound() : super.unbound(); + + static FileStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For FileStub")); + return new FileStub.fromEndpoint(endpoint); + } + + static const String name = FileName; + + + FileCloseResponseParams _FileCloseResponseParamsFactory(types_mojom.Error err) { + var result = new FileCloseResponseParams(); + result.err = err; + return result; + } + FileReadResponseParams _FileReadResponseParamsFactory(types_mojom.Error error, List<int> bytesRead) { + var result = new FileReadResponseParams(); + result.error = error; + result.bytesRead = bytesRead; + return result; + } + FileWriteResponseParams _FileWriteResponseParamsFactory(types_mojom.Error error, int numBytesWritten) { + var result = new FileWriteResponseParams(); + result.error = error; + result.numBytesWritten = numBytesWritten; + return result; + } + FileReadToStreamResponseParams _FileReadToStreamResponseParamsFactory(types_mojom.Error error) { + var result = new FileReadToStreamResponseParams(); + result.error = error; + return result; + } + FileWriteFromStreamResponseParams _FileWriteFromStreamResponseParamsFactory(types_mojom.Error error) { + var result = new FileWriteFromStreamResponseParams(); + result.error = error; + return result; + } + FileTellResponseParams _FileTellResponseParamsFactory(types_mojom.Error error, int position) { + var result = new FileTellResponseParams(); + result.error = error; + result.position = position; + return result; + } + FileSeekResponseParams _FileSeekResponseParamsFactory(types_mojom.Error error, int position) { + var result = new FileSeekResponseParams(); + result.error = error; + result.position = position; + return result; + } + FileStatResponseParams _FileStatResponseParamsFactory(types_mojom.Error error, types_mojom.FileInformation fileInformation) { + var result = new FileStatResponseParams(); + result.error = error; + result.fileInformation = fileInformation; + return result; + } + FileTruncateResponseParams _FileTruncateResponseParamsFactory(types_mojom.Error error) { + var result = new FileTruncateResponseParams(); + result.error = error; + return result; + } + FileTouchResponseParams _FileTouchResponseParamsFactory(types_mojom.Error error) { + var result = new FileTouchResponseParams(); + result.error = error; + return result; + } + FileDupResponseParams _FileDupResponseParamsFactory(types_mojom.Error error) { + var result = new FileDupResponseParams(); + result.error = error; + return result; + } + FileReopenResponseParams _FileReopenResponseParamsFactory(types_mojom.Error error) { + var result = new FileReopenResponseParams(); + result.error = error; + return result; + } + FileAsBufferResponseParams _FileAsBufferResponseParamsFactory(types_mojom.Error error, core.MojoSharedBuffer buffer) { + var result = new FileAsBufferResponseParams(); + result.error = error; + result.buffer = buffer; + return result; + } + FileIoctlResponseParams _FileIoctlResponseParamsFactory(types_mojom.Error error, List<int> outValues) { + var result = new FileIoctlResponseParams(); + result.error = error; + result.outValues = outValues; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kFile_close_name: + var params = FileCloseParams.deserialize( + message.payload); + var response = _impl.close(_FileCloseResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kFile_close_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kFile_close_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kFile_read_name: + var params = FileReadParams.deserialize( + message.payload); + var response = _impl.read(params.numBytesToRead,params.offset,params.whence,_FileReadResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kFile_read_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kFile_read_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kFile_write_name: + var params = FileWriteParams.deserialize( + message.payload); + var response = _impl.write(params.bytesToWrite,params.offset,params.whence,_FileWriteResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kFile_write_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kFile_write_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kFile_readToStream_name: + var params = FileReadToStreamParams.deserialize( + message.payload); + var response = _impl.readToStream(params.source,params.offset,params.whence,params.numBytesToRead,_FileReadToStreamResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kFile_readToStream_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kFile_readToStream_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kFile_writeFromStream_name: + var params = FileWriteFromStreamParams.deserialize( + message.payload); + var response = _impl.writeFromStream(params.sink,params.offset,params.whence,_FileWriteFromStreamResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kFile_writeFromStream_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kFile_writeFromStream_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kFile_tell_name: + var params = FileTellParams.deserialize( + message.payload); + var response = _impl.tell(_FileTellResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kFile_tell_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kFile_tell_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kFile_seek_name: + var params = FileSeekParams.deserialize( + message.payload); + var response = _impl.seek(params.offset,params.whence,_FileSeekResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kFile_seek_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kFile_seek_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kFile_stat_name: + var params = FileStatParams.deserialize( + message.payload); + var response = _impl.stat(_FileStatResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kFile_stat_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kFile_stat_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kFile_truncate_name: + var params = FileTruncateParams.deserialize( + message.payload); + var response = _impl.truncate(params.size,_FileTruncateResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kFile_truncate_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kFile_truncate_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kFile_touch_name: + var params = FileTouchParams.deserialize( + message.payload); + var response = _impl.touch(params.atime,params.mtime,_FileTouchResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kFile_touch_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kFile_touch_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kFile_dup_name: + var params = FileDupParams.deserialize( + message.payload); + var response = _impl.dup(params.file,_FileDupResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kFile_dup_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kFile_dup_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kFile_reopen_name: + var params = FileReopenParams.deserialize( + message.payload); + var response = _impl.reopen(params.file,params.openFlags,_FileReopenResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kFile_reopen_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kFile_reopen_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kFile_asBuffer_name: + var params = FileAsBufferParams.deserialize( + message.payload); + var response = _impl.asBuffer(_FileAsBufferResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kFile_asBuffer_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kFile_asBuffer_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kFile_ioctl_name: + var params = FileIoctlParams.deserialize( + message.payload); + var response = _impl.ioctl(params.request,params.inValues,_FileIoctlResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kFile_ioctl_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kFile_ioctl_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + File get impl => _impl; + set impl(File d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "FileStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/files/files.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/files/files.mojom.dart new file mode 100644 index 0000000..f334180 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/files/files.mojom.dart
@@ -0,0 +1,377 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library files_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo_services/mojo/files/directory.mojom.dart' as directory_mojom; +import 'package:mojo_services/mojo/files/types.mojom.dart' as types_mojom; + + + +class FilesOpenFileSystemParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + String fileSystem = null; + Object directory = null; + + FilesOpenFileSystemParams() : super(kVersions.last.size); + + static FilesOpenFileSystemParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FilesOpenFileSystemParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FilesOpenFileSystemParams result = new FilesOpenFileSystemParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.fileSystem = decoder0.decodeString(8, true); + } + if (mainDataHeader.version >= 0) { + + result.directory = decoder0.decodeInterfaceRequest(16, false, directory_mojom.DirectoryStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(fileSystem, 8, true); + + encoder0.encodeInterfaceRequest(directory, 16, false); + } + + String toString() { + return "FilesOpenFileSystemParams(" + "fileSystem: $fileSystem" ", " + "directory: $directory" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class FilesOpenFileSystemResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + types_mojom.Error error = null; + + FilesOpenFileSystemResponseParams() : super(kVersions.last.size); + + static FilesOpenFileSystemResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FilesOpenFileSystemResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FilesOpenFileSystemResponseParams result = new FilesOpenFileSystemResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + } + + String toString() { + return "FilesOpenFileSystemResponseParams(" + "error: $error" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + return map; + } +} + +const int kFiles_openFileSystem_name = 0; + +const String FilesName = + 'mojo::files::Files'; + +abstract class Files { + dynamic openFileSystem(String fileSystem,Object directory,[Function responseFactory = null]); + +} + + +class FilesProxyImpl extends bindings.Proxy { + FilesProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + FilesProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + FilesProxyImpl.unbound() : super.unbound(); + + static FilesProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For FilesProxyImpl")); + return new FilesProxyImpl.fromEndpoint(endpoint); + } + + String get name => FilesName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kFiles_openFileSystem_name: + var r = FilesOpenFileSystemResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "FilesProxyImpl($superString)"; + } +} + + +class _FilesProxyCalls implements Files { + FilesProxyImpl _proxyImpl; + + _FilesProxyCalls(this._proxyImpl); + dynamic openFileSystem(String fileSystem,Object directory,[Function responseFactory = null]) { + var params = new FilesOpenFileSystemParams(); + params.fileSystem = fileSystem; + params.directory = directory; + return _proxyImpl.sendMessageWithRequestId( + params, + kFiles_openFileSystem_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class FilesProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + Files ptr; + final String name = FilesName; + + FilesProxy(FilesProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _FilesProxyCalls(proxyImpl); + + FilesProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new FilesProxyImpl.fromEndpoint(endpoint) { + ptr = new _FilesProxyCalls(impl); + } + + FilesProxy.fromHandle(core.MojoHandle handle) : + impl = new FilesProxyImpl.fromHandle(handle) { + ptr = new _FilesProxyCalls(impl); + } + + FilesProxy.unbound() : + impl = new FilesProxyImpl.unbound() { + ptr = new _FilesProxyCalls(impl); + } + + factory FilesProxy.connectToService( + bindings.ServiceConnector s, String url) { + FilesProxy p = new FilesProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static FilesProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For FilesProxy")); + return new FilesProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "FilesProxy($impl)"; + } +} + + +class FilesStub extends bindings.Stub { + Files _impl = null; + + FilesStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + FilesStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + FilesStub.unbound() : super.unbound(); + + static FilesStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For FilesStub")); + return new FilesStub.fromEndpoint(endpoint); + } + + static const String name = FilesName; + + + FilesOpenFileSystemResponseParams _FilesOpenFileSystemResponseParamsFactory(types_mojom.Error error) { + var result = new FilesOpenFileSystemResponseParams(); + result.error = error; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kFiles_openFileSystem_name: + var params = FilesOpenFileSystemParams.deserialize( + message.payload); + var response = _impl.openFileSystem(params.fileSystem,params.directory,_FilesOpenFileSystemResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kFiles_openFileSystem_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kFiles_openFileSystem_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + Files get impl => _impl; + set impl(Files d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "FilesStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/files/ioctl.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/files/ioctl.mojom.dart new file mode 100644 index 0000000..b8fc83c --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/files/ioctl.mojom.dart
@@ -0,0 +1,15 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library ioctl_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +const kIoctlInvalid = 0; +const kIoctlTerminal = 1; + + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/files/ioctl_terminal.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/files/ioctl_terminal.mojom.dart new file mode 100644 index 0000000..7622770 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/files/ioctl_terminal.mojom.dart
@@ -0,0 +1,108 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library ioctl_terminal_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +const kIoctlTerminalInvalid = 0; +const kIoctlTerminalGetSettings = 1; +const kIoctlTerminalSetSettings = 2; +const kIoctlTerminalGetWindowSize = 3; +const kIoctlTerminalSetWindowSize = 4; +const kIoctlTerminalTermiosBaseFieldCount = 6; +const kIoctlTerminalTermiosIFlagIndex = 0; +const kIoctlTerminalTermiosOFlagIndex = 1; +const kIoctlTerminalTermiosCFlagIndex = 2; +const kIoctlTerminalTermiosLFlagIndex = 3; +const kIoctlTerminalTermiosISpeedIndex = 4; +const kIoctlTerminalTermiosOSpeedIndex = 5; +const kIoctlTerminalTermiosCtrlCharCount = 17; +const kIoctlTerminalTermiosCtrlCharVINTRIndex = 17; +const kIoctlTerminalTermiosCtrlCharVQUITIndex = 18; +const kIoctlTerminalTermiosCtrlCharVERASEIndex = 19; +const kIoctlTerminalTermiosCtrlCharVKILLIndex = 20; +const kIoctlTerminalTermiosCtrlCharVEOFIndex = 21; +const kIoctlTerminalTermiosCtrlCharVTIMEIndex = 22; +const kIoctlTerminalTermiosCtrlCharVMINIndex = 23; +const kIoctlTerminalTermiosCtrlCharVSWTCIndex = 24; +const kIoctlTerminalTermiosCtrlCharVSTARTIndex = 25; +const kIoctlTerminalTermiosCtrlCharVSTOPIndex = 26; +const kIoctlTerminalTermiosCtrlCharVSUSPIndex = 27; +const kIoctlTerminalTermiosCtrlCharVEOLIndex = 28; +const kIoctlTerminalTermiosCtrlCharVREPRINTIndex = 29; +const kIoctlTerminalTermiosCtrlCharVDISCARDIndex = 30; +const kIoctlTerminalTermiosCtrlCharVWERASEIndex = 31; +const kIoctlTerminalTermiosCtrlCharVLNEXTIndex = 32; +const kIoctlTerminalTermiosCtrlCharVEOL2Index = 33; +const kIoctlTerminalTermiosIFlagIGNBRK = 0x0001; +const kIoctlTerminalTermiosIFlagBRKINT = 0x0002; +const kIoctlTerminalTermiosIFlagIGNPAR = 0x0004; +const kIoctlTerminalTermiosIFlagPARMRK = 0x0008; +const kIoctlTerminalTermiosIFlagINPCK = 0x0010; +const kIoctlTerminalTermiosIFlagISTRIP = 0x0020; +const kIoctlTerminalTermiosIFlagINLCR = 0x0040; +const kIoctlTerminalTermiosIFlagIGNCR = 0x0080; +const kIoctlTerminalTermiosIFlagICRNL = 0x0100; +const kIoctlTerminalTermiosIFlagIUCLC = 0x0200; +const kIoctlTerminalTermiosIFlagIXON = 0x0400; +const kIoctlTerminalTermiosIFlagIXANY = 0x0800; +const kIoctlTerminalTermiosIFlagIXOFF = 0x1000; +const kIoctlTerminalTermiosIFlagIMAXBEL = 0x2000; +const kIoctlTerminalTermiosIFlagIUTF8 = 0x4000; +const kIoctlTerminalTermiosOFlagOPOST = 0x0001; +const kIoctlTerminalTermiosOFlagOLCUC = 0x0002; +const kIoctlTerminalTermiosOFlagONLCR = 0x0004; +const kIoctlTerminalTermiosOFlagOCRNL = 0x0008; +const kIoctlTerminalTermiosOFlagONOCR = 0x0010; +const kIoctlTerminalTermiosOFlagONLRET = 0x0020; +const kIoctlTerminalTermiosOFlagOFILL = 0x0040; +const kIoctlTerminalTermiosOFlagOFDEL = 0x0080; +const kIoctlTerminalTermiosOFlagNLDLY = 0x0100; +const kIoctlTerminalTermiosOFlagNL0 = 0x0000; +const kIoctlTerminalTermiosOFlagNL1 = 0x0100; +const kIoctlTerminalTermiosOFlagCRDLY = 0x0600; +const kIoctlTerminalTermiosOFlagCR0 = 0x0000; +const kIoctlTerminalTermiosOFlagCR1 = 0x0200; +const kIoctlTerminalTermiosOFlagCR2 = 0x0400; +const kIoctlTerminalTermiosOFlagCR3 = 0x0600; +const kIoctlTerminalTermiosOFlagTABDLY = 0x1800; +const kIoctlTerminalTermiosOFlagTAB0 = 0x0000; +const kIoctlTerminalTermiosOFlagTAB1 = 0x0800; +const kIoctlTerminalTermiosOFlagTAB2 = 0x1000; +const kIoctlTerminalTermiosOFlagTAB3 = 0x1800; +const kIoctlTerminalTermiosOFlagBSDLY = 0x2000; +const kIoctlTerminalTermiosOFlagBS0 = 0x0000; +const kIoctlTerminalTermiosOFlagBS1 = 0x2000; +const kIoctlTerminalTermiosOFlagVTDLY = 0x4000; +const kIoctlTerminalTermiosOFlagVT0 = 0x0000; +const kIoctlTerminalTermiosOFlagVT1 = 0x4000; +const kIoctlTerminalTermiosOFlagFFDLY = 0x8000; +const kIoctlTerminalTermiosOFlagFF0 = 0x0000; +const kIoctlTerminalTermiosOFlagFF1 = 0x8000; +const kIoctlTerminalTermiosCFlagCSIZE = 0x0003; +const kIoctlTerminalTermiosCFlagCS5 = 0x0000; +const kIoctlTerminalTermiosCFlagCS6 = 0x0001; +const kIoctlTerminalTermiosCFlagCS7 = 0x0002; +const kIoctlTerminalTermiosCFlagCS8 = 0x0003; +const kIoctlTerminalTermiosCFlagCSTOPB = 0x0004; +const kIoctlTerminalTermiosCFlagCREAD = 0x0008; +const kIoctlTerminalTermiosCFlagPARENB = 0x0010; +const kIoctlTerminalTermiosCFlagPARODD = 0x0020; +const kIoctlTerminalTermiosCFlagHUPCL = 0x0040; +const kIoctlTerminalTermiosCFlagCLOCAL = 0x0080; +const kIoctlTerminalTermiosLFlagISIG = 0x0001; +const kIoctlTerminalTermiosLFlagICANON = 0x0002; +const kIoctlTerminalTermiosLFlagXCASE = 0x0004; +const kIoctlTerminalTermiosLFlagECHO = 0x0008; +const kIoctlTerminalTermiosLFlagECHOE = 0x0010; +const kIoctlTerminalTermiosLFlagECHOK = 0x0020; +const kIoctlTerminalTermiosLFlagECHONL = 0x0040; +const kIoctlTerminalTermiosLFlagNOFLSH = 0x0080; +const kIoctlTerminalTermiosLFlagTOSTOP = 0x0100; + + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/files/types.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/files/types.mojom.dart new file mode 100644 index 0000000..f66d54f --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/files/types.mojom.dart
@@ -0,0 +1,565 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library types_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +const kOpenFlagRead = 0x1; +const kOpenFlagWrite = 0x2; +const kOpenFlagCreate = 0x4; +const kOpenFlagExclusive = 0x8; +const kOpenFlagAppend = 0x10; +const kOpenFlagTruncate = 0x20; +const kDeleteFlagFileOnly = 0x1; +const kDeleteFlagDirectoryOnly = 0x2; +const kDeleteFlagRecursive = 0x4; +class Error extends bindings.MojoEnum { + static const OK = const Error._(0); + static const UNKNOWN = const Error._(1); + static const INVALID_ARGUMENT = const Error._(2); + static const PERMISSION_DENIED = const Error._(3); + static const OUT_OF_RANGE = const Error._(4); + static const UNIMPLEMENTED = const Error._(5); + static const CLOSED = const Error._(6); + static const UNAVAILABLE = const Error._(7); + static const INTERNAL = const Error._(8); + + const Error._(int v) : super(v); + + static const Map<String, Error> valuesMap = const { + "OK": OK, + "UNKNOWN": UNKNOWN, + "INVALID_ARGUMENT": INVALID_ARGUMENT, + "PERMISSION_DENIED": PERMISSION_DENIED, + "OUT_OF_RANGE": OUT_OF_RANGE, + "UNIMPLEMENTED": UNIMPLEMENTED, + "CLOSED": CLOSED, + "UNAVAILABLE": UNAVAILABLE, + "INTERNAL": INTERNAL, + }; + static const List<Error> values = const [ + OK, + UNKNOWN, + INVALID_ARGUMENT, + PERMISSION_DENIED, + OUT_OF_RANGE, + UNIMPLEMENTED, + CLOSED, + UNAVAILABLE, + INTERNAL, + ]; + + static Error valueOf(String name) => valuesMap[name]; + + factory Error(int v) { + switch (v) { + case 0: + return OK; + case 1: + return UNKNOWN; + case 2: + return INVALID_ARGUMENT; + case 3: + return PERMISSION_DENIED; + case 4: + return OUT_OF_RANGE; + case 5: + return UNIMPLEMENTED; + case 6: + return CLOSED; + case 7: + return UNAVAILABLE; + case 8: + return INTERNAL; + default: + return null; + } + } + + static Error decode(bindings.Decoder decoder0, int offset) { + int v = decoder0.decodeUint32(offset); + Error result = new Error(v); + if (result == null) { + throw new bindings.MojoCodecError( + 'Bad value $v for enum Error.'); + } + return result; + } + + String toString() { + switch(this) { + case OK: + return 'Error.OK'; + case UNKNOWN: + return 'Error.UNKNOWN'; + case INVALID_ARGUMENT: + return 'Error.INVALID_ARGUMENT'; + case PERMISSION_DENIED: + return 'Error.PERMISSION_DENIED'; + case OUT_OF_RANGE: + return 'Error.OUT_OF_RANGE'; + case UNIMPLEMENTED: + return 'Error.UNIMPLEMENTED'; + case CLOSED: + return 'Error.CLOSED'; + case UNAVAILABLE: + return 'Error.UNAVAILABLE'; + case INTERNAL: + return 'Error.INTERNAL'; + } + } + + int toJson() => value; +} +class Whence extends bindings.MojoEnum { + static const FROM_CURRENT = const Whence._(0); + static const FROM_START = const Whence._(1); + static const FROM_END = const Whence._(2); + + const Whence._(int v) : super(v); + + static const Map<String, Whence> valuesMap = const { + "FROM_CURRENT": FROM_CURRENT, + "FROM_START": FROM_START, + "FROM_END": FROM_END, + }; + static const List<Whence> values = const [ + FROM_CURRENT, + FROM_START, + FROM_END, + ]; + + static Whence valueOf(String name) => valuesMap[name]; + + factory Whence(int v) { + switch (v) { + case 0: + return FROM_CURRENT; + case 1: + return FROM_START; + case 2: + return FROM_END; + default: + return null; + } + } + + static Whence decode(bindings.Decoder decoder0, int offset) { + int v = decoder0.decodeUint32(offset); + Whence result = new Whence(v); + if (result == null) { + throw new bindings.MojoCodecError( + 'Bad value $v for enum Whence.'); + } + return result; + } + + String toString() { + switch(this) { + case FROM_CURRENT: + return 'Whence.FROM_CURRENT'; + case FROM_START: + return 'Whence.FROM_START'; + case FROM_END: + return 'Whence.FROM_END'; + } + } + + int toJson() => value; +} +class FileType extends bindings.MojoEnum { + static const UNKNOWN = const FileType._(0); + static const REGULAR_FILE = const FileType._(1); + static const DIRECTORY = const FileType._(2); + + const FileType._(int v) : super(v); + + static const Map<String, FileType> valuesMap = const { + "UNKNOWN": UNKNOWN, + "REGULAR_FILE": REGULAR_FILE, + "DIRECTORY": DIRECTORY, + }; + static const List<FileType> values = const [ + UNKNOWN, + REGULAR_FILE, + DIRECTORY, + ]; + + static FileType valueOf(String name) => valuesMap[name]; + + factory FileType(int v) { + switch (v) { + case 0: + return UNKNOWN; + case 1: + return REGULAR_FILE; + case 2: + return DIRECTORY; + default: + return null; + } + } + + static FileType decode(bindings.Decoder decoder0, int offset) { + int v = decoder0.decodeUint32(offset); + FileType result = new FileType(v); + if (result == null) { + throw new bindings.MojoCodecError( + 'Bad value $v for enum FileType.'); + } + return result; + } + + String toString() { + switch(this) { + case UNKNOWN: + return 'FileType.UNKNOWN'; + case REGULAR_FILE: + return 'FileType.REGULAR_FILE'; + case DIRECTORY: + return 'FileType.DIRECTORY'; + } + } + + int toJson() => value; +} + + + +class Timespec extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int seconds = 0; + int nanoseconds = 0; + + Timespec() : super(kVersions.last.size); + + static Timespec deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static Timespec decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + Timespec result = new Timespec(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.seconds = decoder0.decodeInt64(8); + } + if (mainDataHeader.version >= 0) { + + result.nanoseconds = decoder0.decodeInt32(16); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt64(seconds, 8); + + encoder0.encodeInt32(nanoseconds, 16); + } + + String toString() { + return "Timespec(" + "seconds: $seconds" ", " + "nanoseconds: $nanoseconds" ")"; + } + + Map toJson() { + Map map = new Map(); + map["seconds"] = seconds; + map["nanoseconds"] = nanoseconds; + return map; + } +} + + +class TimespecOrNow extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + bool now = false; + Timespec timespec = null; + + TimespecOrNow() : super(kVersions.last.size); + + static TimespecOrNow deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static TimespecOrNow decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + TimespecOrNow result = new TimespecOrNow(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.now = decoder0.decodeBool(8, 0); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, true); + result.timespec = Timespec.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeBool(now, 8, 0); + + encoder0.encodeStruct(timespec, 16, true); + } + + String toString() { + return "TimespecOrNow(" + "now: $now" ", " + "timespec: $timespec" ")"; + } + + Map toJson() { + Map map = new Map(); + map["now"] = now; + map["timespec"] = timespec; + return map; + } +} + + +class FileInformation extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(40, 0) + ]; + FileType type = null; + int size = 0; + Timespec atime = null; + Timespec mtime = null; + + FileInformation() : super(kVersions.last.size); + + static FileInformation deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static FileInformation decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + FileInformation result = new FileInformation(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.type = FileType.decode(decoder0, 8); + if (result.type == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable FileType.'); + } + } + if (mainDataHeader.version >= 0) { + + result.size = decoder0.decodeInt64(16); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(24, true); + result.atime = Timespec.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(32, true); + result.mtime = Timespec.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(type, 8); + + encoder0.encodeInt64(size, 16); + + encoder0.encodeStruct(atime, 24, true); + + encoder0.encodeStruct(mtime, 32, true); + } + + String toString() { + return "FileInformation(" + "type: $type" ", " + "size: $size" ", " + "atime: $atime" ", " + "mtime: $mtime" ")"; + } + + Map toJson() { + Map map = new Map(); + map["type"] = type; + map["size"] = size; + map["atime"] = atime; + map["mtime"] = mtime; + return map; + } +} + + +class DirectoryEntry extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + FileType type = null; + String name = null; + + DirectoryEntry() : super(kVersions.last.size); + + static DirectoryEntry deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static DirectoryEntry decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + DirectoryEntry result = new DirectoryEntry(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.type = FileType.decode(decoder0, 8); + if (result.type == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable FileType.'); + } + } + if (mainDataHeader.version >= 0) { + + result.name = decoder0.decodeString(16, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(type, 8); + + encoder0.encodeString(name, 16, false); + } + + String toString() { + return "DirectoryEntry(" + "type: $type" ", " + "name: $name" ")"; + } + + Map toJson() { + Map map = new Map(); + map["type"] = type; + map["name"] = name; + return map; + } +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/geocoder.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/geocoder.mojom.dart new file mode 100644 index 0000000..2cc532b --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/geocoder.mojom.dart
@@ -0,0 +1,1239 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library geocoder_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo_services/mojo/location.mojom.dart' as location_mojom; + + + +class LocationType extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + static const ROOFTOP = "ROOFTOP"; + static const RANGE_INTERPOLATED = "RANGE_INTERPOLATED"; + static const GEOMETRIC_CENTER = "GEOMETRIC_CENTER"; + static const APPROXIMATE = "APPROXIMATE"; + + LocationType() : super(kVersions.last.size); + + static LocationType deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static LocationType decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + LocationType result = new LocationType(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "LocationType("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class Bounds extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + location_mojom.Location northeast = null; + location_mojom.Location southwest = null; + + Bounds() : super(kVersions.last.size); + + static Bounds deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static Bounds decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + Bounds result = new Bounds(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.northeast = location_mojom.Location.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + result.southwest = location_mojom.Location.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(northeast, 8, false); + + encoder0.encodeStruct(southwest, 16, false); + } + + String toString() { + return "Bounds(" + "northeast: $northeast" ", " + "southwest: $southwest" ")"; + } + + Map toJson() { + Map map = new Map(); + map["northeast"] = northeast; + map["southwest"] = southwest; + return map; + } +} + + +class ComponentRestrictions extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(48, 0) + ]; + String administrativeArea = null; + String country = null; + String locality = null; + String postalCode = null; + String route = null; + + ComponentRestrictions() : super(kVersions.last.size); + + static ComponentRestrictions deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ComponentRestrictions decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ComponentRestrictions result = new ComponentRestrictions(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.administrativeArea = decoder0.decodeString(8, true); + } + if (mainDataHeader.version >= 0) { + + result.country = decoder0.decodeString(16, true); + } + if (mainDataHeader.version >= 0) { + + result.locality = decoder0.decodeString(24, true); + } + if (mainDataHeader.version >= 0) { + + result.postalCode = decoder0.decodeString(32, true); + } + if (mainDataHeader.version >= 0) { + + result.route = decoder0.decodeString(40, true); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(administrativeArea, 8, true); + + encoder0.encodeString(country, 16, true); + + encoder0.encodeString(locality, 24, true); + + encoder0.encodeString(postalCode, 32, true); + + encoder0.encodeString(route, 40, true); + } + + String toString() { + return "ComponentRestrictions(" + "administrativeArea: $administrativeArea" ", " + "country: $country" ", " + "locality: $locality" ", " + "postalCode: $postalCode" ", " + "route: $route" ")"; + } + + Map toJson() { + Map map = new Map(); + map["administrativeArea"] = administrativeArea; + map["country"] = country; + map["locality"] = locality; + map["postalCode"] = postalCode; + map["route"] = route; + return map; + } +} + + +class Options extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(32, 0) + ]; + ComponentRestrictions restrictions = null; + location_mojom.Location location = null; + String region = null; + + Options() : super(kVersions.last.size); + + static Options deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static Options decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + Options result = new Options(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, true); + result.restrictions = ComponentRestrictions.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, true); + result.location = location_mojom.Location.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + result.region = decoder0.decodeString(24, true); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(restrictions, 8, true); + + encoder0.encodeStruct(location, 16, true); + + encoder0.encodeString(region, 24, true); + } + + String toString() { + return "Options(" + "restrictions: $restrictions" ", " + "location: $location" ", " + "region: $region" ")"; + } + + Map toJson() { + Map map = new Map(); + map["restrictions"] = restrictions; + map["location"] = location; + map["region"] = region; + return map; + } +} + + +class Geometry extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(40, 0) + ]; + location_mojom.Location location = null; + LocationType locationType = null; + Bounds viewport = null; + Bounds bounds = null; + + Geometry() : super(kVersions.last.size); + + static Geometry deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static Geometry decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + Geometry result = new Geometry(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.location = location_mojom.Location.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + result.locationType = LocationType.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(24, false); + result.viewport = Bounds.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(32, true); + result.bounds = Bounds.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(location, 8, false); + + encoder0.encodeStruct(locationType, 16, false); + + encoder0.encodeStruct(viewport, 24, false); + + encoder0.encodeStruct(bounds, 32, true); + } + + String toString() { + return "Geometry(" + "location: $location" ", " + "locationType: $locationType" ", " + "viewport: $viewport" ", " + "bounds: $bounds" ")"; + } + + Map toJson() { + Map map = new Map(); + map["location"] = location; + map["locationType"] = locationType; + map["viewport"] = viewport; + map["bounds"] = bounds; + return map; + } +} + + +class Result extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(40, 0) + ]; + bool partialMatch = false; + Geometry geometry = null; + String formattedAddress = null; + List<String> types = null; + + Result() : super(kVersions.last.size); + + static Result deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static Result decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + Result result = new Result(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.partialMatch = decoder0.decodeBool(8, 0); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + result.geometry = Geometry.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + result.formattedAddress = decoder0.decodeString(24, false); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(32, false); + { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.types = new List<String>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + result.types[i1] = decoder1.decodeString(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + } + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeBool(partialMatch, 8, 0); + + encoder0.encodeStruct(geometry, 16, false); + + encoder0.encodeString(formattedAddress, 24, false); + + if (types == null) { + encoder0.encodeNullPointer(32, false); + } else { + var encoder1 = encoder0.encodePointerArray(types.length, 32, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < types.length; ++i0) { + + encoder1.encodeString(types[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + } + + String toString() { + return "Result(" + "partialMatch: $partialMatch" ", " + "geometry: $geometry" ", " + "formattedAddress: $formattedAddress" ", " + "types: $types" ")"; + } + + Map toJson() { + Map map = new Map(); + map["partialMatch"] = partialMatch; + map["geometry"] = geometry; + map["formattedAddress"] = formattedAddress; + map["types"] = types; + return map; + } +} + + +class Status extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + static const OK = "OK"; + static const ZERO_RESULTS = "ZERO_RESULTS"; + static const OVER_QUERY_LIMIT = "OVER_QUERY_LIMIT"; + static const REQUEST_DENIED = "REQUEST_DENIED"; + static const INVALID_REQUEST = "INVALID_REQUEST"; + + Status() : super(kVersions.last.size); + + static Status deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static Status decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + Status result = new Status(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "Status("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class GeocoderAddressToLocationParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + String address = null; + Options options = null; + + GeocoderAddressToLocationParams() : super(kVersions.last.size); + + static GeocoderAddressToLocationParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static GeocoderAddressToLocationParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + GeocoderAddressToLocationParams result = new GeocoderAddressToLocationParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.address = decoder0.decodeString(8, false); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, true); + result.options = Options.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(address, 8, false); + + encoder0.encodeStruct(options, 16, true); + } + + String toString() { + return "GeocoderAddressToLocationParams(" + "address: $address" ", " + "options: $options" ")"; + } + + Map toJson() { + Map map = new Map(); + map["address"] = address; + map["options"] = options; + return map; + } +} + + +class GeocoderAddressToLocationResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + String status = null; + List<Result> results = null; + + GeocoderAddressToLocationResponseParams() : super(kVersions.last.size); + + static GeocoderAddressToLocationResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static GeocoderAddressToLocationResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + GeocoderAddressToLocationResponseParams result = new GeocoderAddressToLocationResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.status = decoder0.decodeString(8, false); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, true); + if (decoder1 == null) { + result.results = null; + } else { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.results = new List<Result>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + var decoder2 = decoder1.decodePointer(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + result.results[i1] = Result.decode(decoder2); + } + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(status, 8, false); + + if (results == null) { + encoder0.encodeNullPointer(16, true); + } else { + var encoder1 = encoder0.encodePointerArray(results.length, 16, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < results.length; ++i0) { + + encoder1.encodeStruct(results[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + } + + String toString() { + return "GeocoderAddressToLocationResponseParams(" + "status: $status" ", " + "results: $results" ")"; + } + + Map toJson() { + Map map = new Map(); + map["status"] = status; + map["results"] = results; + return map; + } +} + + +class GeocoderLocationToAddressParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + location_mojom.Location location = null; + Options options = null; + + GeocoderLocationToAddressParams() : super(kVersions.last.size); + + static GeocoderLocationToAddressParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static GeocoderLocationToAddressParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + GeocoderLocationToAddressParams result = new GeocoderLocationToAddressParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.location = location_mojom.Location.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, true); + result.options = Options.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(location, 8, false); + + encoder0.encodeStruct(options, 16, true); + } + + String toString() { + return "GeocoderLocationToAddressParams(" + "location: $location" ", " + "options: $options" ")"; + } + + Map toJson() { + Map map = new Map(); + map["location"] = location; + map["options"] = options; + return map; + } +} + + +class GeocoderLocationToAddressResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + String status = null; + List<Result> results = null; + + GeocoderLocationToAddressResponseParams() : super(kVersions.last.size); + + static GeocoderLocationToAddressResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static GeocoderLocationToAddressResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + GeocoderLocationToAddressResponseParams result = new GeocoderLocationToAddressResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.status = decoder0.decodeString(8, false); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, true); + if (decoder1 == null) { + result.results = null; + } else { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.results = new List<Result>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + var decoder2 = decoder1.decodePointer(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + result.results[i1] = Result.decode(decoder2); + } + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(status, 8, false); + + if (results == null) { + encoder0.encodeNullPointer(16, true); + } else { + var encoder1 = encoder0.encodePointerArray(results.length, 16, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < results.length; ++i0) { + + encoder1.encodeStruct(results[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + } + + String toString() { + return "GeocoderLocationToAddressResponseParams(" + "status: $status" ", " + "results: $results" ")"; + } + + Map toJson() { + Map map = new Map(); + map["status"] = status; + map["results"] = results; + return map; + } +} + +const int kGeocoder_addressToLocation_name = 0; +const int kGeocoder_locationToAddress_name = 1; + +const String GeocoderName = + 'mojo::Geocoder'; + +abstract class Geocoder { + dynamic addressToLocation(String address,Options options,[Function responseFactory = null]); + dynamic locationToAddress(location_mojom.Location location,Options options,[Function responseFactory = null]); + +} + + +class GeocoderProxyImpl extends bindings.Proxy { + GeocoderProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + GeocoderProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + GeocoderProxyImpl.unbound() : super.unbound(); + + static GeocoderProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For GeocoderProxyImpl")); + return new GeocoderProxyImpl.fromEndpoint(endpoint); + } + + String get name => GeocoderName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kGeocoder_addressToLocation_name: + var r = GeocoderAddressToLocationResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kGeocoder_locationToAddress_name: + var r = GeocoderLocationToAddressResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "GeocoderProxyImpl($superString)"; + } +} + + +class _GeocoderProxyCalls implements Geocoder { + GeocoderProxyImpl _proxyImpl; + + _GeocoderProxyCalls(this._proxyImpl); + dynamic addressToLocation(String address,Options options,[Function responseFactory = null]) { + var params = new GeocoderAddressToLocationParams(); + params.address = address; + params.options = options; + return _proxyImpl.sendMessageWithRequestId( + params, + kGeocoder_addressToLocation_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic locationToAddress(location_mojom.Location location,Options options,[Function responseFactory = null]) { + var params = new GeocoderLocationToAddressParams(); + params.location = location; + params.options = options; + return _proxyImpl.sendMessageWithRequestId( + params, + kGeocoder_locationToAddress_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class GeocoderProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + Geocoder ptr; + final String name = GeocoderName; + + GeocoderProxy(GeocoderProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _GeocoderProxyCalls(proxyImpl); + + GeocoderProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new GeocoderProxyImpl.fromEndpoint(endpoint) { + ptr = new _GeocoderProxyCalls(impl); + } + + GeocoderProxy.fromHandle(core.MojoHandle handle) : + impl = new GeocoderProxyImpl.fromHandle(handle) { + ptr = new _GeocoderProxyCalls(impl); + } + + GeocoderProxy.unbound() : + impl = new GeocoderProxyImpl.unbound() { + ptr = new _GeocoderProxyCalls(impl); + } + + factory GeocoderProxy.connectToService( + bindings.ServiceConnector s, String url) { + GeocoderProxy p = new GeocoderProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static GeocoderProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For GeocoderProxy")); + return new GeocoderProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "GeocoderProxy($impl)"; + } +} + + +class GeocoderStub extends bindings.Stub { + Geocoder _impl = null; + + GeocoderStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + GeocoderStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + GeocoderStub.unbound() : super.unbound(); + + static GeocoderStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For GeocoderStub")); + return new GeocoderStub.fromEndpoint(endpoint); + } + + static const String name = GeocoderName; + + + GeocoderAddressToLocationResponseParams _GeocoderAddressToLocationResponseParamsFactory(String status, List<Result> results) { + var result = new GeocoderAddressToLocationResponseParams(); + result.status = status; + result.results = results; + return result; + } + GeocoderLocationToAddressResponseParams _GeocoderLocationToAddressResponseParamsFactory(String status, List<Result> results) { + var result = new GeocoderLocationToAddressResponseParams(); + result.status = status; + result.results = results; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kGeocoder_addressToLocation_name: + var params = GeocoderAddressToLocationParams.deserialize( + message.payload); + var response = _impl.addressToLocation(params.address,params.options,_GeocoderAddressToLocationResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kGeocoder_addressToLocation_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kGeocoder_addressToLocation_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kGeocoder_locationToAddress_name: + var params = GeocoderLocationToAddressParams.deserialize( + message.payload); + var response = _impl.locationToAddress(params.location,params.options,_GeocoderLocationToAddressResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kGeocoder_locationToAddress_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kGeocoder_locationToAddress_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + Geocoder get impl => _impl; + set impl(Geocoder d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "GeocoderStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/geometry.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/geometry.mojom.dart new file mode 100644 index 0000000..90422dd --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/geometry.mojom.dart
@@ -0,0 +1,496 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library geometry_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; + + + +class Point extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int x = 0; + int y = 0; + + Point() : super(kVersions.last.size); + + static Point deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static Point decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + Point result = new Point(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.x = decoder0.decodeInt32(8); + } + if (mainDataHeader.version >= 0) { + + result.y = decoder0.decodeInt32(12); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt32(x, 8); + + encoder0.encodeInt32(y, 12); + } + + String toString() { + return "Point(" + "x: $x" ", " + "y: $y" ")"; + } + + Map toJson() { + Map map = new Map(); + map["x"] = x; + map["y"] = y; + return map; + } +} + + +class PointF extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + double x = 0.0; + double y = 0.0; + + PointF() : super(kVersions.last.size); + + static PointF deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static PointF decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + PointF result = new PointF(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.x = decoder0.decodeFloat(8); + } + if (mainDataHeader.version >= 0) { + + result.y = decoder0.decodeFloat(12); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeFloat(x, 8); + + encoder0.encodeFloat(y, 12); + } + + String toString() { + return "PointF(" + "x: $x" ", " + "y: $y" ")"; + } + + Map toJson() { + Map map = new Map(); + map["x"] = x; + map["y"] = y; + return map; + } +} + + +class Size extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int width = 0; + int height = 0; + + Size() : super(kVersions.last.size); + + static Size deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static Size decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + Size result = new Size(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.width = decoder0.decodeInt32(8); + } + if (mainDataHeader.version >= 0) { + + result.height = decoder0.decodeInt32(12); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt32(width, 8); + + encoder0.encodeInt32(height, 12); + } + + String toString() { + return "Size(" + "width: $width" ", " + "height: $height" ")"; + } + + Map toJson() { + Map map = new Map(); + map["width"] = width; + map["height"] = height; + return map; + } +} + + +class Rect extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int x = 0; + int y = 0; + int width = 0; + int height = 0; + + Rect() : super(kVersions.last.size); + + static Rect deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static Rect decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + Rect result = new Rect(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.x = decoder0.decodeInt32(8); + } + if (mainDataHeader.version >= 0) { + + result.y = decoder0.decodeInt32(12); + } + if (mainDataHeader.version >= 0) { + + result.width = decoder0.decodeInt32(16); + } + if (mainDataHeader.version >= 0) { + + result.height = decoder0.decodeInt32(20); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt32(x, 8); + + encoder0.encodeInt32(y, 12); + + encoder0.encodeInt32(width, 16); + + encoder0.encodeInt32(height, 20); + } + + String toString() { + return "Rect(" + "x: $x" ", " + "y: $y" ", " + "width: $width" ", " + "height: $height" ")"; + } + + Map toJson() { + Map map = new Map(); + map["x"] = x; + map["y"] = y; + map["width"] = width; + map["height"] = height; + return map; + } +} + + +class RectF extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + double x = 0.0; + double y = 0.0; + double width = 0.0; + double height = 0.0; + + RectF() : super(kVersions.last.size); + + static RectF deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static RectF decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + RectF result = new RectF(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.x = decoder0.decodeFloat(8); + } + if (mainDataHeader.version >= 0) { + + result.y = decoder0.decodeFloat(12); + } + if (mainDataHeader.version >= 0) { + + result.width = decoder0.decodeFloat(16); + } + if (mainDataHeader.version >= 0) { + + result.height = decoder0.decodeFloat(20); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeFloat(x, 8); + + encoder0.encodeFloat(y, 12); + + encoder0.encodeFloat(width, 16); + + encoder0.encodeFloat(height, 20); + } + + String toString() { + return "RectF(" + "x: $x" ", " + "y: $y" ", " + "width: $width" ", " + "height: $height" ")"; + } + + Map toJson() { + Map map = new Map(); + map["x"] = x; + map["y"] = y; + map["width"] = width; + map["height"] = height; + return map; + } +} + + +class Transform extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + List<double> matrix = null; + + Transform() : super(kVersions.last.size); + + static Transform deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static Transform decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + Transform result = new Transform(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.matrix = decoder0.decodeFloatArray(8, bindings.kNothingNullable, 16); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeFloatArray(matrix, 8, bindings.kNothingNullable, 16); + } + + String toString() { + return "Transform(" + "matrix: $matrix" ")"; + } + + Map toJson() { + Map map = new Map(); + map["matrix"] = matrix; + return map; + } +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/gpu.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/gpu.mojom.dart new file mode 100644 index 0000000..b817729 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/gpu.mojom.dart
@@ -0,0 +1,255 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library gpu_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo_services/mojo/command_buffer.mojom.dart' as command_buffer_mojom; + + + +class GpuCreateOffscreenGleS2ContextParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + Object gles2Client = null; + + GpuCreateOffscreenGleS2ContextParams() : super(kVersions.last.size); + + static GpuCreateOffscreenGleS2ContextParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static GpuCreateOffscreenGleS2ContextParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + GpuCreateOffscreenGleS2ContextParams result = new GpuCreateOffscreenGleS2ContextParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.gles2Client = decoder0.decodeInterfaceRequest(8, false, command_buffer_mojom.CommandBufferStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterfaceRequest(gles2Client, 8, false); + } + + String toString() { + return "GpuCreateOffscreenGleS2ContextParams(" + "gles2Client: $gles2Client" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + +const int kGpu_createOffscreenGleS2Context_name = 0; + +const String GpuName = + 'mojo::Gpu'; + +abstract class Gpu { + void createOffscreenGleS2Context(Object gles2Client); + +} + + +class GpuProxyImpl extends bindings.Proxy { + GpuProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + GpuProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + GpuProxyImpl.unbound() : super.unbound(); + + static GpuProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For GpuProxyImpl")); + return new GpuProxyImpl.fromEndpoint(endpoint); + } + + String get name => GpuName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "GpuProxyImpl($superString)"; + } +} + + +class _GpuProxyCalls implements Gpu { + GpuProxyImpl _proxyImpl; + + _GpuProxyCalls(this._proxyImpl); + void createOffscreenGleS2Context(Object gles2Client) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new GpuCreateOffscreenGleS2ContextParams(); + params.gles2Client = gles2Client; + _proxyImpl.sendMessage(params, kGpu_createOffscreenGleS2Context_name); + } + +} + + +class GpuProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + Gpu ptr; + final String name = GpuName; + + GpuProxy(GpuProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _GpuProxyCalls(proxyImpl); + + GpuProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new GpuProxyImpl.fromEndpoint(endpoint) { + ptr = new _GpuProxyCalls(impl); + } + + GpuProxy.fromHandle(core.MojoHandle handle) : + impl = new GpuProxyImpl.fromHandle(handle) { + ptr = new _GpuProxyCalls(impl); + } + + GpuProxy.unbound() : + impl = new GpuProxyImpl.unbound() { + ptr = new _GpuProxyCalls(impl); + } + + factory GpuProxy.connectToService( + bindings.ServiceConnector s, String url) { + GpuProxy p = new GpuProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static GpuProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For GpuProxy")); + return new GpuProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "GpuProxy($impl)"; + } +} + + +class GpuStub extends bindings.Stub { + Gpu _impl = null; + + GpuStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + GpuStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + GpuStub.unbound() : super.unbound(); + + static GpuStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For GpuStub")); + return new GpuStub.fromEndpoint(endpoint); + } + + static const String name = GpuName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kGpu_createOffscreenGleS2Context_name: + var params = GpuCreateOffscreenGleS2ContextParams.deserialize( + message.payload); + _impl.createOffscreenGleS2Context(params.gles2Client); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + Gpu get impl => _impl; + set impl(Gpu d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "GpuStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/gpu_capabilities.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/gpu_capabilities.mojom.dart new file mode 100644 index 0000000..c9c57fc --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/gpu_capabilities.mojom.dart
@@ -0,0 +1,546 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library gpu_capabilities_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; + + + +class GpuShaderPrecision extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int minRange = 0; + int maxRange = 0; + int precision = 0; + + GpuShaderPrecision() : super(kVersions.last.size); + + static GpuShaderPrecision deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static GpuShaderPrecision decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + GpuShaderPrecision result = new GpuShaderPrecision(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.minRange = decoder0.decodeInt32(8); + } + if (mainDataHeader.version >= 0) { + + result.maxRange = decoder0.decodeInt32(12); + } + if (mainDataHeader.version >= 0) { + + result.precision = decoder0.decodeInt32(16); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt32(minRange, 8); + + encoder0.encodeInt32(maxRange, 12); + + encoder0.encodeInt32(precision, 16); + } + + String toString() { + return "GpuShaderPrecision(" + "minRange: $minRange" ", " + "maxRange: $maxRange" ", " + "precision: $precision" ")"; + } + + Map toJson() { + Map map = new Map(); + map["minRange"] = minRange; + map["maxRange"] = maxRange; + map["precision"] = precision; + return map; + } +} + + +class GpuPerStagePrecisions extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(56, 0) + ]; + GpuShaderPrecision lowInt = null; + GpuShaderPrecision mediumInt = null; + GpuShaderPrecision highInt = null; + GpuShaderPrecision lowFloat = null; + GpuShaderPrecision mediumFloat = null; + GpuShaderPrecision highFloat = null; + + GpuPerStagePrecisions() : super(kVersions.last.size); + + static GpuPerStagePrecisions deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static GpuPerStagePrecisions decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + GpuPerStagePrecisions result = new GpuPerStagePrecisions(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.lowInt = GpuShaderPrecision.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + result.mediumInt = GpuShaderPrecision.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(24, false); + result.highInt = GpuShaderPrecision.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(32, false); + result.lowFloat = GpuShaderPrecision.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(40, false); + result.mediumFloat = GpuShaderPrecision.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(48, false); + result.highFloat = GpuShaderPrecision.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(lowInt, 8, false); + + encoder0.encodeStruct(mediumInt, 16, false); + + encoder0.encodeStruct(highInt, 24, false); + + encoder0.encodeStruct(lowFloat, 32, false); + + encoder0.encodeStruct(mediumFloat, 40, false); + + encoder0.encodeStruct(highFloat, 48, false); + } + + String toString() { + return "GpuPerStagePrecisions(" + "lowInt: $lowInt" ", " + "mediumInt: $mediumInt" ", " + "highInt: $highInt" ", " + "lowFloat: $lowFloat" ", " + "mediumFloat: $mediumFloat" ", " + "highFloat: $highFloat" ")"; + } + + Map toJson() { + Map map = new Map(); + map["lowInt"] = lowInt; + map["mediumInt"] = mediumInt; + map["highInt"] = highInt; + map["lowFloat"] = lowFloat; + map["mediumFloat"] = mediumFloat; + map["highFloat"] = highFloat; + return map; + } +} + + +class GpuCapabilities extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(80, 0) + ]; + GpuPerStagePrecisions vertexShaderPrecisions = null; + GpuPerStagePrecisions fragmentShaderPrecisions = null; + int maxCombinedTextureImageUnits = 0; + int maxCubeMapTextureSize = 0; + int maxFragmentUniformVectors = 0; + int maxRenderbufferSize = 0; + int maxTextureImageUnits = 0; + int maxTextureSize = 0; + int maxVaryingVectors = 0; + int maxVertexAttribs = 0; + int maxVertexTextureImageUnits = 0; + int maxVertexUniformVectors = 0; + int numCompressedTextureFormats = 0; + int numShaderBinaryFormats = 0; + int bindGeneratesResourceChromium = 0; + bool postSubBuffer = false; + bool eglImageExternal = false; + bool textureFormatBgra8888 = false; + bool textureFormatEtc1 = false; + bool textureFormatEtc1Npot = false; + bool textureRectangle = false; + bool iosurface = false; + bool textureUsage = false; + bool textureStorage = false; + bool discardFramebuffer = false; + bool syncQuery = false; + bool image = false; + bool futureSyncPoints = false; + bool blendEquationAdvanced = false; + bool blendEquationAdvancedCoherent = false; + + GpuCapabilities() : super(kVersions.last.size); + + static GpuCapabilities deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static GpuCapabilities decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + GpuCapabilities result = new GpuCapabilities(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.vertexShaderPrecisions = GpuPerStagePrecisions.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + result.fragmentShaderPrecisions = GpuPerStagePrecisions.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + result.maxCombinedTextureImageUnits = decoder0.decodeInt32(24); + } + if (mainDataHeader.version >= 0) { + + result.maxCubeMapTextureSize = decoder0.decodeInt32(28); + } + if (mainDataHeader.version >= 0) { + + result.maxFragmentUniformVectors = decoder0.decodeInt32(32); + } + if (mainDataHeader.version >= 0) { + + result.maxRenderbufferSize = decoder0.decodeInt32(36); + } + if (mainDataHeader.version >= 0) { + + result.maxTextureImageUnits = decoder0.decodeInt32(40); + } + if (mainDataHeader.version >= 0) { + + result.maxTextureSize = decoder0.decodeInt32(44); + } + if (mainDataHeader.version >= 0) { + + result.maxVaryingVectors = decoder0.decodeInt32(48); + } + if (mainDataHeader.version >= 0) { + + result.maxVertexAttribs = decoder0.decodeInt32(52); + } + if (mainDataHeader.version >= 0) { + + result.maxVertexTextureImageUnits = decoder0.decodeInt32(56); + } + if (mainDataHeader.version >= 0) { + + result.maxVertexUniformVectors = decoder0.decodeInt32(60); + } + if (mainDataHeader.version >= 0) { + + result.numCompressedTextureFormats = decoder0.decodeInt32(64); + } + if (mainDataHeader.version >= 0) { + + result.numShaderBinaryFormats = decoder0.decodeInt32(68); + } + if (mainDataHeader.version >= 0) { + + result.bindGeneratesResourceChromium = decoder0.decodeInt32(72); + } + if (mainDataHeader.version >= 0) { + + result.postSubBuffer = decoder0.decodeBool(76, 0); + } + if (mainDataHeader.version >= 0) { + + result.eglImageExternal = decoder0.decodeBool(76, 1); + } + if (mainDataHeader.version >= 0) { + + result.textureFormatBgra8888 = decoder0.decodeBool(76, 2); + } + if (mainDataHeader.version >= 0) { + + result.textureFormatEtc1 = decoder0.decodeBool(76, 3); + } + if (mainDataHeader.version >= 0) { + + result.textureFormatEtc1Npot = decoder0.decodeBool(76, 4); + } + if (mainDataHeader.version >= 0) { + + result.textureRectangle = decoder0.decodeBool(76, 5); + } + if (mainDataHeader.version >= 0) { + + result.iosurface = decoder0.decodeBool(76, 6); + } + if (mainDataHeader.version >= 0) { + + result.textureUsage = decoder0.decodeBool(76, 7); + } + if (mainDataHeader.version >= 0) { + + result.textureStorage = decoder0.decodeBool(77, 0); + } + if (mainDataHeader.version >= 0) { + + result.discardFramebuffer = decoder0.decodeBool(77, 1); + } + if (mainDataHeader.version >= 0) { + + result.syncQuery = decoder0.decodeBool(77, 2); + } + if (mainDataHeader.version >= 0) { + + result.image = decoder0.decodeBool(77, 3); + } + if (mainDataHeader.version >= 0) { + + result.futureSyncPoints = decoder0.decodeBool(77, 4); + } + if (mainDataHeader.version >= 0) { + + result.blendEquationAdvanced = decoder0.decodeBool(77, 5); + } + if (mainDataHeader.version >= 0) { + + result.blendEquationAdvancedCoherent = decoder0.decodeBool(77, 6); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(vertexShaderPrecisions, 8, false); + + encoder0.encodeStruct(fragmentShaderPrecisions, 16, false); + + encoder0.encodeInt32(maxCombinedTextureImageUnits, 24); + + encoder0.encodeInt32(maxCubeMapTextureSize, 28); + + encoder0.encodeInt32(maxFragmentUniformVectors, 32); + + encoder0.encodeInt32(maxRenderbufferSize, 36); + + encoder0.encodeInt32(maxTextureImageUnits, 40); + + encoder0.encodeInt32(maxTextureSize, 44); + + encoder0.encodeInt32(maxVaryingVectors, 48); + + encoder0.encodeInt32(maxVertexAttribs, 52); + + encoder0.encodeInt32(maxVertexTextureImageUnits, 56); + + encoder0.encodeInt32(maxVertexUniformVectors, 60); + + encoder0.encodeInt32(numCompressedTextureFormats, 64); + + encoder0.encodeInt32(numShaderBinaryFormats, 68); + + encoder0.encodeInt32(bindGeneratesResourceChromium, 72); + + encoder0.encodeBool(postSubBuffer, 76, 0); + + encoder0.encodeBool(eglImageExternal, 76, 1); + + encoder0.encodeBool(textureFormatBgra8888, 76, 2); + + encoder0.encodeBool(textureFormatEtc1, 76, 3); + + encoder0.encodeBool(textureFormatEtc1Npot, 76, 4); + + encoder0.encodeBool(textureRectangle, 76, 5); + + encoder0.encodeBool(iosurface, 76, 6); + + encoder0.encodeBool(textureUsage, 76, 7); + + encoder0.encodeBool(textureStorage, 77, 0); + + encoder0.encodeBool(discardFramebuffer, 77, 1); + + encoder0.encodeBool(syncQuery, 77, 2); + + encoder0.encodeBool(image, 77, 3); + + encoder0.encodeBool(futureSyncPoints, 77, 4); + + encoder0.encodeBool(blendEquationAdvanced, 77, 5); + + encoder0.encodeBool(blendEquationAdvancedCoherent, 77, 6); + } + + String toString() { + return "GpuCapabilities(" + "vertexShaderPrecisions: $vertexShaderPrecisions" ", " + "fragmentShaderPrecisions: $fragmentShaderPrecisions" ", " + "maxCombinedTextureImageUnits: $maxCombinedTextureImageUnits" ", " + "maxCubeMapTextureSize: $maxCubeMapTextureSize" ", " + "maxFragmentUniformVectors: $maxFragmentUniformVectors" ", " + "maxRenderbufferSize: $maxRenderbufferSize" ", " + "maxTextureImageUnits: $maxTextureImageUnits" ", " + "maxTextureSize: $maxTextureSize" ", " + "maxVaryingVectors: $maxVaryingVectors" ", " + "maxVertexAttribs: $maxVertexAttribs" ", " + "maxVertexTextureImageUnits: $maxVertexTextureImageUnits" ", " + "maxVertexUniformVectors: $maxVertexUniformVectors" ", " + "numCompressedTextureFormats: $numCompressedTextureFormats" ", " + "numShaderBinaryFormats: $numShaderBinaryFormats" ", " + "bindGeneratesResourceChromium: $bindGeneratesResourceChromium" ", " + "postSubBuffer: $postSubBuffer" ", " + "eglImageExternal: $eglImageExternal" ", " + "textureFormatBgra8888: $textureFormatBgra8888" ", " + "textureFormatEtc1: $textureFormatEtc1" ", " + "textureFormatEtc1Npot: $textureFormatEtc1Npot" ", " + "textureRectangle: $textureRectangle" ", " + "iosurface: $iosurface" ", " + "textureUsage: $textureUsage" ", " + "textureStorage: $textureStorage" ", " + "discardFramebuffer: $discardFramebuffer" ", " + "syncQuery: $syncQuery" ", " + "image: $image" ", " + "futureSyncPoints: $futureSyncPoints" ", " + "blendEquationAdvanced: $blendEquationAdvanced" ", " + "blendEquationAdvancedCoherent: $blendEquationAdvancedCoherent" ")"; + } + + Map toJson() { + Map map = new Map(); + map["vertexShaderPrecisions"] = vertexShaderPrecisions; + map["fragmentShaderPrecisions"] = fragmentShaderPrecisions; + map["maxCombinedTextureImageUnits"] = maxCombinedTextureImageUnits; + map["maxCubeMapTextureSize"] = maxCubeMapTextureSize; + map["maxFragmentUniformVectors"] = maxFragmentUniformVectors; + map["maxRenderbufferSize"] = maxRenderbufferSize; + map["maxTextureImageUnits"] = maxTextureImageUnits; + map["maxTextureSize"] = maxTextureSize; + map["maxVaryingVectors"] = maxVaryingVectors; + map["maxVertexAttribs"] = maxVertexAttribs; + map["maxVertexTextureImageUnits"] = maxVertexTextureImageUnits; + map["maxVertexUniformVectors"] = maxVertexUniformVectors; + map["numCompressedTextureFormats"] = numCompressedTextureFormats; + map["numShaderBinaryFormats"] = numShaderBinaryFormats; + map["bindGeneratesResourceChromium"] = bindGeneratesResourceChromium; + map["postSubBuffer"] = postSubBuffer; + map["eglImageExternal"] = eglImageExternal; + map["textureFormatBgra8888"] = textureFormatBgra8888; + map["textureFormatEtc1"] = textureFormatEtc1; + map["textureFormatEtc1Npot"] = textureFormatEtc1Npot; + map["textureRectangle"] = textureRectangle; + map["iosurface"] = iosurface; + map["textureUsage"] = textureUsage; + map["textureStorage"] = textureStorage; + map["discardFramebuffer"] = discardFramebuffer; + map["syncQuery"] = syncQuery; + map["image"] = image; + map["futureSyncPoints"] = futureSyncPoints; + map["blendEquationAdvanced"] = blendEquationAdvanced; + map["blendEquationAdvancedCoherent"] = blendEquationAdvancedCoherent; + return map; + } +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/host_resolver.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/host_resolver.mojom.dart new file mode 100644 index 0000000..47b703d --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/host_resolver.mojom.dart
@@ -0,0 +1,409 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library host_resolver_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo/mojo/network_error.mojom.dart' as network_error_mojom; +import 'package:mojo_services/mojo/net_address.mojom.dart' as net_address_mojom; + + + +class HostResolverGetHostAddressesParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + String host = null; + net_address_mojom.NetAddressFamily family = null; + + HostResolverGetHostAddressesParams() : super(kVersions.last.size); + + static HostResolverGetHostAddressesParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static HostResolverGetHostAddressesParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + HostResolverGetHostAddressesParams result = new HostResolverGetHostAddressesParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.host = decoder0.decodeString(8, false); + } + if (mainDataHeader.version >= 0) { + + result.family = net_address_mojom.NetAddressFamily.decode(decoder0, 16); + if (result.family == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable net_address_mojom.NetAddressFamily.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(host, 8, false); + + encoder0.encodeEnum(family, 16); + } + + String toString() { + return "HostResolverGetHostAddressesParams(" + "host: $host" ", " + "family: $family" ")"; + } + + Map toJson() { + Map map = new Map(); + map["host"] = host; + map["family"] = family; + return map; + } +} + + +class HostResolverGetHostAddressesResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + network_error_mojom.NetworkError result = null; + List<net_address_mojom.NetAddress> addresses = null; + + HostResolverGetHostAddressesResponseParams() : super(kVersions.last.size); + + static HostResolverGetHostAddressesResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static HostResolverGetHostAddressesResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + HostResolverGetHostAddressesResponseParams result = new HostResolverGetHostAddressesResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.result = network_error_mojom.NetworkError.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, true); + if (decoder1 == null) { + result.addresses = null; + } else { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.addresses = new List<net_address_mojom.NetAddress>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + var decoder2 = decoder1.decodePointer(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + result.addresses[i1] = net_address_mojom.NetAddress.decode(decoder2); + } + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(result, 8, false); + + if (addresses == null) { + encoder0.encodeNullPointer(16, true); + } else { + var encoder1 = encoder0.encodePointerArray(addresses.length, 16, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < addresses.length; ++i0) { + + encoder1.encodeStruct(addresses[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + } + + String toString() { + return "HostResolverGetHostAddressesResponseParams(" + "result: $result" ", " + "addresses: $addresses" ")"; + } + + Map toJson() { + Map map = new Map(); + map["result"] = result; + map["addresses"] = addresses; + return map; + } +} + +const int kHostResolver_getHostAddresses_name = 0; + +const String HostResolverName = + 'mojo::HostResolver'; + +abstract class HostResolver { + dynamic getHostAddresses(String host,net_address_mojom.NetAddressFamily family,[Function responseFactory = null]); + +} + + +class HostResolverProxyImpl extends bindings.Proxy { + HostResolverProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + HostResolverProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + HostResolverProxyImpl.unbound() : super.unbound(); + + static HostResolverProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For HostResolverProxyImpl")); + return new HostResolverProxyImpl.fromEndpoint(endpoint); + } + + String get name => HostResolverName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kHostResolver_getHostAddresses_name: + var r = HostResolverGetHostAddressesResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "HostResolverProxyImpl($superString)"; + } +} + + +class _HostResolverProxyCalls implements HostResolver { + HostResolverProxyImpl _proxyImpl; + + _HostResolverProxyCalls(this._proxyImpl); + dynamic getHostAddresses(String host,net_address_mojom.NetAddressFamily family,[Function responseFactory = null]) { + var params = new HostResolverGetHostAddressesParams(); + params.host = host; + params.family = family; + return _proxyImpl.sendMessageWithRequestId( + params, + kHostResolver_getHostAddresses_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class HostResolverProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + HostResolver ptr; + final String name = HostResolverName; + + HostResolverProxy(HostResolverProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _HostResolverProxyCalls(proxyImpl); + + HostResolverProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new HostResolverProxyImpl.fromEndpoint(endpoint) { + ptr = new _HostResolverProxyCalls(impl); + } + + HostResolverProxy.fromHandle(core.MojoHandle handle) : + impl = new HostResolverProxyImpl.fromHandle(handle) { + ptr = new _HostResolverProxyCalls(impl); + } + + HostResolverProxy.unbound() : + impl = new HostResolverProxyImpl.unbound() { + ptr = new _HostResolverProxyCalls(impl); + } + + factory HostResolverProxy.connectToService( + bindings.ServiceConnector s, String url) { + HostResolverProxy p = new HostResolverProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static HostResolverProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For HostResolverProxy")); + return new HostResolverProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "HostResolverProxy($impl)"; + } +} + + +class HostResolverStub extends bindings.Stub { + HostResolver _impl = null; + + HostResolverStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + HostResolverStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + HostResolverStub.unbound() : super.unbound(); + + static HostResolverStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For HostResolverStub")); + return new HostResolverStub.fromEndpoint(endpoint); + } + + static const String name = HostResolverName; + + + HostResolverGetHostAddressesResponseParams _HostResolverGetHostAddressesResponseParamsFactory(network_error_mojom.NetworkError result, List<net_address_mojom.NetAddress> addresses) { + var result = new HostResolverGetHostAddressesResponseParams(); + result.result = result; + result.addresses = addresses; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kHostResolver_getHostAddresses_name: + var params = HostResolverGetHostAddressesParams.deserialize( + message.payload); + var response = _impl.getHostAddresses(params.host,params.family,_HostResolverGetHostAddressesResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kHostResolver_getHostAddresses_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kHostResolver_getHostAddresses_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + HostResolver get impl => _impl; + set impl(HostResolver d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "HostResolverStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/http_connection.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/http_connection.mojom.dart new file mode 100644 index 0000000..146dfeb --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/http_connection.mojom.dart
@@ -0,0 +1,1119 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library http_connection_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo/mojo/network_error.mojom.dart' as network_error_mojom; +import 'package:mojo_services/mojo/http_message.mojom.dart' as http_message_mojom; +import 'package:mojo_services/mojo/web_socket.mojom.dart' as web_socket_mojom; + + + +class HttpConnectionSetSendBufferSizeParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int size = 0; + + HttpConnectionSetSendBufferSizeParams() : super(kVersions.last.size); + + static HttpConnectionSetSendBufferSizeParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static HttpConnectionSetSendBufferSizeParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + HttpConnectionSetSendBufferSizeParams result = new HttpConnectionSetSendBufferSizeParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.size = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(size, 8); + } + + String toString() { + return "HttpConnectionSetSendBufferSizeParams(" + "size: $size" ")"; + } + + Map toJson() { + Map map = new Map(); + map["size"] = size; + return map; + } +} + + +class HttpConnectionSetSendBufferSizeResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + network_error_mojom.NetworkError result = null; + + HttpConnectionSetSendBufferSizeResponseParams() : super(kVersions.last.size); + + static HttpConnectionSetSendBufferSizeResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static HttpConnectionSetSendBufferSizeResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + HttpConnectionSetSendBufferSizeResponseParams result = new HttpConnectionSetSendBufferSizeResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.result = network_error_mojom.NetworkError.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(result, 8, false); + } + + String toString() { + return "HttpConnectionSetSendBufferSizeResponseParams(" + "result: $result" ")"; + } + + Map toJson() { + Map map = new Map(); + map["result"] = result; + return map; + } +} + + +class HttpConnectionSetReceiveBufferSizeParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int size = 0; + + HttpConnectionSetReceiveBufferSizeParams() : super(kVersions.last.size); + + static HttpConnectionSetReceiveBufferSizeParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static HttpConnectionSetReceiveBufferSizeParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + HttpConnectionSetReceiveBufferSizeParams result = new HttpConnectionSetReceiveBufferSizeParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.size = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(size, 8); + } + + String toString() { + return "HttpConnectionSetReceiveBufferSizeParams(" + "size: $size" ")"; + } + + Map toJson() { + Map map = new Map(); + map["size"] = size; + return map; + } +} + + +class HttpConnectionSetReceiveBufferSizeResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + network_error_mojom.NetworkError result = null; + + HttpConnectionSetReceiveBufferSizeResponseParams() : super(kVersions.last.size); + + static HttpConnectionSetReceiveBufferSizeResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static HttpConnectionSetReceiveBufferSizeResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + HttpConnectionSetReceiveBufferSizeResponseParams result = new HttpConnectionSetReceiveBufferSizeResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.result = network_error_mojom.NetworkError.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(result, 8, false); + } + + String toString() { + return "HttpConnectionSetReceiveBufferSizeResponseParams(" + "result: $result" ")"; + } + + Map toJson() { + Map map = new Map(); + map["result"] = result; + return map; + } +} + + +class HttpConnectionDelegateOnReceivedRequestParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + http_message_mojom.HttpRequest request = null; + + HttpConnectionDelegateOnReceivedRequestParams() : super(kVersions.last.size); + + static HttpConnectionDelegateOnReceivedRequestParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static HttpConnectionDelegateOnReceivedRequestParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + HttpConnectionDelegateOnReceivedRequestParams result = new HttpConnectionDelegateOnReceivedRequestParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.request = http_message_mojom.HttpRequest.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(request, 8, false); + } + + String toString() { + return "HttpConnectionDelegateOnReceivedRequestParams(" + "request: $request" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class HttpConnectionDelegateOnReceivedRequestResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + http_message_mojom.HttpResponse response = null; + + HttpConnectionDelegateOnReceivedRequestResponseParams() : super(kVersions.last.size); + + static HttpConnectionDelegateOnReceivedRequestResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static HttpConnectionDelegateOnReceivedRequestResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + HttpConnectionDelegateOnReceivedRequestResponseParams result = new HttpConnectionDelegateOnReceivedRequestResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.response = http_message_mojom.HttpResponse.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(response, 8, false); + } + + String toString() { + return "HttpConnectionDelegateOnReceivedRequestResponseParams(" + "response: $response" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class HttpConnectionDelegateOnReceivedWebSocketRequestParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + http_message_mojom.HttpRequest request = null; + + HttpConnectionDelegateOnReceivedWebSocketRequestParams() : super(kVersions.last.size); + + static HttpConnectionDelegateOnReceivedWebSocketRequestParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static HttpConnectionDelegateOnReceivedWebSocketRequestParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + HttpConnectionDelegateOnReceivedWebSocketRequestParams result = new HttpConnectionDelegateOnReceivedWebSocketRequestParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.request = http_message_mojom.HttpRequest.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(request, 8, false); + } + + String toString() { + return "HttpConnectionDelegateOnReceivedWebSocketRequestParams(" + "request: $request" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class HttpConnectionDelegateOnReceivedWebSocketRequestResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + Object webSocket = null; + core.MojoDataPipeConsumer sendStream = null; + Object client = null; + + HttpConnectionDelegateOnReceivedWebSocketRequestResponseParams() : super(kVersions.last.size); + + static HttpConnectionDelegateOnReceivedWebSocketRequestResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static HttpConnectionDelegateOnReceivedWebSocketRequestResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + HttpConnectionDelegateOnReceivedWebSocketRequestResponseParams result = new HttpConnectionDelegateOnReceivedWebSocketRequestResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.webSocket = decoder0.decodeInterfaceRequest(8, true, web_socket_mojom.WebSocketStub.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.sendStream = decoder0.decodeConsumerHandle(12, true); + } + if (mainDataHeader.version >= 0) { + + result.client = decoder0.decodeServiceInterface(16, true, web_socket_mojom.WebSocketClientProxy.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterfaceRequest(webSocket, 8, true); + + encoder0.encodeConsumerHandle(sendStream, 12, true); + + encoder0.encodeInterface(client, 16, true); + } + + String toString() { + return "HttpConnectionDelegateOnReceivedWebSocketRequestResponseParams(" + "webSocket: $webSocket" ", " + "sendStream: $sendStream" ", " + "client: $client" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + +const int kHttpConnection_setSendBufferSize_name = 0; +const int kHttpConnection_setReceiveBufferSize_name = 1; + +const String HttpConnectionName = + 'mojo::HttpConnection'; + +abstract class HttpConnection { + dynamic setSendBufferSize(int size,[Function responseFactory = null]); + dynamic setReceiveBufferSize(int size,[Function responseFactory = null]); + +} + + +class HttpConnectionProxyImpl extends bindings.Proxy { + HttpConnectionProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + HttpConnectionProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + HttpConnectionProxyImpl.unbound() : super.unbound(); + + static HttpConnectionProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For HttpConnectionProxyImpl")); + return new HttpConnectionProxyImpl.fromEndpoint(endpoint); + } + + String get name => HttpConnectionName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kHttpConnection_setSendBufferSize_name: + var r = HttpConnectionSetSendBufferSizeResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kHttpConnection_setReceiveBufferSize_name: + var r = HttpConnectionSetReceiveBufferSizeResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "HttpConnectionProxyImpl($superString)"; + } +} + + +class _HttpConnectionProxyCalls implements HttpConnection { + HttpConnectionProxyImpl _proxyImpl; + + _HttpConnectionProxyCalls(this._proxyImpl); + dynamic setSendBufferSize(int size,[Function responseFactory = null]) { + var params = new HttpConnectionSetSendBufferSizeParams(); + params.size = size; + return _proxyImpl.sendMessageWithRequestId( + params, + kHttpConnection_setSendBufferSize_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic setReceiveBufferSize(int size,[Function responseFactory = null]) { + var params = new HttpConnectionSetReceiveBufferSizeParams(); + params.size = size; + return _proxyImpl.sendMessageWithRequestId( + params, + kHttpConnection_setReceiveBufferSize_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class HttpConnectionProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + HttpConnection ptr; + final String name = HttpConnectionName; + + HttpConnectionProxy(HttpConnectionProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _HttpConnectionProxyCalls(proxyImpl); + + HttpConnectionProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new HttpConnectionProxyImpl.fromEndpoint(endpoint) { + ptr = new _HttpConnectionProxyCalls(impl); + } + + HttpConnectionProxy.fromHandle(core.MojoHandle handle) : + impl = new HttpConnectionProxyImpl.fromHandle(handle) { + ptr = new _HttpConnectionProxyCalls(impl); + } + + HttpConnectionProxy.unbound() : + impl = new HttpConnectionProxyImpl.unbound() { + ptr = new _HttpConnectionProxyCalls(impl); + } + + factory HttpConnectionProxy.connectToService( + bindings.ServiceConnector s, String url) { + HttpConnectionProxy p = new HttpConnectionProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static HttpConnectionProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For HttpConnectionProxy")); + return new HttpConnectionProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "HttpConnectionProxy($impl)"; + } +} + + +class HttpConnectionStub extends bindings.Stub { + HttpConnection _impl = null; + + HttpConnectionStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + HttpConnectionStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + HttpConnectionStub.unbound() : super.unbound(); + + static HttpConnectionStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For HttpConnectionStub")); + return new HttpConnectionStub.fromEndpoint(endpoint); + } + + static const String name = HttpConnectionName; + + + HttpConnectionSetSendBufferSizeResponseParams _HttpConnectionSetSendBufferSizeResponseParamsFactory(network_error_mojom.NetworkError result) { + var result = new HttpConnectionSetSendBufferSizeResponseParams(); + result.result = result; + return result; + } + HttpConnectionSetReceiveBufferSizeResponseParams _HttpConnectionSetReceiveBufferSizeResponseParamsFactory(network_error_mojom.NetworkError result) { + var result = new HttpConnectionSetReceiveBufferSizeResponseParams(); + result.result = result; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kHttpConnection_setSendBufferSize_name: + var params = HttpConnectionSetSendBufferSizeParams.deserialize( + message.payload); + var response = _impl.setSendBufferSize(params.size,_HttpConnectionSetSendBufferSizeResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kHttpConnection_setSendBufferSize_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kHttpConnection_setSendBufferSize_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kHttpConnection_setReceiveBufferSize_name: + var params = HttpConnectionSetReceiveBufferSizeParams.deserialize( + message.payload); + var response = _impl.setReceiveBufferSize(params.size,_HttpConnectionSetReceiveBufferSizeResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kHttpConnection_setReceiveBufferSize_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kHttpConnection_setReceiveBufferSize_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + HttpConnection get impl => _impl; + set impl(HttpConnection d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "HttpConnectionStub($superString)"; + } + + int get version => 0; +} + +const int kHttpConnectionDelegate_onReceivedRequest_name = 0; +const int kHttpConnectionDelegate_onReceivedWebSocketRequest_name = 1; + +const String HttpConnectionDelegateName = + 'mojo::HttpConnectionDelegate'; + +abstract class HttpConnectionDelegate { + dynamic onReceivedRequest(http_message_mojom.HttpRequest request,[Function responseFactory = null]); + dynamic onReceivedWebSocketRequest(http_message_mojom.HttpRequest request,[Function responseFactory = null]); + +} + + +class HttpConnectionDelegateProxyImpl extends bindings.Proxy { + HttpConnectionDelegateProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + HttpConnectionDelegateProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + HttpConnectionDelegateProxyImpl.unbound() : super.unbound(); + + static HttpConnectionDelegateProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For HttpConnectionDelegateProxyImpl")); + return new HttpConnectionDelegateProxyImpl.fromEndpoint(endpoint); + } + + String get name => HttpConnectionDelegateName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kHttpConnectionDelegate_onReceivedRequest_name: + var r = HttpConnectionDelegateOnReceivedRequestResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kHttpConnectionDelegate_onReceivedWebSocketRequest_name: + var r = HttpConnectionDelegateOnReceivedWebSocketRequestResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "HttpConnectionDelegateProxyImpl($superString)"; + } +} + + +class _HttpConnectionDelegateProxyCalls implements HttpConnectionDelegate { + HttpConnectionDelegateProxyImpl _proxyImpl; + + _HttpConnectionDelegateProxyCalls(this._proxyImpl); + dynamic onReceivedRequest(http_message_mojom.HttpRequest request,[Function responseFactory = null]) { + var params = new HttpConnectionDelegateOnReceivedRequestParams(); + params.request = request; + return _proxyImpl.sendMessageWithRequestId( + params, + kHttpConnectionDelegate_onReceivedRequest_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic onReceivedWebSocketRequest(http_message_mojom.HttpRequest request,[Function responseFactory = null]) { + var params = new HttpConnectionDelegateOnReceivedWebSocketRequestParams(); + params.request = request; + return _proxyImpl.sendMessageWithRequestId( + params, + kHttpConnectionDelegate_onReceivedWebSocketRequest_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class HttpConnectionDelegateProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + HttpConnectionDelegate ptr; + final String name = HttpConnectionDelegateName; + + HttpConnectionDelegateProxy(HttpConnectionDelegateProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _HttpConnectionDelegateProxyCalls(proxyImpl); + + HttpConnectionDelegateProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new HttpConnectionDelegateProxyImpl.fromEndpoint(endpoint) { + ptr = new _HttpConnectionDelegateProxyCalls(impl); + } + + HttpConnectionDelegateProxy.fromHandle(core.MojoHandle handle) : + impl = new HttpConnectionDelegateProxyImpl.fromHandle(handle) { + ptr = new _HttpConnectionDelegateProxyCalls(impl); + } + + HttpConnectionDelegateProxy.unbound() : + impl = new HttpConnectionDelegateProxyImpl.unbound() { + ptr = new _HttpConnectionDelegateProxyCalls(impl); + } + + factory HttpConnectionDelegateProxy.connectToService( + bindings.ServiceConnector s, String url) { + HttpConnectionDelegateProxy p = new HttpConnectionDelegateProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static HttpConnectionDelegateProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For HttpConnectionDelegateProxy")); + return new HttpConnectionDelegateProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "HttpConnectionDelegateProxy($impl)"; + } +} + + +class HttpConnectionDelegateStub extends bindings.Stub { + HttpConnectionDelegate _impl = null; + + HttpConnectionDelegateStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + HttpConnectionDelegateStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + HttpConnectionDelegateStub.unbound() : super.unbound(); + + static HttpConnectionDelegateStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For HttpConnectionDelegateStub")); + return new HttpConnectionDelegateStub.fromEndpoint(endpoint); + } + + static const String name = HttpConnectionDelegateName; + + + HttpConnectionDelegateOnReceivedRequestResponseParams _HttpConnectionDelegateOnReceivedRequestResponseParamsFactory(http_message_mojom.HttpResponse response) { + var result = new HttpConnectionDelegateOnReceivedRequestResponseParams(); + result.response = response; + return result; + } + HttpConnectionDelegateOnReceivedWebSocketRequestResponseParams _HttpConnectionDelegateOnReceivedWebSocketRequestResponseParamsFactory(Object webSocket, core.MojoDataPipeConsumer sendStream, Object client) { + var result = new HttpConnectionDelegateOnReceivedWebSocketRequestResponseParams(); + result.webSocket = webSocket; + result.sendStream = sendStream; + result.client = client; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kHttpConnectionDelegate_onReceivedRequest_name: + var params = HttpConnectionDelegateOnReceivedRequestParams.deserialize( + message.payload); + var response = _impl.onReceivedRequest(params.request,_HttpConnectionDelegateOnReceivedRequestResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kHttpConnectionDelegate_onReceivedRequest_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kHttpConnectionDelegate_onReceivedRequest_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kHttpConnectionDelegate_onReceivedWebSocketRequest_name: + var params = HttpConnectionDelegateOnReceivedWebSocketRequestParams.deserialize( + message.payload); + var response = _impl.onReceivedWebSocketRequest(params.request,_HttpConnectionDelegateOnReceivedWebSocketRequestResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kHttpConnectionDelegate_onReceivedWebSocketRequest_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kHttpConnectionDelegate_onReceivedWebSocketRequest_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + HttpConnectionDelegate get impl => _impl; + set impl(HttpConnectionDelegate d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "HttpConnectionDelegateStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/http_message.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/http_message.mojom.dart new file mode 100644 index 0000000..959db5c --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/http_message.mojom.dart
@@ -0,0 +1,224 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library http_message_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo/mojo/http_header.mojom.dart' as http_header_mojom; + + + +class HttpRequest extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(40, 0) + ]; + String method = "GET"; + String url = null; + List<http_header_mojom.HttpHeader> headers = null; + core.MojoDataPipeConsumer body = null; + + HttpRequest() : super(kVersions.last.size); + + static HttpRequest deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static HttpRequest decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + HttpRequest result = new HttpRequest(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.method = decoder0.decodeString(8, false); + } + if (mainDataHeader.version >= 0) { + + result.url = decoder0.decodeString(16, false); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(24, true); + if (decoder1 == null) { + result.headers = null; + } else { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.headers = new List<http_header_mojom.HttpHeader>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + var decoder2 = decoder1.decodePointer(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + result.headers[i1] = http_header_mojom.HttpHeader.decode(decoder2); + } + } + } + if (mainDataHeader.version >= 0) { + + result.body = decoder0.decodeConsumerHandle(32, true); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(method, 8, false); + + encoder0.encodeString(url, 16, false); + + if (headers == null) { + encoder0.encodeNullPointer(24, true); + } else { + var encoder1 = encoder0.encodePointerArray(headers.length, 24, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < headers.length; ++i0) { + + encoder1.encodeStruct(headers[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + + encoder0.encodeConsumerHandle(body, 32, true); + } + + String toString() { + return "HttpRequest(" + "method: $method" ", " + "url: $url" ", " + "headers: $headers" ", " + "body: $body" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class HttpResponse extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int statusCode = 200; + core.MojoDataPipeConsumer body = null; + List<http_header_mojom.HttpHeader> headers = null; + + HttpResponse() : super(kVersions.last.size); + + static HttpResponse deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static HttpResponse decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + HttpResponse result = new HttpResponse(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.statusCode = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + result.body = decoder0.decodeConsumerHandle(12, true); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, true); + if (decoder1 == null) { + result.headers = null; + } else { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.headers = new List<http_header_mojom.HttpHeader>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + var decoder2 = decoder1.decodePointer(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + result.headers[i1] = http_header_mojom.HttpHeader.decode(decoder2); + } + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(statusCode, 8); + + encoder0.encodeConsumerHandle(body, 12, true); + + if (headers == null) { + encoder0.encodeNullPointer(16, true); + } else { + var encoder1 = encoder0.encodePointerArray(headers.length, 16, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < headers.length; ++i0) { + + encoder1.encodeStruct(headers[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + } + + String toString() { + return "HttpResponse(" + "statusCode: $statusCode" ", " + "body: $body" ", " + "headers: $headers" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/http_server.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/http_server.mojom.dart new file mode 100644 index 0000000..ee107e2 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/http_server.mojom.dart
@@ -0,0 +1,264 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library http_server_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo_services/mojo/http_connection.mojom.dart' as http_connection_mojom; + + + +class HttpServerDelegateOnConnectedParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + Object connection = null; + Object delegate = null; + + HttpServerDelegateOnConnectedParams() : super(kVersions.last.size); + + static HttpServerDelegateOnConnectedParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static HttpServerDelegateOnConnectedParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + HttpServerDelegateOnConnectedParams result = new HttpServerDelegateOnConnectedParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.connection = decoder0.decodeServiceInterface(8, false, http_connection_mojom.HttpConnectionProxy.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.delegate = decoder0.decodeInterfaceRequest(16, false, http_connection_mojom.HttpConnectionDelegateStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterface(connection, 8, false); + + encoder0.encodeInterfaceRequest(delegate, 16, false); + } + + String toString() { + return "HttpServerDelegateOnConnectedParams(" + "connection: $connection" ", " + "delegate: $delegate" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + +const int kHttpServerDelegate_onConnected_name = 0; + +const String HttpServerDelegateName = + 'mojo::HttpServerDelegate'; + +abstract class HttpServerDelegate { + void onConnected(Object connection, Object delegate); + +} + + +class HttpServerDelegateProxyImpl extends bindings.Proxy { + HttpServerDelegateProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + HttpServerDelegateProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + HttpServerDelegateProxyImpl.unbound() : super.unbound(); + + static HttpServerDelegateProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For HttpServerDelegateProxyImpl")); + return new HttpServerDelegateProxyImpl.fromEndpoint(endpoint); + } + + String get name => HttpServerDelegateName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "HttpServerDelegateProxyImpl($superString)"; + } +} + + +class _HttpServerDelegateProxyCalls implements HttpServerDelegate { + HttpServerDelegateProxyImpl _proxyImpl; + + _HttpServerDelegateProxyCalls(this._proxyImpl); + void onConnected(Object connection, Object delegate) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new HttpServerDelegateOnConnectedParams(); + params.connection = connection; + params.delegate = delegate; + _proxyImpl.sendMessage(params, kHttpServerDelegate_onConnected_name); + } + +} + + +class HttpServerDelegateProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + HttpServerDelegate ptr; + final String name = HttpServerDelegateName; + + HttpServerDelegateProxy(HttpServerDelegateProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _HttpServerDelegateProxyCalls(proxyImpl); + + HttpServerDelegateProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new HttpServerDelegateProxyImpl.fromEndpoint(endpoint) { + ptr = new _HttpServerDelegateProxyCalls(impl); + } + + HttpServerDelegateProxy.fromHandle(core.MojoHandle handle) : + impl = new HttpServerDelegateProxyImpl.fromHandle(handle) { + ptr = new _HttpServerDelegateProxyCalls(impl); + } + + HttpServerDelegateProxy.unbound() : + impl = new HttpServerDelegateProxyImpl.unbound() { + ptr = new _HttpServerDelegateProxyCalls(impl); + } + + factory HttpServerDelegateProxy.connectToService( + bindings.ServiceConnector s, String url) { + HttpServerDelegateProxy p = new HttpServerDelegateProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static HttpServerDelegateProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For HttpServerDelegateProxy")); + return new HttpServerDelegateProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "HttpServerDelegateProxy($impl)"; + } +} + + +class HttpServerDelegateStub extends bindings.Stub { + HttpServerDelegate _impl = null; + + HttpServerDelegateStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + HttpServerDelegateStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + HttpServerDelegateStub.unbound() : super.unbound(); + + static HttpServerDelegateStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For HttpServerDelegateStub")); + return new HttpServerDelegateStub.fromEndpoint(endpoint); + } + + static const String name = HttpServerDelegateName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kHttpServerDelegate_onConnected_name: + var params = HttpServerDelegateOnConnectedParams.deserialize( + message.payload); + _impl.onConnected(params.connection, params.delegate); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + HttpServerDelegate get impl => _impl; + set impl(HttpServerDelegate d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "HttpServerDelegateStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/input_event_constants.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/input_event_constants.mojom.dart new file mode 100644 index 0000000..757541a --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/input_event_constants.mojom.dart
@@ -0,0 +1,328 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library input_event_constants_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +class EventType extends bindings.MojoEnum { + static const UNKNOWN = const EventType._(0); + static const KEY_PRESSED = const EventType._(1); + static const KEY_RELEASED = const EventType._(2); + static const POINTER_CANCEL = const EventType._(3); + static const POINTER_DOWN = const EventType._(4); + static const POINTER_MOVE = const EventType._(5); + static const POINTER_UP = const EventType._(6); + + const EventType._(int v) : super(v); + + static const Map<String, EventType> valuesMap = const { + "UNKNOWN": UNKNOWN, + "KEY_PRESSED": KEY_PRESSED, + "KEY_RELEASED": KEY_RELEASED, + "POINTER_CANCEL": POINTER_CANCEL, + "POINTER_DOWN": POINTER_DOWN, + "POINTER_MOVE": POINTER_MOVE, + "POINTER_UP": POINTER_UP, + }; + static const List<EventType> values = const [ + UNKNOWN, + KEY_PRESSED, + KEY_RELEASED, + POINTER_CANCEL, + POINTER_DOWN, + POINTER_MOVE, + POINTER_UP, + ]; + + static EventType valueOf(String name) => valuesMap[name]; + + factory EventType(int v) { + switch (v) { + case 0: + return UNKNOWN; + case 1: + return KEY_PRESSED; + case 2: + return KEY_RELEASED; + case 3: + return POINTER_CANCEL; + case 4: + return POINTER_DOWN; + case 5: + return POINTER_MOVE; + case 6: + return POINTER_UP; + default: + return null; + } + } + + static EventType decode(bindings.Decoder decoder0, int offset) { + int v = decoder0.decodeUint32(offset); + EventType result = new EventType(v); + if (result == null) { + throw new bindings.MojoCodecError( + 'Bad value $v for enum EventType.'); + } + return result; + } + + String toString() { + switch(this) { + case UNKNOWN: + return 'EventType.UNKNOWN'; + case KEY_PRESSED: + return 'EventType.KEY_PRESSED'; + case KEY_RELEASED: + return 'EventType.KEY_RELEASED'; + case POINTER_CANCEL: + return 'EventType.POINTER_CANCEL'; + case POINTER_DOWN: + return 'EventType.POINTER_DOWN'; + case POINTER_MOVE: + return 'EventType.POINTER_MOVE'; + case POINTER_UP: + return 'EventType.POINTER_UP'; + } + } + + int toJson() => value; +} +class EventFlags extends bindings.MojoEnum { + static const NONE = const EventFlags._(0); + static const CAPS_LOCK_DOWN = const EventFlags._(1); + static const SHIFT_DOWN = const EventFlags._(2); + static const CONTROL_DOWN = const EventFlags._(4); + static const ALT_DOWN = const EventFlags._(8); + static const LEFT_MOUSE_BUTTON = const EventFlags._(16); + static const MIDDLE_MOUSE_BUTTON = const EventFlags._(32); + static const RIGHT_MOUSE_BUTTON = const EventFlags._(64); + static const COMMAND_DOWN = const EventFlags._(128); + static const EXTENDED = const EventFlags._(256); + static const IS_SYNTHESIZED = const EventFlags._(512); + static const ALTGR_DOWN = const EventFlags._(1024); + static const MOD3_DOWN = const EventFlags._(2048); + + const EventFlags._(int v) : super(v); + + static const Map<String, EventFlags> valuesMap = const { + "NONE": NONE, + "CAPS_LOCK_DOWN": CAPS_LOCK_DOWN, + "SHIFT_DOWN": SHIFT_DOWN, + "CONTROL_DOWN": CONTROL_DOWN, + "ALT_DOWN": ALT_DOWN, + "LEFT_MOUSE_BUTTON": LEFT_MOUSE_BUTTON, + "MIDDLE_MOUSE_BUTTON": MIDDLE_MOUSE_BUTTON, + "RIGHT_MOUSE_BUTTON": RIGHT_MOUSE_BUTTON, + "COMMAND_DOWN": COMMAND_DOWN, + "EXTENDED": EXTENDED, + "IS_SYNTHESIZED": IS_SYNTHESIZED, + "ALTGR_DOWN": ALTGR_DOWN, + "MOD3_DOWN": MOD3_DOWN, + }; + static const List<EventFlags> values = const [ + NONE, + CAPS_LOCK_DOWN, + SHIFT_DOWN, + CONTROL_DOWN, + ALT_DOWN, + LEFT_MOUSE_BUTTON, + MIDDLE_MOUSE_BUTTON, + RIGHT_MOUSE_BUTTON, + COMMAND_DOWN, + EXTENDED, + IS_SYNTHESIZED, + ALTGR_DOWN, + MOD3_DOWN, + ]; + + static EventFlags valueOf(String name) => valuesMap[name]; + + factory EventFlags(int v) { + switch (v) { + case 0: + return NONE; + case 1: + return CAPS_LOCK_DOWN; + case 2: + return SHIFT_DOWN; + case 4: + return CONTROL_DOWN; + case 8: + return ALT_DOWN; + case 16: + return LEFT_MOUSE_BUTTON; + case 32: + return MIDDLE_MOUSE_BUTTON; + case 64: + return RIGHT_MOUSE_BUTTON; + case 128: + return COMMAND_DOWN; + case 256: + return EXTENDED; + case 512: + return IS_SYNTHESIZED; + case 1024: + return ALTGR_DOWN; + case 2048: + return MOD3_DOWN; + default: + return null; + } + } + + static EventFlags decode(bindings.Decoder decoder0, int offset) { + int v = decoder0.decodeUint32(offset); + EventFlags result = new EventFlags(v); + if (result == null) { + throw new bindings.MojoCodecError( + 'Bad value $v for enum EventFlags.'); + } + return result; + } + + String toString() { + switch(this) { + case NONE: + return 'EventFlags.NONE'; + case CAPS_LOCK_DOWN: + return 'EventFlags.CAPS_LOCK_DOWN'; + case SHIFT_DOWN: + return 'EventFlags.SHIFT_DOWN'; + case CONTROL_DOWN: + return 'EventFlags.CONTROL_DOWN'; + case ALT_DOWN: + return 'EventFlags.ALT_DOWN'; + case LEFT_MOUSE_BUTTON: + return 'EventFlags.LEFT_MOUSE_BUTTON'; + case MIDDLE_MOUSE_BUTTON: + return 'EventFlags.MIDDLE_MOUSE_BUTTON'; + case RIGHT_MOUSE_BUTTON: + return 'EventFlags.RIGHT_MOUSE_BUTTON'; + case COMMAND_DOWN: + return 'EventFlags.COMMAND_DOWN'; + case EXTENDED: + return 'EventFlags.EXTENDED'; + case IS_SYNTHESIZED: + return 'EventFlags.IS_SYNTHESIZED'; + case ALTGR_DOWN: + return 'EventFlags.ALTGR_DOWN'; + case MOD3_DOWN: + return 'EventFlags.MOD3_DOWN'; + } + } + + int toJson() => value; +} +class MouseEventFlags extends bindings.MojoEnum { + static const IS_DOUBLE_CLICK = const MouseEventFlags._(65536); + static const IS_TRIPLE_CLICK = const MouseEventFlags._(131072); + static const IS_NON_CLIENT = const MouseEventFlags._(262144); + + const MouseEventFlags._(int v) : super(v); + + static const Map<String, MouseEventFlags> valuesMap = const { + "IS_DOUBLE_CLICK": IS_DOUBLE_CLICK, + "IS_TRIPLE_CLICK": IS_TRIPLE_CLICK, + "IS_NON_CLIENT": IS_NON_CLIENT, + }; + static const List<MouseEventFlags> values = const [ + IS_DOUBLE_CLICK, + IS_TRIPLE_CLICK, + IS_NON_CLIENT, + ]; + + static MouseEventFlags valueOf(String name) => valuesMap[name]; + + factory MouseEventFlags(int v) { + switch (v) { + case 65536: + return IS_DOUBLE_CLICK; + case 131072: + return IS_TRIPLE_CLICK; + case 262144: + return IS_NON_CLIENT; + default: + return null; + } + } + + static MouseEventFlags decode(bindings.Decoder decoder0, int offset) { + int v = decoder0.decodeUint32(offset); + MouseEventFlags result = new MouseEventFlags(v); + if (result == null) { + throw new bindings.MojoCodecError( + 'Bad value $v for enum MouseEventFlags.'); + } + return result; + } + + String toString() { + switch(this) { + case IS_DOUBLE_CLICK: + return 'MouseEventFlags.IS_DOUBLE_CLICK'; + case IS_TRIPLE_CLICK: + return 'MouseEventFlags.IS_TRIPLE_CLICK'; + case IS_NON_CLIENT: + return 'MouseEventFlags.IS_NON_CLIENT'; + } + } + + int toJson() => value; +} +class PointerKind extends bindings.MojoEnum { + static const TOUCH = const PointerKind._(0); + static const MOUSE = const PointerKind._(1); + + const PointerKind._(int v) : super(v); + + static const Map<String, PointerKind> valuesMap = const { + "TOUCH": TOUCH, + "MOUSE": MOUSE, + }; + static const List<PointerKind> values = const [ + TOUCH, + MOUSE, + ]; + + static PointerKind valueOf(String name) => valuesMap[name]; + + factory PointerKind(int v) { + switch (v) { + case 0: + return TOUCH; + case 1: + return MOUSE; + default: + return null; + } + } + + static PointerKind decode(bindings.Decoder decoder0, int offset) { + int v = decoder0.decodeUint32(offset); + PointerKind result = new PointerKind(v); + if (result == null) { + throw new bindings.MojoCodecError( + 'Bad value $v for enum PointerKind.'); + } + return result; + } + + String toString() { + switch(this) { + case TOUCH: + return 'PointerKind.TOUCH'; + case MOUSE: + return 'PointerKind.MOUSE'; + } + } + + int toJson() => value; +} + + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/input_events.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/input_events.mojom.dart new file mode 100644 index 0000000..6ac0aeb --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/input_events.mojom.dart
@@ -0,0 +1,424 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library input_events_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo_services/mojo/geometry.mojom.dart' as geometry_mojom; +import 'package:mojo_services/mojo/input_event_constants.mojom.dart' as input_event_constants_mojom; +import 'package:mojo_services/mojo/input_key_codes.mojom.dart' as input_key_codes_mojom; + + + +class KeyData extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(32, 0) + ]; + int keyCode = 0; + bool isChar = false; + int character = 0; + input_key_codes_mojom.KeyboardCode windowsKeyCode = null; + int nativeKeyCode = 0; + int text = 0; + int unmodifiedText = 0; + + KeyData() : super(kVersions.last.size); + + static KeyData deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static KeyData decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + KeyData result = new KeyData(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.keyCode = decoder0.decodeInt32(8); + } + if (mainDataHeader.version >= 0) { + + result.isChar = decoder0.decodeBool(12, 0); + } + if (mainDataHeader.version >= 0) { + + result.character = decoder0.decodeUint16(14); + } + if (mainDataHeader.version >= 0) { + + result.windowsKeyCode = input_key_codes_mojom.KeyboardCode.decode(decoder0, 16); + if (result.windowsKeyCode == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable input_key_codes_mojom.KeyboardCode.'); + } + } + if (mainDataHeader.version >= 0) { + + result.nativeKeyCode = decoder0.decodeInt32(20); + } + if (mainDataHeader.version >= 0) { + + result.text = decoder0.decodeUint16(24); + } + if (mainDataHeader.version >= 0) { + + result.unmodifiedText = decoder0.decodeUint16(26); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt32(keyCode, 8); + + encoder0.encodeBool(isChar, 12, 0); + + encoder0.encodeUint16(character, 14); + + encoder0.encodeEnum(windowsKeyCode, 16); + + encoder0.encodeInt32(nativeKeyCode, 20); + + encoder0.encodeUint16(text, 24); + + encoder0.encodeUint16(unmodifiedText, 26); + } + + String toString() { + return "KeyData(" + "keyCode: $keyCode" ", " + "isChar: $isChar" ", " + "character: $character" ", " + "windowsKeyCode: $windowsKeyCode" ", " + "nativeKeyCode: $nativeKeyCode" ", " + "text: $text" ", " + "unmodifiedText: $unmodifiedText" ")"; + } + + Map toJson() { + Map map = new Map(); + map["keyCode"] = keyCode; + map["isChar"] = isChar; + map["character"] = character; + map["windowsKeyCode"] = windowsKeyCode; + map["nativeKeyCode"] = nativeKeyCode; + map["text"] = text; + map["unmodifiedText"] = unmodifiedText; + return map; + } +} + + +class PointerData extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(56, 0) + ]; + int pointerId = 0; + input_event_constants_mojom.PointerKind kind = null; + double x = 0.0; + double y = 0.0; + double screenX = 0.0; + double screenY = 0.0; + double pressure = 0.0; + double radiusMajor = 0.0; + double radiusMinor = 0.0; + double orientation = 0.0; + double horizontalWheel = 0.0; + double verticalWheel = 0.0; + + PointerData() : super(kVersions.last.size); + + static PointerData deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static PointerData decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + PointerData result = new PointerData(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.pointerId = decoder0.decodeInt32(8); + } + if (mainDataHeader.version >= 0) { + + result.kind = input_event_constants_mojom.PointerKind.decode(decoder0, 12); + if (result.kind == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable input_event_constants_mojom.PointerKind.'); + } + } + if (mainDataHeader.version >= 0) { + + result.x = decoder0.decodeFloat(16); + } + if (mainDataHeader.version >= 0) { + + result.y = decoder0.decodeFloat(20); + } + if (mainDataHeader.version >= 0) { + + result.screenX = decoder0.decodeFloat(24); + } + if (mainDataHeader.version >= 0) { + + result.screenY = decoder0.decodeFloat(28); + } + if (mainDataHeader.version >= 0) { + + result.pressure = decoder0.decodeFloat(32); + } + if (mainDataHeader.version >= 0) { + + result.radiusMajor = decoder0.decodeFloat(36); + } + if (mainDataHeader.version >= 0) { + + result.radiusMinor = decoder0.decodeFloat(40); + } + if (mainDataHeader.version >= 0) { + + result.orientation = decoder0.decodeFloat(44); + } + if (mainDataHeader.version >= 0) { + + result.horizontalWheel = decoder0.decodeFloat(48); + } + if (mainDataHeader.version >= 0) { + + result.verticalWheel = decoder0.decodeFloat(52); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt32(pointerId, 8); + + encoder0.encodeEnum(kind, 12); + + encoder0.encodeFloat(x, 16); + + encoder0.encodeFloat(y, 20); + + encoder0.encodeFloat(screenX, 24); + + encoder0.encodeFloat(screenY, 28); + + encoder0.encodeFloat(pressure, 32); + + encoder0.encodeFloat(radiusMajor, 36); + + encoder0.encodeFloat(radiusMinor, 40); + + encoder0.encodeFloat(orientation, 44); + + encoder0.encodeFloat(horizontalWheel, 48); + + encoder0.encodeFloat(verticalWheel, 52); + } + + String toString() { + return "PointerData(" + "pointerId: $pointerId" ", " + "kind: $kind" ", " + "x: $x" ", " + "y: $y" ", " + "screenX: $screenX" ", " + "screenY: $screenY" ", " + "pressure: $pressure" ", " + "radiusMajor: $radiusMajor" ", " + "radiusMinor: $radiusMinor" ", " + "orientation: $orientation" ", " + "horizontalWheel: $horizontalWheel" ", " + "verticalWheel: $verticalWheel" ")"; + } + + Map toJson() { + Map map = new Map(); + map["pointerId"] = pointerId; + map["kind"] = kind; + map["x"] = x; + map["y"] = y; + map["screenX"] = screenX; + map["screenY"] = screenY; + map["pressure"] = pressure; + map["radiusMajor"] = radiusMajor; + map["radiusMinor"] = radiusMinor; + map["orientation"] = orientation; + map["horizontalWheel"] = horizontalWheel; + map["verticalWheel"] = verticalWheel; + return map; + } +} + + +class Event extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(40, 0) + ]; + input_event_constants_mojom.EventType action = null; + input_event_constants_mojom.EventFlags flags = null; + int timeStamp = 0; + KeyData keyData = null; + PointerData pointerData = null; + + Event() : super(kVersions.last.size); + + static Event deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static Event decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + Event result = new Event(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.action = input_event_constants_mojom.EventType.decode(decoder0, 8); + if (result.action == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable input_event_constants_mojom.EventType.'); + } + } + if (mainDataHeader.version >= 0) { + + result.flags = input_event_constants_mojom.EventFlags.decode(decoder0, 12); + if (result.flags == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable input_event_constants_mojom.EventFlags.'); + } + } + if (mainDataHeader.version >= 0) { + + result.timeStamp = decoder0.decodeInt64(16); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(24, true); + result.keyData = KeyData.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(32, true); + result.pointerData = PointerData.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(action, 8); + + encoder0.encodeEnum(flags, 12); + + encoder0.encodeInt64(timeStamp, 16); + + encoder0.encodeStruct(keyData, 24, true); + + encoder0.encodeStruct(pointerData, 32, true); + } + + String toString() { + return "Event(" + "action: $action" ", " + "flags: $flags" ", " + "timeStamp: $timeStamp" ", " + "keyData: $keyData" ", " + "pointerData: $pointerData" ")"; + } + + Map toJson() { + Map map = new Map(); + map["action"] = action; + map["flags"] = flags; + map["timeStamp"] = timeStamp; + map["keyData"] = keyData; + map["pointerData"] = pointerData; + return map; + } +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/input_key_codes.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/input_key_codes.mojom.dart new file mode 100644 index 0000000..04a8109 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/input_key_codes.mojom.dart
@@ -0,0 +1,1245 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library input_key_codes_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +class KeyboardCode extends bindings.MojoEnum { + static const BACK = const KeyboardCode._(8); + static const TAB = const KeyboardCode._(9); + static const CLEAR = const KeyboardCode._(12); + static const RETURN = const KeyboardCode._(13); + static const SHIFT = const KeyboardCode._(16); + static const CONTROL = const KeyboardCode._(17); + static const MENU = const KeyboardCode._(18); + static const PAUSE = const KeyboardCode._(19); + static const CAPITAL = const KeyboardCode._(20); + static const KANA = const KeyboardCode._(21); + static const HANGUL = const KeyboardCode._(21); + static const JUNJA = const KeyboardCode._(23); + static const FINAL = const KeyboardCode._(24); + static const HANJA = const KeyboardCode._(25); + static const KANJI = const KeyboardCode._(25); + static const ESCAPE = const KeyboardCode._(27); + static const CONVERT = const KeyboardCode._(28); + static const NONCONVERT = const KeyboardCode._(29); + static const ACCEPT = const KeyboardCode._(30); + static const MODECHANGE = const KeyboardCode._(31); + static const SPACE = const KeyboardCode._(32); + static const PRIOR = const KeyboardCode._(33); + static const NEXT = const KeyboardCode._(34); + static const END = const KeyboardCode._(35); + static const HOME = const KeyboardCode._(36); + static const LEFT = const KeyboardCode._(37); + static const UP = const KeyboardCode._(38); + static const RIGHT = const KeyboardCode._(39); + static const DOWN = const KeyboardCode._(40); + static const SELECT = const KeyboardCode._(41); + static const PRINT = const KeyboardCode._(42); + static const EXECUTE = const KeyboardCode._(43); + static const SNAPSHOT = const KeyboardCode._(44); + static const INSERT = const KeyboardCode._(45); + static const DELETE = const KeyboardCode._(46); + static const HELP = const KeyboardCode._(47); + static const NUM_0 = const KeyboardCode._(48); + static const NUM_1 = const KeyboardCode._(49); + static const NUM_2 = const KeyboardCode._(50); + static const NUM_3 = const KeyboardCode._(51); + static const NUM_4 = const KeyboardCode._(52); + static const NUM_5 = const KeyboardCode._(53); + static const NUM_6 = const KeyboardCode._(54); + static const NUM_7 = const KeyboardCode._(55); + static const NUM_8 = const KeyboardCode._(56); + static const NUM_9 = const KeyboardCode._(57); + static const A = const KeyboardCode._(65); + static const B = const KeyboardCode._(66); + static const C = const KeyboardCode._(67); + static const D = const KeyboardCode._(68); + static const E = const KeyboardCode._(69); + static const F = const KeyboardCode._(70); + static const G = const KeyboardCode._(71); + static const H = const KeyboardCode._(72); + static const I = const KeyboardCode._(73); + static const J = const KeyboardCode._(74); + static const K = const KeyboardCode._(75); + static const L = const KeyboardCode._(76); + static const M = const KeyboardCode._(77); + static const N = const KeyboardCode._(78); + static const O = const KeyboardCode._(79); + static const P = const KeyboardCode._(80); + static const Q = const KeyboardCode._(81); + static const R = const KeyboardCode._(82); + static const S = const KeyboardCode._(83); + static const T = const KeyboardCode._(84); + static const U = const KeyboardCode._(85); + static const V = const KeyboardCode._(86); + static const W = const KeyboardCode._(87); + static const X = const KeyboardCode._(88); + static const Y = const KeyboardCode._(89); + static const Z = const KeyboardCode._(90); + static const LWIN = const KeyboardCode._(91); + static const COMMAND = const KeyboardCode._(91); + static const RWIN = const KeyboardCode._(92); + static const APPS = const KeyboardCode._(93); + static const SLEEP = const KeyboardCode._(95); + static const NUMPAD0 = const KeyboardCode._(96); + static const NUMPAD1 = const KeyboardCode._(97); + static const NUMPAD2 = const KeyboardCode._(98); + static const NUMPAD3 = const KeyboardCode._(99); + static const NUMPAD4 = const KeyboardCode._(100); + static const NUMPAD5 = const KeyboardCode._(101); + static const NUMPAD6 = const KeyboardCode._(102); + static const NUMPAD7 = const KeyboardCode._(103); + static const NUMPAD8 = const KeyboardCode._(104); + static const NUMPAD9 = const KeyboardCode._(105); + static const MULTIPLY = const KeyboardCode._(106); + static const ADD = const KeyboardCode._(107); + static const SEPARATOR = const KeyboardCode._(108); + static const SUBTRACT = const KeyboardCode._(109); + static const DECIMAL = const KeyboardCode._(110); + static const DIVIDE = const KeyboardCode._(111); + static const F1 = const KeyboardCode._(112); + static const F2 = const KeyboardCode._(113); + static const F3 = const KeyboardCode._(114); + static const F4 = const KeyboardCode._(115); + static const F5 = const KeyboardCode._(116); + static const F6 = const KeyboardCode._(117); + static const F7 = const KeyboardCode._(118); + static const F8 = const KeyboardCode._(119); + static const F9 = const KeyboardCode._(120); + static const F10 = const KeyboardCode._(121); + static const F11 = const KeyboardCode._(122); + static const F12 = const KeyboardCode._(123); + static const F13 = const KeyboardCode._(124); + static const F14 = const KeyboardCode._(125); + static const F15 = const KeyboardCode._(126); + static const F16 = const KeyboardCode._(127); + static const F17 = const KeyboardCode._(128); + static const F18 = const KeyboardCode._(129); + static const F19 = const KeyboardCode._(130); + static const F20 = const KeyboardCode._(131); + static const F21 = const KeyboardCode._(132); + static const F22 = const KeyboardCode._(133); + static const F23 = const KeyboardCode._(134); + static const F24 = const KeyboardCode._(135); + static const NUMLOCK = const KeyboardCode._(144); + static const SCROLL = const KeyboardCode._(145); + static const LSHIFT = const KeyboardCode._(160); + static const RSHIFT = const KeyboardCode._(161); + static const LCONTROL = const KeyboardCode._(162); + static const RCONTROL = const KeyboardCode._(163); + static const LMENU = const KeyboardCode._(164); + static const RMENU = const KeyboardCode._(165); + static const BROWSER_BACK = const KeyboardCode._(166); + static const BROWSER_FORWARD = const KeyboardCode._(167); + static const BROWSER_REFRESH = const KeyboardCode._(168); + static const BROWSER_STOP = const KeyboardCode._(169); + static const BROWSER_SEARCH = const KeyboardCode._(170); + static const BROWSER_FAVORITES = const KeyboardCode._(171); + static const BROWSER_HOME = const KeyboardCode._(172); + static const VOLUME_MUTE = const KeyboardCode._(173); + static const VOLUME_DOWN = const KeyboardCode._(174); + static const VOLUME_UP = const KeyboardCode._(175); + static const MEDIA_NEXT_TRACK = const KeyboardCode._(176); + static const MEDIA_PREV_TRACK = const KeyboardCode._(177); + static const MEDIA_STOP = const KeyboardCode._(178); + static const MEDIA_PLAY_PAUSE = const KeyboardCode._(179); + static const MEDIA_LAUNCH_MAIL = const KeyboardCode._(180); + static const MEDIA_LAUNCH_MEDIA_SELECT = const KeyboardCode._(181); + static const MEDIA_LAUNCH_APP1 = const KeyboardCode._(182); + static const MEDIA_LAUNCH_APP2 = const KeyboardCode._(183); + static const OEM_1 = const KeyboardCode._(186); + static const OEM_PLUS = const KeyboardCode._(187); + static const OEM_COMMA = const KeyboardCode._(188); + static const OEM_MINUS = const KeyboardCode._(189); + static const OEM_PERIOD = const KeyboardCode._(190); + static const OEM_2 = const KeyboardCode._(191); + static const OEM_3 = const KeyboardCode._(192); + static const OEM_4 = const KeyboardCode._(219); + static const OEM_5 = const KeyboardCode._(220); + static const OEM_6 = const KeyboardCode._(221); + static const OEM_7 = const KeyboardCode._(222); + static const OEM_8 = const KeyboardCode._(223); + static const OEM_102 = const KeyboardCode._(226); + static const PROCESSKEY = const KeyboardCode._(229); + static const PACKET = const KeyboardCode._(231); + static const DBE_SBCSCHAR = const KeyboardCode._(243); + static const DBE_DBCSCHAR = const KeyboardCode._(244); + static const ATTN = const KeyboardCode._(246); + static const CRSEL = const KeyboardCode._(247); + static const EXSEL = const KeyboardCode._(248); + static const EREOF = const KeyboardCode._(249); + static const PLAY = const KeyboardCode._(250); + static const ZOOM = const KeyboardCode._(251); + static const NONAME = const KeyboardCode._(252); + static const PA1 = const KeyboardCode._(253); + static const OEM_CLEAR = const KeyboardCode._(254); + static const UNKNOWN = const KeyboardCode._(0); + static const ALTGR = const KeyboardCode._(225); + + const KeyboardCode._(int v) : super(v); + + static const Map<String, KeyboardCode> valuesMap = const { + "BACK": BACK, + "TAB": TAB, + "CLEAR": CLEAR, + "RETURN": RETURN, + "SHIFT": SHIFT, + "CONTROL": CONTROL, + "MENU": MENU, + "PAUSE": PAUSE, + "CAPITAL": CAPITAL, + "KANA": KANA, + "HANGUL": HANGUL, + "JUNJA": JUNJA, + "FINAL": FINAL, + "HANJA": HANJA, + "KANJI": KANJI, + "ESCAPE": ESCAPE, + "CONVERT": CONVERT, + "NONCONVERT": NONCONVERT, + "ACCEPT": ACCEPT, + "MODECHANGE": MODECHANGE, + "SPACE": SPACE, + "PRIOR": PRIOR, + "NEXT": NEXT, + "END": END, + "HOME": HOME, + "LEFT": LEFT, + "UP": UP, + "RIGHT": RIGHT, + "DOWN": DOWN, + "SELECT": SELECT, + "PRINT": PRINT, + "EXECUTE": EXECUTE, + "SNAPSHOT": SNAPSHOT, + "INSERT": INSERT, + "DELETE": DELETE, + "HELP": HELP, + "NUM_0": NUM_0, + "NUM_1": NUM_1, + "NUM_2": NUM_2, + "NUM_3": NUM_3, + "NUM_4": NUM_4, + "NUM_5": NUM_5, + "NUM_6": NUM_6, + "NUM_7": NUM_7, + "NUM_8": NUM_8, + "NUM_9": NUM_9, + "A": A, + "B": B, + "C": C, + "D": D, + "E": E, + "F": F, + "G": G, + "H": H, + "I": I, + "J": J, + "K": K, + "L": L, + "M": M, + "N": N, + "O": O, + "P": P, + "Q": Q, + "R": R, + "S": S, + "T": T, + "U": U, + "V": V, + "W": W, + "X": X, + "Y": Y, + "Z": Z, + "LWIN": LWIN, + "COMMAND": COMMAND, + "RWIN": RWIN, + "APPS": APPS, + "SLEEP": SLEEP, + "NUMPAD0": NUMPAD0, + "NUMPAD1": NUMPAD1, + "NUMPAD2": NUMPAD2, + "NUMPAD3": NUMPAD3, + "NUMPAD4": NUMPAD4, + "NUMPAD5": NUMPAD5, + "NUMPAD6": NUMPAD6, + "NUMPAD7": NUMPAD7, + "NUMPAD8": NUMPAD8, + "NUMPAD9": NUMPAD9, + "MULTIPLY": MULTIPLY, + "ADD": ADD, + "SEPARATOR": SEPARATOR, + "SUBTRACT": SUBTRACT, + "DECIMAL": DECIMAL, + "DIVIDE": DIVIDE, + "F1": F1, + "F2": F2, + "F3": F3, + "F4": F4, + "F5": F5, + "F6": F6, + "F7": F7, + "F8": F8, + "F9": F9, + "F10": F10, + "F11": F11, + "F12": F12, + "F13": F13, + "F14": F14, + "F15": F15, + "F16": F16, + "F17": F17, + "F18": F18, + "F19": F19, + "F20": F20, + "F21": F21, + "F22": F22, + "F23": F23, + "F24": F24, + "NUMLOCK": NUMLOCK, + "SCROLL": SCROLL, + "LSHIFT": LSHIFT, + "RSHIFT": RSHIFT, + "LCONTROL": LCONTROL, + "RCONTROL": RCONTROL, + "LMENU": LMENU, + "RMENU": RMENU, + "BROWSER_BACK": BROWSER_BACK, + "BROWSER_FORWARD": BROWSER_FORWARD, + "BROWSER_REFRESH": BROWSER_REFRESH, + "BROWSER_STOP": BROWSER_STOP, + "BROWSER_SEARCH": BROWSER_SEARCH, + "BROWSER_FAVORITES": BROWSER_FAVORITES, + "BROWSER_HOME": BROWSER_HOME, + "VOLUME_MUTE": VOLUME_MUTE, + "VOLUME_DOWN": VOLUME_DOWN, + "VOLUME_UP": VOLUME_UP, + "MEDIA_NEXT_TRACK": MEDIA_NEXT_TRACK, + "MEDIA_PREV_TRACK": MEDIA_PREV_TRACK, + "MEDIA_STOP": MEDIA_STOP, + "MEDIA_PLAY_PAUSE": MEDIA_PLAY_PAUSE, + "MEDIA_LAUNCH_MAIL": MEDIA_LAUNCH_MAIL, + "MEDIA_LAUNCH_MEDIA_SELECT": MEDIA_LAUNCH_MEDIA_SELECT, + "MEDIA_LAUNCH_APP1": MEDIA_LAUNCH_APP1, + "MEDIA_LAUNCH_APP2": MEDIA_LAUNCH_APP2, + "OEM_1": OEM_1, + "OEM_PLUS": OEM_PLUS, + "OEM_COMMA": OEM_COMMA, + "OEM_MINUS": OEM_MINUS, + "OEM_PERIOD": OEM_PERIOD, + "OEM_2": OEM_2, + "OEM_3": OEM_3, + "OEM_4": OEM_4, + "OEM_5": OEM_5, + "OEM_6": OEM_6, + "OEM_7": OEM_7, + "OEM_8": OEM_8, + "OEM_102": OEM_102, + "PROCESSKEY": PROCESSKEY, + "PACKET": PACKET, + "DBE_SBCSCHAR": DBE_SBCSCHAR, + "DBE_DBCSCHAR": DBE_DBCSCHAR, + "ATTN": ATTN, + "CRSEL": CRSEL, + "EXSEL": EXSEL, + "EREOF": EREOF, + "PLAY": PLAY, + "ZOOM": ZOOM, + "NONAME": NONAME, + "PA1": PA1, + "OEM_CLEAR": OEM_CLEAR, + "UNKNOWN": UNKNOWN, + "ALTGR": ALTGR, + }; + static const List<KeyboardCode> values = const [ + BACK, + TAB, + CLEAR, + RETURN, + SHIFT, + CONTROL, + MENU, + PAUSE, + CAPITAL, + KANA, + HANGUL, + JUNJA, + FINAL, + HANJA, + KANJI, + ESCAPE, + CONVERT, + NONCONVERT, + ACCEPT, + MODECHANGE, + SPACE, + PRIOR, + NEXT, + END, + HOME, + LEFT, + UP, + RIGHT, + DOWN, + SELECT, + PRINT, + EXECUTE, + SNAPSHOT, + INSERT, + DELETE, + HELP, + NUM_0, + NUM_1, + NUM_2, + NUM_3, + NUM_4, + NUM_5, + NUM_6, + NUM_7, + NUM_8, + NUM_9, + A, + B, + C, + D, + E, + F, + G, + H, + I, + J, + K, + L, + M, + N, + O, + P, + Q, + R, + S, + T, + U, + V, + W, + X, + Y, + Z, + LWIN, + COMMAND, + RWIN, + APPS, + SLEEP, + NUMPAD0, + NUMPAD1, + NUMPAD2, + NUMPAD3, + NUMPAD4, + NUMPAD5, + NUMPAD6, + NUMPAD7, + NUMPAD8, + NUMPAD9, + MULTIPLY, + ADD, + SEPARATOR, + SUBTRACT, + DECIMAL, + DIVIDE, + F1, + F2, + F3, + F4, + F5, + F6, + F7, + F8, + F9, + F10, + F11, + F12, + F13, + F14, + F15, + F16, + F17, + F18, + F19, + F20, + F21, + F22, + F23, + F24, + NUMLOCK, + SCROLL, + LSHIFT, + RSHIFT, + LCONTROL, + RCONTROL, + LMENU, + RMENU, + BROWSER_BACK, + BROWSER_FORWARD, + BROWSER_REFRESH, + BROWSER_STOP, + BROWSER_SEARCH, + BROWSER_FAVORITES, + BROWSER_HOME, + VOLUME_MUTE, + VOLUME_DOWN, + VOLUME_UP, + MEDIA_NEXT_TRACK, + MEDIA_PREV_TRACK, + MEDIA_STOP, + MEDIA_PLAY_PAUSE, + MEDIA_LAUNCH_MAIL, + MEDIA_LAUNCH_MEDIA_SELECT, + MEDIA_LAUNCH_APP1, + MEDIA_LAUNCH_APP2, + OEM_1, + OEM_PLUS, + OEM_COMMA, + OEM_MINUS, + OEM_PERIOD, + OEM_2, + OEM_3, + OEM_4, + OEM_5, + OEM_6, + OEM_7, + OEM_8, + OEM_102, + PROCESSKEY, + PACKET, + DBE_SBCSCHAR, + DBE_DBCSCHAR, + ATTN, + CRSEL, + EXSEL, + EREOF, + PLAY, + ZOOM, + NONAME, + PA1, + OEM_CLEAR, + UNKNOWN, + ALTGR, + ]; + + static KeyboardCode valueOf(String name) => valuesMap[name]; + + factory KeyboardCode(int v) { + switch (v) { + case 8: + return BACK; + case 9: + return TAB; + case 12: + return CLEAR; + case 13: + return RETURN; + case 16: + return SHIFT; + case 17: + return CONTROL; + case 18: + return MENU; + case 19: + return PAUSE; + case 20: + return CAPITAL; + case 21: + return KANA; + case 21: + return HANGUL; + case 23: + return JUNJA; + case 24: + return FINAL; + case 25: + return HANJA; + case 25: + return KANJI; + case 27: + return ESCAPE; + case 28: + return CONVERT; + case 29: + return NONCONVERT; + case 30: + return ACCEPT; + case 31: + return MODECHANGE; + case 32: + return SPACE; + case 33: + return PRIOR; + case 34: + return NEXT; + case 35: + return END; + case 36: + return HOME; + case 37: + return LEFT; + case 38: + return UP; + case 39: + return RIGHT; + case 40: + return DOWN; + case 41: + return SELECT; + case 42: + return PRINT; + case 43: + return EXECUTE; + case 44: + return SNAPSHOT; + case 45: + return INSERT; + case 46: + return DELETE; + case 47: + return HELP; + case 48: + return NUM_0; + case 49: + return NUM_1; + case 50: + return NUM_2; + case 51: + return NUM_3; + case 52: + return NUM_4; + case 53: + return NUM_5; + case 54: + return NUM_6; + case 55: + return NUM_7; + case 56: + return NUM_8; + case 57: + return NUM_9; + case 65: + return A; + case 66: + return B; + case 67: + return C; + case 68: + return D; + case 69: + return E; + case 70: + return F; + case 71: + return G; + case 72: + return H; + case 73: + return I; + case 74: + return J; + case 75: + return K; + case 76: + return L; + case 77: + return M; + case 78: + return N; + case 79: + return O; + case 80: + return P; + case 81: + return Q; + case 82: + return R; + case 83: + return S; + case 84: + return T; + case 85: + return U; + case 86: + return V; + case 87: + return W; + case 88: + return X; + case 89: + return Y; + case 90: + return Z; + case 91: + return LWIN; + case 91: + return COMMAND; + case 92: + return RWIN; + case 93: + return APPS; + case 95: + return SLEEP; + case 96: + return NUMPAD0; + case 97: + return NUMPAD1; + case 98: + return NUMPAD2; + case 99: + return NUMPAD3; + case 100: + return NUMPAD4; + case 101: + return NUMPAD5; + case 102: + return NUMPAD6; + case 103: + return NUMPAD7; + case 104: + return NUMPAD8; + case 105: + return NUMPAD9; + case 106: + return MULTIPLY; + case 107: + return ADD; + case 108: + return SEPARATOR; + case 109: + return SUBTRACT; + case 110: + return DECIMAL; + case 111: + return DIVIDE; + case 112: + return F1; + case 113: + return F2; + case 114: + return F3; + case 115: + return F4; + case 116: + return F5; + case 117: + return F6; + case 118: + return F7; + case 119: + return F8; + case 120: + return F9; + case 121: + return F10; + case 122: + return F11; + case 123: + return F12; + case 124: + return F13; + case 125: + return F14; + case 126: + return F15; + case 127: + return F16; + case 128: + return F17; + case 129: + return F18; + case 130: + return F19; + case 131: + return F20; + case 132: + return F21; + case 133: + return F22; + case 134: + return F23; + case 135: + return F24; + case 144: + return NUMLOCK; + case 145: + return SCROLL; + case 160: + return LSHIFT; + case 161: + return RSHIFT; + case 162: + return LCONTROL; + case 163: + return RCONTROL; + case 164: + return LMENU; + case 165: + return RMENU; + case 166: + return BROWSER_BACK; + case 167: + return BROWSER_FORWARD; + case 168: + return BROWSER_REFRESH; + case 169: + return BROWSER_STOP; + case 170: + return BROWSER_SEARCH; + case 171: + return BROWSER_FAVORITES; + case 172: + return BROWSER_HOME; + case 173: + return VOLUME_MUTE; + case 174: + return VOLUME_DOWN; + case 175: + return VOLUME_UP; + case 176: + return MEDIA_NEXT_TRACK; + case 177: + return MEDIA_PREV_TRACK; + case 178: + return MEDIA_STOP; + case 179: + return MEDIA_PLAY_PAUSE; + case 180: + return MEDIA_LAUNCH_MAIL; + case 181: + return MEDIA_LAUNCH_MEDIA_SELECT; + case 182: + return MEDIA_LAUNCH_APP1; + case 183: + return MEDIA_LAUNCH_APP2; + case 186: + return OEM_1; + case 187: + return OEM_PLUS; + case 188: + return OEM_COMMA; + case 189: + return OEM_MINUS; + case 190: + return OEM_PERIOD; + case 191: + return OEM_2; + case 192: + return OEM_3; + case 219: + return OEM_4; + case 220: + return OEM_5; + case 221: + return OEM_6; + case 222: + return OEM_7; + case 223: + return OEM_8; + case 226: + return OEM_102; + case 229: + return PROCESSKEY; + case 231: + return PACKET; + case 243: + return DBE_SBCSCHAR; + case 244: + return DBE_DBCSCHAR; + case 246: + return ATTN; + case 247: + return CRSEL; + case 248: + return EXSEL; + case 249: + return EREOF; + case 250: + return PLAY; + case 251: + return ZOOM; + case 252: + return NONAME; + case 253: + return PA1; + case 254: + return OEM_CLEAR; + case 0: + return UNKNOWN; + case 225: + return ALTGR; + default: + return null; + } + } + + static KeyboardCode decode(bindings.Decoder decoder0, int offset) { + int v = decoder0.decodeUint32(offset); + KeyboardCode result = new KeyboardCode(v); + if (result == null) { + throw new bindings.MojoCodecError( + 'Bad value $v for enum KeyboardCode.'); + } + return result; + } + + String toString() { + switch(this) { + case BACK: + return 'KeyboardCode.BACK'; + case TAB: + return 'KeyboardCode.TAB'; + case CLEAR: + return 'KeyboardCode.CLEAR'; + case RETURN: + return 'KeyboardCode.RETURN'; + case SHIFT: + return 'KeyboardCode.SHIFT'; + case CONTROL: + return 'KeyboardCode.CONTROL'; + case MENU: + return 'KeyboardCode.MENU'; + case PAUSE: + return 'KeyboardCode.PAUSE'; + case CAPITAL: + return 'KeyboardCode.CAPITAL'; + case KANA: + return 'KeyboardCode.KANA'; + case HANGUL: + return 'KeyboardCode.HANGUL'; + case JUNJA: + return 'KeyboardCode.JUNJA'; + case FINAL: + return 'KeyboardCode.FINAL'; + case HANJA: + return 'KeyboardCode.HANJA'; + case KANJI: + return 'KeyboardCode.KANJI'; + case ESCAPE: + return 'KeyboardCode.ESCAPE'; + case CONVERT: + return 'KeyboardCode.CONVERT'; + case NONCONVERT: + return 'KeyboardCode.NONCONVERT'; + case ACCEPT: + return 'KeyboardCode.ACCEPT'; + case MODECHANGE: + return 'KeyboardCode.MODECHANGE'; + case SPACE: + return 'KeyboardCode.SPACE'; + case PRIOR: + return 'KeyboardCode.PRIOR'; + case NEXT: + return 'KeyboardCode.NEXT'; + case END: + return 'KeyboardCode.END'; + case HOME: + return 'KeyboardCode.HOME'; + case LEFT: + return 'KeyboardCode.LEFT'; + case UP: + return 'KeyboardCode.UP'; + case RIGHT: + return 'KeyboardCode.RIGHT'; + case DOWN: + return 'KeyboardCode.DOWN'; + case SELECT: + return 'KeyboardCode.SELECT'; + case PRINT: + return 'KeyboardCode.PRINT'; + case EXECUTE: + return 'KeyboardCode.EXECUTE'; + case SNAPSHOT: + return 'KeyboardCode.SNAPSHOT'; + case INSERT: + return 'KeyboardCode.INSERT'; + case DELETE: + return 'KeyboardCode.DELETE'; + case HELP: + return 'KeyboardCode.HELP'; + case NUM_0: + return 'KeyboardCode.NUM_0'; + case NUM_1: + return 'KeyboardCode.NUM_1'; + case NUM_2: + return 'KeyboardCode.NUM_2'; + case NUM_3: + return 'KeyboardCode.NUM_3'; + case NUM_4: + return 'KeyboardCode.NUM_4'; + case NUM_5: + return 'KeyboardCode.NUM_5'; + case NUM_6: + return 'KeyboardCode.NUM_6'; + case NUM_7: + return 'KeyboardCode.NUM_7'; + case NUM_8: + return 'KeyboardCode.NUM_8'; + case NUM_9: + return 'KeyboardCode.NUM_9'; + case A: + return 'KeyboardCode.A'; + case B: + return 'KeyboardCode.B'; + case C: + return 'KeyboardCode.C'; + case D: + return 'KeyboardCode.D'; + case E: + return 'KeyboardCode.E'; + case F: + return 'KeyboardCode.F'; + case G: + return 'KeyboardCode.G'; + case H: + return 'KeyboardCode.H'; + case I: + return 'KeyboardCode.I'; + case J: + return 'KeyboardCode.J'; + case K: + return 'KeyboardCode.K'; + case L: + return 'KeyboardCode.L'; + case M: + return 'KeyboardCode.M'; + case N: + return 'KeyboardCode.N'; + case O: + return 'KeyboardCode.O'; + case P: + return 'KeyboardCode.P'; + case Q: + return 'KeyboardCode.Q'; + case R: + return 'KeyboardCode.R'; + case S: + return 'KeyboardCode.S'; + case T: + return 'KeyboardCode.T'; + case U: + return 'KeyboardCode.U'; + case V: + return 'KeyboardCode.V'; + case W: + return 'KeyboardCode.W'; + case X: + return 'KeyboardCode.X'; + case Y: + return 'KeyboardCode.Y'; + case Z: + return 'KeyboardCode.Z'; + case LWIN: + return 'KeyboardCode.LWIN'; + case COMMAND: + return 'KeyboardCode.COMMAND'; + case RWIN: + return 'KeyboardCode.RWIN'; + case APPS: + return 'KeyboardCode.APPS'; + case SLEEP: + return 'KeyboardCode.SLEEP'; + case NUMPAD0: + return 'KeyboardCode.NUMPAD0'; + case NUMPAD1: + return 'KeyboardCode.NUMPAD1'; + case NUMPAD2: + return 'KeyboardCode.NUMPAD2'; + case NUMPAD3: + return 'KeyboardCode.NUMPAD3'; + case NUMPAD4: + return 'KeyboardCode.NUMPAD4'; + case NUMPAD5: + return 'KeyboardCode.NUMPAD5'; + case NUMPAD6: + return 'KeyboardCode.NUMPAD6'; + case NUMPAD7: + return 'KeyboardCode.NUMPAD7'; + case NUMPAD8: + return 'KeyboardCode.NUMPAD8'; + case NUMPAD9: + return 'KeyboardCode.NUMPAD9'; + case MULTIPLY: + return 'KeyboardCode.MULTIPLY'; + case ADD: + return 'KeyboardCode.ADD'; + case SEPARATOR: + return 'KeyboardCode.SEPARATOR'; + case SUBTRACT: + return 'KeyboardCode.SUBTRACT'; + case DECIMAL: + return 'KeyboardCode.DECIMAL'; + case DIVIDE: + return 'KeyboardCode.DIVIDE'; + case F1: + return 'KeyboardCode.F1'; + case F2: + return 'KeyboardCode.F2'; + case F3: + return 'KeyboardCode.F3'; + case F4: + return 'KeyboardCode.F4'; + case F5: + return 'KeyboardCode.F5'; + case F6: + return 'KeyboardCode.F6'; + case F7: + return 'KeyboardCode.F7'; + case F8: + return 'KeyboardCode.F8'; + case F9: + return 'KeyboardCode.F9'; + case F10: + return 'KeyboardCode.F10'; + case F11: + return 'KeyboardCode.F11'; + case F12: + return 'KeyboardCode.F12'; + case F13: + return 'KeyboardCode.F13'; + case F14: + return 'KeyboardCode.F14'; + case F15: + return 'KeyboardCode.F15'; + case F16: + return 'KeyboardCode.F16'; + case F17: + return 'KeyboardCode.F17'; + case F18: + return 'KeyboardCode.F18'; + case F19: + return 'KeyboardCode.F19'; + case F20: + return 'KeyboardCode.F20'; + case F21: + return 'KeyboardCode.F21'; + case F22: + return 'KeyboardCode.F22'; + case F23: + return 'KeyboardCode.F23'; + case F24: + return 'KeyboardCode.F24'; + case NUMLOCK: + return 'KeyboardCode.NUMLOCK'; + case SCROLL: + return 'KeyboardCode.SCROLL'; + case LSHIFT: + return 'KeyboardCode.LSHIFT'; + case RSHIFT: + return 'KeyboardCode.RSHIFT'; + case LCONTROL: + return 'KeyboardCode.LCONTROL'; + case RCONTROL: + return 'KeyboardCode.RCONTROL'; + case LMENU: + return 'KeyboardCode.LMENU'; + case RMENU: + return 'KeyboardCode.RMENU'; + case BROWSER_BACK: + return 'KeyboardCode.BROWSER_BACK'; + case BROWSER_FORWARD: + return 'KeyboardCode.BROWSER_FORWARD'; + case BROWSER_REFRESH: + return 'KeyboardCode.BROWSER_REFRESH'; + case BROWSER_STOP: + return 'KeyboardCode.BROWSER_STOP'; + case BROWSER_SEARCH: + return 'KeyboardCode.BROWSER_SEARCH'; + case BROWSER_FAVORITES: + return 'KeyboardCode.BROWSER_FAVORITES'; + case BROWSER_HOME: + return 'KeyboardCode.BROWSER_HOME'; + case VOLUME_MUTE: + return 'KeyboardCode.VOLUME_MUTE'; + case VOLUME_DOWN: + return 'KeyboardCode.VOLUME_DOWN'; + case VOLUME_UP: + return 'KeyboardCode.VOLUME_UP'; + case MEDIA_NEXT_TRACK: + return 'KeyboardCode.MEDIA_NEXT_TRACK'; + case MEDIA_PREV_TRACK: + return 'KeyboardCode.MEDIA_PREV_TRACK'; + case MEDIA_STOP: + return 'KeyboardCode.MEDIA_STOP'; + case MEDIA_PLAY_PAUSE: + return 'KeyboardCode.MEDIA_PLAY_PAUSE'; + case MEDIA_LAUNCH_MAIL: + return 'KeyboardCode.MEDIA_LAUNCH_MAIL'; + case MEDIA_LAUNCH_MEDIA_SELECT: + return 'KeyboardCode.MEDIA_LAUNCH_MEDIA_SELECT'; + case MEDIA_LAUNCH_APP1: + return 'KeyboardCode.MEDIA_LAUNCH_APP1'; + case MEDIA_LAUNCH_APP2: + return 'KeyboardCode.MEDIA_LAUNCH_APP2'; + case OEM_1: + return 'KeyboardCode.OEM_1'; + case OEM_PLUS: + return 'KeyboardCode.OEM_PLUS'; + case OEM_COMMA: + return 'KeyboardCode.OEM_COMMA'; + case OEM_MINUS: + return 'KeyboardCode.OEM_MINUS'; + case OEM_PERIOD: + return 'KeyboardCode.OEM_PERIOD'; + case OEM_2: + return 'KeyboardCode.OEM_2'; + case OEM_3: + return 'KeyboardCode.OEM_3'; + case OEM_4: + return 'KeyboardCode.OEM_4'; + case OEM_5: + return 'KeyboardCode.OEM_5'; + case OEM_6: + return 'KeyboardCode.OEM_6'; + case OEM_7: + return 'KeyboardCode.OEM_7'; + case OEM_8: + return 'KeyboardCode.OEM_8'; + case OEM_102: + return 'KeyboardCode.OEM_102'; + case PROCESSKEY: + return 'KeyboardCode.PROCESSKEY'; + case PACKET: + return 'KeyboardCode.PACKET'; + case DBE_SBCSCHAR: + return 'KeyboardCode.DBE_SBCSCHAR'; + case DBE_DBCSCHAR: + return 'KeyboardCode.DBE_DBCSCHAR'; + case ATTN: + return 'KeyboardCode.ATTN'; + case CRSEL: + return 'KeyboardCode.CRSEL'; + case EXSEL: + return 'KeyboardCode.EXSEL'; + case EREOF: + return 'KeyboardCode.EREOF'; + case PLAY: + return 'KeyboardCode.PLAY'; + case ZOOM: + return 'KeyboardCode.ZOOM'; + case NONAME: + return 'KeyboardCode.NONAME'; + case PA1: + return 'KeyboardCode.PA1'; + case OEM_CLEAR: + return 'KeyboardCode.OEM_CLEAR'; + case UNKNOWN: + return 'KeyboardCode.UNKNOWN'; + case ALTGR: + return 'KeyboardCode.ALTGR'; + } + } + + int toJson() => value; +} + + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/location.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/location.mojom.dart new file mode 100644 index 0000000..d67da00 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/location.mojom.dart
@@ -0,0 +1,188 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library location_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; + + + +class Location extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(64, 0) + ]; + int time = 0; + bool hasElapsedRealTimeNanos = false; + bool hasAltitude = false; + bool hasSpeed = false; + bool hasBearing = false; + bool hasAccuracy = false; + double speed = 0.0; + int elapsedRealTimeNanos = 0; + double latitude = 0.0; + double longitude = 0.0; + double altitude = 0.0; + double bearing = 0.0; + double accuracy = 0.0; + + Location() : super(kVersions.last.size); + + static Location deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static Location decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + Location result = new Location(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.time = decoder0.decodeUint64(8); + } + if (mainDataHeader.version >= 0) { + + result.hasElapsedRealTimeNanos = decoder0.decodeBool(16, 0); + } + if (mainDataHeader.version >= 0) { + + result.hasAltitude = decoder0.decodeBool(16, 1); + } + if (mainDataHeader.version >= 0) { + + result.hasSpeed = decoder0.decodeBool(16, 2); + } + if (mainDataHeader.version >= 0) { + + result.hasBearing = decoder0.decodeBool(16, 3); + } + if (mainDataHeader.version >= 0) { + + result.hasAccuracy = decoder0.decodeBool(16, 4); + } + if (mainDataHeader.version >= 0) { + + result.speed = decoder0.decodeFloat(20); + } + if (mainDataHeader.version >= 0) { + + result.elapsedRealTimeNanos = decoder0.decodeUint64(24); + } + if (mainDataHeader.version >= 0) { + + result.latitude = decoder0.decodeDouble(32); + } + if (mainDataHeader.version >= 0) { + + result.longitude = decoder0.decodeDouble(40); + } + if (mainDataHeader.version >= 0) { + + result.altitude = decoder0.decodeDouble(48); + } + if (mainDataHeader.version >= 0) { + + result.bearing = decoder0.decodeFloat(56); + } + if (mainDataHeader.version >= 0) { + + result.accuracy = decoder0.decodeFloat(60); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint64(time, 8); + + encoder0.encodeBool(hasElapsedRealTimeNanos, 16, 0); + + encoder0.encodeBool(hasAltitude, 16, 1); + + encoder0.encodeBool(hasSpeed, 16, 2); + + encoder0.encodeBool(hasBearing, 16, 3); + + encoder0.encodeBool(hasAccuracy, 16, 4); + + encoder0.encodeFloat(speed, 20); + + encoder0.encodeUint64(elapsedRealTimeNanos, 24); + + encoder0.encodeDouble(latitude, 32); + + encoder0.encodeDouble(longitude, 40); + + encoder0.encodeDouble(altitude, 48); + + encoder0.encodeFloat(bearing, 56); + + encoder0.encodeFloat(accuracy, 60); + } + + String toString() { + return "Location(" + "time: $time" ", " + "hasElapsedRealTimeNanos: $hasElapsedRealTimeNanos" ", " + "hasAltitude: $hasAltitude" ", " + "hasSpeed: $hasSpeed" ", " + "hasBearing: $hasBearing" ", " + "hasAccuracy: $hasAccuracy" ", " + "speed: $speed" ", " + "elapsedRealTimeNanos: $elapsedRealTimeNanos" ", " + "latitude: $latitude" ", " + "longitude: $longitude" ", " + "altitude: $altitude" ", " + "bearing: $bearing" ", " + "accuracy: $accuracy" ")"; + } + + Map toJson() { + Map map = new Map(); + map["time"] = time; + map["hasElapsedRealTimeNanos"] = hasElapsedRealTimeNanos; + map["hasAltitude"] = hasAltitude; + map["hasSpeed"] = hasSpeed; + map["hasBearing"] = hasBearing; + map["hasAccuracy"] = hasAccuracy; + map["speed"] = speed; + map["elapsedRealTimeNanos"] = elapsedRealTimeNanos; + map["latitude"] = latitude; + map["longitude"] = longitude; + map["altitude"] = altitude; + map["bearing"] = bearing; + map["accuracy"] = accuracy; + return map; + } +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/location_service.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/location_service.mojom.dart new file mode 100644 index 0000000..05b8b75 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/location_service.mojom.dart
@@ -0,0 +1,432 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library location_service_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo_services/mojo/location.mojom.dart' as location_mojom; + + + +class LocationServiceGetNextLocationParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + LocationServiceUpdatePriority priority = null; + + LocationServiceGetNextLocationParams() : super(kVersions.last.size); + + static LocationServiceGetNextLocationParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static LocationServiceGetNextLocationParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + LocationServiceGetNextLocationParams result = new LocationServiceGetNextLocationParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.priority = LocationServiceUpdatePriority.decode(decoder0, 8); + if (result.priority == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable LocationServiceUpdatePriority.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(priority, 8); + } + + String toString() { + return "LocationServiceGetNextLocationParams(" + "priority: $priority" ")"; + } + + Map toJson() { + Map map = new Map(); + map["priority"] = priority; + return map; + } +} + + +class LocationServiceGetNextLocationResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + location_mojom.Location location = null; + + LocationServiceGetNextLocationResponseParams() : super(kVersions.last.size); + + static LocationServiceGetNextLocationResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static LocationServiceGetNextLocationResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + LocationServiceGetNextLocationResponseParams result = new LocationServiceGetNextLocationResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, true); + result.location = location_mojom.Location.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(location, 8, true); + } + + String toString() { + return "LocationServiceGetNextLocationResponseParams(" + "location: $location" ")"; + } + + Map toJson() { + Map map = new Map(); + map["location"] = location; + return map; + } +} + +const int kLocationService_getNextLocation_name = 0; + +const String LocationServiceName = + 'mojo::LocationService'; + class LocationServiceUpdatePriority extends bindings.MojoEnum { + static const PRIORITY_BALANCED_POWER_ACCURACY = const LocationServiceUpdatePriority._(0); + static const PRIORITY_HIGH_ACCURACY = const LocationServiceUpdatePriority._(1); + static const PRIORITY_LOW_POWER = const LocationServiceUpdatePriority._(2); + static const PRIORITY_NO_POWER = const LocationServiceUpdatePriority._(3); + + const LocationServiceUpdatePriority._(int v) : super(v); + + static const Map<String, LocationServiceUpdatePriority> valuesMap = const { + "PRIORITY_BALANCED_POWER_ACCURACY": PRIORITY_BALANCED_POWER_ACCURACY, + "PRIORITY_HIGH_ACCURACY": PRIORITY_HIGH_ACCURACY, + "PRIORITY_LOW_POWER": PRIORITY_LOW_POWER, + "PRIORITY_NO_POWER": PRIORITY_NO_POWER, + }; + static const List<LocationServiceUpdatePriority> values = const [ + PRIORITY_BALANCED_POWER_ACCURACY, + PRIORITY_HIGH_ACCURACY, + PRIORITY_LOW_POWER, + PRIORITY_NO_POWER, + ]; + + static LocationServiceUpdatePriority valueOf(String name) => valuesMap[name]; + + factory LocationServiceUpdatePriority(int v) { + switch (v) { + case 0: + return PRIORITY_BALANCED_POWER_ACCURACY; + case 1: + return PRIORITY_HIGH_ACCURACY; + case 2: + return PRIORITY_LOW_POWER; + case 3: + return PRIORITY_NO_POWER; + default: + return null; + } + } + + static LocationServiceUpdatePriority decode(bindings.Decoder decoder0, int offset) { + int v = decoder0.decodeUint32(offset); + LocationServiceUpdatePriority result = new LocationServiceUpdatePriority(v); + if (result == null) { + throw new bindings.MojoCodecError( + 'Bad value $v for enum LocationServiceUpdatePriority.'); + } + return result; + } + + String toString() { + switch(this) { + case PRIORITY_BALANCED_POWER_ACCURACY: + return 'LocationServiceUpdatePriority.PRIORITY_BALANCED_POWER_ACCURACY'; + case PRIORITY_HIGH_ACCURACY: + return 'LocationServiceUpdatePriority.PRIORITY_HIGH_ACCURACY'; + case PRIORITY_LOW_POWER: + return 'LocationServiceUpdatePriority.PRIORITY_LOW_POWER'; + case PRIORITY_NO_POWER: + return 'LocationServiceUpdatePriority.PRIORITY_NO_POWER'; + } + } + + int toJson() => value; +} + +abstract class LocationService { + dynamic getNextLocation(LocationServiceUpdatePriority priority,[Function responseFactory = null]); + +} + + +class LocationServiceProxyImpl extends bindings.Proxy { + LocationServiceProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + LocationServiceProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + LocationServiceProxyImpl.unbound() : super.unbound(); + + static LocationServiceProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For LocationServiceProxyImpl")); + return new LocationServiceProxyImpl.fromEndpoint(endpoint); + } + + String get name => LocationServiceName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kLocationService_getNextLocation_name: + var r = LocationServiceGetNextLocationResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "LocationServiceProxyImpl($superString)"; + } +} + + +class _LocationServiceProxyCalls implements LocationService { + LocationServiceProxyImpl _proxyImpl; + + _LocationServiceProxyCalls(this._proxyImpl); + dynamic getNextLocation(LocationServiceUpdatePriority priority,[Function responseFactory = null]) { + var params = new LocationServiceGetNextLocationParams(); + params.priority = priority; + return _proxyImpl.sendMessageWithRequestId( + params, + kLocationService_getNextLocation_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class LocationServiceProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + LocationService ptr; + final String name = LocationServiceName; + + LocationServiceProxy(LocationServiceProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _LocationServiceProxyCalls(proxyImpl); + + LocationServiceProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new LocationServiceProxyImpl.fromEndpoint(endpoint) { + ptr = new _LocationServiceProxyCalls(impl); + } + + LocationServiceProxy.fromHandle(core.MojoHandle handle) : + impl = new LocationServiceProxyImpl.fromHandle(handle) { + ptr = new _LocationServiceProxyCalls(impl); + } + + LocationServiceProxy.unbound() : + impl = new LocationServiceProxyImpl.unbound() { + ptr = new _LocationServiceProxyCalls(impl); + } + + factory LocationServiceProxy.connectToService( + bindings.ServiceConnector s, String url) { + LocationServiceProxy p = new LocationServiceProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static LocationServiceProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For LocationServiceProxy")); + return new LocationServiceProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "LocationServiceProxy($impl)"; + } +} + + +class LocationServiceStub extends bindings.Stub { + LocationService _impl = null; + + LocationServiceStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + LocationServiceStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + LocationServiceStub.unbound() : super.unbound(); + + static LocationServiceStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For LocationServiceStub")); + return new LocationServiceStub.fromEndpoint(endpoint); + } + + static const String name = LocationServiceName; + + + LocationServiceGetNextLocationResponseParams _LocationServiceGetNextLocationResponseParamsFactory(location_mojom.Location location) { + var result = new LocationServiceGetNextLocationResponseParams(); + result.location = location; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kLocationService_getNextLocation_name: + var params = LocationServiceGetNextLocationParams.deserialize( + message.payload); + var response = _impl.getNextLocation(params.priority,_LocationServiceGetNextLocationResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kLocationService_getNextLocation_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kLocationService_getNextLocation_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + LocationService get impl => _impl; + set impl(LocationService d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "LocationServiceStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/native_viewport.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/native_viewport.mojom.dart new file mode 100644 index 0000000..69d6b76 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/native_viewport.mojom.dart
@@ -0,0 +1,1565 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library native_viewport_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo_services/mojo/geometry.mojom.dart' as geometry_mojom; +import 'package:mojo_services/mojo/context_provider.mojom.dart' as context_provider_mojom; +import 'package:mojo_services/mojo/input_events.mojom.dart' as input_events_mojom; + + + +class ViewportMetrics extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + geometry_mojom.Size size = null; + double devicePixelRatio = 1.0; + + ViewportMetrics() : super(kVersions.last.size); + + static ViewportMetrics deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewportMetrics decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewportMetrics result = new ViewportMetrics(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.size = geometry_mojom.Size.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + result.devicePixelRatio = decoder0.decodeFloat(16); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(size, 8, false); + + encoder0.encodeFloat(devicePixelRatio, 16); + } + + String toString() { + return "ViewportMetrics(" + "size: $size" ", " + "devicePixelRatio: $devicePixelRatio" ")"; + } + + Map toJson() { + Map map = new Map(); + map["size"] = size; + map["devicePixelRatio"] = devicePixelRatio; + return map; + } +} + + +class SurfaceConfiguration extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int redBits = 8; + int greenBits = 8; + int blueBits = 8; + int alphaBits = 8; + int depthBits = 0; + int stencilBits = 0; + + SurfaceConfiguration() : super(kVersions.last.size); + + static SurfaceConfiguration deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static SurfaceConfiguration decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + SurfaceConfiguration result = new SurfaceConfiguration(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.redBits = decoder0.decodeUint8(8); + } + if (mainDataHeader.version >= 0) { + + result.greenBits = decoder0.decodeUint8(9); + } + if (mainDataHeader.version >= 0) { + + result.blueBits = decoder0.decodeUint8(10); + } + if (mainDataHeader.version >= 0) { + + result.alphaBits = decoder0.decodeUint8(11); + } + if (mainDataHeader.version >= 0) { + + result.depthBits = decoder0.decodeUint8(12); + } + if (mainDataHeader.version >= 0) { + + result.stencilBits = decoder0.decodeUint8(13); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint8(redBits, 8); + + encoder0.encodeUint8(greenBits, 9); + + encoder0.encodeUint8(blueBits, 10); + + encoder0.encodeUint8(alphaBits, 11); + + encoder0.encodeUint8(depthBits, 12); + + encoder0.encodeUint8(stencilBits, 13); + } + + String toString() { + return "SurfaceConfiguration(" + "redBits: $redBits" ", " + "greenBits: $greenBits" ", " + "blueBits: $blueBits" ", " + "alphaBits: $alphaBits" ", " + "depthBits: $depthBits" ", " + "stencilBits: $stencilBits" ")"; + } + + Map toJson() { + Map map = new Map(); + map["redBits"] = redBits; + map["greenBits"] = greenBits; + map["blueBits"] = blueBits; + map["alphaBits"] = alphaBits; + map["depthBits"] = depthBits; + map["stencilBits"] = stencilBits; + return map; + } +} + + +class NativeViewportCreateParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + geometry_mojom.Size size = null; + SurfaceConfiguration requestedConfiguration = null; + + NativeViewportCreateParams() : super(kVersions.last.size); + + static NativeViewportCreateParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NativeViewportCreateParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NativeViewportCreateParams result = new NativeViewportCreateParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.size = geometry_mojom.Size.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, true); + result.requestedConfiguration = SurfaceConfiguration.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(size, 8, false); + + encoder0.encodeStruct(requestedConfiguration, 16, true); + } + + String toString() { + return "NativeViewportCreateParams(" + "size: $size" ", " + "requestedConfiguration: $requestedConfiguration" ")"; + } + + Map toJson() { + Map map = new Map(); + map["size"] = size; + map["requestedConfiguration"] = requestedConfiguration; + return map; + } +} + + +class NativeViewportCreateResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + ViewportMetrics metrics = null; + + NativeViewportCreateResponseParams() : super(kVersions.last.size); + + static NativeViewportCreateResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NativeViewportCreateResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NativeViewportCreateResponseParams result = new NativeViewportCreateResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.metrics = ViewportMetrics.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(metrics, 8, false); + } + + String toString() { + return "NativeViewportCreateResponseParams(" + "metrics: $metrics" ")"; + } + + Map toJson() { + Map map = new Map(); + map["metrics"] = metrics; + return map; + } +} + + +class NativeViewportShowParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + NativeViewportShowParams() : super(kVersions.last.size); + + static NativeViewportShowParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NativeViewportShowParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NativeViewportShowParams result = new NativeViewportShowParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "NativeViewportShowParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class NativeViewportHideParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + NativeViewportHideParams() : super(kVersions.last.size); + + static NativeViewportHideParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NativeViewportHideParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NativeViewportHideParams result = new NativeViewportHideParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "NativeViewportHideParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class NativeViewportCloseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + NativeViewportCloseParams() : super(kVersions.last.size); + + static NativeViewportCloseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NativeViewportCloseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NativeViewportCloseParams result = new NativeViewportCloseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "NativeViewportCloseParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class NativeViewportSetSizeParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + geometry_mojom.Size size = null; + + NativeViewportSetSizeParams() : super(kVersions.last.size); + + static NativeViewportSetSizeParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NativeViewportSetSizeParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NativeViewportSetSizeParams result = new NativeViewportSetSizeParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.size = geometry_mojom.Size.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(size, 8, false); + } + + String toString() { + return "NativeViewportSetSizeParams(" + "size: $size" ")"; + } + + Map toJson() { + Map map = new Map(); + map["size"] = size; + return map; + } +} + + +class NativeViewportSetEventDispatcherParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + Object dispatcher = null; + + NativeViewportSetEventDispatcherParams() : super(kVersions.last.size); + + static NativeViewportSetEventDispatcherParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NativeViewportSetEventDispatcherParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NativeViewportSetEventDispatcherParams result = new NativeViewportSetEventDispatcherParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.dispatcher = decoder0.decodeServiceInterface(8, false, NativeViewportEventDispatcherProxy.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterface(dispatcher, 8, false); + } + + String toString() { + return "NativeViewportSetEventDispatcherParams(" + "dispatcher: $dispatcher" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class NativeViewportGetContextProviderParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + Object provider = null; + + NativeViewportGetContextProviderParams() : super(kVersions.last.size); + + static NativeViewportGetContextProviderParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NativeViewportGetContextProviderParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NativeViewportGetContextProviderParams result = new NativeViewportGetContextProviderParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.provider = decoder0.decodeInterfaceRequest(8, false, context_provider_mojom.ContextProviderStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterfaceRequest(provider, 8, false); + } + + String toString() { + return "NativeViewportGetContextProviderParams(" + "provider: $provider" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class NativeViewportRequestMetricsParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + NativeViewportRequestMetricsParams() : super(kVersions.last.size); + + static NativeViewportRequestMetricsParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NativeViewportRequestMetricsParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NativeViewportRequestMetricsParams result = new NativeViewportRequestMetricsParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "NativeViewportRequestMetricsParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class NativeViewportRequestMetricsResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + ViewportMetrics metrics = null; + + NativeViewportRequestMetricsResponseParams() : super(kVersions.last.size); + + static NativeViewportRequestMetricsResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NativeViewportRequestMetricsResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NativeViewportRequestMetricsResponseParams result = new NativeViewportRequestMetricsResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.metrics = ViewportMetrics.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(metrics, 8, false); + } + + String toString() { + return "NativeViewportRequestMetricsResponseParams(" + "metrics: $metrics" ")"; + } + + Map toJson() { + Map map = new Map(); + map["metrics"] = metrics; + return map; + } +} + + +class NativeViewportEventDispatcherOnEventParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + input_events_mojom.Event event = null; + + NativeViewportEventDispatcherOnEventParams() : super(kVersions.last.size); + + static NativeViewportEventDispatcherOnEventParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NativeViewportEventDispatcherOnEventParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NativeViewportEventDispatcherOnEventParams result = new NativeViewportEventDispatcherOnEventParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.event = input_events_mojom.Event.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(event, 8, false); + } + + String toString() { + return "NativeViewportEventDispatcherOnEventParams(" + "event: $event" ")"; + } + + Map toJson() { + Map map = new Map(); + map["event"] = event; + return map; + } +} + + +class NativeViewportEventDispatcherOnEventResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + NativeViewportEventDispatcherOnEventResponseParams() : super(kVersions.last.size); + + static NativeViewportEventDispatcherOnEventResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NativeViewportEventDispatcherOnEventResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NativeViewportEventDispatcherOnEventResponseParams result = new NativeViewportEventDispatcherOnEventResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "NativeViewportEventDispatcherOnEventResponseParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + +const int kNativeViewport_create_name = 0; +const int kNativeViewport_show_name = 1; +const int kNativeViewport_hide_name = 2; +const int kNativeViewport_close_name = 3; +const int kNativeViewport_setSize_name = 4; +const int kNativeViewport_setEventDispatcher_name = 5; +const int kNativeViewport_getContextProvider_name = 6; +const int kNativeViewport_requestMetrics_name = 7; + +const String NativeViewportName = + 'mojo::NativeViewport'; + +abstract class NativeViewport { + dynamic create(geometry_mojom.Size size,SurfaceConfiguration requestedConfiguration,[Function responseFactory = null]); + void show(); + void hide(); + void close(); + void setSize(geometry_mojom.Size size); + void setEventDispatcher(Object dispatcher); + void getContextProvider(Object provider); + dynamic requestMetrics([Function responseFactory = null]); + +} + + +class NativeViewportProxyImpl extends bindings.Proxy { + NativeViewportProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + NativeViewportProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + NativeViewportProxyImpl.unbound() : super.unbound(); + + static NativeViewportProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NativeViewportProxyImpl")); + return new NativeViewportProxyImpl.fromEndpoint(endpoint); + } + + String get name => NativeViewportName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kNativeViewport_create_name: + var r = NativeViewportCreateResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kNativeViewport_requestMetrics_name: + var r = NativeViewportRequestMetricsResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "NativeViewportProxyImpl($superString)"; + } +} + + +class _NativeViewportProxyCalls implements NativeViewport { + NativeViewportProxyImpl _proxyImpl; + + _NativeViewportProxyCalls(this._proxyImpl); + dynamic create(geometry_mojom.Size size,SurfaceConfiguration requestedConfiguration,[Function responseFactory = null]) { + var params = new NativeViewportCreateParams(); + params.size = size; + params.requestedConfiguration = requestedConfiguration; + return _proxyImpl.sendMessageWithRequestId( + params, + kNativeViewport_create_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + void show() { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new NativeViewportShowParams(); + _proxyImpl.sendMessage(params, kNativeViewport_show_name); + } + + void hide() { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new NativeViewportHideParams(); + _proxyImpl.sendMessage(params, kNativeViewport_hide_name); + } + + void close() { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new NativeViewportCloseParams(); + _proxyImpl.sendMessage(params, kNativeViewport_close_name); + } + + void setSize(geometry_mojom.Size size) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new NativeViewportSetSizeParams(); + params.size = size; + _proxyImpl.sendMessage(params, kNativeViewport_setSize_name); + } + + void setEventDispatcher(Object dispatcher) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new NativeViewportSetEventDispatcherParams(); + params.dispatcher = dispatcher; + _proxyImpl.sendMessage(params, kNativeViewport_setEventDispatcher_name); + } + + void getContextProvider(Object provider) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new NativeViewportGetContextProviderParams(); + params.provider = provider; + _proxyImpl.sendMessage(params, kNativeViewport_getContextProvider_name); + } + + dynamic requestMetrics([Function responseFactory = null]) { + var params = new NativeViewportRequestMetricsParams(); + return _proxyImpl.sendMessageWithRequestId( + params, + kNativeViewport_requestMetrics_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class NativeViewportProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + NativeViewport ptr; + final String name = NativeViewportName; + + NativeViewportProxy(NativeViewportProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _NativeViewportProxyCalls(proxyImpl); + + NativeViewportProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new NativeViewportProxyImpl.fromEndpoint(endpoint) { + ptr = new _NativeViewportProxyCalls(impl); + } + + NativeViewportProxy.fromHandle(core.MojoHandle handle) : + impl = new NativeViewportProxyImpl.fromHandle(handle) { + ptr = new _NativeViewportProxyCalls(impl); + } + + NativeViewportProxy.unbound() : + impl = new NativeViewportProxyImpl.unbound() { + ptr = new _NativeViewportProxyCalls(impl); + } + + factory NativeViewportProxy.connectToService( + bindings.ServiceConnector s, String url) { + NativeViewportProxy p = new NativeViewportProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static NativeViewportProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NativeViewportProxy")); + return new NativeViewportProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "NativeViewportProxy($impl)"; + } +} + + +class NativeViewportStub extends bindings.Stub { + NativeViewport _impl = null; + + NativeViewportStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + NativeViewportStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + NativeViewportStub.unbound() : super.unbound(); + + static NativeViewportStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NativeViewportStub")); + return new NativeViewportStub.fromEndpoint(endpoint); + } + + static const String name = NativeViewportName; + + + NativeViewportCreateResponseParams _NativeViewportCreateResponseParamsFactory(ViewportMetrics metrics) { + var result = new NativeViewportCreateResponseParams(); + result.metrics = metrics; + return result; + } + NativeViewportRequestMetricsResponseParams _NativeViewportRequestMetricsResponseParamsFactory(ViewportMetrics metrics) { + var result = new NativeViewportRequestMetricsResponseParams(); + result.metrics = metrics; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kNativeViewport_create_name: + var params = NativeViewportCreateParams.deserialize( + message.payload); + var response = _impl.create(params.size,params.requestedConfiguration,_NativeViewportCreateResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kNativeViewport_create_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kNativeViewport_create_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kNativeViewport_show_name: + var params = NativeViewportShowParams.deserialize( + message.payload); + _impl.show(); + break; + case kNativeViewport_hide_name: + var params = NativeViewportHideParams.deserialize( + message.payload); + _impl.hide(); + break; + case kNativeViewport_close_name: + var params = NativeViewportCloseParams.deserialize( + message.payload); + _impl.close(); + break; + case kNativeViewport_setSize_name: + var params = NativeViewportSetSizeParams.deserialize( + message.payload); + _impl.setSize(params.size); + break; + case kNativeViewport_setEventDispatcher_name: + var params = NativeViewportSetEventDispatcherParams.deserialize( + message.payload); + _impl.setEventDispatcher(params.dispatcher); + break; + case kNativeViewport_getContextProvider_name: + var params = NativeViewportGetContextProviderParams.deserialize( + message.payload); + _impl.getContextProvider(params.provider); + break; + case kNativeViewport_requestMetrics_name: + var params = NativeViewportRequestMetricsParams.deserialize( + message.payload); + var response = _impl.requestMetrics(_NativeViewportRequestMetricsResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kNativeViewport_requestMetrics_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kNativeViewport_requestMetrics_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + NativeViewport get impl => _impl; + set impl(NativeViewport d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "NativeViewportStub($superString)"; + } + + int get version => 0; +} + +const int kNativeViewportEventDispatcher_onEvent_name = 0; + +const String NativeViewportEventDispatcherName = + 'mojo::NativeViewportEventDispatcher'; + +abstract class NativeViewportEventDispatcher { + dynamic onEvent(input_events_mojom.Event event,[Function responseFactory = null]); + +} + + +class NativeViewportEventDispatcherProxyImpl extends bindings.Proxy { + NativeViewportEventDispatcherProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + NativeViewportEventDispatcherProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + NativeViewportEventDispatcherProxyImpl.unbound() : super.unbound(); + + static NativeViewportEventDispatcherProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NativeViewportEventDispatcherProxyImpl")); + return new NativeViewportEventDispatcherProxyImpl.fromEndpoint(endpoint); + } + + String get name => NativeViewportEventDispatcherName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kNativeViewportEventDispatcher_onEvent_name: + var r = NativeViewportEventDispatcherOnEventResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "NativeViewportEventDispatcherProxyImpl($superString)"; + } +} + + +class _NativeViewportEventDispatcherProxyCalls implements NativeViewportEventDispatcher { + NativeViewportEventDispatcherProxyImpl _proxyImpl; + + _NativeViewportEventDispatcherProxyCalls(this._proxyImpl); + dynamic onEvent(input_events_mojom.Event event,[Function responseFactory = null]) { + var params = new NativeViewportEventDispatcherOnEventParams(); + params.event = event; + return _proxyImpl.sendMessageWithRequestId( + params, + kNativeViewportEventDispatcher_onEvent_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class NativeViewportEventDispatcherProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + NativeViewportEventDispatcher ptr; + final String name = NativeViewportEventDispatcherName; + + NativeViewportEventDispatcherProxy(NativeViewportEventDispatcherProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _NativeViewportEventDispatcherProxyCalls(proxyImpl); + + NativeViewportEventDispatcherProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new NativeViewportEventDispatcherProxyImpl.fromEndpoint(endpoint) { + ptr = new _NativeViewportEventDispatcherProxyCalls(impl); + } + + NativeViewportEventDispatcherProxy.fromHandle(core.MojoHandle handle) : + impl = new NativeViewportEventDispatcherProxyImpl.fromHandle(handle) { + ptr = new _NativeViewportEventDispatcherProxyCalls(impl); + } + + NativeViewportEventDispatcherProxy.unbound() : + impl = new NativeViewportEventDispatcherProxyImpl.unbound() { + ptr = new _NativeViewportEventDispatcherProxyCalls(impl); + } + + factory NativeViewportEventDispatcherProxy.connectToService( + bindings.ServiceConnector s, String url) { + NativeViewportEventDispatcherProxy p = new NativeViewportEventDispatcherProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static NativeViewportEventDispatcherProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NativeViewportEventDispatcherProxy")); + return new NativeViewportEventDispatcherProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "NativeViewportEventDispatcherProxy($impl)"; + } +} + + +class NativeViewportEventDispatcherStub extends bindings.Stub { + NativeViewportEventDispatcher _impl = null; + + NativeViewportEventDispatcherStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + NativeViewportEventDispatcherStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + NativeViewportEventDispatcherStub.unbound() : super.unbound(); + + static NativeViewportEventDispatcherStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NativeViewportEventDispatcherStub")); + return new NativeViewportEventDispatcherStub.fromEndpoint(endpoint); + } + + static const String name = NativeViewportEventDispatcherName; + + + NativeViewportEventDispatcherOnEventResponseParams _NativeViewportEventDispatcherOnEventResponseParamsFactory() { + var result = new NativeViewportEventDispatcherOnEventResponseParams(); + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kNativeViewportEventDispatcher_onEvent_name: + var params = NativeViewportEventDispatcherOnEventParams.deserialize( + message.payload); + var response = _impl.onEvent(params.event,_NativeViewportEventDispatcherOnEventResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kNativeViewportEventDispatcher_onEvent_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kNativeViewportEventDispatcher_onEvent_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + NativeViewportEventDispatcher get impl => _impl; + set impl(NativeViewportEventDispatcher d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "NativeViewportEventDispatcherStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/navigation.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/navigation.mojom.dart new file mode 100644 index 0000000..4968d4c --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/navigation.mojom.dart
@@ -0,0 +1,493 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library navigation_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo/mojo/url_request.mojom.dart' as url_request_mojom; +class Target extends bindings.MojoEnum { + static const DEFAULT = const Target._(0); + static const SOURCE_NODE = const Target._(1); + static const NEW_NODE = const Target._(2); + + const Target._(int v) : super(v); + + static const Map<String, Target> valuesMap = const { + "DEFAULT": DEFAULT, + "SOURCE_NODE": SOURCE_NODE, + "NEW_NODE": NEW_NODE, + }; + static const List<Target> values = const [ + DEFAULT, + SOURCE_NODE, + NEW_NODE, + ]; + + static Target valueOf(String name) => valuesMap[name]; + + factory Target(int v) { + switch (v) { + case 0: + return DEFAULT; + case 1: + return SOURCE_NODE; + case 2: + return NEW_NODE; + default: + return null; + } + } + + static Target decode(bindings.Decoder decoder0, int offset) { + int v = decoder0.decodeUint32(offset); + Target result = new Target(v); + if (result == null) { + throw new bindings.MojoCodecError( + 'Bad value $v for enum Target.'); + } + return result; + } + + String toString() { + switch(this) { + case DEFAULT: + return 'Target.DEFAULT'; + case SOURCE_NODE: + return 'Target.SOURCE_NODE'; + case NEW_NODE: + return 'Target.NEW_NODE'; + } + } + + int toJson() => value; +} + + + +class NavigatorHostRequestNavigateParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + Target target = null; + url_request_mojom.UrlRequest request = null; + + NavigatorHostRequestNavigateParams() : super(kVersions.last.size); + + static NavigatorHostRequestNavigateParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NavigatorHostRequestNavigateParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NavigatorHostRequestNavigateParams result = new NavigatorHostRequestNavigateParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.target = Target.decode(decoder0, 8); + if (result.target == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable Target.'); + } + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + result.request = url_request_mojom.UrlRequest.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(target, 8); + + encoder0.encodeStruct(request, 16, false); + } + + String toString() { + return "NavigatorHostRequestNavigateParams(" + "target: $target" ", " + "request: $request" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class NavigatorHostRequestNavigateHistoryParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int delta = 0; + + NavigatorHostRequestNavigateHistoryParams() : super(kVersions.last.size); + + static NavigatorHostRequestNavigateHistoryParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NavigatorHostRequestNavigateHistoryParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NavigatorHostRequestNavigateHistoryParams result = new NavigatorHostRequestNavigateHistoryParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.delta = decoder0.decodeInt32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt32(delta, 8); + } + + String toString() { + return "NavigatorHostRequestNavigateHistoryParams(" + "delta: $delta" ")"; + } + + Map toJson() { + Map map = new Map(); + map["delta"] = delta; + return map; + } +} + + +class NavigatorHostDidNavigateLocallyParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + String url = null; + + NavigatorHostDidNavigateLocallyParams() : super(kVersions.last.size); + + static NavigatorHostDidNavigateLocallyParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NavigatorHostDidNavigateLocallyParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NavigatorHostDidNavigateLocallyParams result = new NavigatorHostDidNavigateLocallyParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.url = decoder0.decodeString(8, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(url, 8, false); + } + + String toString() { + return "NavigatorHostDidNavigateLocallyParams(" + "url: $url" ")"; + } + + Map toJson() { + Map map = new Map(); + map["url"] = url; + return map; + } +} + +const int kNavigatorHost_requestNavigate_name = 0; +const int kNavigatorHost_requestNavigateHistory_name = 1; +const int kNavigatorHost_didNavigateLocally_name = 2; + +const String NavigatorHostName = + 'mojo::NavigatorHost'; + +abstract class NavigatorHost { + void requestNavigate(Target target, url_request_mojom.UrlRequest request); + void requestNavigateHistory(int delta); + void didNavigateLocally(String url); + +} + + +class NavigatorHostProxyImpl extends bindings.Proxy { + NavigatorHostProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + NavigatorHostProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + NavigatorHostProxyImpl.unbound() : super.unbound(); + + static NavigatorHostProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NavigatorHostProxyImpl")); + return new NavigatorHostProxyImpl.fromEndpoint(endpoint); + } + + String get name => NavigatorHostName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "NavigatorHostProxyImpl($superString)"; + } +} + + +class _NavigatorHostProxyCalls implements NavigatorHost { + NavigatorHostProxyImpl _proxyImpl; + + _NavigatorHostProxyCalls(this._proxyImpl); + void requestNavigate(Target target, url_request_mojom.UrlRequest request) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new NavigatorHostRequestNavigateParams(); + params.target = target; + params.request = request; + _proxyImpl.sendMessage(params, kNavigatorHost_requestNavigate_name); + } + + void requestNavigateHistory(int delta) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new NavigatorHostRequestNavigateHistoryParams(); + params.delta = delta; + _proxyImpl.sendMessage(params, kNavigatorHost_requestNavigateHistory_name); + } + + void didNavigateLocally(String url) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new NavigatorHostDidNavigateLocallyParams(); + params.url = url; + _proxyImpl.sendMessage(params, kNavigatorHost_didNavigateLocally_name); + } + +} + + +class NavigatorHostProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + NavigatorHost ptr; + final String name = NavigatorHostName; + + NavigatorHostProxy(NavigatorHostProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _NavigatorHostProxyCalls(proxyImpl); + + NavigatorHostProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new NavigatorHostProxyImpl.fromEndpoint(endpoint) { + ptr = new _NavigatorHostProxyCalls(impl); + } + + NavigatorHostProxy.fromHandle(core.MojoHandle handle) : + impl = new NavigatorHostProxyImpl.fromHandle(handle) { + ptr = new _NavigatorHostProxyCalls(impl); + } + + NavigatorHostProxy.unbound() : + impl = new NavigatorHostProxyImpl.unbound() { + ptr = new _NavigatorHostProxyCalls(impl); + } + + factory NavigatorHostProxy.connectToService( + bindings.ServiceConnector s, String url) { + NavigatorHostProxy p = new NavigatorHostProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static NavigatorHostProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NavigatorHostProxy")); + return new NavigatorHostProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "NavigatorHostProxy($impl)"; + } +} + + +class NavigatorHostStub extends bindings.Stub { + NavigatorHost _impl = null; + + NavigatorHostStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + NavigatorHostStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + NavigatorHostStub.unbound() : super.unbound(); + + static NavigatorHostStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NavigatorHostStub")); + return new NavigatorHostStub.fromEndpoint(endpoint); + } + + static const String name = NavigatorHostName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kNavigatorHost_requestNavigate_name: + var params = NavigatorHostRequestNavigateParams.deserialize( + message.payload); + _impl.requestNavigate(params.target, params.request); + break; + case kNavigatorHost_requestNavigateHistory_name: + var params = NavigatorHostRequestNavigateHistoryParams.deserialize( + message.payload); + _impl.requestNavigateHistory(params.delta); + break; + case kNavigatorHost_didNavigateLocally_name: + var params = NavigatorHostDidNavigateLocallyParams.deserialize( + message.payload); + _impl.didNavigateLocally(params.url); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + NavigatorHost get impl => _impl; + set impl(NavigatorHost d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "NavigatorHostStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/net_address.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/net_address.mojom.dart new file mode 100644 index 0000000..ab3ebb3 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/net_address.mojom.dart
@@ -0,0 +1,312 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library net_address_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +class NetAddressFamily extends bindings.MojoEnum { + static const UNSPECIFIED = const NetAddressFamily._(0); + static const IPV4 = const NetAddressFamily._(1); + static const IPV6 = const NetAddressFamily._(2); + + const NetAddressFamily._(int v) : super(v); + + static const Map<String, NetAddressFamily> valuesMap = const { + "UNSPECIFIED": UNSPECIFIED, + "IPV4": IPV4, + "IPV6": IPV6, + }; + static const List<NetAddressFamily> values = const [ + UNSPECIFIED, + IPV4, + IPV6, + ]; + + static NetAddressFamily valueOf(String name) => valuesMap[name]; + + factory NetAddressFamily(int v) { + switch (v) { + case 0: + return UNSPECIFIED; + case 1: + return IPV4; + case 2: + return IPV6; + default: + return null; + } + } + + static NetAddressFamily decode(bindings.Decoder decoder0, int offset) { + int v = decoder0.decodeUint32(offset); + NetAddressFamily result = new NetAddressFamily(v); + if (result == null) { + throw new bindings.MojoCodecError( + 'Bad value $v for enum NetAddressFamily.'); + } + return result; + } + + String toString() { + switch(this) { + case UNSPECIFIED: + return 'NetAddressFamily.UNSPECIFIED'; + case IPV4: + return 'NetAddressFamily.IPV4'; + case IPV6: + return 'NetAddressFamily.IPV6'; + } + } + + int toJson() => value; +} + + + +class NetAddressIPv4 extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int port = 0; + List<int> addr = null; + + NetAddressIPv4() : super(kVersions.last.size); + + static NetAddressIPv4 deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NetAddressIPv4 decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NetAddressIPv4 result = new NetAddressIPv4(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.port = decoder0.decodeUint16(8); + } + if (mainDataHeader.version >= 0) { + + result.addr = decoder0.decodeUint8Array(16, bindings.kNothingNullable, 4); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint16(port, 8); + + encoder0.encodeUint8Array(addr, 16, bindings.kNothingNullable, 4); + } + + String toString() { + return "NetAddressIPv4(" + "port: $port" ", " + "addr: $addr" ")"; + } + + Map toJson() { + Map map = new Map(); + map["port"] = port; + map["addr"] = addr; + return map; + } +} + + +class NetAddressIPv6 extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int port = 0; + List<int> addr = null; + + NetAddressIPv6() : super(kVersions.last.size); + + static NetAddressIPv6 deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NetAddressIPv6 decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NetAddressIPv6 result = new NetAddressIPv6(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.port = decoder0.decodeUint16(8); + } + if (mainDataHeader.version >= 0) { + + result.addr = decoder0.decodeUint8Array(16, bindings.kNothingNullable, 16); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint16(port, 8); + + encoder0.encodeUint8Array(addr, 16, bindings.kNothingNullable, 16); + } + + String toString() { + return "NetAddressIPv6(" + "port: $port" ", " + "addr: $addr" ")"; + } + + Map toJson() { + Map map = new Map(); + map["port"] = port; + map["addr"] = addr; + return map; + } +} + + +class NetAddress extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(32, 0) + ]; + NetAddressFamily family = new NetAddressFamily(0); + NetAddressIPv4 ipv4 = null; + NetAddressIPv6 ipv6 = null; + + NetAddress() : super(kVersions.last.size); + + static NetAddress deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NetAddress decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NetAddress result = new NetAddress(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.family = NetAddressFamily.decode(decoder0, 8); + if (result.family == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable NetAddressFamily.'); + } + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, true); + result.ipv4 = NetAddressIPv4.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(24, true); + result.ipv6 = NetAddressIPv6.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(family, 8); + + encoder0.encodeStruct(ipv4, 16, true); + + encoder0.encodeStruct(ipv6, 24, true); + } + + String toString() { + return "NetAddress(" + "family: $family" ", " + "ipv4: $ipv4" ", " + "ipv6: $ipv6" ")"; + } + + Map toJson() { + Map map = new Map(); + map["family"] = family; + map["ipv4"] = ipv4; + map["ipv6"] = ipv6; + return map; + } +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/network_service.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/network_service.mojom.dart new file mode 100644 index 0000000..8a811ff --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/network_service.mojom.dart
@@ -0,0 +1,1337 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library network_service_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo/mojo/network_error.mojom.dart' as network_error_mojom; +import 'package:mojo_services/mojo/cookie_store.mojom.dart' as cookie_store_mojom; +import 'package:mojo_services/mojo/host_resolver.mojom.dart' as host_resolver_mojom; +import 'package:mojo_services/mojo/http_server.mojom.dart' as http_server_mojom; +import 'package:mojo_services/mojo/net_address.mojom.dart' as net_address_mojom; +import 'package:mojo_services/mojo/tcp_bound_socket.mojom.dart' as tcp_bound_socket_mojom; +import 'package:mojo_services/mojo/tcp_connected_socket.mojom.dart' as tcp_connected_socket_mojom; +import 'package:mojo_services/mojo/udp_socket.mojom.dart' as udp_socket_mojom; +import 'package:mojo_services/mojo/url_loader.mojom.dart' as url_loader_mojom; +import 'package:mojo_services/mojo/url_loader_interceptor.mojom.dart' as url_loader_interceptor_mojom; +import 'package:mojo_services/mojo/web_socket.mojom.dart' as web_socket_mojom; + + + +class NetworkServiceCreateUrlLoaderParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + Object loader = null; + + NetworkServiceCreateUrlLoaderParams() : super(kVersions.last.size); + + static NetworkServiceCreateUrlLoaderParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NetworkServiceCreateUrlLoaderParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NetworkServiceCreateUrlLoaderParams result = new NetworkServiceCreateUrlLoaderParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.loader = decoder0.decodeInterfaceRequest(8, false, url_loader_mojom.UrlLoaderStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterfaceRequest(loader, 8, false); + } + + String toString() { + return "NetworkServiceCreateUrlLoaderParams(" + "loader: $loader" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class NetworkServiceGetCookieStoreParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + Object cookieStore = null; + + NetworkServiceGetCookieStoreParams() : super(kVersions.last.size); + + static NetworkServiceGetCookieStoreParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NetworkServiceGetCookieStoreParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NetworkServiceGetCookieStoreParams result = new NetworkServiceGetCookieStoreParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.cookieStore = decoder0.decodeInterfaceRequest(8, false, cookie_store_mojom.CookieStoreStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterfaceRequest(cookieStore, 8, false); + } + + String toString() { + return "NetworkServiceGetCookieStoreParams(" + "cookieStore: $cookieStore" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class NetworkServiceCreateWebSocketParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + Object socket = null; + + NetworkServiceCreateWebSocketParams() : super(kVersions.last.size); + + static NetworkServiceCreateWebSocketParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NetworkServiceCreateWebSocketParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NetworkServiceCreateWebSocketParams result = new NetworkServiceCreateWebSocketParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.socket = decoder0.decodeInterfaceRequest(8, false, web_socket_mojom.WebSocketStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterfaceRequest(socket, 8, false); + } + + String toString() { + return "NetworkServiceCreateWebSocketParams(" + "socket: $socket" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class NetworkServiceCreateTcpBoundSocketParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + net_address_mojom.NetAddress localAddress = null; + Object boundSocket = null; + + NetworkServiceCreateTcpBoundSocketParams() : super(kVersions.last.size); + + static NetworkServiceCreateTcpBoundSocketParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NetworkServiceCreateTcpBoundSocketParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NetworkServiceCreateTcpBoundSocketParams result = new NetworkServiceCreateTcpBoundSocketParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, true); + result.localAddress = net_address_mojom.NetAddress.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + result.boundSocket = decoder0.decodeInterfaceRequest(16, false, tcp_bound_socket_mojom.TcpBoundSocketStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(localAddress, 8, true); + + encoder0.encodeInterfaceRequest(boundSocket, 16, false); + } + + String toString() { + return "NetworkServiceCreateTcpBoundSocketParams(" + "localAddress: $localAddress" ", " + "boundSocket: $boundSocket" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class NetworkServiceCreateTcpBoundSocketResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + network_error_mojom.NetworkError result = null; + net_address_mojom.NetAddress boundTo = null; + + NetworkServiceCreateTcpBoundSocketResponseParams() : super(kVersions.last.size); + + static NetworkServiceCreateTcpBoundSocketResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NetworkServiceCreateTcpBoundSocketResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NetworkServiceCreateTcpBoundSocketResponseParams result = new NetworkServiceCreateTcpBoundSocketResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.result = network_error_mojom.NetworkError.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, true); + result.boundTo = net_address_mojom.NetAddress.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(result, 8, false); + + encoder0.encodeStruct(boundTo, 16, true); + } + + String toString() { + return "NetworkServiceCreateTcpBoundSocketResponseParams(" + "result: $result" ", " + "boundTo: $boundTo" ")"; + } + + Map toJson() { + Map map = new Map(); + map["result"] = result; + map["boundTo"] = boundTo; + return map; + } +} + + +class NetworkServiceCreateTcpConnectedSocketParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(32, 0) + ]; + net_address_mojom.NetAddress remoteAddress = null; + core.MojoDataPipeConsumer sendStream = null; + core.MojoDataPipeProducer receiveStream = null; + Object clientSocket = null; + + NetworkServiceCreateTcpConnectedSocketParams() : super(kVersions.last.size); + + static NetworkServiceCreateTcpConnectedSocketParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NetworkServiceCreateTcpConnectedSocketParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NetworkServiceCreateTcpConnectedSocketParams result = new NetworkServiceCreateTcpConnectedSocketParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.remoteAddress = net_address_mojom.NetAddress.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + result.sendStream = decoder0.decodeConsumerHandle(16, false); + } + if (mainDataHeader.version >= 0) { + + result.receiveStream = decoder0.decodeProducerHandle(20, false); + } + if (mainDataHeader.version >= 0) { + + result.clientSocket = decoder0.decodeInterfaceRequest(24, false, tcp_connected_socket_mojom.TcpConnectedSocketStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(remoteAddress, 8, false); + + encoder0.encodeConsumerHandle(sendStream, 16, false); + + encoder0.encodeProducerHandle(receiveStream, 20, false); + + encoder0.encodeInterfaceRequest(clientSocket, 24, false); + } + + String toString() { + return "NetworkServiceCreateTcpConnectedSocketParams(" + "remoteAddress: $remoteAddress" ", " + "sendStream: $sendStream" ", " + "receiveStream: $receiveStream" ", " + "clientSocket: $clientSocket" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class NetworkServiceCreateTcpConnectedSocketResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + network_error_mojom.NetworkError result = null; + net_address_mojom.NetAddress localAddress = null; + + NetworkServiceCreateTcpConnectedSocketResponseParams() : super(kVersions.last.size); + + static NetworkServiceCreateTcpConnectedSocketResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NetworkServiceCreateTcpConnectedSocketResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NetworkServiceCreateTcpConnectedSocketResponseParams result = new NetworkServiceCreateTcpConnectedSocketResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.result = network_error_mojom.NetworkError.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, true); + result.localAddress = net_address_mojom.NetAddress.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(result, 8, false); + + encoder0.encodeStruct(localAddress, 16, true); + } + + String toString() { + return "NetworkServiceCreateTcpConnectedSocketResponseParams(" + "result: $result" ", " + "localAddress: $localAddress" ")"; + } + + Map toJson() { + Map map = new Map(); + map["result"] = result; + map["localAddress"] = localAddress; + return map; + } +} + + +class NetworkServiceCreateUdpSocketParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + Object socket = null; + + NetworkServiceCreateUdpSocketParams() : super(kVersions.last.size); + + static NetworkServiceCreateUdpSocketParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NetworkServiceCreateUdpSocketParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NetworkServiceCreateUdpSocketParams result = new NetworkServiceCreateUdpSocketParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.socket = decoder0.decodeInterfaceRequest(8, false, udp_socket_mojom.UdpSocketStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterfaceRequest(socket, 8, false); + } + + String toString() { + return "NetworkServiceCreateUdpSocketParams(" + "socket: $socket" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class NetworkServiceCreateHttpServerParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + net_address_mojom.NetAddress localAddress = null; + Object delegate = null; + + NetworkServiceCreateHttpServerParams() : super(kVersions.last.size); + + static NetworkServiceCreateHttpServerParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NetworkServiceCreateHttpServerParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NetworkServiceCreateHttpServerParams result = new NetworkServiceCreateHttpServerParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.localAddress = net_address_mojom.NetAddress.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + result.delegate = decoder0.decodeServiceInterface(16, false, http_server_mojom.HttpServerDelegateProxy.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(localAddress, 8, false); + + encoder0.encodeInterface(delegate, 16, false); + } + + String toString() { + return "NetworkServiceCreateHttpServerParams(" + "localAddress: $localAddress" ", " + "delegate: $delegate" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class NetworkServiceCreateHttpServerResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + network_error_mojom.NetworkError result = null; + net_address_mojom.NetAddress boundTo = null; + + NetworkServiceCreateHttpServerResponseParams() : super(kVersions.last.size); + + static NetworkServiceCreateHttpServerResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NetworkServiceCreateHttpServerResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NetworkServiceCreateHttpServerResponseParams result = new NetworkServiceCreateHttpServerResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.result = network_error_mojom.NetworkError.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, true); + result.boundTo = net_address_mojom.NetAddress.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(result, 8, false); + + encoder0.encodeStruct(boundTo, 16, true); + } + + String toString() { + return "NetworkServiceCreateHttpServerResponseParams(" + "result: $result" ", " + "boundTo: $boundTo" ")"; + } + + Map toJson() { + Map map = new Map(); + map["result"] = result; + map["boundTo"] = boundTo; + return map; + } +} + + +class NetworkServiceRegisterUrlLoaderInterceptorParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + Object factory = null; + + NetworkServiceRegisterUrlLoaderInterceptorParams() : super(kVersions.last.size); + + static NetworkServiceRegisterUrlLoaderInterceptorParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NetworkServiceRegisterUrlLoaderInterceptorParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NetworkServiceRegisterUrlLoaderInterceptorParams result = new NetworkServiceRegisterUrlLoaderInterceptorParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.factory = decoder0.decodeServiceInterface(8, false, url_loader_interceptor_mojom.UrlLoaderInterceptorFactoryProxy.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterface(factory, 8, false); + } + + String toString() { + return "NetworkServiceRegisterUrlLoaderInterceptorParams(" + "factory: $factory" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class NetworkServiceCreateHostResolverParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + Object hostResolver = null; + + NetworkServiceCreateHostResolverParams() : super(kVersions.last.size); + + static NetworkServiceCreateHostResolverParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NetworkServiceCreateHostResolverParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NetworkServiceCreateHostResolverParams result = new NetworkServiceCreateHostResolverParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.hostResolver = decoder0.decodeInterfaceRequest(8, false, host_resolver_mojom.HostResolverStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterfaceRequest(hostResolver, 8, false); + } + + String toString() { + return "NetworkServiceCreateHostResolverParams(" + "hostResolver: $hostResolver" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + +const int kNetworkService_createUrlLoader_name = 0; +const int kNetworkService_getCookieStore_name = 1; +const int kNetworkService_createWebSocket_name = 2; +const int kNetworkService_createTcpBoundSocket_name = 3; +const int kNetworkService_createTcpConnectedSocket_name = 4; +const int kNetworkService_createUdpSocket_name = 5; +const int kNetworkService_createHttpServer_name = 6; +const int kNetworkService_registerUrlLoaderInterceptor_name = 7; +const int kNetworkService_createHostResolver_name = 8; + +const String NetworkServiceName = + 'mojo::NetworkService'; + +abstract class NetworkService { + void createUrlLoader(Object loader); + void getCookieStore(Object cookieStore); + void createWebSocket(Object socket); + dynamic createTcpBoundSocket(net_address_mojom.NetAddress localAddress,Object boundSocket,[Function responseFactory = null]); + dynamic createTcpConnectedSocket(net_address_mojom.NetAddress remoteAddress,core.MojoDataPipeConsumer sendStream,core.MojoDataPipeProducer receiveStream,Object clientSocket,[Function responseFactory = null]); + void createUdpSocket(Object socket); + dynamic createHttpServer(net_address_mojom.NetAddress localAddress,Object delegate,[Function responseFactory = null]); + void registerUrlLoaderInterceptor(Object factory); + void createHostResolver(Object hostResolver); + +} + + +class NetworkServiceProxyImpl extends bindings.Proxy { + NetworkServiceProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + NetworkServiceProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + NetworkServiceProxyImpl.unbound() : super.unbound(); + + static NetworkServiceProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NetworkServiceProxyImpl")); + return new NetworkServiceProxyImpl.fromEndpoint(endpoint); + } + + String get name => NetworkServiceName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kNetworkService_createTcpBoundSocket_name: + var r = NetworkServiceCreateTcpBoundSocketResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kNetworkService_createTcpConnectedSocket_name: + var r = NetworkServiceCreateTcpConnectedSocketResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kNetworkService_createHttpServer_name: + var r = NetworkServiceCreateHttpServerResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "NetworkServiceProxyImpl($superString)"; + } +} + + +class _NetworkServiceProxyCalls implements NetworkService { + NetworkServiceProxyImpl _proxyImpl; + + _NetworkServiceProxyCalls(this._proxyImpl); + void createUrlLoader(Object loader) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new NetworkServiceCreateUrlLoaderParams(); + params.loader = loader; + _proxyImpl.sendMessage(params, kNetworkService_createUrlLoader_name); + } + + void getCookieStore(Object cookieStore) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new NetworkServiceGetCookieStoreParams(); + params.cookieStore = cookieStore; + _proxyImpl.sendMessage(params, kNetworkService_getCookieStore_name); + } + + void createWebSocket(Object socket) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new NetworkServiceCreateWebSocketParams(); + params.socket = socket; + _proxyImpl.sendMessage(params, kNetworkService_createWebSocket_name); + } + + dynamic createTcpBoundSocket(net_address_mojom.NetAddress localAddress,Object boundSocket,[Function responseFactory = null]) { + var params = new NetworkServiceCreateTcpBoundSocketParams(); + params.localAddress = localAddress; + params.boundSocket = boundSocket; + return _proxyImpl.sendMessageWithRequestId( + params, + kNetworkService_createTcpBoundSocket_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic createTcpConnectedSocket(net_address_mojom.NetAddress remoteAddress,core.MojoDataPipeConsumer sendStream,core.MojoDataPipeProducer receiveStream,Object clientSocket,[Function responseFactory = null]) { + var params = new NetworkServiceCreateTcpConnectedSocketParams(); + params.remoteAddress = remoteAddress; + params.sendStream = sendStream; + params.receiveStream = receiveStream; + params.clientSocket = clientSocket; + return _proxyImpl.sendMessageWithRequestId( + params, + kNetworkService_createTcpConnectedSocket_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + void createUdpSocket(Object socket) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new NetworkServiceCreateUdpSocketParams(); + params.socket = socket; + _proxyImpl.sendMessage(params, kNetworkService_createUdpSocket_name); + } + + dynamic createHttpServer(net_address_mojom.NetAddress localAddress,Object delegate,[Function responseFactory = null]) { + var params = new NetworkServiceCreateHttpServerParams(); + params.localAddress = localAddress; + params.delegate = delegate; + return _proxyImpl.sendMessageWithRequestId( + params, + kNetworkService_createHttpServer_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + void registerUrlLoaderInterceptor(Object factory) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new NetworkServiceRegisterUrlLoaderInterceptorParams(); + params.factory = factory; + _proxyImpl.sendMessage(params, kNetworkService_registerUrlLoaderInterceptor_name); + } + + void createHostResolver(Object hostResolver) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new NetworkServiceCreateHostResolverParams(); + params.hostResolver = hostResolver; + _proxyImpl.sendMessage(params, kNetworkService_createHostResolver_name); + } + +} + + +class NetworkServiceProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + NetworkService ptr; + final String name = NetworkServiceName; + + NetworkServiceProxy(NetworkServiceProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _NetworkServiceProxyCalls(proxyImpl); + + NetworkServiceProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new NetworkServiceProxyImpl.fromEndpoint(endpoint) { + ptr = new _NetworkServiceProxyCalls(impl); + } + + NetworkServiceProxy.fromHandle(core.MojoHandle handle) : + impl = new NetworkServiceProxyImpl.fromHandle(handle) { + ptr = new _NetworkServiceProxyCalls(impl); + } + + NetworkServiceProxy.unbound() : + impl = new NetworkServiceProxyImpl.unbound() { + ptr = new _NetworkServiceProxyCalls(impl); + } + + factory NetworkServiceProxy.connectToService( + bindings.ServiceConnector s, String url) { + NetworkServiceProxy p = new NetworkServiceProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static NetworkServiceProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NetworkServiceProxy")); + return new NetworkServiceProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "NetworkServiceProxy($impl)"; + } +} + + +class NetworkServiceStub extends bindings.Stub { + NetworkService _impl = null; + + NetworkServiceStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + NetworkServiceStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + NetworkServiceStub.unbound() : super.unbound(); + + static NetworkServiceStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NetworkServiceStub")); + return new NetworkServiceStub.fromEndpoint(endpoint); + } + + static const String name = NetworkServiceName; + + + NetworkServiceCreateTcpBoundSocketResponseParams _NetworkServiceCreateTcpBoundSocketResponseParamsFactory(network_error_mojom.NetworkError result, net_address_mojom.NetAddress boundTo) { + var result = new NetworkServiceCreateTcpBoundSocketResponseParams(); + result.result = result; + result.boundTo = boundTo; + return result; + } + NetworkServiceCreateTcpConnectedSocketResponseParams _NetworkServiceCreateTcpConnectedSocketResponseParamsFactory(network_error_mojom.NetworkError result, net_address_mojom.NetAddress localAddress) { + var result = new NetworkServiceCreateTcpConnectedSocketResponseParams(); + result.result = result; + result.localAddress = localAddress; + return result; + } + NetworkServiceCreateHttpServerResponseParams _NetworkServiceCreateHttpServerResponseParamsFactory(network_error_mojom.NetworkError result, net_address_mojom.NetAddress boundTo) { + var result = new NetworkServiceCreateHttpServerResponseParams(); + result.result = result; + result.boundTo = boundTo; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kNetworkService_createUrlLoader_name: + var params = NetworkServiceCreateUrlLoaderParams.deserialize( + message.payload); + _impl.createUrlLoader(params.loader); + break; + case kNetworkService_getCookieStore_name: + var params = NetworkServiceGetCookieStoreParams.deserialize( + message.payload); + _impl.getCookieStore(params.cookieStore); + break; + case kNetworkService_createWebSocket_name: + var params = NetworkServiceCreateWebSocketParams.deserialize( + message.payload); + _impl.createWebSocket(params.socket); + break; + case kNetworkService_createTcpBoundSocket_name: + var params = NetworkServiceCreateTcpBoundSocketParams.deserialize( + message.payload); + var response = _impl.createTcpBoundSocket(params.localAddress,params.boundSocket,_NetworkServiceCreateTcpBoundSocketResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kNetworkService_createTcpBoundSocket_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kNetworkService_createTcpBoundSocket_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kNetworkService_createTcpConnectedSocket_name: + var params = NetworkServiceCreateTcpConnectedSocketParams.deserialize( + message.payload); + var response = _impl.createTcpConnectedSocket(params.remoteAddress,params.sendStream,params.receiveStream,params.clientSocket,_NetworkServiceCreateTcpConnectedSocketResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kNetworkService_createTcpConnectedSocket_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kNetworkService_createTcpConnectedSocket_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kNetworkService_createUdpSocket_name: + var params = NetworkServiceCreateUdpSocketParams.deserialize( + message.payload); + _impl.createUdpSocket(params.socket); + break; + case kNetworkService_createHttpServer_name: + var params = NetworkServiceCreateHttpServerParams.deserialize( + message.payload); + var response = _impl.createHttpServer(params.localAddress,params.delegate,_NetworkServiceCreateHttpServerResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kNetworkService_createHttpServer_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kNetworkService_createHttpServer_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kNetworkService_registerUrlLoaderInterceptor_name: + var params = NetworkServiceRegisterUrlLoaderInterceptorParams.deserialize( + message.payload); + _impl.registerUrlLoaderInterceptor(params.factory); + break; + case kNetworkService_createHostResolver_name: + var params = NetworkServiceCreateHostResolverParams.deserialize( + message.payload); + _impl.createHostResolver(params.hostResolver); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + NetworkService get impl => _impl; + set impl(NetworkService d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "NetworkServiceStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/quads.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/quads.mojom.dart new file mode 100644 index 0000000..52493f6 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/quads.mojom.dart
@@ -0,0 +1,1939 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library quads_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo_services/mojo/geometry.mojom.dart' as geometry_mojom; +import 'package:mojo_services/mojo/surface_id.mojom.dart' as surface_id_mojom; +class YuvColorSpace extends bindings.MojoEnum { + static const REC_601 = const YuvColorSpace._(0); + static const REC_709 = const YuvColorSpace._(1); + static const JPEG = const YuvColorSpace._(2); + + const YuvColorSpace._(int v) : super(v); + + static const Map<String, YuvColorSpace> valuesMap = const { + "REC_601": REC_601, + "REC_709": REC_709, + "JPEG": JPEG, + }; + static const List<YuvColorSpace> values = const [ + REC_601, + REC_709, + JPEG, + ]; + + static YuvColorSpace valueOf(String name) => valuesMap[name]; + + factory YuvColorSpace(int v) { + switch (v) { + case 0: + return REC_601; + case 1: + return REC_709; + case 2: + return JPEG; + default: + return null; + } + } + + static YuvColorSpace decode(bindings.Decoder decoder0, int offset) { + int v = decoder0.decodeUint32(offset); + YuvColorSpace result = new YuvColorSpace(v); + if (result == null) { + throw new bindings.MojoCodecError( + 'Bad value $v for enum YuvColorSpace.'); + } + return result; + } + + String toString() { + switch(this) { + case REC_601: + return 'YuvColorSpace.REC_601'; + case REC_709: + return 'YuvColorSpace.REC_709'; + case JPEG: + return 'YuvColorSpace.JPEG'; + } + } + + int toJson() => value; +} +class Material extends bindings.MojoEnum { + static const CHECKERBOARD = const Material._(1); + static const DEBUG_BORDER = const Material._(2); + static const IO_SURFACE_CONTENT = const Material._(3); + static const PICTURE_CONTENT = const Material._(4); + static const RENDER_PASS = const Material._(5); + static const SOLID_COLOR = const Material._(6); + static const STREAM_VIDEO_CONTENT = const Material._(7); + static const SURFACE_CONTENT = const Material._(8); + static const TEXTURE_CONTENT = const Material._(9); + static const TILED_CONTENT = const Material._(10); + static const YUV_VIDEO_CONTENT = const Material._(11); + + const Material._(int v) : super(v); + + static const Map<String, Material> valuesMap = const { + "CHECKERBOARD": CHECKERBOARD, + "DEBUG_BORDER": DEBUG_BORDER, + "IO_SURFACE_CONTENT": IO_SURFACE_CONTENT, + "PICTURE_CONTENT": PICTURE_CONTENT, + "RENDER_PASS": RENDER_PASS, + "SOLID_COLOR": SOLID_COLOR, + "STREAM_VIDEO_CONTENT": STREAM_VIDEO_CONTENT, + "SURFACE_CONTENT": SURFACE_CONTENT, + "TEXTURE_CONTENT": TEXTURE_CONTENT, + "TILED_CONTENT": TILED_CONTENT, + "YUV_VIDEO_CONTENT": YUV_VIDEO_CONTENT, + }; + static const List<Material> values = const [ + CHECKERBOARD, + DEBUG_BORDER, + IO_SURFACE_CONTENT, + PICTURE_CONTENT, + RENDER_PASS, + SOLID_COLOR, + STREAM_VIDEO_CONTENT, + SURFACE_CONTENT, + TEXTURE_CONTENT, + TILED_CONTENT, + YUV_VIDEO_CONTENT, + ]; + + static Material valueOf(String name) => valuesMap[name]; + + factory Material(int v) { + switch (v) { + case 1: + return CHECKERBOARD; + case 2: + return DEBUG_BORDER; + case 3: + return IO_SURFACE_CONTENT; + case 4: + return PICTURE_CONTENT; + case 5: + return RENDER_PASS; + case 6: + return SOLID_COLOR; + case 7: + return STREAM_VIDEO_CONTENT; + case 8: + return SURFACE_CONTENT; + case 9: + return TEXTURE_CONTENT; + case 10: + return TILED_CONTENT; + case 11: + return YUV_VIDEO_CONTENT; + default: + return null; + } + } + + static Material decode(bindings.Decoder decoder0, int offset) { + int v = decoder0.decodeUint32(offset); + Material result = new Material(v); + if (result == null) { + throw new bindings.MojoCodecError( + 'Bad value $v for enum Material.'); + } + return result; + } + + String toString() { + switch(this) { + case CHECKERBOARD: + return 'Material.CHECKERBOARD'; + case DEBUG_BORDER: + return 'Material.DEBUG_BORDER'; + case IO_SURFACE_CONTENT: + return 'Material.IO_SURFACE_CONTENT'; + case PICTURE_CONTENT: + return 'Material.PICTURE_CONTENT'; + case RENDER_PASS: + return 'Material.RENDER_PASS'; + case SOLID_COLOR: + return 'Material.SOLID_COLOR'; + case STREAM_VIDEO_CONTENT: + return 'Material.STREAM_VIDEO_CONTENT'; + case SURFACE_CONTENT: + return 'Material.SURFACE_CONTENT'; + case TEXTURE_CONTENT: + return 'Material.TEXTURE_CONTENT'; + case TILED_CONTENT: + return 'Material.TILED_CONTENT'; + case YUV_VIDEO_CONTENT: + return 'Material.YUV_VIDEO_CONTENT'; + } + } + + int toJson() => value; +} +class SkXfermode extends bindings.MojoEnum { + static const kClear_Mode = const SkXfermode._(0); + static const kSrc_Mode = const SkXfermode._(1); + static const kDst_Mode = const SkXfermode._(2); + static const kSrcOver_Mode = const SkXfermode._(3); + static const kDstOver_Mode = const SkXfermode._(4); + static const kSrcIn_Mode = const SkXfermode._(5); + static const kDstIn_Mode = const SkXfermode._(6); + static const kSrcOut_Mode = const SkXfermode._(7); + static const kDstOut_Mode = const SkXfermode._(8); + static const kSrcATop_Mode = const SkXfermode._(9); + static const kDstATop_Mode = const SkXfermode._(10); + static const kXor_Mode = const SkXfermode._(11); + static const kPlus_Mode = const SkXfermode._(12); + static const kModulate_Mode = const SkXfermode._(13); + static const kScreen_Mode = const SkXfermode._(14); + static const kLastCoeffMode = const SkXfermode._(14); + static const kOverlay_Mode = const SkXfermode._(15); + static const kDarken_Mode = const SkXfermode._(16); + static const kLighten_Mode = const SkXfermode._(17); + static const kColorDodge_Mode = const SkXfermode._(18); + static const kColorBurn_Mode = const SkXfermode._(19); + static const kHardLight_Mode = const SkXfermode._(20); + static const kSoftLight_Mode = const SkXfermode._(21); + static const kDifference_Mode = const SkXfermode._(22); + static const kExclusion_Mode = const SkXfermode._(23); + static const kMultiply_Mode = const SkXfermode._(24); + static const kLastSeparableMode = const SkXfermode._(24); + static const kHue_Mode = const SkXfermode._(25); + static const kSaturation_Mode = const SkXfermode._(26); + static const kColor_Mode = const SkXfermode._(27); + static const kLuminosity_Mode = const SkXfermode._(28); + static const kLastMode = const SkXfermode._(28); + + const SkXfermode._(int v) : super(v); + + static const Map<String, SkXfermode> valuesMap = const { + "kClear_Mode": kClear_Mode, + "kSrc_Mode": kSrc_Mode, + "kDst_Mode": kDst_Mode, + "kSrcOver_Mode": kSrcOver_Mode, + "kDstOver_Mode": kDstOver_Mode, + "kSrcIn_Mode": kSrcIn_Mode, + "kDstIn_Mode": kDstIn_Mode, + "kSrcOut_Mode": kSrcOut_Mode, + "kDstOut_Mode": kDstOut_Mode, + "kSrcATop_Mode": kSrcATop_Mode, + "kDstATop_Mode": kDstATop_Mode, + "kXor_Mode": kXor_Mode, + "kPlus_Mode": kPlus_Mode, + "kModulate_Mode": kModulate_Mode, + "kScreen_Mode": kScreen_Mode, + "kLastCoeffMode": kLastCoeffMode, + "kOverlay_Mode": kOverlay_Mode, + "kDarken_Mode": kDarken_Mode, + "kLighten_Mode": kLighten_Mode, + "kColorDodge_Mode": kColorDodge_Mode, + "kColorBurn_Mode": kColorBurn_Mode, + "kHardLight_Mode": kHardLight_Mode, + "kSoftLight_Mode": kSoftLight_Mode, + "kDifference_Mode": kDifference_Mode, + "kExclusion_Mode": kExclusion_Mode, + "kMultiply_Mode": kMultiply_Mode, + "kLastSeparableMode": kLastSeparableMode, + "kHue_Mode": kHue_Mode, + "kSaturation_Mode": kSaturation_Mode, + "kColor_Mode": kColor_Mode, + "kLuminosity_Mode": kLuminosity_Mode, + "kLastMode": kLastMode, + }; + static const List<SkXfermode> values = const [ + kClear_Mode, + kSrc_Mode, + kDst_Mode, + kSrcOver_Mode, + kDstOver_Mode, + kSrcIn_Mode, + kDstIn_Mode, + kSrcOut_Mode, + kDstOut_Mode, + kSrcATop_Mode, + kDstATop_Mode, + kXor_Mode, + kPlus_Mode, + kModulate_Mode, + kScreen_Mode, + kLastCoeffMode, + kOverlay_Mode, + kDarken_Mode, + kLighten_Mode, + kColorDodge_Mode, + kColorBurn_Mode, + kHardLight_Mode, + kSoftLight_Mode, + kDifference_Mode, + kExclusion_Mode, + kMultiply_Mode, + kLastSeparableMode, + kHue_Mode, + kSaturation_Mode, + kColor_Mode, + kLuminosity_Mode, + kLastMode, + ]; + + static SkXfermode valueOf(String name) => valuesMap[name]; + + factory SkXfermode(int v) { + switch (v) { + case 0: + return kClear_Mode; + case 1: + return kSrc_Mode; + case 2: + return kDst_Mode; + case 3: + return kSrcOver_Mode; + case 4: + return kDstOver_Mode; + case 5: + return kSrcIn_Mode; + case 6: + return kDstIn_Mode; + case 7: + return kSrcOut_Mode; + case 8: + return kDstOut_Mode; + case 9: + return kSrcATop_Mode; + case 10: + return kDstATop_Mode; + case 11: + return kXor_Mode; + case 12: + return kPlus_Mode; + case 13: + return kModulate_Mode; + case 14: + return kScreen_Mode; + case 14: + return kLastCoeffMode; + case 15: + return kOverlay_Mode; + case 16: + return kDarken_Mode; + case 17: + return kLighten_Mode; + case 18: + return kColorDodge_Mode; + case 19: + return kColorBurn_Mode; + case 20: + return kHardLight_Mode; + case 21: + return kSoftLight_Mode; + case 22: + return kDifference_Mode; + case 23: + return kExclusion_Mode; + case 24: + return kMultiply_Mode; + case 24: + return kLastSeparableMode; + case 25: + return kHue_Mode; + case 26: + return kSaturation_Mode; + case 27: + return kColor_Mode; + case 28: + return kLuminosity_Mode; + case 28: + return kLastMode; + default: + return null; + } + } + + static SkXfermode decode(bindings.Decoder decoder0, int offset) { + int v = decoder0.decodeUint32(offset); + SkXfermode result = new SkXfermode(v); + if (result == null) { + throw new bindings.MojoCodecError( + 'Bad value $v for enum SkXfermode.'); + } + return result; + } + + String toString() { + switch(this) { + case kClear_Mode: + return 'SkXfermode.kClear_Mode'; + case kSrc_Mode: + return 'SkXfermode.kSrc_Mode'; + case kDst_Mode: + return 'SkXfermode.kDst_Mode'; + case kSrcOver_Mode: + return 'SkXfermode.kSrcOver_Mode'; + case kDstOver_Mode: + return 'SkXfermode.kDstOver_Mode'; + case kSrcIn_Mode: + return 'SkXfermode.kSrcIn_Mode'; + case kDstIn_Mode: + return 'SkXfermode.kDstIn_Mode'; + case kSrcOut_Mode: + return 'SkXfermode.kSrcOut_Mode'; + case kDstOut_Mode: + return 'SkXfermode.kDstOut_Mode'; + case kSrcATop_Mode: + return 'SkXfermode.kSrcATop_Mode'; + case kDstATop_Mode: + return 'SkXfermode.kDstATop_Mode'; + case kXor_Mode: + return 'SkXfermode.kXor_Mode'; + case kPlus_Mode: + return 'SkXfermode.kPlus_Mode'; + case kModulate_Mode: + return 'SkXfermode.kModulate_Mode'; + case kScreen_Mode: + return 'SkXfermode.kScreen_Mode'; + case kLastCoeffMode: + return 'SkXfermode.kLastCoeffMode'; + case kOverlay_Mode: + return 'SkXfermode.kOverlay_Mode'; + case kDarken_Mode: + return 'SkXfermode.kDarken_Mode'; + case kLighten_Mode: + return 'SkXfermode.kLighten_Mode'; + case kColorDodge_Mode: + return 'SkXfermode.kColorDodge_Mode'; + case kColorBurn_Mode: + return 'SkXfermode.kColorBurn_Mode'; + case kHardLight_Mode: + return 'SkXfermode.kHardLight_Mode'; + case kSoftLight_Mode: + return 'SkXfermode.kSoftLight_Mode'; + case kDifference_Mode: + return 'SkXfermode.kDifference_Mode'; + case kExclusion_Mode: + return 'SkXfermode.kExclusion_Mode'; + case kMultiply_Mode: + return 'SkXfermode.kMultiply_Mode'; + case kLastSeparableMode: + return 'SkXfermode.kLastSeparableMode'; + case kHue_Mode: + return 'SkXfermode.kHue_Mode'; + case kSaturation_Mode: + return 'SkXfermode.kSaturation_Mode'; + case kColor_Mode: + return 'SkXfermode.kColor_Mode'; + case kLuminosity_Mode: + return 'SkXfermode.kLuminosity_Mode'; + case kLastMode: + return 'SkXfermode.kLastMode'; + } + } + + int toJson() => value; +} + + + +class Color extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int rgba = 0; + + Color() : super(kVersions.last.size); + + static Color deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static Color decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + Color result = new Color(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.rgba = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(rgba, 8); + } + + String toString() { + return "Color(" + "rgba: $rgba" ")"; + } + + Map toJson() { + Map map = new Map(); + map["rgba"] = rgba; + return map; + } +} + + +class CheckerboardQuadState extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + CheckerboardQuadState() : super(kVersions.last.size); + + static CheckerboardQuadState deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static CheckerboardQuadState decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + CheckerboardQuadState result = new CheckerboardQuadState(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "CheckerboardQuadState("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class DebugBorderQuadState extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + DebugBorderQuadState() : super(kVersions.last.size); + + static DebugBorderQuadState deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static DebugBorderQuadState decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + DebugBorderQuadState result = new DebugBorderQuadState(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "DebugBorderQuadState("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class IoSurfaceContentQuadState extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + IoSurfaceContentQuadState() : super(kVersions.last.size); + + static IoSurfaceContentQuadState deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static IoSurfaceContentQuadState decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + IoSurfaceContentQuadState result = new IoSurfaceContentQuadState(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "IoSurfaceContentQuadState("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class RenderPassId extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int layerId = 0; + int index = 0; + + RenderPassId() : super(kVersions.last.size); + + static RenderPassId deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static RenderPassId decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + RenderPassId result = new RenderPassId(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.layerId = decoder0.decodeInt32(8); + } + if (mainDataHeader.version >= 0) { + + result.index = decoder0.decodeInt32(12); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt32(layerId, 8); + + encoder0.encodeInt32(index, 12); + } + + String toString() { + return "RenderPassId(" + "layerId: $layerId" ", " + "index: $index" ")"; + } + + Map toJson() { + Map map = new Map(); + map["layerId"] = layerId; + map["index"] = index; + return map; + } +} + + +class RenderPassQuadState extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(48, 0) + ]; + RenderPassId renderPassId = null; + int maskResourceId = 0; + geometry_mojom.PointF maskUvScale = null; + geometry_mojom.Size maskTextureSize = null; + geometry_mojom.PointF filtersScale = null; + + RenderPassQuadState() : super(kVersions.last.size); + + static RenderPassQuadState deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static RenderPassQuadState decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + RenderPassQuadState result = new RenderPassQuadState(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.renderPassId = RenderPassId.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + result.maskResourceId = decoder0.decodeUint32(16); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(24, false); + result.maskUvScale = geometry_mojom.PointF.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(32, false); + result.maskTextureSize = geometry_mojom.Size.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(40, false); + result.filtersScale = geometry_mojom.PointF.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(renderPassId, 8, false); + + encoder0.encodeUint32(maskResourceId, 16); + + encoder0.encodeStruct(maskUvScale, 24, false); + + encoder0.encodeStruct(maskTextureSize, 32, false); + + encoder0.encodeStruct(filtersScale, 40, false); + } + + String toString() { + return "RenderPassQuadState(" + "renderPassId: $renderPassId" ", " + "maskResourceId: $maskResourceId" ", " + "maskUvScale: $maskUvScale" ", " + "maskTextureSize: $maskTextureSize" ", " + "filtersScale: $filtersScale" ")"; + } + + Map toJson() { + Map map = new Map(); + map["renderPassId"] = renderPassId; + map["maskResourceId"] = maskResourceId; + map["maskUvScale"] = maskUvScale; + map["maskTextureSize"] = maskTextureSize; + map["filtersScale"] = filtersScale; + return map; + } +} + + +class SolidColorQuadState extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + Color color = null; + bool forceAntiAliasingOff = false; + + SolidColorQuadState() : super(kVersions.last.size); + + static SolidColorQuadState deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static SolidColorQuadState decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + SolidColorQuadState result = new SolidColorQuadState(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.color = Color.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + result.forceAntiAliasingOff = decoder0.decodeBool(16, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(color, 8, false); + + encoder0.encodeBool(forceAntiAliasingOff, 16, 0); + } + + String toString() { + return "SolidColorQuadState(" + "color: $color" ", " + "forceAntiAliasingOff: $forceAntiAliasingOff" ")"; + } + + Map toJson() { + Map map = new Map(); + map["color"] = color; + map["forceAntiAliasingOff"] = forceAntiAliasingOff; + return map; + } +} + + +class SurfaceQuadState extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + surface_id_mojom.SurfaceId surface = null; + + SurfaceQuadState() : super(kVersions.last.size); + + static SurfaceQuadState deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static SurfaceQuadState decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + SurfaceQuadState result = new SurfaceQuadState(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.surface = surface_id_mojom.SurfaceId.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(surface, 8, false); + } + + String toString() { + return "SurfaceQuadState(" + "surface: $surface" ")"; + } + + Map toJson() { + Map map = new Map(); + map["surface"] = surface; + return map; + } +} + + +class TextureQuadState extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(48, 0) + ]; + int resourceId = 0; + bool premultipliedAlpha = false; + bool flipped = false; + bool nearestNeighbor = false; + geometry_mojom.PointF uvTopLeft = null; + geometry_mojom.PointF uvBottomRight = null; + Color backgroundColor = null; + List<double> vertexOpacity = null; + + TextureQuadState() : super(kVersions.last.size); + + static TextureQuadState deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static TextureQuadState decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + TextureQuadState result = new TextureQuadState(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.resourceId = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + result.premultipliedAlpha = decoder0.decodeBool(12, 0); + } + if (mainDataHeader.version >= 0) { + + result.flipped = decoder0.decodeBool(12, 1); + } + if (mainDataHeader.version >= 0) { + + result.nearestNeighbor = decoder0.decodeBool(12, 2); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + result.uvTopLeft = geometry_mojom.PointF.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(24, false); + result.uvBottomRight = geometry_mojom.PointF.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(32, false); + result.backgroundColor = Color.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + result.vertexOpacity = decoder0.decodeFloatArray(40, bindings.kNothingNullable, 4); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(resourceId, 8); + + encoder0.encodeBool(premultipliedAlpha, 12, 0); + + encoder0.encodeBool(flipped, 12, 1); + + encoder0.encodeBool(nearestNeighbor, 12, 2); + + encoder0.encodeStruct(uvTopLeft, 16, false); + + encoder0.encodeStruct(uvBottomRight, 24, false); + + encoder0.encodeStruct(backgroundColor, 32, false); + + encoder0.encodeFloatArray(vertexOpacity, 40, bindings.kNothingNullable, 4); + } + + String toString() { + return "TextureQuadState(" + "resourceId: $resourceId" ", " + "premultipliedAlpha: $premultipliedAlpha" ", " + "flipped: $flipped" ", " + "nearestNeighbor: $nearestNeighbor" ", " + "uvTopLeft: $uvTopLeft" ", " + "uvBottomRight: $uvBottomRight" ", " + "backgroundColor: $backgroundColor" ", " + "vertexOpacity: $vertexOpacity" ")"; + } + + Map toJson() { + Map map = new Map(); + map["resourceId"] = resourceId; + map["premultipliedAlpha"] = premultipliedAlpha; + map["flipped"] = flipped; + map["nearestNeighbor"] = nearestNeighbor; + map["uvTopLeft"] = uvTopLeft; + map["uvBottomRight"] = uvBottomRight; + map["backgroundColor"] = backgroundColor; + map["vertexOpacity"] = vertexOpacity; + return map; + } +} + + +class TileQuadState extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(32, 0) + ]; + geometry_mojom.RectF texCoordRect = null; + geometry_mojom.Size textureSize = null; + bool swizzleContents = false; + bool nearestNeighbor = false; + int resourceId = 0; + + TileQuadState() : super(kVersions.last.size); + + static TileQuadState deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static TileQuadState decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + TileQuadState result = new TileQuadState(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.texCoordRect = geometry_mojom.RectF.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + result.textureSize = geometry_mojom.Size.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + result.swizzleContents = decoder0.decodeBool(24, 0); + } + if (mainDataHeader.version >= 0) { + + result.nearestNeighbor = decoder0.decodeBool(24, 1); + } + if (mainDataHeader.version >= 0) { + + result.resourceId = decoder0.decodeUint32(28); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(texCoordRect, 8, false); + + encoder0.encodeStruct(textureSize, 16, false); + + encoder0.encodeBool(swizzleContents, 24, 0); + + encoder0.encodeBool(nearestNeighbor, 24, 1); + + encoder0.encodeUint32(resourceId, 28); + } + + String toString() { + return "TileQuadState(" + "texCoordRect: $texCoordRect" ", " + "textureSize: $textureSize" ", " + "swizzleContents: $swizzleContents" ", " + "nearestNeighbor: $nearestNeighbor" ", " + "resourceId: $resourceId" ")"; + } + + Map toJson() { + Map map = new Map(); + map["texCoordRect"] = texCoordRect; + map["textureSize"] = textureSize; + map["swizzleContents"] = swizzleContents; + map["nearestNeighbor"] = nearestNeighbor; + map["resourceId"] = resourceId; + return map; + } +} + + +class StreamVideoQuadState extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + StreamVideoQuadState() : super(kVersions.last.size); + + static StreamVideoQuadState deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static StreamVideoQuadState decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + StreamVideoQuadState result = new StreamVideoQuadState(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "StreamVideoQuadState("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class YuvVideoQuadState extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(40, 0) + ]; + geometry_mojom.RectF texCoordRect = null; + int yPlaneResourceId = 0; + int uPlaneResourceId = 0; + int vPlaneResourceId = 0; + int aPlaneResourceId = 0; + YuvColorSpace colorSpace = null; + + YuvVideoQuadState() : super(kVersions.last.size); + + static YuvVideoQuadState deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static YuvVideoQuadState decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + YuvVideoQuadState result = new YuvVideoQuadState(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.texCoordRect = geometry_mojom.RectF.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + result.yPlaneResourceId = decoder0.decodeUint32(16); + } + if (mainDataHeader.version >= 0) { + + result.uPlaneResourceId = decoder0.decodeUint32(20); + } + if (mainDataHeader.version >= 0) { + + result.vPlaneResourceId = decoder0.decodeUint32(24); + } + if (mainDataHeader.version >= 0) { + + result.aPlaneResourceId = decoder0.decodeUint32(28); + } + if (mainDataHeader.version >= 0) { + + result.colorSpace = YuvColorSpace.decode(decoder0, 32); + if (result.colorSpace == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable YuvColorSpace.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(texCoordRect, 8, false); + + encoder0.encodeUint32(yPlaneResourceId, 16); + + encoder0.encodeUint32(uPlaneResourceId, 20); + + encoder0.encodeUint32(vPlaneResourceId, 24); + + encoder0.encodeUint32(aPlaneResourceId, 28); + + encoder0.encodeEnum(colorSpace, 32); + } + + String toString() { + return "YuvVideoQuadState(" + "texCoordRect: $texCoordRect" ", " + "yPlaneResourceId: $yPlaneResourceId" ", " + "uPlaneResourceId: $uPlaneResourceId" ", " + "vPlaneResourceId: $vPlaneResourceId" ", " + "aPlaneResourceId: $aPlaneResourceId" ", " + "colorSpace: $colorSpace" ")"; + } + + Map toJson() { + Map map = new Map(); + map["texCoordRect"] = texCoordRect; + map["yPlaneResourceId"] = yPlaneResourceId; + map["uPlaneResourceId"] = uPlaneResourceId; + map["vPlaneResourceId"] = vPlaneResourceId; + map["aPlaneResourceId"] = aPlaneResourceId; + map["colorSpace"] = colorSpace; + return map; + } +} + + +class Quad extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(128, 0) + ]; + Material material = null; + bool needsBlending = false; + geometry_mojom.Rect rect = null; + geometry_mojom.Rect opaqueRect = null; + geometry_mojom.Rect visibleRect = null; + int sharedQuadStateIndex = 0; + CheckerboardQuadState checkerboardQuadState = null; + DebugBorderQuadState debugBorderQuadState = null; + IoSurfaceContentQuadState ioSurfaceQuadState = null; + RenderPassQuadState renderPassQuadState = null; + SolidColorQuadState solidColorQuadState = null; + SurfaceQuadState surfaceQuadState = null; + TextureQuadState textureQuadState = null; + TileQuadState tileQuadState = null; + StreamVideoQuadState streamVideoQuadState = null; + YuvVideoQuadState yuvVideoQuadState = null; + + Quad() : super(kVersions.last.size); + + static Quad deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static Quad decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + Quad result = new Quad(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.material = Material.decode(decoder0, 8); + if (result.material == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable Material.'); + } + } + if (mainDataHeader.version >= 0) { + + result.needsBlending = decoder0.decodeBool(12, 0); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + result.rect = geometry_mojom.Rect.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(24, false); + result.opaqueRect = geometry_mojom.Rect.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(32, false); + result.visibleRect = geometry_mojom.Rect.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + result.sharedQuadStateIndex = decoder0.decodeUint32(40); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(48, true); + result.checkerboardQuadState = CheckerboardQuadState.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(56, true); + result.debugBorderQuadState = DebugBorderQuadState.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(64, true); + result.ioSurfaceQuadState = IoSurfaceContentQuadState.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(72, true); + result.renderPassQuadState = RenderPassQuadState.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(80, true); + result.solidColorQuadState = SolidColorQuadState.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(88, true); + result.surfaceQuadState = SurfaceQuadState.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(96, true); + result.textureQuadState = TextureQuadState.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(104, true); + result.tileQuadState = TileQuadState.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(112, true); + result.streamVideoQuadState = StreamVideoQuadState.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(120, true); + result.yuvVideoQuadState = YuvVideoQuadState.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(material, 8); + + encoder0.encodeBool(needsBlending, 12, 0); + + encoder0.encodeStruct(rect, 16, false); + + encoder0.encodeStruct(opaqueRect, 24, false); + + encoder0.encodeStruct(visibleRect, 32, false); + + encoder0.encodeUint32(sharedQuadStateIndex, 40); + + encoder0.encodeStruct(checkerboardQuadState, 48, true); + + encoder0.encodeStruct(debugBorderQuadState, 56, true); + + encoder0.encodeStruct(ioSurfaceQuadState, 64, true); + + encoder0.encodeStruct(renderPassQuadState, 72, true); + + encoder0.encodeStruct(solidColorQuadState, 80, true); + + encoder0.encodeStruct(surfaceQuadState, 88, true); + + encoder0.encodeStruct(textureQuadState, 96, true); + + encoder0.encodeStruct(tileQuadState, 104, true); + + encoder0.encodeStruct(streamVideoQuadState, 112, true); + + encoder0.encodeStruct(yuvVideoQuadState, 120, true); + } + + String toString() { + return "Quad(" + "material: $material" ", " + "needsBlending: $needsBlending" ", " + "rect: $rect" ", " + "opaqueRect: $opaqueRect" ", " + "visibleRect: $visibleRect" ", " + "sharedQuadStateIndex: $sharedQuadStateIndex" ", " + "checkerboardQuadState: $checkerboardQuadState" ", " + "debugBorderQuadState: $debugBorderQuadState" ", " + "ioSurfaceQuadState: $ioSurfaceQuadState" ", " + "renderPassQuadState: $renderPassQuadState" ", " + "solidColorQuadState: $solidColorQuadState" ", " + "surfaceQuadState: $surfaceQuadState" ", " + "textureQuadState: $textureQuadState" ", " + "tileQuadState: $tileQuadState" ", " + "streamVideoQuadState: $streamVideoQuadState" ", " + "yuvVideoQuadState: $yuvVideoQuadState" ")"; + } + + Map toJson() { + Map map = new Map(); + map["material"] = material; + map["needsBlending"] = needsBlending; + map["rect"] = rect; + map["opaqueRect"] = opaqueRect; + map["visibleRect"] = visibleRect; + map["sharedQuadStateIndex"] = sharedQuadStateIndex; + map["checkerboardQuadState"] = checkerboardQuadState; + map["debugBorderQuadState"] = debugBorderQuadState; + map["ioSurfaceQuadState"] = ioSurfaceQuadState; + map["renderPassQuadState"] = renderPassQuadState; + map["solidColorQuadState"] = solidColorQuadState; + map["surfaceQuadState"] = surfaceQuadState; + map["textureQuadState"] = textureQuadState; + map["tileQuadState"] = tileQuadState; + map["streamVideoQuadState"] = streamVideoQuadState; + map["yuvVideoQuadState"] = yuvVideoQuadState; + return map; + } +} + + +class SharedQuadState extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(56, 0) + ]; + geometry_mojom.Transform contentToTargetTransform = null; + geometry_mojom.Size contentBounds = null; + geometry_mojom.Rect visibleContentRect = null; + geometry_mojom.Rect clipRect = null; + bool isClipped = false; + double opacity = 0.0; + SkXfermode blendMode = null; + int sortingContextId = 0; + + SharedQuadState() : super(kVersions.last.size); + + static SharedQuadState deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static SharedQuadState decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + SharedQuadState result = new SharedQuadState(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.contentToTargetTransform = geometry_mojom.Transform.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + result.contentBounds = geometry_mojom.Size.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(24, false); + result.visibleContentRect = geometry_mojom.Rect.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(32, false); + result.clipRect = geometry_mojom.Rect.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + result.isClipped = decoder0.decodeBool(40, 0); + } + if (mainDataHeader.version >= 0) { + + result.opacity = decoder0.decodeFloat(44); + } + if (mainDataHeader.version >= 0) { + + result.blendMode = SkXfermode.decode(decoder0, 48); + if (result.blendMode == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable SkXfermode.'); + } + } + if (mainDataHeader.version >= 0) { + + result.sortingContextId = decoder0.decodeInt32(52); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(contentToTargetTransform, 8, false); + + encoder0.encodeStruct(contentBounds, 16, false); + + encoder0.encodeStruct(visibleContentRect, 24, false); + + encoder0.encodeStruct(clipRect, 32, false); + + encoder0.encodeBool(isClipped, 40, 0); + + encoder0.encodeFloat(opacity, 44); + + encoder0.encodeEnum(blendMode, 48); + + encoder0.encodeInt32(sortingContextId, 52); + } + + String toString() { + return "SharedQuadState(" + "contentToTargetTransform: $contentToTargetTransform" ", " + "contentBounds: $contentBounds" ", " + "visibleContentRect: $visibleContentRect" ", " + "clipRect: $clipRect" ", " + "isClipped: $isClipped" ", " + "opacity: $opacity" ", " + "blendMode: $blendMode" ", " + "sortingContextId: $sortingContextId" ")"; + } + + Map toJson() { + Map map = new Map(); + map["contentToTargetTransform"] = contentToTargetTransform; + map["contentBounds"] = contentBounds; + map["visibleContentRect"] = visibleContentRect; + map["clipRect"] = clipRect; + map["isClipped"] = isClipped; + map["opacity"] = opacity; + map["blendMode"] = blendMode; + map["sortingContextId"] = sortingContextId; + return map; + } +} + + +class Pass extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(56, 0) + ]; + int id = 0; + bool hasTransparentBackground = false; + geometry_mojom.Rect outputRect = null; + geometry_mojom.Rect damageRect = null; + geometry_mojom.Transform transformToRootTarget = null; + List<Quad> quads = null; + List<SharedQuadState> sharedQuadStates = null; + + Pass() : super(kVersions.last.size); + + static Pass deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static Pass decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + Pass result = new Pass(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.id = decoder0.decodeInt32(8); + } + if (mainDataHeader.version >= 0) { + + result.hasTransparentBackground = decoder0.decodeBool(12, 0); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + result.outputRect = geometry_mojom.Rect.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(24, false); + result.damageRect = geometry_mojom.Rect.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(32, false); + result.transformToRootTarget = geometry_mojom.Transform.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(40, false); + { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.quads = new List<Quad>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + var decoder2 = decoder1.decodePointer(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + result.quads[i1] = Quad.decode(decoder2); + } + } + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(48, false); + { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.sharedQuadStates = new List<SharedQuadState>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + var decoder2 = decoder1.decodePointer(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + result.sharedQuadStates[i1] = SharedQuadState.decode(decoder2); + } + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt32(id, 8); + + encoder0.encodeBool(hasTransparentBackground, 12, 0); + + encoder0.encodeStruct(outputRect, 16, false); + + encoder0.encodeStruct(damageRect, 24, false); + + encoder0.encodeStruct(transformToRootTarget, 32, false); + + if (quads == null) { + encoder0.encodeNullPointer(40, false); + } else { + var encoder1 = encoder0.encodePointerArray(quads.length, 40, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < quads.length; ++i0) { + + encoder1.encodeStruct(quads[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + + if (sharedQuadStates == null) { + encoder0.encodeNullPointer(48, false); + } else { + var encoder1 = encoder0.encodePointerArray(sharedQuadStates.length, 48, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < sharedQuadStates.length; ++i0) { + + encoder1.encodeStruct(sharedQuadStates[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + } + + String toString() { + return "Pass(" + "id: $id" ", " + "hasTransparentBackground: $hasTransparentBackground" ", " + "outputRect: $outputRect" ", " + "damageRect: $damageRect" ", " + "transformToRootTarget: $transformToRootTarget" ", " + "quads: $quads" ", " + "sharedQuadStates: $sharedQuadStates" ")"; + } + + Map toJson() { + Map map = new Map(); + map["id"] = id; + map["hasTransparentBackground"] = hasTransparentBackground; + map["outputRect"] = outputRect; + map["damageRect"] = damageRect; + map["transformToRootTarget"] = transformToRootTarget; + map["quads"] = quads; + map["sharedQuadStates"] = sharedQuadStates; + return map; + } +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/service_registry.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/service_registry.mojom.dart new file mode 100644 index 0000000..92cd58c --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/service_registry.mojom.dart
@@ -0,0 +1,280 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library service_registry_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo/mojo/service_provider.mojom.dart' as service_provider_mojom; + + + +class ServiceRegistryAddServicesParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + List<String> interfaceNames = null; + Object serviceProvider = null; + + ServiceRegistryAddServicesParams() : super(kVersions.last.size); + + static ServiceRegistryAddServicesParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ServiceRegistryAddServicesParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ServiceRegistryAddServicesParams result = new ServiceRegistryAddServicesParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.interfaceNames = new List<String>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + result.interfaceNames[i1] = decoder1.decodeString(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + } + } + } + if (mainDataHeader.version >= 0) { + + result.serviceProvider = decoder0.decodeServiceInterface(16, false, service_provider_mojom.ServiceProviderProxy.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + if (interfaceNames == null) { + encoder0.encodeNullPointer(8, false); + } else { + var encoder1 = encoder0.encodePointerArray(interfaceNames.length, 8, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < interfaceNames.length; ++i0) { + + encoder1.encodeString(interfaceNames[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + + encoder0.encodeInterface(serviceProvider, 16, false); + } + + String toString() { + return "ServiceRegistryAddServicesParams(" + "interfaceNames: $interfaceNames" ", " + "serviceProvider: $serviceProvider" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + +const int kServiceRegistry_addServices_name = 0; + +const String ServiceRegistryName = + 'mojo::ServiceRegistry'; + +abstract class ServiceRegistry { + void addServices(List<String> interfaceNames, Object serviceProvider); + +} + + +class ServiceRegistryProxyImpl extends bindings.Proxy { + ServiceRegistryProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + ServiceRegistryProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + ServiceRegistryProxyImpl.unbound() : super.unbound(); + + static ServiceRegistryProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ServiceRegistryProxyImpl")); + return new ServiceRegistryProxyImpl.fromEndpoint(endpoint); + } + + String get name => ServiceRegistryName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "ServiceRegistryProxyImpl($superString)"; + } +} + + +class _ServiceRegistryProxyCalls implements ServiceRegistry { + ServiceRegistryProxyImpl _proxyImpl; + + _ServiceRegistryProxyCalls(this._proxyImpl); + void addServices(List<String> interfaceNames, Object serviceProvider) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new ServiceRegistryAddServicesParams(); + params.interfaceNames = interfaceNames; + params.serviceProvider = serviceProvider; + _proxyImpl.sendMessage(params, kServiceRegistry_addServices_name); + } + +} + + +class ServiceRegistryProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + ServiceRegistry ptr; + final String name = ServiceRegistryName; + + ServiceRegistryProxy(ServiceRegistryProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _ServiceRegistryProxyCalls(proxyImpl); + + ServiceRegistryProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new ServiceRegistryProxyImpl.fromEndpoint(endpoint) { + ptr = new _ServiceRegistryProxyCalls(impl); + } + + ServiceRegistryProxy.fromHandle(core.MojoHandle handle) : + impl = new ServiceRegistryProxyImpl.fromHandle(handle) { + ptr = new _ServiceRegistryProxyCalls(impl); + } + + ServiceRegistryProxy.unbound() : + impl = new ServiceRegistryProxyImpl.unbound() { + ptr = new _ServiceRegistryProxyCalls(impl); + } + + factory ServiceRegistryProxy.connectToService( + bindings.ServiceConnector s, String url) { + ServiceRegistryProxy p = new ServiceRegistryProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static ServiceRegistryProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ServiceRegistryProxy")); + return new ServiceRegistryProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "ServiceRegistryProxy($impl)"; + } +} + + +class ServiceRegistryStub extends bindings.Stub { + ServiceRegistry _impl = null; + + ServiceRegistryStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + ServiceRegistryStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + ServiceRegistryStub.unbound() : super.unbound(); + + static ServiceRegistryStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ServiceRegistryStub")); + return new ServiceRegistryStub.fromEndpoint(endpoint); + } + + static const String name = ServiceRegistryName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kServiceRegistry_addServices_name: + var params = ServiceRegistryAddServicesParams.deserialize( + message.payload); + _impl.addServices(params.interfaceNames, params.serviceProvider); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + ServiceRegistry get impl => _impl; + set impl(ServiceRegistry d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "ServiceRegistryStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/sharing.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/sharing.mojom.dart new file mode 100644 index 0000000..f4e4686 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/sharing.mojom.dart
@@ -0,0 +1,255 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library sharing_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; + + + +class SharingServiceShareTextParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + String text = null; + + SharingServiceShareTextParams() : super(kVersions.last.size); + + static SharingServiceShareTextParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static SharingServiceShareTextParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + SharingServiceShareTextParams result = new SharingServiceShareTextParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.text = decoder0.decodeString(8, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(text, 8, false); + } + + String toString() { + return "SharingServiceShareTextParams(" + "text: $text" ")"; + } + + Map toJson() { + Map map = new Map(); + map["text"] = text; + return map; + } +} + +const int kSharingService_shareText_name = 0; + +const String SharingServiceName = + 'mojo::SharingService'; + +abstract class SharingService { + void shareText(String text); + +} + + +class SharingServiceProxyImpl extends bindings.Proxy { + SharingServiceProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + SharingServiceProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + SharingServiceProxyImpl.unbound() : super.unbound(); + + static SharingServiceProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For SharingServiceProxyImpl")); + return new SharingServiceProxyImpl.fromEndpoint(endpoint); + } + + String get name => SharingServiceName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "SharingServiceProxyImpl($superString)"; + } +} + + +class _SharingServiceProxyCalls implements SharingService { + SharingServiceProxyImpl _proxyImpl; + + _SharingServiceProxyCalls(this._proxyImpl); + void shareText(String text) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new SharingServiceShareTextParams(); + params.text = text; + _proxyImpl.sendMessage(params, kSharingService_shareText_name); + } + +} + + +class SharingServiceProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + SharingService ptr; + final String name = SharingServiceName; + + SharingServiceProxy(SharingServiceProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _SharingServiceProxyCalls(proxyImpl); + + SharingServiceProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new SharingServiceProxyImpl.fromEndpoint(endpoint) { + ptr = new _SharingServiceProxyCalls(impl); + } + + SharingServiceProxy.fromHandle(core.MojoHandle handle) : + impl = new SharingServiceProxyImpl.fromHandle(handle) { + ptr = new _SharingServiceProxyCalls(impl); + } + + SharingServiceProxy.unbound() : + impl = new SharingServiceProxyImpl.unbound() { + ptr = new _SharingServiceProxyCalls(impl); + } + + factory SharingServiceProxy.connectToService( + bindings.ServiceConnector s, String url) { + SharingServiceProxy p = new SharingServiceProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static SharingServiceProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For SharingServiceProxy")); + return new SharingServiceProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "SharingServiceProxy($impl)"; + } +} + + +class SharingServiceStub extends bindings.Stub { + SharingService _impl = null; + + SharingServiceStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + SharingServiceStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + SharingServiceStub.unbound() : super.unbound(); + + static SharingServiceStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For SharingServiceStub")); + return new SharingServiceStub.fromEndpoint(endpoint); + } + + static const String name = SharingServiceName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kSharingService_shareText_name: + var params = SharingServiceShareTextParams.deserialize( + message.payload); + _impl.shareText(params.text); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + SharingService get impl => _impl; + set impl(SharingService d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "SharingServiceStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/surface_id.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/surface_id.mojom.dart new file mode 100644 index 0000000..05d9a90 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/surface_id.mojom.dart
@@ -0,0 +1,89 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library surface_id_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; + + + +class SurfaceId extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int local = 0; + int idNamespace = 0; + + SurfaceId() : super(kVersions.last.size); + + static SurfaceId deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static SurfaceId decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + SurfaceId result = new SurfaceId(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.local = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + result.idNamespace = decoder0.decodeUint32(12); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(local, 8); + + encoder0.encodeUint32(idNamespace, 12); + } + + String toString() { + return "SurfaceId(" + "local: $local" ", " + "idNamespace: $idNamespace" ")"; + } + + Map toJson() { + Map map = new Map(); + map["local"] = local; + map["idNamespace"] = idNamespace; + return map; + } +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/surfaces.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/surfaces.mojom.dart new file mode 100644 index 0000000..4fd551a --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/surfaces.mojom.dart
@@ -0,0 +1,1627 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library surfaces_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo_services/mojo/geometry.mojom.dart' as geometry_mojom; +import 'package:mojo_services/mojo/quads.mojom.dart' as quads_mojom; +import 'package:mojo_services/mojo/surface_id.mojom.dart' as surface_id_mojom; +class ResourceFormat extends bindings.MojoEnum { + static const RGBA_8888 = const ResourceFormat._(0); + static const RGBA_4444 = const ResourceFormat._(1); + static const BGRA_8888 = const ResourceFormat._(2); + static const ALPHA_8 = const ResourceFormat._(3); + static const LUMINANCE_8 = const ResourceFormat._(4); + static const RGB_565 = const ResourceFormat._(5); + static const ETC1 = const ResourceFormat._(6); + + const ResourceFormat._(int v) : super(v); + + static const Map<String, ResourceFormat> valuesMap = const { + "RGBA_8888": RGBA_8888, + "RGBA_4444": RGBA_4444, + "BGRA_8888": BGRA_8888, + "ALPHA_8": ALPHA_8, + "LUMINANCE_8": LUMINANCE_8, + "RGB_565": RGB_565, + "ETC1": ETC1, + }; + static const List<ResourceFormat> values = const [ + RGBA_8888, + RGBA_4444, + BGRA_8888, + ALPHA_8, + LUMINANCE_8, + RGB_565, + ETC1, + ]; + + static ResourceFormat valueOf(String name) => valuesMap[name]; + + factory ResourceFormat(int v) { + switch (v) { + case 0: + return RGBA_8888; + case 1: + return RGBA_4444; + case 2: + return BGRA_8888; + case 3: + return ALPHA_8; + case 4: + return LUMINANCE_8; + case 5: + return RGB_565; + case 6: + return ETC1; + default: + return null; + } + } + + static ResourceFormat decode(bindings.Decoder decoder0, int offset) { + int v = decoder0.decodeUint32(offset); + ResourceFormat result = new ResourceFormat(v); + if (result == null) { + throw new bindings.MojoCodecError( + 'Bad value $v for enum ResourceFormat.'); + } + return result; + } + + String toString() { + switch(this) { + case RGBA_8888: + return 'ResourceFormat.RGBA_8888'; + case RGBA_4444: + return 'ResourceFormat.RGBA_4444'; + case BGRA_8888: + return 'ResourceFormat.BGRA_8888'; + case ALPHA_8: + return 'ResourceFormat.ALPHA_8'; + case LUMINANCE_8: + return 'ResourceFormat.LUMINANCE_8'; + case RGB_565: + return 'ResourceFormat.RGB_565'; + case ETC1: + return 'ResourceFormat.ETC1'; + } + } + + int toJson() => value; +} + + + +class Mailbox extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + List<int> name = null; + + Mailbox() : super(kVersions.last.size); + + static Mailbox deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static Mailbox decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + Mailbox result = new Mailbox(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.name = decoder0.decodeInt8Array(8, bindings.kNothingNullable, 64); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt8Array(name, 8, bindings.kNothingNullable, 64); + } + + String toString() { + return "Mailbox(" + "name: $name" ")"; + } + + Map toJson() { + Map map = new Map(); + map["name"] = name; + return map; + } +} + + +class MailboxHolder extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + Mailbox mailbox = null; + int textureTarget = 0; + int syncPoint = 0; + + MailboxHolder() : super(kVersions.last.size); + + static MailboxHolder deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static MailboxHolder decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + MailboxHolder result = new MailboxHolder(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.mailbox = Mailbox.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + result.textureTarget = decoder0.decodeUint32(16); + } + if (mainDataHeader.version >= 0) { + + result.syncPoint = decoder0.decodeUint32(20); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(mailbox, 8, false); + + encoder0.encodeUint32(textureTarget, 16); + + encoder0.encodeUint32(syncPoint, 20); + } + + String toString() { + return "MailboxHolder(" + "mailbox: $mailbox" ", " + "textureTarget: $textureTarget" ", " + "syncPoint: $syncPoint" ")"; + } + + Map toJson() { + Map map = new Map(); + map["mailbox"] = mailbox; + map["textureTarget"] = textureTarget; + map["syncPoint"] = syncPoint; + return map; + } +} + + +class TransferableResource extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(40, 0) + ]; + int id = 0; + ResourceFormat format = null; + int filter = 0; + bool isRepeated = false; + bool isSoftware = false; + geometry_mojom.Size size = null; + MailboxHolder mailboxHolder = null; + + TransferableResource() : super(kVersions.last.size); + + static TransferableResource deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static TransferableResource decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + TransferableResource result = new TransferableResource(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.id = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + result.format = ResourceFormat.decode(decoder0, 12); + if (result.format == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable ResourceFormat.'); + } + } + if (mainDataHeader.version >= 0) { + + result.filter = decoder0.decodeUint32(16); + } + if (mainDataHeader.version >= 0) { + + result.isRepeated = decoder0.decodeBool(20, 0); + } + if (mainDataHeader.version >= 0) { + + result.isSoftware = decoder0.decodeBool(20, 1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(24, false); + result.size = geometry_mojom.Size.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(32, false); + result.mailboxHolder = MailboxHolder.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(id, 8); + + encoder0.encodeEnum(format, 12); + + encoder0.encodeUint32(filter, 16); + + encoder0.encodeBool(isRepeated, 20, 0); + + encoder0.encodeBool(isSoftware, 20, 1); + + encoder0.encodeStruct(size, 24, false); + + encoder0.encodeStruct(mailboxHolder, 32, false); + } + + String toString() { + return "TransferableResource(" + "id: $id" ", " + "format: $format" ", " + "filter: $filter" ", " + "isRepeated: $isRepeated" ", " + "isSoftware: $isSoftware" ", " + "size: $size" ", " + "mailboxHolder: $mailboxHolder" ")"; + } + + Map toJson() { + Map map = new Map(); + map["id"] = id; + map["format"] = format; + map["filter"] = filter; + map["isRepeated"] = isRepeated; + map["isSoftware"] = isSoftware; + map["size"] = size; + map["mailboxHolder"] = mailboxHolder; + return map; + } +} + + +class ReturnedResource extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int id = 0; + int syncPoint = 0; + int count = 0; + bool lost = false; + + ReturnedResource() : super(kVersions.last.size); + + static ReturnedResource deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ReturnedResource decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ReturnedResource result = new ReturnedResource(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.id = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + result.syncPoint = decoder0.decodeUint32(12); + } + if (mainDataHeader.version >= 0) { + + result.count = decoder0.decodeInt32(16); + } + if (mainDataHeader.version >= 0) { + + result.lost = decoder0.decodeBool(20, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(id, 8); + + encoder0.encodeUint32(syncPoint, 12); + + encoder0.encodeInt32(count, 16); + + encoder0.encodeBool(lost, 20, 0); + } + + String toString() { + return "ReturnedResource(" + "id: $id" ", " + "syncPoint: $syncPoint" ", " + "count: $count" ", " + "lost: $lost" ")"; + } + + Map toJson() { + Map map = new Map(); + map["id"] = id; + map["syncPoint"] = syncPoint; + map["count"] = count; + map["lost"] = lost; + return map; + } +} + + +class Frame extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + List<TransferableResource> resources = null; + List<quads_mojom.Pass> passes = null; + + Frame() : super(kVersions.last.size); + + static Frame deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static Frame decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + Frame result = new Frame(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.resources = new List<TransferableResource>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + var decoder2 = decoder1.decodePointer(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + result.resources[i1] = TransferableResource.decode(decoder2); + } + } + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.passes = new List<quads_mojom.Pass>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + var decoder2 = decoder1.decodePointer(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + result.passes[i1] = quads_mojom.Pass.decode(decoder2); + } + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + if (resources == null) { + encoder0.encodeNullPointer(8, false); + } else { + var encoder1 = encoder0.encodePointerArray(resources.length, 8, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < resources.length; ++i0) { + + encoder1.encodeStruct(resources[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + + if (passes == null) { + encoder0.encodeNullPointer(16, false); + } else { + var encoder1 = encoder0.encodePointerArray(passes.length, 16, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < passes.length; ++i0) { + + encoder1.encodeStruct(passes[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + } + + String toString() { + return "Frame(" + "resources: $resources" ", " + "passes: $passes" ")"; + } + + Map toJson() { + Map map = new Map(); + map["resources"] = resources; + map["passes"] = passes; + return map; + } +} + + +class ResourceReturnerReturnResourcesParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + List<ReturnedResource> resources = null; + + ResourceReturnerReturnResourcesParams() : super(kVersions.last.size); + + static ResourceReturnerReturnResourcesParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ResourceReturnerReturnResourcesParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ResourceReturnerReturnResourcesParams result = new ResourceReturnerReturnResourcesParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.resources = new List<ReturnedResource>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + var decoder2 = decoder1.decodePointer(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + result.resources[i1] = ReturnedResource.decode(decoder2); + } + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + if (resources == null) { + encoder0.encodeNullPointer(8, false); + } else { + var encoder1 = encoder0.encodePointerArray(resources.length, 8, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < resources.length; ++i0) { + + encoder1.encodeStruct(resources[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + } + + String toString() { + return "ResourceReturnerReturnResourcesParams(" + "resources: $resources" ")"; + } + + Map toJson() { + Map map = new Map(); + map["resources"] = resources; + return map; + } +} + + +class SurfaceGetIdNamespaceParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + SurfaceGetIdNamespaceParams() : super(kVersions.last.size); + + static SurfaceGetIdNamespaceParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static SurfaceGetIdNamespaceParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + SurfaceGetIdNamespaceParams result = new SurfaceGetIdNamespaceParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "SurfaceGetIdNamespaceParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class SurfaceGetIdNamespaceResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int idNamespace = 0; + + SurfaceGetIdNamespaceResponseParams() : super(kVersions.last.size); + + static SurfaceGetIdNamespaceResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static SurfaceGetIdNamespaceResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + SurfaceGetIdNamespaceResponseParams result = new SurfaceGetIdNamespaceResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.idNamespace = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(idNamespace, 8); + } + + String toString() { + return "SurfaceGetIdNamespaceResponseParams(" + "idNamespace: $idNamespace" ")"; + } + + Map toJson() { + Map map = new Map(); + map["idNamespace"] = idNamespace; + return map; + } +} + + +class SurfaceSetResourceReturnerParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + Object returner = null; + + SurfaceSetResourceReturnerParams() : super(kVersions.last.size); + + static SurfaceSetResourceReturnerParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static SurfaceSetResourceReturnerParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + SurfaceSetResourceReturnerParams result = new SurfaceSetResourceReturnerParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.returner = decoder0.decodeServiceInterface(8, false, ResourceReturnerProxy.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterface(returner, 8, false); + } + + String toString() { + return "SurfaceSetResourceReturnerParams(" + "returner: $returner" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class SurfaceCreateSurfaceParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int idLocal = 0; + + SurfaceCreateSurfaceParams() : super(kVersions.last.size); + + static SurfaceCreateSurfaceParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static SurfaceCreateSurfaceParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + SurfaceCreateSurfaceParams result = new SurfaceCreateSurfaceParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.idLocal = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(idLocal, 8); + } + + String toString() { + return "SurfaceCreateSurfaceParams(" + "idLocal: $idLocal" ")"; + } + + Map toJson() { + Map map = new Map(); + map["idLocal"] = idLocal; + return map; + } +} + + +class SurfaceSubmitFrameParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int idLocal = 0; + Frame frame = null; + + SurfaceSubmitFrameParams() : super(kVersions.last.size); + + static SurfaceSubmitFrameParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static SurfaceSubmitFrameParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + SurfaceSubmitFrameParams result = new SurfaceSubmitFrameParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.idLocal = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + result.frame = Frame.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(idLocal, 8); + + encoder0.encodeStruct(frame, 16, false); + } + + String toString() { + return "SurfaceSubmitFrameParams(" + "idLocal: $idLocal" ", " + "frame: $frame" ")"; + } + + Map toJson() { + Map map = new Map(); + map["idLocal"] = idLocal; + map["frame"] = frame; + return map; + } +} + + +class SurfaceSubmitFrameResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + SurfaceSubmitFrameResponseParams() : super(kVersions.last.size); + + static SurfaceSubmitFrameResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static SurfaceSubmitFrameResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + SurfaceSubmitFrameResponseParams result = new SurfaceSubmitFrameResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "SurfaceSubmitFrameResponseParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class SurfaceDestroySurfaceParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int idLocal = 0; + + SurfaceDestroySurfaceParams() : super(kVersions.last.size); + + static SurfaceDestroySurfaceParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static SurfaceDestroySurfaceParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + SurfaceDestroySurfaceParams result = new SurfaceDestroySurfaceParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.idLocal = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(idLocal, 8); + } + + String toString() { + return "SurfaceDestroySurfaceParams(" + "idLocal: $idLocal" ")"; + } + + Map toJson() { + Map map = new Map(); + map["idLocal"] = idLocal; + return map; + } +} + +const int kResourceReturner_returnResources_name = 0; + +const String ResourceReturnerName = + 'mojo::ResourceReturner'; + +abstract class ResourceReturner { + void returnResources(List<ReturnedResource> resources); + +} + + +class ResourceReturnerProxyImpl extends bindings.Proxy { + ResourceReturnerProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + ResourceReturnerProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + ResourceReturnerProxyImpl.unbound() : super.unbound(); + + static ResourceReturnerProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ResourceReturnerProxyImpl")); + return new ResourceReturnerProxyImpl.fromEndpoint(endpoint); + } + + String get name => ResourceReturnerName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "ResourceReturnerProxyImpl($superString)"; + } +} + + +class _ResourceReturnerProxyCalls implements ResourceReturner { + ResourceReturnerProxyImpl _proxyImpl; + + _ResourceReturnerProxyCalls(this._proxyImpl); + void returnResources(List<ReturnedResource> resources) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new ResourceReturnerReturnResourcesParams(); + params.resources = resources; + _proxyImpl.sendMessage(params, kResourceReturner_returnResources_name); + } + +} + + +class ResourceReturnerProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + ResourceReturner ptr; + final String name = ResourceReturnerName; + + ResourceReturnerProxy(ResourceReturnerProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _ResourceReturnerProxyCalls(proxyImpl); + + ResourceReturnerProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new ResourceReturnerProxyImpl.fromEndpoint(endpoint) { + ptr = new _ResourceReturnerProxyCalls(impl); + } + + ResourceReturnerProxy.fromHandle(core.MojoHandle handle) : + impl = new ResourceReturnerProxyImpl.fromHandle(handle) { + ptr = new _ResourceReturnerProxyCalls(impl); + } + + ResourceReturnerProxy.unbound() : + impl = new ResourceReturnerProxyImpl.unbound() { + ptr = new _ResourceReturnerProxyCalls(impl); + } + + factory ResourceReturnerProxy.connectToService( + bindings.ServiceConnector s, String url) { + ResourceReturnerProxy p = new ResourceReturnerProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static ResourceReturnerProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ResourceReturnerProxy")); + return new ResourceReturnerProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "ResourceReturnerProxy($impl)"; + } +} + + +class ResourceReturnerStub extends bindings.Stub { + ResourceReturner _impl = null; + + ResourceReturnerStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + ResourceReturnerStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + ResourceReturnerStub.unbound() : super.unbound(); + + static ResourceReturnerStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ResourceReturnerStub")); + return new ResourceReturnerStub.fromEndpoint(endpoint); + } + + static const String name = ResourceReturnerName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kResourceReturner_returnResources_name: + var params = ResourceReturnerReturnResourcesParams.deserialize( + message.payload); + _impl.returnResources(params.resources); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + ResourceReturner get impl => _impl; + set impl(ResourceReturner d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "ResourceReturnerStub($superString)"; + } + + int get version => 0; +} + +const int kSurface_getIdNamespace_name = 0; +const int kSurface_setResourceReturner_name = 1; +const int kSurface_createSurface_name = 2; +const int kSurface_submitFrame_name = 3; +const int kSurface_destroySurface_name = 4; + +const String SurfaceName = + 'mojo::Surface'; + +abstract class Surface { + dynamic getIdNamespace([Function responseFactory = null]); + void setResourceReturner(Object returner); + void createSurface(int idLocal); + dynamic submitFrame(int idLocal,Frame frame,[Function responseFactory = null]); + void destroySurface(int idLocal); + +} + + +class SurfaceProxyImpl extends bindings.Proxy { + SurfaceProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + SurfaceProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + SurfaceProxyImpl.unbound() : super.unbound(); + + static SurfaceProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For SurfaceProxyImpl")); + return new SurfaceProxyImpl.fromEndpoint(endpoint); + } + + String get name => SurfaceName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kSurface_getIdNamespace_name: + var r = SurfaceGetIdNamespaceResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kSurface_submitFrame_name: + var r = SurfaceSubmitFrameResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "SurfaceProxyImpl($superString)"; + } +} + + +class _SurfaceProxyCalls implements Surface { + SurfaceProxyImpl _proxyImpl; + + _SurfaceProxyCalls(this._proxyImpl); + dynamic getIdNamespace([Function responseFactory = null]) { + var params = new SurfaceGetIdNamespaceParams(); + return _proxyImpl.sendMessageWithRequestId( + params, + kSurface_getIdNamespace_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + void setResourceReturner(Object returner) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new SurfaceSetResourceReturnerParams(); + params.returner = returner; + _proxyImpl.sendMessage(params, kSurface_setResourceReturner_name); + } + + void createSurface(int idLocal) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new SurfaceCreateSurfaceParams(); + params.idLocal = idLocal; + _proxyImpl.sendMessage(params, kSurface_createSurface_name); + } + + dynamic submitFrame(int idLocal,Frame frame,[Function responseFactory = null]) { + var params = new SurfaceSubmitFrameParams(); + params.idLocal = idLocal; + params.frame = frame; + return _proxyImpl.sendMessageWithRequestId( + params, + kSurface_submitFrame_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + void destroySurface(int idLocal) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new SurfaceDestroySurfaceParams(); + params.idLocal = idLocal; + _proxyImpl.sendMessage(params, kSurface_destroySurface_name); + } + +} + + +class SurfaceProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + Surface ptr; + final String name = SurfaceName; + + SurfaceProxy(SurfaceProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _SurfaceProxyCalls(proxyImpl); + + SurfaceProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new SurfaceProxyImpl.fromEndpoint(endpoint) { + ptr = new _SurfaceProxyCalls(impl); + } + + SurfaceProxy.fromHandle(core.MojoHandle handle) : + impl = new SurfaceProxyImpl.fromHandle(handle) { + ptr = new _SurfaceProxyCalls(impl); + } + + SurfaceProxy.unbound() : + impl = new SurfaceProxyImpl.unbound() { + ptr = new _SurfaceProxyCalls(impl); + } + + factory SurfaceProxy.connectToService( + bindings.ServiceConnector s, String url) { + SurfaceProxy p = new SurfaceProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static SurfaceProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For SurfaceProxy")); + return new SurfaceProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "SurfaceProxy($impl)"; + } +} + + +class SurfaceStub extends bindings.Stub { + Surface _impl = null; + + SurfaceStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + SurfaceStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + SurfaceStub.unbound() : super.unbound(); + + static SurfaceStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For SurfaceStub")); + return new SurfaceStub.fromEndpoint(endpoint); + } + + static const String name = SurfaceName; + + + SurfaceGetIdNamespaceResponseParams _SurfaceGetIdNamespaceResponseParamsFactory(int idNamespace) { + var result = new SurfaceGetIdNamespaceResponseParams(); + result.idNamespace = idNamespace; + return result; + } + SurfaceSubmitFrameResponseParams _SurfaceSubmitFrameResponseParamsFactory() { + var result = new SurfaceSubmitFrameResponseParams(); + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kSurface_getIdNamespace_name: + var params = SurfaceGetIdNamespaceParams.deserialize( + message.payload); + var response = _impl.getIdNamespace(_SurfaceGetIdNamespaceResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kSurface_getIdNamespace_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kSurface_getIdNamespace_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kSurface_setResourceReturner_name: + var params = SurfaceSetResourceReturnerParams.deserialize( + message.payload); + _impl.setResourceReturner(params.returner); + break; + case kSurface_createSurface_name: + var params = SurfaceCreateSurfaceParams.deserialize( + message.payload); + _impl.createSurface(params.idLocal); + break; + case kSurface_submitFrame_name: + var params = SurfaceSubmitFrameParams.deserialize( + message.payload); + var response = _impl.submitFrame(params.idLocal,params.frame,_SurfaceSubmitFrameResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kSurface_submitFrame_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kSurface_submitFrame_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kSurface_destroySurface_name: + var params = SurfaceDestroySurfaceParams.deserialize( + message.payload); + _impl.destroySurface(params.idLocal); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + Surface get impl => _impl; + set impl(Surface d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "SurfaceStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/tcp_bound_socket.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/tcp_bound_socket.mojom.dart new file mode 100644 index 0000000..3d46fc9 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/tcp_bound_socket.mojom.dart
@@ -0,0 +1,587 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library tcp_bound_socket_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo/mojo/network_error.mojom.dart' as network_error_mojom; +import 'package:mojo_services/mojo/net_address.mojom.dart' as net_address_mojom; +import 'package:mojo_services/mojo/tcp_connected_socket.mojom.dart' as tcp_connected_socket_mojom; +import 'package:mojo_services/mojo/tcp_server_socket.mojom.dart' as tcp_server_socket_mojom; + + + +class TcpBoundSocketStartListeningParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + Object server = null; + + TcpBoundSocketStartListeningParams() : super(kVersions.last.size); + + static TcpBoundSocketStartListeningParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static TcpBoundSocketStartListeningParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + TcpBoundSocketStartListeningParams result = new TcpBoundSocketStartListeningParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.server = decoder0.decodeInterfaceRequest(8, false, tcp_server_socket_mojom.TcpServerSocketStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterfaceRequest(server, 8, false); + } + + String toString() { + return "TcpBoundSocketStartListeningParams(" + "server: $server" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class TcpBoundSocketStartListeningResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + network_error_mojom.NetworkError result = null; + + TcpBoundSocketStartListeningResponseParams() : super(kVersions.last.size); + + static TcpBoundSocketStartListeningResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static TcpBoundSocketStartListeningResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + TcpBoundSocketStartListeningResponseParams result = new TcpBoundSocketStartListeningResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.result = network_error_mojom.NetworkError.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(result, 8, false); + } + + String toString() { + return "TcpBoundSocketStartListeningResponseParams(" + "result: $result" ")"; + } + + Map toJson() { + Map map = new Map(); + map["result"] = result; + return map; + } +} + + +class TcpBoundSocketConnectParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(32, 0) + ]; + net_address_mojom.NetAddress remoteAddress = null; + core.MojoDataPipeConsumer sendStream = null; + core.MojoDataPipeProducer receiveStream = null; + Object clientSocket = null; + + TcpBoundSocketConnectParams() : super(kVersions.last.size); + + static TcpBoundSocketConnectParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static TcpBoundSocketConnectParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + TcpBoundSocketConnectParams result = new TcpBoundSocketConnectParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.remoteAddress = net_address_mojom.NetAddress.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + result.sendStream = decoder0.decodeConsumerHandle(16, false); + } + if (mainDataHeader.version >= 0) { + + result.receiveStream = decoder0.decodeProducerHandle(20, false); + } + if (mainDataHeader.version >= 0) { + + result.clientSocket = decoder0.decodeInterfaceRequest(24, false, tcp_connected_socket_mojom.TcpConnectedSocketStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(remoteAddress, 8, false); + + encoder0.encodeConsumerHandle(sendStream, 16, false); + + encoder0.encodeProducerHandle(receiveStream, 20, false); + + encoder0.encodeInterfaceRequest(clientSocket, 24, false); + } + + String toString() { + return "TcpBoundSocketConnectParams(" + "remoteAddress: $remoteAddress" ", " + "sendStream: $sendStream" ", " + "receiveStream: $receiveStream" ", " + "clientSocket: $clientSocket" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class TcpBoundSocketConnectResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + network_error_mojom.NetworkError result = null; + + TcpBoundSocketConnectResponseParams() : super(kVersions.last.size); + + static TcpBoundSocketConnectResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static TcpBoundSocketConnectResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + TcpBoundSocketConnectResponseParams result = new TcpBoundSocketConnectResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.result = network_error_mojom.NetworkError.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(result, 8, false); + } + + String toString() { + return "TcpBoundSocketConnectResponseParams(" + "result: $result" ")"; + } + + Map toJson() { + Map map = new Map(); + map["result"] = result; + return map; + } +} + +const int kTcpBoundSocket_startListening_name = 0; +const int kTcpBoundSocket_connect_name = 1; + +const String TcpBoundSocketName = + 'mojo::TCPBoundSocket'; + +abstract class TcpBoundSocket { + dynamic startListening(Object server,[Function responseFactory = null]); + dynamic connect(net_address_mojom.NetAddress remoteAddress,core.MojoDataPipeConsumer sendStream,core.MojoDataPipeProducer receiveStream,Object clientSocket,[Function responseFactory = null]); + +} + + +class TcpBoundSocketProxyImpl extends bindings.Proxy { + TcpBoundSocketProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + TcpBoundSocketProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + TcpBoundSocketProxyImpl.unbound() : super.unbound(); + + static TcpBoundSocketProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For TcpBoundSocketProxyImpl")); + return new TcpBoundSocketProxyImpl.fromEndpoint(endpoint); + } + + String get name => TcpBoundSocketName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kTcpBoundSocket_startListening_name: + var r = TcpBoundSocketStartListeningResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kTcpBoundSocket_connect_name: + var r = TcpBoundSocketConnectResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "TcpBoundSocketProxyImpl($superString)"; + } +} + + +class _TcpBoundSocketProxyCalls implements TcpBoundSocket { + TcpBoundSocketProxyImpl _proxyImpl; + + _TcpBoundSocketProxyCalls(this._proxyImpl); + dynamic startListening(Object server,[Function responseFactory = null]) { + var params = new TcpBoundSocketStartListeningParams(); + params.server = server; + return _proxyImpl.sendMessageWithRequestId( + params, + kTcpBoundSocket_startListening_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic connect(net_address_mojom.NetAddress remoteAddress,core.MojoDataPipeConsumer sendStream,core.MojoDataPipeProducer receiveStream,Object clientSocket,[Function responseFactory = null]) { + var params = new TcpBoundSocketConnectParams(); + params.remoteAddress = remoteAddress; + params.sendStream = sendStream; + params.receiveStream = receiveStream; + params.clientSocket = clientSocket; + return _proxyImpl.sendMessageWithRequestId( + params, + kTcpBoundSocket_connect_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class TcpBoundSocketProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + TcpBoundSocket ptr; + final String name = TcpBoundSocketName; + + TcpBoundSocketProxy(TcpBoundSocketProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _TcpBoundSocketProxyCalls(proxyImpl); + + TcpBoundSocketProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new TcpBoundSocketProxyImpl.fromEndpoint(endpoint) { + ptr = new _TcpBoundSocketProxyCalls(impl); + } + + TcpBoundSocketProxy.fromHandle(core.MojoHandle handle) : + impl = new TcpBoundSocketProxyImpl.fromHandle(handle) { + ptr = new _TcpBoundSocketProxyCalls(impl); + } + + TcpBoundSocketProxy.unbound() : + impl = new TcpBoundSocketProxyImpl.unbound() { + ptr = new _TcpBoundSocketProxyCalls(impl); + } + + factory TcpBoundSocketProxy.connectToService( + bindings.ServiceConnector s, String url) { + TcpBoundSocketProxy p = new TcpBoundSocketProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static TcpBoundSocketProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For TcpBoundSocketProxy")); + return new TcpBoundSocketProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "TcpBoundSocketProxy($impl)"; + } +} + + +class TcpBoundSocketStub extends bindings.Stub { + TcpBoundSocket _impl = null; + + TcpBoundSocketStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + TcpBoundSocketStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + TcpBoundSocketStub.unbound() : super.unbound(); + + static TcpBoundSocketStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For TcpBoundSocketStub")); + return new TcpBoundSocketStub.fromEndpoint(endpoint); + } + + static const String name = TcpBoundSocketName; + + + TcpBoundSocketStartListeningResponseParams _TcpBoundSocketStartListeningResponseParamsFactory(network_error_mojom.NetworkError result) { + var result = new TcpBoundSocketStartListeningResponseParams(); + result.result = result; + return result; + } + TcpBoundSocketConnectResponseParams _TcpBoundSocketConnectResponseParamsFactory(network_error_mojom.NetworkError result) { + var result = new TcpBoundSocketConnectResponseParams(); + result.result = result; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kTcpBoundSocket_startListening_name: + var params = TcpBoundSocketStartListeningParams.deserialize( + message.payload); + var response = _impl.startListening(params.server,_TcpBoundSocketStartListeningResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kTcpBoundSocket_startListening_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kTcpBoundSocket_startListening_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kTcpBoundSocket_connect_name: + var params = TcpBoundSocketConnectParams.deserialize( + message.payload); + var response = _impl.connect(params.remoteAddress,params.sendStream,params.receiveStream,params.clientSocket,_TcpBoundSocketConnectResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kTcpBoundSocket_connect_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kTcpBoundSocket_connect_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + TcpBoundSocket get impl => _impl; + set impl(TcpBoundSocket d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "TcpBoundSocketStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/tcp_connected_socket.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/tcp_connected_socket.mojom.dart new file mode 100644 index 0000000..a13a3a5 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/tcp_connected_socket.mojom.dart
@@ -0,0 +1,171 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library tcp_connected_socket_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; + + + +const String TcpConnectedSocketName = + 'mojo::TCPConnectedSocket'; + +abstract class TcpConnectedSocket { + +} + + +class TcpConnectedSocketProxyImpl extends bindings.Proxy { + TcpConnectedSocketProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + TcpConnectedSocketProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + TcpConnectedSocketProxyImpl.unbound() : super.unbound(); + + static TcpConnectedSocketProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For TcpConnectedSocketProxyImpl")); + return new TcpConnectedSocketProxyImpl.fromEndpoint(endpoint); + } + + String get name => TcpConnectedSocketName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "TcpConnectedSocketProxyImpl($superString)"; + } +} + + +class _TcpConnectedSocketProxyCalls implements TcpConnectedSocket { + TcpConnectedSocketProxyImpl _proxyImpl; + + _TcpConnectedSocketProxyCalls(this._proxyImpl); +} + + +class TcpConnectedSocketProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + TcpConnectedSocket ptr; + final String name = TcpConnectedSocketName; + + TcpConnectedSocketProxy(TcpConnectedSocketProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _TcpConnectedSocketProxyCalls(proxyImpl); + + TcpConnectedSocketProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new TcpConnectedSocketProxyImpl.fromEndpoint(endpoint) { + ptr = new _TcpConnectedSocketProxyCalls(impl); + } + + TcpConnectedSocketProxy.fromHandle(core.MojoHandle handle) : + impl = new TcpConnectedSocketProxyImpl.fromHandle(handle) { + ptr = new _TcpConnectedSocketProxyCalls(impl); + } + + TcpConnectedSocketProxy.unbound() : + impl = new TcpConnectedSocketProxyImpl.unbound() { + ptr = new _TcpConnectedSocketProxyCalls(impl); + } + + factory TcpConnectedSocketProxy.connectToService( + bindings.ServiceConnector s, String url) { + TcpConnectedSocketProxy p = new TcpConnectedSocketProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static TcpConnectedSocketProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For TcpConnectedSocketProxy")); + return new TcpConnectedSocketProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "TcpConnectedSocketProxy($impl)"; + } +} + + +class TcpConnectedSocketStub extends bindings.Stub { + TcpConnectedSocket _impl = null; + + TcpConnectedSocketStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + TcpConnectedSocketStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + TcpConnectedSocketStub.unbound() : super.unbound(); + + static TcpConnectedSocketStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For TcpConnectedSocketStub")); + return new TcpConnectedSocketStub.fromEndpoint(endpoint); + } + + static const String name = TcpConnectedSocketName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + TcpConnectedSocket get impl => _impl; + set impl(TcpConnectedSocket d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "TcpConnectedSocketStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/tcp_server_socket.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/tcp_server_socket.mojom.dart new file mode 100644 index 0000000..2567ba0 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/tcp_server_socket.mojom.dart
@@ -0,0 +1,395 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library tcp_server_socket_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo/mojo/network_error.mojom.dart' as network_error_mojom; +import 'package:mojo_services/mojo/net_address.mojom.dart' as net_address_mojom; +import 'package:mojo_services/mojo/tcp_connected_socket.mojom.dart' as tcp_connected_socket_mojom; + + + +class TcpServerSocketAcceptParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + core.MojoDataPipeConsumer sendStream = null; + core.MojoDataPipeProducer receiveStream = null; + Object clientSocket = null; + + TcpServerSocketAcceptParams() : super(kVersions.last.size); + + static TcpServerSocketAcceptParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static TcpServerSocketAcceptParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + TcpServerSocketAcceptParams result = new TcpServerSocketAcceptParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.sendStream = decoder0.decodeConsumerHandle(8, false); + } + if (mainDataHeader.version >= 0) { + + result.receiveStream = decoder0.decodeProducerHandle(12, false); + } + if (mainDataHeader.version >= 0) { + + result.clientSocket = decoder0.decodeInterfaceRequest(16, false, tcp_connected_socket_mojom.TcpConnectedSocketStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeConsumerHandle(sendStream, 8, false); + + encoder0.encodeProducerHandle(receiveStream, 12, false); + + encoder0.encodeInterfaceRequest(clientSocket, 16, false); + } + + String toString() { + return "TcpServerSocketAcceptParams(" + "sendStream: $sendStream" ", " + "receiveStream: $receiveStream" ", " + "clientSocket: $clientSocket" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class TcpServerSocketAcceptResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + network_error_mojom.NetworkError result = null; + net_address_mojom.NetAddress remoteAddress = null; + + TcpServerSocketAcceptResponseParams() : super(kVersions.last.size); + + static TcpServerSocketAcceptResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static TcpServerSocketAcceptResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + TcpServerSocketAcceptResponseParams result = new TcpServerSocketAcceptResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.result = network_error_mojom.NetworkError.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, true); + result.remoteAddress = net_address_mojom.NetAddress.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(result, 8, false); + + encoder0.encodeStruct(remoteAddress, 16, true); + } + + String toString() { + return "TcpServerSocketAcceptResponseParams(" + "result: $result" ", " + "remoteAddress: $remoteAddress" ")"; + } + + Map toJson() { + Map map = new Map(); + map["result"] = result; + map["remoteAddress"] = remoteAddress; + return map; + } +} + +const int kTcpServerSocket_accept_name = 0; + +const String TcpServerSocketName = + 'mojo::TCPServerSocket'; + +abstract class TcpServerSocket { + dynamic accept(core.MojoDataPipeConsumer sendStream,core.MojoDataPipeProducer receiveStream,Object clientSocket,[Function responseFactory = null]); + +} + + +class TcpServerSocketProxyImpl extends bindings.Proxy { + TcpServerSocketProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + TcpServerSocketProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + TcpServerSocketProxyImpl.unbound() : super.unbound(); + + static TcpServerSocketProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For TcpServerSocketProxyImpl")); + return new TcpServerSocketProxyImpl.fromEndpoint(endpoint); + } + + String get name => TcpServerSocketName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kTcpServerSocket_accept_name: + var r = TcpServerSocketAcceptResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "TcpServerSocketProxyImpl($superString)"; + } +} + + +class _TcpServerSocketProxyCalls implements TcpServerSocket { + TcpServerSocketProxyImpl _proxyImpl; + + _TcpServerSocketProxyCalls(this._proxyImpl); + dynamic accept(core.MojoDataPipeConsumer sendStream,core.MojoDataPipeProducer receiveStream,Object clientSocket,[Function responseFactory = null]) { + var params = new TcpServerSocketAcceptParams(); + params.sendStream = sendStream; + params.receiveStream = receiveStream; + params.clientSocket = clientSocket; + return _proxyImpl.sendMessageWithRequestId( + params, + kTcpServerSocket_accept_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class TcpServerSocketProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + TcpServerSocket ptr; + final String name = TcpServerSocketName; + + TcpServerSocketProxy(TcpServerSocketProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _TcpServerSocketProxyCalls(proxyImpl); + + TcpServerSocketProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new TcpServerSocketProxyImpl.fromEndpoint(endpoint) { + ptr = new _TcpServerSocketProxyCalls(impl); + } + + TcpServerSocketProxy.fromHandle(core.MojoHandle handle) : + impl = new TcpServerSocketProxyImpl.fromHandle(handle) { + ptr = new _TcpServerSocketProxyCalls(impl); + } + + TcpServerSocketProxy.unbound() : + impl = new TcpServerSocketProxyImpl.unbound() { + ptr = new _TcpServerSocketProxyCalls(impl); + } + + factory TcpServerSocketProxy.connectToService( + bindings.ServiceConnector s, String url) { + TcpServerSocketProxy p = new TcpServerSocketProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static TcpServerSocketProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For TcpServerSocketProxy")); + return new TcpServerSocketProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "TcpServerSocketProxy($impl)"; + } +} + + +class TcpServerSocketStub extends bindings.Stub { + TcpServerSocket _impl = null; + + TcpServerSocketStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + TcpServerSocketStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + TcpServerSocketStub.unbound() : super.unbound(); + + static TcpServerSocketStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For TcpServerSocketStub")); + return new TcpServerSocketStub.fromEndpoint(endpoint); + } + + static const String name = TcpServerSocketName; + + + TcpServerSocketAcceptResponseParams _TcpServerSocketAcceptResponseParamsFactory(network_error_mojom.NetworkError result, net_address_mojom.NetAddress remoteAddress) { + var result = new TcpServerSocketAcceptResponseParams(); + result.result = result; + result.remoteAddress = remoteAddress; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kTcpServerSocket_accept_name: + var params = TcpServerSocketAcceptParams.deserialize( + message.payload); + var response = _impl.accept(params.sendStream,params.receiveStream,params.clientSocket,_TcpServerSocketAcceptResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kTcpServerSocket_accept_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kTcpServerSocket_accept_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + TcpServerSocket get impl => _impl; + set impl(TcpServerSocket d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "TcpServerSocketStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/terminal/terminal.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/terminal/terminal.mojom.dart new file mode 100644 index 0000000..c064085 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/terminal/terminal.mojom.dart
@@ -0,0 +1,1024 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library terminal_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo_services/mojo/files/file.mojom.dart' as file_mojom; +import 'package:mojo_services/mojo/files/types.mojom.dart' as types_mojom; +import 'package:mojo_services/mojo/terminal/terminal_client.mojom.dart' as terminal_client_mojom; + + + +class TerminalConnectParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + Object terminalFile = null; + bool force = false; + + TerminalConnectParams() : super(kVersions.last.size); + + static TerminalConnectParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static TerminalConnectParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + TerminalConnectParams result = new TerminalConnectParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.terminalFile = decoder0.decodeInterfaceRequest(8, false, file_mojom.FileStub.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.force = decoder0.decodeBool(12, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterfaceRequest(terminalFile, 8, false); + + encoder0.encodeBool(force, 12, 0); + } + + String toString() { + return "TerminalConnectParams(" + "terminalFile: $terminalFile" ", " + "force: $force" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class TerminalConnectResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + types_mojom.Error error = null; + + TerminalConnectResponseParams() : super(kVersions.last.size); + + static TerminalConnectResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static TerminalConnectResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + TerminalConnectResponseParams result = new TerminalConnectResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + } + + String toString() { + return "TerminalConnectResponseParams(" + "error: $error" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + return map; + } +} + + +class TerminalConnectToClientParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + Object terminalClient = null; + bool force = false; + + TerminalConnectToClientParams() : super(kVersions.last.size); + + static TerminalConnectToClientParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static TerminalConnectToClientParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + TerminalConnectToClientParams result = new TerminalConnectToClientParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.terminalClient = decoder0.decodeServiceInterface(8, false, terminal_client_mojom.TerminalClientProxy.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.force = decoder0.decodeBool(16, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterface(terminalClient, 8, false); + + encoder0.encodeBool(force, 16, 0); + } + + String toString() { + return "TerminalConnectToClientParams(" + "terminalClient: $terminalClient" ", " + "force: $force" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class TerminalConnectToClientResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + types_mojom.Error error = null; + + TerminalConnectToClientResponseParams() : super(kVersions.last.size); + + static TerminalConnectToClientResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static TerminalConnectToClientResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + TerminalConnectToClientResponseParams result = new TerminalConnectToClientResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + } + + String toString() { + return "TerminalConnectToClientResponseParams(" + "error: $error" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + return map; + } +} + + +class TerminalGetSizeParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + TerminalGetSizeParams() : super(kVersions.last.size); + + static TerminalGetSizeParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static TerminalGetSizeParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + TerminalGetSizeParams result = new TerminalGetSizeParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "TerminalGetSizeParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class TerminalGetSizeResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + types_mojom.Error error = null; + int rows = 0; + int columns = 0; + + TerminalGetSizeResponseParams() : super(kVersions.last.size); + + static TerminalGetSizeResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static TerminalGetSizeResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + TerminalGetSizeResponseParams result = new TerminalGetSizeResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + if (mainDataHeader.version >= 0) { + + result.rows = decoder0.decodeUint32(12); + } + if (mainDataHeader.version >= 0) { + + result.columns = decoder0.decodeUint32(16); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + + encoder0.encodeUint32(rows, 12); + + encoder0.encodeUint32(columns, 16); + } + + String toString() { + return "TerminalGetSizeResponseParams(" + "error: $error" ", " + "rows: $rows" ", " + "columns: $columns" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + map["rows"] = rows; + map["columns"] = columns; + return map; + } +} + + +class TerminalSetSizeParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int rows = 0; + int columns = 0; + bool reset = false; + + TerminalSetSizeParams() : super(kVersions.last.size); + + static TerminalSetSizeParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static TerminalSetSizeParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + TerminalSetSizeParams result = new TerminalSetSizeParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.rows = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + result.columns = decoder0.decodeUint32(12); + } + if (mainDataHeader.version >= 0) { + + result.reset = decoder0.decodeBool(16, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(rows, 8); + + encoder0.encodeUint32(columns, 12); + + encoder0.encodeBool(reset, 16, 0); + } + + String toString() { + return "TerminalSetSizeParams(" + "rows: $rows" ", " + "columns: $columns" ", " + "reset: $reset" ")"; + } + + Map toJson() { + Map map = new Map(); + map["rows"] = rows; + map["columns"] = columns; + map["reset"] = reset; + return map; + } +} + + +class TerminalSetSizeResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + types_mojom.Error error = null; + int rows = 0; + int columns = 0; + + TerminalSetSizeResponseParams() : super(kVersions.last.size); + + static TerminalSetSizeResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static TerminalSetSizeResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + TerminalSetSizeResponseParams result = new TerminalSetSizeResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + if (mainDataHeader.version >= 0) { + + result.rows = decoder0.decodeUint32(12); + } + if (mainDataHeader.version >= 0) { + + result.columns = decoder0.decodeUint32(16); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + + encoder0.encodeUint32(rows, 12); + + encoder0.encodeUint32(columns, 16); + } + + String toString() { + return "TerminalSetSizeResponseParams(" + "error: $error" ", " + "rows: $rows" ", " + "columns: $columns" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + map["rows"] = rows; + map["columns"] = columns; + return map; + } +} + +const int kTerminal_connect_name = 0; +const int kTerminal_connectToClient_name = 1; +const int kTerminal_getSize_name = 2; +const int kTerminal_setSize_name = 3; + +const String TerminalName = + 'mojo::terminal::Terminal'; + +abstract class Terminal { + dynamic connect(Object terminalFile,bool force,[Function responseFactory = null]); + dynamic connectToClient(Object terminalClient,bool force,[Function responseFactory = null]); + dynamic getSize([Function responseFactory = null]); + dynamic setSize(int rows,int columns,bool reset,[Function responseFactory = null]); + +} + + +class TerminalProxyImpl extends bindings.Proxy { + TerminalProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + TerminalProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + TerminalProxyImpl.unbound() : super.unbound(); + + static TerminalProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For TerminalProxyImpl")); + return new TerminalProxyImpl.fromEndpoint(endpoint); + } + + String get name => TerminalName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kTerminal_connect_name: + var r = TerminalConnectResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kTerminal_connectToClient_name: + var r = TerminalConnectToClientResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kTerminal_getSize_name: + var r = TerminalGetSizeResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kTerminal_setSize_name: + var r = TerminalSetSizeResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "TerminalProxyImpl($superString)"; + } +} + + +class _TerminalProxyCalls implements Terminal { + TerminalProxyImpl _proxyImpl; + + _TerminalProxyCalls(this._proxyImpl); + dynamic connect(Object terminalFile,bool force,[Function responseFactory = null]) { + var params = new TerminalConnectParams(); + params.terminalFile = terminalFile; + params.force = force; + return _proxyImpl.sendMessageWithRequestId( + params, + kTerminal_connect_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic connectToClient(Object terminalClient,bool force,[Function responseFactory = null]) { + var params = new TerminalConnectToClientParams(); + params.terminalClient = terminalClient; + params.force = force; + return _proxyImpl.sendMessageWithRequestId( + params, + kTerminal_connectToClient_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic getSize([Function responseFactory = null]) { + var params = new TerminalGetSizeParams(); + return _proxyImpl.sendMessageWithRequestId( + params, + kTerminal_getSize_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic setSize(int rows,int columns,bool reset,[Function responseFactory = null]) { + var params = new TerminalSetSizeParams(); + params.rows = rows; + params.columns = columns; + params.reset = reset; + return _proxyImpl.sendMessageWithRequestId( + params, + kTerminal_setSize_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class TerminalProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + Terminal ptr; + final String name = TerminalName; + + TerminalProxy(TerminalProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _TerminalProxyCalls(proxyImpl); + + TerminalProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new TerminalProxyImpl.fromEndpoint(endpoint) { + ptr = new _TerminalProxyCalls(impl); + } + + TerminalProxy.fromHandle(core.MojoHandle handle) : + impl = new TerminalProxyImpl.fromHandle(handle) { + ptr = new _TerminalProxyCalls(impl); + } + + TerminalProxy.unbound() : + impl = new TerminalProxyImpl.unbound() { + ptr = new _TerminalProxyCalls(impl); + } + + factory TerminalProxy.connectToService( + bindings.ServiceConnector s, String url) { + TerminalProxy p = new TerminalProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static TerminalProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For TerminalProxy")); + return new TerminalProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "TerminalProxy($impl)"; + } +} + + +class TerminalStub extends bindings.Stub { + Terminal _impl = null; + + TerminalStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + TerminalStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + TerminalStub.unbound() : super.unbound(); + + static TerminalStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For TerminalStub")); + return new TerminalStub.fromEndpoint(endpoint); + } + + static const String name = TerminalName; + + + TerminalConnectResponseParams _TerminalConnectResponseParamsFactory(types_mojom.Error error) { + var result = new TerminalConnectResponseParams(); + result.error = error; + return result; + } + TerminalConnectToClientResponseParams _TerminalConnectToClientResponseParamsFactory(types_mojom.Error error) { + var result = new TerminalConnectToClientResponseParams(); + result.error = error; + return result; + } + TerminalGetSizeResponseParams _TerminalGetSizeResponseParamsFactory(types_mojom.Error error, int rows, int columns) { + var result = new TerminalGetSizeResponseParams(); + result.error = error; + result.rows = rows; + result.columns = columns; + return result; + } + TerminalSetSizeResponseParams _TerminalSetSizeResponseParamsFactory(types_mojom.Error error, int rows, int columns) { + var result = new TerminalSetSizeResponseParams(); + result.error = error; + result.rows = rows; + result.columns = columns; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kTerminal_connect_name: + var params = TerminalConnectParams.deserialize( + message.payload); + var response = _impl.connect(params.terminalFile,params.force,_TerminalConnectResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kTerminal_connect_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kTerminal_connect_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kTerminal_connectToClient_name: + var params = TerminalConnectToClientParams.deserialize( + message.payload); + var response = _impl.connectToClient(params.terminalClient,params.force,_TerminalConnectToClientResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kTerminal_connectToClient_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kTerminal_connectToClient_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kTerminal_getSize_name: + var params = TerminalGetSizeParams.deserialize( + message.payload); + var response = _impl.getSize(_TerminalGetSizeResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kTerminal_getSize_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kTerminal_getSize_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kTerminal_setSize_name: + var params = TerminalSetSizeParams.deserialize( + message.payload); + var response = _impl.setSize(params.rows,params.columns,params.reset,_TerminalSetSizeResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kTerminal_setSize_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kTerminal_setSize_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + Terminal get impl => _impl; + set impl(Terminal d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "TerminalStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/terminal/terminal_client.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/terminal/terminal_client.mojom.dart new file mode 100644 index 0000000..5705c47 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/terminal/terminal_client.mojom.dart
@@ -0,0 +1,255 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library terminal_client_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo_services/mojo/files/file.mojom.dart' as file_mojom; + + + +class TerminalClientConnectToTerminalParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + Object terminal = null; + + TerminalClientConnectToTerminalParams() : super(kVersions.last.size); + + static TerminalClientConnectToTerminalParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static TerminalClientConnectToTerminalParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + TerminalClientConnectToTerminalParams result = new TerminalClientConnectToTerminalParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.terminal = decoder0.decodeServiceInterface(8, false, file_mojom.FileProxy.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterface(terminal, 8, false); + } + + String toString() { + return "TerminalClientConnectToTerminalParams(" + "terminal: $terminal" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + +const int kTerminalClient_connectToTerminal_name = 0; + +const String TerminalClientName = + 'mojo::terminal::TerminalClient'; + +abstract class TerminalClient { + void connectToTerminal(Object terminal); + +} + + +class TerminalClientProxyImpl extends bindings.Proxy { + TerminalClientProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + TerminalClientProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + TerminalClientProxyImpl.unbound() : super.unbound(); + + static TerminalClientProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For TerminalClientProxyImpl")); + return new TerminalClientProxyImpl.fromEndpoint(endpoint); + } + + String get name => TerminalClientName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "TerminalClientProxyImpl($superString)"; + } +} + + +class _TerminalClientProxyCalls implements TerminalClient { + TerminalClientProxyImpl _proxyImpl; + + _TerminalClientProxyCalls(this._proxyImpl); + void connectToTerminal(Object terminal) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new TerminalClientConnectToTerminalParams(); + params.terminal = terminal; + _proxyImpl.sendMessage(params, kTerminalClient_connectToTerminal_name); + } + +} + + +class TerminalClientProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + TerminalClient ptr; + final String name = TerminalClientName; + + TerminalClientProxy(TerminalClientProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _TerminalClientProxyCalls(proxyImpl); + + TerminalClientProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new TerminalClientProxyImpl.fromEndpoint(endpoint) { + ptr = new _TerminalClientProxyCalls(impl); + } + + TerminalClientProxy.fromHandle(core.MojoHandle handle) : + impl = new TerminalClientProxyImpl.fromHandle(handle) { + ptr = new _TerminalClientProxyCalls(impl); + } + + TerminalClientProxy.unbound() : + impl = new TerminalClientProxyImpl.unbound() { + ptr = new _TerminalClientProxyCalls(impl); + } + + factory TerminalClientProxy.connectToService( + bindings.ServiceConnector s, String url) { + TerminalClientProxy p = new TerminalClientProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static TerminalClientProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For TerminalClientProxy")); + return new TerminalClientProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "TerminalClientProxy($impl)"; + } +} + + +class TerminalClientStub extends bindings.Stub { + TerminalClient _impl = null; + + TerminalClientStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + TerminalClientStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + TerminalClientStub.unbound() : super.unbound(); + + static TerminalClientStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For TerminalClientStub")); + return new TerminalClientStub.fromEndpoint(endpoint); + } + + static const String name = TerminalClientName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kTerminalClient_connectToTerminal_name: + var params = TerminalClientConnectToTerminalParams.deserialize( + message.payload); + _impl.connectToTerminal(params.terminal); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + TerminalClient get impl => _impl; + set impl(TerminalClient d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "TerminalClientStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/udp_socket.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/udp_socket.mojom.dart new file mode 100644 index 0000000..8eaaa71 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/udp_socket.mojom.dart
@@ -0,0 +1,1910 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library udp_socket_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo/mojo/network_error.mojom.dart' as network_error_mojom; +import 'package:mojo_services/mojo/net_address.mojom.dart' as net_address_mojom; + + + +class UdpSocketAllowAddressReuseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + UdpSocketAllowAddressReuseParams() : super(kVersions.last.size); + + static UdpSocketAllowAddressReuseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UdpSocketAllowAddressReuseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UdpSocketAllowAddressReuseParams result = new UdpSocketAllowAddressReuseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "UdpSocketAllowAddressReuseParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class UdpSocketAllowAddressReuseResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + network_error_mojom.NetworkError result = null; + + UdpSocketAllowAddressReuseResponseParams() : super(kVersions.last.size); + + static UdpSocketAllowAddressReuseResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UdpSocketAllowAddressReuseResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UdpSocketAllowAddressReuseResponseParams result = new UdpSocketAllowAddressReuseResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.result = network_error_mojom.NetworkError.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(result, 8, false); + } + + String toString() { + return "UdpSocketAllowAddressReuseResponseParams(" + "result: $result" ")"; + } + + Map toJson() { + Map map = new Map(); + map["result"] = result; + return map; + } +} + + +class UdpSocketBindParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + net_address_mojom.NetAddress addr = null; + + UdpSocketBindParams() : super(kVersions.last.size); + + static UdpSocketBindParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UdpSocketBindParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UdpSocketBindParams result = new UdpSocketBindParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.addr = net_address_mojom.NetAddress.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(addr, 8, false); + } + + String toString() { + return "UdpSocketBindParams(" + "addr: $addr" ")"; + } + + Map toJson() { + Map map = new Map(); + map["addr"] = addr; + return map; + } +} + + +class UdpSocketBindResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(32, 0) + ]; + network_error_mojom.NetworkError result = null; + net_address_mojom.NetAddress boundAddr = null; + Object receiver = null; + + UdpSocketBindResponseParams() : super(kVersions.last.size); + + static UdpSocketBindResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UdpSocketBindResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UdpSocketBindResponseParams result = new UdpSocketBindResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.result = network_error_mojom.NetworkError.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, true); + result.boundAddr = net_address_mojom.NetAddress.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + result.receiver = decoder0.decodeInterfaceRequest(24, true, UdpSocketReceiverStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(result, 8, false); + + encoder0.encodeStruct(boundAddr, 16, true); + + encoder0.encodeInterfaceRequest(receiver, 24, true); + } + + String toString() { + return "UdpSocketBindResponseParams(" + "result: $result" ", " + "boundAddr: $boundAddr" ", " + "receiver: $receiver" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class UdpSocketConnectParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + net_address_mojom.NetAddress remoteAddr = null; + + UdpSocketConnectParams() : super(kVersions.last.size); + + static UdpSocketConnectParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UdpSocketConnectParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UdpSocketConnectParams result = new UdpSocketConnectParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.remoteAddr = net_address_mojom.NetAddress.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(remoteAddr, 8, false); + } + + String toString() { + return "UdpSocketConnectParams(" + "remoteAddr: $remoteAddr" ")"; + } + + Map toJson() { + Map map = new Map(); + map["remoteAddr"] = remoteAddr; + return map; + } +} + + +class UdpSocketConnectResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(32, 0) + ]; + network_error_mojom.NetworkError result = null; + net_address_mojom.NetAddress localAddr = null; + Object receiver = null; + + UdpSocketConnectResponseParams() : super(kVersions.last.size); + + static UdpSocketConnectResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UdpSocketConnectResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UdpSocketConnectResponseParams result = new UdpSocketConnectResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.result = network_error_mojom.NetworkError.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, true); + result.localAddr = net_address_mojom.NetAddress.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + result.receiver = decoder0.decodeInterfaceRequest(24, true, UdpSocketReceiverStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(result, 8, false); + + encoder0.encodeStruct(localAddr, 16, true); + + encoder0.encodeInterfaceRequest(receiver, 24, true); + } + + String toString() { + return "UdpSocketConnectResponseParams(" + "result: $result" ", " + "localAddr: $localAddr" ", " + "receiver: $receiver" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class UdpSocketSetSendBufferSizeParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int size = 0; + + UdpSocketSetSendBufferSizeParams() : super(kVersions.last.size); + + static UdpSocketSetSendBufferSizeParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UdpSocketSetSendBufferSizeParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UdpSocketSetSendBufferSizeParams result = new UdpSocketSetSendBufferSizeParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.size = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(size, 8); + } + + String toString() { + return "UdpSocketSetSendBufferSizeParams(" + "size: $size" ")"; + } + + Map toJson() { + Map map = new Map(); + map["size"] = size; + return map; + } +} + + +class UdpSocketSetSendBufferSizeResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + network_error_mojom.NetworkError result = null; + + UdpSocketSetSendBufferSizeResponseParams() : super(kVersions.last.size); + + static UdpSocketSetSendBufferSizeResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UdpSocketSetSendBufferSizeResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UdpSocketSetSendBufferSizeResponseParams result = new UdpSocketSetSendBufferSizeResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.result = network_error_mojom.NetworkError.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(result, 8, false); + } + + String toString() { + return "UdpSocketSetSendBufferSizeResponseParams(" + "result: $result" ")"; + } + + Map toJson() { + Map map = new Map(); + map["result"] = result; + return map; + } +} + + +class UdpSocketSetReceiveBufferSizeParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int size = 0; + + UdpSocketSetReceiveBufferSizeParams() : super(kVersions.last.size); + + static UdpSocketSetReceiveBufferSizeParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UdpSocketSetReceiveBufferSizeParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UdpSocketSetReceiveBufferSizeParams result = new UdpSocketSetReceiveBufferSizeParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.size = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(size, 8); + } + + String toString() { + return "UdpSocketSetReceiveBufferSizeParams(" + "size: $size" ")"; + } + + Map toJson() { + Map map = new Map(); + map["size"] = size; + return map; + } +} + + +class UdpSocketSetReceiveBufferSizeResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + network_error_mojom.NetworkError result = null; + + UdpSocketSetReceiveBufferSizeResponseParams() : super(kVersions.last.size); + + static UdpSocketSetReceiveBufferSizeResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UdpSocketSetReceiveBufferSizeResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UdpSocketSetReceiveBufferSizeResponseParams result = new UdpSocketSetReceiveBufferSizeResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.result = network_error_mojom.NetworkError.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(result, 8, false); + } + + String toString() { + return "UdpSocketSetReceiveBufferSizeResponseParams(" + "result: $result" ")"; + } + + Map toJson() { + Map map = new Map(); + map["result"] = result; + return map; + } +} + + +class UdpSocketNegotiateMaxPendingSendRequestsParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int requestedSize = 0; + + UdpSocketNegotiateMaxPendingSendRequestsParams() : super(kVersions.last.size); + + static UdpSocketNegotiateMaxPendingSendRequestsParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UdpSocketNegotiateMaxPendingSendRequestsParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UdpSocketNegotiateMaxPendingSendRequestsParams result = new UdpSocketNegotiateMaxPendingSendRequestsParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.requestedSize = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(requestedSize, 8); + } + + String toString() { + return "UdpSocketNegotiateMaxPendingSendRequestsParams(" + "requestedSize: $requestedSize" ")"; + } + + Map toJson() { + Map map = new Map(); + map["requestedSize"] = requestedSize; + return map; + } +} + + +class UdpSocketNegotiateMaxPendingSendRequestsResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int actualSize = 0; + + UdpSocketNegotiateMaxPendingSendRequestsResponseParams() : super(kVersions.last.size); + + static UdpSocketNegotiateMaxPendingSendRequestsResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UdpSocketNegotiateMaxPendingSendRequestsResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UdpSocketNegotiateMaxPendingSendRequestsResponseParams result = new UdpSocketNegotiateMaxPendingSendRequestsResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.actualSize = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(actualSize, 8); + } + + String toString() { + return "UdpSocketNegotiateMaxPendingSendRequestsResponseParams(" + "actualSize: $actualSize" ")"; + } + + Map toJson() { + Map map = new Map(); + map["actualSize"] = actualSize; + return map; + } +} + + +class UdpSocketReceiveMoreParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int datagramNumber = 0; + + UdpSocketReceiveMoreParams() : super(kVersions.last.size); + + static UdpSocketReceiveMoreParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UdpSocketReceiveMoreParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UdpSocketReceiveMoreParams result = new UdpSocketReceiveMoreParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.datagramNumber = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(datagramNumber, 8); + } + + String toString() { + return "UdpSocketReceiveMoreParams(" + "datagramNumber: $datagramNumber" ")"; + } + + Map toJson() { + Map map = new Map(); + map["datagramNumber"] = datagramNumber; + return map; + } +} + + +class UdpSocketSendToParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + net_address_mojom.NetAddress destAddr = null; + List<int> data = null; + + UdpSocketSendToParams() : super(kVersions.last.size); + + static UdpSocketSendToParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UdpSocketSendToParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UdpSocketSendToParams result = new UdpSocketSendToParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, true); + result.destAddr = net_address_mojom.NetAddress.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + result.data = decoder0.decodeUint8Array(16, bindings.kNothingNullable, bindings.kUnspecifiedArrayLength); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(destAddr, 8, true); + + encoder0.encodeUint8Array(data, 16, bindings.kNothingNullable, bindings.kUnspecifiedArrayLength); + } + + String toString() { + return "UdpSocketSendToParams(" + "destAddr: $destAddr" ", " + "data: $data" ")"; + } + + Map toJson() { + Map map = new Map(); + map["destAddr"] = destAddr; + map["data"] = data; + return map; + } +} + + +class UdpSocketSendToResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + network_error_mojom.NetworkError result = null; + + UdpSocketSendToResponseParams() : super(kVersions.last.size); + + static UdpSocketSendToResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UdpSocketSendToResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UdpSocketSendToResponseParams result = new UdpSocketSendToResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.result = network_error_mojom.NetworkError.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(result, 8, false); + } + + String toString() { + return "UdpSocketSendToResponseParams(" + "result: $result" ")"; + } + + Map toJson() { + Map map = new Map(); + map["result"] = result; + return map; + } +} + + +class UdpSocketReceiverOnReceivedParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(32, 0) + ]; + network_error_mojom.NetworkError result = null; + net_address_mojom.NetAddress srcAddr = null; + List<int> data = null; + + UdpSocketReceiverOnReceivedParams() : super(kVersions.last.size); + + static UdpSocketReceiverOnReceivedParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UdpSocketReceiverOnReceivedParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UdpSocketReceiverOnReceivedParams result = new UdpSocketReceiverOnReceivedParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.result = network_error_mojom.NetworkError.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, true); + result.srcAddr = net_address_mojom.NetAddress.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + result.data = decoder0.decodeUint8Array(24, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(result, 8, false); + + encoder0.encodeStruct(srcAddr, 16, true); + + encoder0.encodeUint8Array(data, 24, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + } + + String toString() { + return "UdpSocketReceiverOnReceivedParams(" + "result: $result" ", " + "srcAddr: $srcAddr" ", " + "data: $data" ")"; + } + + Map toJson() { + Map map = new Map(); + map["result"] = result; + map["srcAddr"] = srcAddr; + map["data"] = data; + return map; + } +} + +const int kUdpSocket_allowAddressReuse_name = 0; +const int kUdpSocket_bind_name = 1; +const int kUdpSocket_connect_name = 2; +const int kUdpSocket_setSendBufferSize_name = 3; +const int kUdpSocket_setReceiveBufferSize_name = 4; +const int kUdpSocket_negotiateMaxPendingSendRequests_name = 5; +const int kUdpSocket_receiveMore_name = 6; +const int kUdpSocket_sendTo_name = 7; + +const String UdpSocketName = + 'mojo::UDPSocket'; + +abstract class UdpSocket { + dynamic allowAddressReuse([Function responseFactory = null]); + dynamic bind(net_address_mojom.NetAddress addr,[Function responseFactory = null]); + dynamic connect(net_address_mojom.NetAddress remoteAddr,[Function responseFactory = null]); + dynamic setSendBufferSize(int size,[Function responseFactory = null]); + dynamic setReceiveBufferSize(int size,[Function responseFactory = null]); + dynamic negotiateMaxPendingSendRequests(int requestedSize,[Function responseFactory = null]); + void receiveMore(int datagramNumber); + dynamic sendTo(net_address_mojom.NetAddress destAddr,List<int> data,[Function responseFactory = null]); + +} + + +class UdpSocketProxyImpl extends bindings.Proxy { + UdpSocketProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + UdpSocketProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + UdpSocketProxyImpl.unbound() : super.unbound(); + + static UdpSocketProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For UdpSocketProxyImpl")); + return new UdpSocketProxyImpl.fromEndpoint(endpoint); + } + + String get name => UdpSocketName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kUdpSocket_allowAddressReuse_name: + var r = UdpSocketAllowAddressReuseResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kUdpSocket_bind_name: + var r = UdpSocketBindResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kUdpSocket_connect_name: + var r = UdpSocketConnectResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kUdpSocket_setSendBufferSize_name: + var r = UdpSocketSetSendBufferSizeResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kUdpSocket_setReceiveBufferSize_name: + var r = UdpSocketSetReceiveBufferSizeResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kUdpSocket_negotiateMaxPendingSendRequests_name: + var r = UdpSocketNegotiateMaxPendingSendRequestsResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kUdpSocket_sendTo_name: + var r = UdpSocketSendToResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "UdpSocketProxyImpl($superString)"; + } +} + + +class _UdpSocketProxyCalls implements UdpSocket { + UdpSocketProxyImpl _proxyImpl; + + _UdpSocketProxyCalls(this._proxyImpl); + dynamic allowAddressReuse([Function responseFactory = null]) { + var params = new UdpSocketAllowAddressReuseParams(); + return _proxyImpl.sendMessageWithRequestId( + params, + kUdpSocket_allowAddressReuse_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic bind(net_address_mojom.NetAddress addr,[Function responseFactory = null]) { + var params = new UdpSocketBindParams(); + params.addr = addr; + return _proxyImpl.sendMessageWithRequestId( + params, + kUdpSocket_bind_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic connect(net_address_mojom.NetAddress remoteAddr,[Function responseFactory = null]) { + var params = new UdpSocketConnectParams(); + params.remoteAddr = remoteAddr; + return _proxyImpl.sendMessageWithRequestId( + params, + kUdpSocket_connect_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic setSendBufferSize(int size,[Function responseFactory = null]) { + var params = new UdpSocketSetSendBufferSizeParams(); + params.size = size; + return _proxyImpl.sendMessageWithRequestId( + params, + kUdpSocket_setSendBufferSize_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic setReceiveBufferSize(int size,[Function responseFactory = null]) { + var params = new UdpSocketSetReceiveBufferSizeParams(); + params.size = size; + return _proxyImpl.sendMessageWithRequestId( + params, + kUdpSocket_setReceiveBufferSize_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic negotiateMaxPendingSendRequests(int requestedSize,[Function responseFactory = null]) { + var params = new UdpSocketNegotiateMaxPendingSendRequestsParams(); + params.requestedSize = requestedSize; + return _proxyImpl.sendMessageWithRequestId( + params, + kUdpSocket_negotiateMaxPendingSendRequests_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + void receiveMore(int datagramNumber) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new UdpSocketReceiveMoreParams(); + params.datagramNumber = datagramNumber; + _proxyImpl.sendMessage(params, kUdpSocket_receiveMore_name); + } + + dynamic sendTo(net_address_mojom.NetAddress destAddr,List<int> data,[Function responseFactory = null]) { + var params = new UdpSocketSendToParams(); + params.destAddr = destAddr; + params.data = data; + return _proxyImpl.sendMessageWithRequestId( + params, + kUdpSocket_sendTo_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class UdpSocketProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + UdpSocket ptr; + final String name = UdpSocketName; + + UdpSocketProxy(UdpSocketProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _UdpSocketProxyCalls(proxyImpl); + + UdpSocketProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new UdpSocketProxyImpl.fromEndpoint(endpoint) { + ptr = new _UdpSocketProxyCalls(impl); + } + + UdpSocketProxy.fromHandle(core.MojoHandle handle) : + impl = new UdpSocketProxyImpl.fromHandle(handle) { + ptr = new _UdpSocketProxyCalls(impl); + } + + UdpSocketProxy.unbound() : + impl = new UdpSocketProxyImpl.unbound() { + ptr = new _UdpSocketProxyCalls(impl); + } + + factory UdpSocketProxy.connectToService( + bindings.ServiceConnector s, String url) { + UdpSocketProxy p = new UdpSocketProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static UdpSocketProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For UdpSocketProxy")); + return new UdpSocketProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "UdpSocketProxy($impl)"; + } +} + + +class UdpSocketStub extends bindings.Stub { + UdpSocket _impl = null; + + UdpSocketStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + UdpSocketStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + UdpSocketStub.unbound() : super.unbound(); + + static UdpSocketStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For UdpSocketStub")); + return new UdpSocketStub.fromEndpoint(endpoint); + } + + static const String name = UdpSocketName; + + + UdpSocketAllowAddressReuseResponseParams _UdpSocketAllowAddressReuseResponseParamsFactory(network_error_mojom.NetworkError result) { + var result = new UdpSocketAllowAddressReuseResponseParams(); + result.result = result; + return result; + } + UdpSocketBindResponseParams _UdpSocketBindResponseParamsFactory(network_error_mojom.NetworkError result, net_address_mojom.NetAddress boundAddr, Object receiver) { + var result = new UdpSocketBindResponseParams(); + result.result = result; + result.boundAddr = boundAddr; + result.receiver = receiver; + return result; + } + UdpSocketConnectResponseParams _UdpSocketConnectResponseParamsFactory(network_error_mojom.NetworkError result, net_address_mojom.NetAddress localAddr, Object receiver) { + var result = new UdpSocketConnectResponseParams(); + result.result = result; + result.localAddr = localAddr; + result.receiver = receiver; + return result; + } + UdpSocketSetSendBufferSizeResponseParams _UdpSocketSetSendBufferSizeResponseParamsFactory(network_error_mojom.NetworkError result) { + var result = new UdpSocketSetSendBufferSizeResponseParams(); + result.result = result; + return result; + } + UdpSocketSetReceiveBufferSizeResponseParams _UdpSocketSetReceiveBufferSizeResponseParamsFactory(network_error_mojom.NetworkError result) { + var result = new UdpSocketSetReceiveBufferSizeResponseParams(); + result.result = result; + return result; + } + UdpSocketNegotiateMaxPendingSendRequestsResponseParams _UdpSocketNegotiateMaxPendingSendRequestsResponseParamsFactory(int actualSize) { + var result = new UdpSocketNegotiateMaxPendingSendRequestsResponseParams(); + result.actualSize = actualSize; + return result; + } + UdpSocketSendToResponseParams _UdpSocketSendToResponseParamsFactory(network_error_mojom.NetworkError result) { + var result = new UdpSocketSendToResponseParams(); + result.result = result; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kUdpSocket_allowAddressReuse_name: + var params = UdpSocketAllowAddressReuseParams.deserialize( + message.payload); + var response = _impl.allowAddressReuse(_UdpSocketAllowAddressReuseResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kUdpSocket_allowAddressReuse_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kUdpSocket_allowAddressReuse_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kUdpSocket_bind_name: + var params = UdpSocketBindParams.deserialize( + message.payload); + var response = _impl.bind(params.addr,_UdpSocketBindResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kUdpSocket_bind_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kUdpSocket_bind_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kUdpSocket_connect_name: + var params = UdpSocketConnectParams.deserialize( + message.payload); + var response = _impl.connect(params.remoteAddr,_UdpSocketConnectResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kUdpSocket_connect_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kUdpSocket_connect_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kUdpSocket_setSendBufferSize_name: + var params = UdpSocketSetSendBufferSizeParams.deserialize( + message.payload); + var response = _impl.setSendBufferSize(params.size,_UdpSocketSetSendBufferSizeResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kUdpSocket_setSendBufferSize_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kUdpSocket_setSendBufferSize_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kUdpSocket_setReceiveBufferSize_name: + var params = UdpSocketSetReceiveBufferSizeParams.deserialize( + message.payload); + var response = _impl.setReceiveBufferSize(params.size,_UdpSocketSetReceiveBufferSizeResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kUdpSocket_setReceiveBufferSize_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kUdpSocket_setReceiveBufferSize_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kUdpSocket_negotiateMaxPendingSendRequests_name: + var params = UdpSocketNegotiateMaxPendingSendRequestsParams.deserialize( + message.payload); + var response = _impl.negotiateMaxPendingSendRequests(params.requestedSize,_UdpSocketNegotiateMaxPendingSendRequestsResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kUdpSocket_negotiateMaxPendingSendRequests_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kUdpSocket_negotiateMaxPendingSendRequests_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kUdpSocket_receiveMore_name: + var params = UdpSocketReceiveMoreParams.deserialize( + message.payload); + _impl.receiveMore(params.datagramNumber); + break; + case kUdpSocket_sendTo_name: + var params = UdpSocketSendToParams.deserialize( + message.payload); + var response = _impl.sendTo(params.destAddr,params.data,_UdpSocketSendToResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kUdpSocket_sendTo_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kUdpSocket_sendTo_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + UdpSocket get impl => _impl; + set impl(UdpSocket d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "UdpSocketStub($superString)"; + } + + int get version => 0; +} + +const int kUdpSocketReceiver_onReceived_name = 0; + +const String UdpSocketReceiverName = + 'mojo::UDPSocketReceiver'; + +abstract class UdpSocketReceiver { + void onReceived(network_error_mojom.NetworkError result, net_address_mojom.NetAddress srcAddr, List<int> data); + +} + + +class UdpSocketReceiverProxyImpl extends bindings.Proxy { + UdpSocketReceiverProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + UdpSocketReceiverProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + UdpSocketReceiverProxyImpl.unbound() : super.unbound(); + + static UdpSocketReceiverProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For UdpSocketReceiverProxyImpl")); + return new UdpSocketReceiverProxyImpl.fromEndpoint(endpoint); + } + + String get name => UdpSocketReceiverName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "UdpSocketReceiverProxyImpl($superString)"; + } +} + + +class _UdpSocketReceiverProxyCalls implements UdpSocketReceiver { + UdpSocketReceiverProxyImpl _proxyImpl; + + _UdpSocketReceiverProxyCalls(this._proxyImpl); + void onReceived(network_error_mojom.NetworkError result, net_address_mojom.NetAddress srcAddr, List<int> data) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new UdpSocketReceiverOnReceivedParams(); + params.result = result; + params.srcAddr = srcAddr; + params.data = data; + _proxyImpl.sendMessage(params, kUdpSocketReceiver_onReceived_name); + } + +} + + +class UdpSocketReceiverProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + UdpSocketReceiver ptr; + final String name = UdpSocketReceiverName; + + UdpSocketReceiverProxy(UdpSocketReceiverProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _UdpSocketReceiverProxyCalls(proxyImpl); + + UdpSocketReceiverProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new UdpSocketReceiverProxyImpl.fromEndpoint(endpoint) { + ptr = new _UdpSocketReceiverProxyCalls(impl); + } + + UdpSocketReceiverProxy.fromHandle(core.MojoHandle handle) : + impl = new UdpSocketReceiverProxyImpl.fromHandle(handle) { + ptr = new _UdpSocketReceiverProxyCalls(impl); + } + + UdpSocketReceiverProxy.unbound() : + impl = new UdpSocketReceiverProxyImpl.unbound() { + ptr = new _UdpSocketReceiverProxyCalls(impl); + } + + factory UdpSocketReceiverProxy.connectToService( + bindings.ServiceConnector s, String url) { + UdpSocketReceiverProxy p = new UdpSocketReceiverProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static UdpSocketReceiverProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For UdpSocketReceiverProxy")); + return new UdpSocketReceiverProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "UdpSocketReceiverProxy($impl)"; + } +} + + +class UdpSocketReceiverStub extends bindings.Stub { + UdpSocketReceiver _impl = null; + + UdpSocketReceiverStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + UdpSocketReceiverStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + UdpSocketReceiverStub.unbound() : super.unbound(); + + static UdpSocketReceiverStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For UdpSocketReceiverStub")); + return new UdpSocketReceiverStub.fromEndpoint(endpoint); + } + + static const String name = UdpSocketReceiverName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kUdpSocketReceiver_onReceived_name: + var params = UdpSocketReceiverOnReceivedParams.deserialize( + message.payload); + _impl.onReceived(params.result, params.srcAddr, params.data); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + UdpSocketReceiver get impl => _impl; + set impl(UdpSocketReceiver d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "UdpSocketReceiverStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/ui/layouts.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/ui/layouts.mojom.dart new file mode 100644 index 0000000..bc16ff7 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/ui/layouts.mojom.dart
@@ -0,0 +1,264 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library layouts_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo_services/mojo/geometry.mojom.dart' as geometry_mojom; +import 'package:mojo_services/mojo/surface_id.mojom.dart' as surface_id_mojom; + + + +class BoxConstraints extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int minWidth = 0; + int maxWidth = 0; + int minHeight = 0; + int maxHeight = 0; + + BoxConstraints() : super(kVersions.last.size); + + static BoxConstraints deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static BoxConstraints decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + BoxConstraints result = new BoxConstraints(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.minWidth = decoder0.decodeInt32(8); + } + if (mainDataHeader.version >= 0) { + + result.maxWidth = decoder0.decodeInt32(12); + } + if (mainDataHeader.version >= 0) { + + result.minHeight = decoder0.decodeInt32(16); + } + if (mainDataHeader.version >= 0) { + + result.maxHeight = decoder0.decodeInt32(20); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt32(minWidth, 8); + + encoder0.encodeInt32(maxWidth, 12); + + encoder0.encodeInt32(minHeight, 16); + + encoder0.encodeInt32(maxHeight, 20); + } + + String toString() { + return "BoxConstraints(" + "minWidth: $minWidth" ", " + "maxWidth: $maxWidth" ", " + "minHeight: $minHeight" ", " + "maxHeight: $maxHeight" ")"; + } + + Map toJson() { + Map map = new Map(); + map["minWidth"] = minWidth; + map["maxWidth"] = maxWidth; + map["minHeight"] = minHeight; + map["maxHeight"] = maxHeight; + return map; + } +} + + +class ViewLayoutParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + BoxConstraints constraints = null; + double devicePixelRatio = 1.0; + + ViewLayoutParams() : super(kVersions.last.size); + + static ViewLayoutParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewLayoutParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewLayoutParams result = new ViewLayoutParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.constraints = BoxConstraints.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + result.devicePixelRatio = decoder0.decodeFloat(16); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(constraints, 8, false); + + encoder0.encodeFloat(devicePixelRatio, 16); + } + + String toString() { + return "ViewLayoutParams(" + "constraints: $constraints" ", " + "devicePixelRatio: $devicePixelRatio" ")"; + } + + Map toJson() { + Map map = new Map(); + map["constraints"] = constraints; + map["devicePixelRatio"] = devicePixelRatio; + return map; + } +} + + +class ViewLayoutInfo extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + surface_id_mojom.SurfaceId surfaceId = null; + geometry_mojom.Size size = null; + + ViewLayoutInfo() : super(kVersions.last.size); + + static ViewLayoutInfo deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewLayoutInfo decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewLayoutInfo result = new ViewLayoutInfo(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.surfaceId = surface_id_mojom.SurfaceId.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + result.size = geometry_mojom.Size.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(surfaceId, 8, false); + + encoder0.encodeStruct(size, 16, false); + } + + String toString() { + return "ViewLayoutInfo(" + "surfaceId: $surfaceId" ", " + "size: $size" ")"; + } + + Map toJson() { + Map map = new Map(); + map["surfaceId"] = surfaceId; + map["size"] = size; + return map; + } +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/ui/view_manager.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/ui/view_manager.mojom.dart new file mode 100644 index 0000000..df01587 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/ui/view_manager.mojom.dart
@@ -0,0 +1,564 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library view_manager_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo_services/mojo/ui/views.mojom.dart' as views_mojom; +import 'package:mojo_services/mojo/ui/view_trees.mojom.dart' as view_trees_mojom; + + + +class ViewManagerRegisterViewParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + Object view = null; + Object viewHost = null; + + ViewManagerRegisterViewParams() : super(kVersions.last.size); + + static ViewManagerRegisterViewParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerRegisterViewParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerRegisterViewParams result = new ViewManagerRegisterViewParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.view = decoder0.decodeServiceInterface(8, false, views_mojom.ViewProxy.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.viewHost = decoder0.decodeInterfaceRequest(16, false, views_mojom.ViewHostStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterface(view, 8, false); + + encoder0.encodeInterfaceRequest(viewHost, 16, false); + } + + String toString() { + return "ViewManagerRegisterViewParams(" + "view: $view" ", " + "viewHost: $viewHost" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class ViewManagerRegisterViewResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + views_mojom.ViewToken viewToken = null; + + ViewManagerRegisterViewResponseParams() : super(kVersions.last.size); + + static ViewManagerRegisterViewResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerRegisterViewResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerRegisterViewResponseParams result = new ViewManagerRegisterViewResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.viewToken = views_mojom.ViewToken.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(viewToken, 8, false); + } + + String toString() { + return "ViewManagerRegisterViewResponseParams(" + "viewToken: $viewToken" ")"; + } + + Map toJson() { + Map map = new Map(); + map["viewToken"] = viewToken; + return map; + } +} + + +class ViewManagerRegisterViewTreeParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + Object viewTree = null; + Object viewTreeHost = null; + + ViewManagerRegisterViewTreeParams() : super(kVersions.last.size); + + static ViewManagerRegisterViewTreeParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerRegisterViewTreeParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerRegisterViewTreeParams result = new ViewManagerRegisterViewTreeParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.viewTree = decoder0.decodeServiceInterface(8, false, view_trees_mojom.ViewTreeProxy.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.viewTreeHost = decoder0.decodeInterfaceRequest(16, false, view_trees_mojom.ViewTreeHostStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterface(viewTree, 8, false); + + encoder0.encodeInterfaceRequest(viewTreeHost, 16, false); + } + + String toString() { + return "ViewManagerRegisterViewTreeParams(" + "viewTree: $viewTree" ", " + "viewTreeHost: $viewTreeHost" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class ViewManagerRegisterViewTreeResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + ViewManagerRegisterViewTreeResponseParams() : super(kVersions.last.size); + + static ViewManagerRegisterViewTreeResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerRegisterViewTreeResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerRegisterViewTreeResponseParams result = new ViewManagerRegisterViewTreeResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "ViewManagerRegisterViewTreeResponseParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + +const int kViewManager_registerView_name = 0; +const int kViewManager_registerViewTree_name = 1; + +const String ViewManagerName = + 'mojo::ui::ViewManager'; + +abstract class ViewManager { + dynamic registerView(Object view,Object viewHost,[Function responseFactory = null]); + dynamic registerViewTree(Object viewTree,Object viewTreeHost,[Function responseFactory = null]); + +} + + +class ViewManagerProxyImpl extends bindings.Proxy { + ViewManagerProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + ViewManagerProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + ViewManagerProxyImpl.unbound() : super.unbound(); + + static ViewManagerProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ViewManagerProxyImpl")); + return new ViewManagerProxyImpl.fromEndpoint(endpoint); + } + + String get name => ViewManagerName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kViewManager_registerView_name: + var r = ViewManagerRegisterViewResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kViewManager_registerViewTree_name: + var r = ViewManagerRegisterViewTreeResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "ViewManagerProxyImpl($superString)"; + } +} + + +class _ViewManagerProxyCalls implements ViewManager { + ViewManagerProxyImpl _proxyImpl; + + _ViewManagerProxyCalls(this._proxyImpl); + dynamic registerView(Object view,Object viewHost,[Function responseFactory = null]) { + var params = new ViewManagerRegisterViewParams(); + params.view = view; + params.viewHost = viewHost; + return _proxyImpl.sendMessageWithRequestId( + params, + kViewManager_registerView_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic registerViewTree(Object viewTree,Object viewTreeHost,[Function responseFactory = null]) { + var params = new ViewManagerRegisterViewTreeParams(); + params.viewTree = viewTree; + params.viewTreeHost = viewTreeHost; + return _proxyImpl.sendMessageWithRequestId( + params, + kViewManager_registerViewTree_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class ViewManagerProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + ViewManager ptr; + final String name = ViewManagerName; + + ViewManagerProxy(ViewManagerProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _ViewManagerProxyCalls(proxyImpl); + + ViewManagerProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new ViewManagerProxyImpl.fromEndpoint(endpoint) { + ptr = new _ViewManagerProxyCalls(impl); + } + + ViewManagerProxy.fromHandle(core.MojoHandle handle) : + impl = new ViewManagerProxyImpl.fromHandle(handle) { + ptr = new _ViewManagerProxyCalls(impl); + } + + ViewManagerProxy.unbound() : + impl = new ViewManagerProxyImpl.unbound() { + ptr = new _ViewManagerProxyCalls(impl); + } + + factory ViewManagerProxy.connectToService( + bindings.ServiceConnector s, String url) { + ViewManagerProxy p = new ViewManagerProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static ViewManagerProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ViewManagerProxy")); + return new ViewManagerProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "ViewManagerProxy($impl)"; + } +} + + +class ViewManagerStub extends bindings.Stub { + ViewManager _impl = null; + + ViewManagerStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + ViewManagerStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + ViewManagerStub.unbound() : super.unbound(); + + static ViewManagerStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ViewManagerStub")); + return new ViewManagerStub.fromEndpoint(endpoint); + } + + static const String name = ViewManagerName; + + + ViewManagerRegisterViewResponseParams _ViewManagerRegisterViewResponseParamsFactory(views_mojom.ViewToken viewToken) { + var result = new ViewManagerRegisterViewResponseParams(); + result.viewToken = viewToken; + return result; + } + ViewManagerRegisterViewTreeResponseParams _ViewManagerRegisterViewTreeResponseParamsFactory() { + var result = new ViewManagerRegisterViewTreeResponseParams(); + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kViewManager_registerView_name: + var params = ViewManagerRegisterViewParams.deserialize( + message.payload); + var response = _impl.registerView(params.view,params.viewHost,_ViewManagerRegisterViewResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kViewManager_registerView_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kViewManager_registerView_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kViewManager_registerViewTree_name: + var params = ViewManagerRegisterViewTreeParams.deserialize( + message.payload); + var response = _impl.registerViewTree(params.viewTree,params.viewTreeHost,_ViewManagerRegisterViewTreeResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kViewManager_registerViewTree_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kViewManager_registerViewTree_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + ViewManager get impl => _impl; + set impl(ViewManager d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "ViewManagerStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/ui/view_provider.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/ui/view_provider.mojom.dart new file mode 100644 index 0000000..bb5c712 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/ui/view_provider.mojom.dart
@@ -0,0 +1,374 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library view_provider_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo/mojo/service_provider.mojom.dart' as service_provider_mojom; +import 'package:mojo_services/mojo/ui/views.mojom.dart' as views_mojom; + + + +class ViewProviderCreateViewParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + Object services = null; + Object exposedServices = null; + + ViewProviderCreateViewParams() : super(kVersions.last.size); + + static ViewProviderCreateViewParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewProviderCreateViewParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewProviderCreateViewParams result = new ViewProviderCreateViewParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.services = decoder0.decodeInterfaceRequest(8, true, service_provider_mojom.ServiceProviderStub.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.exposedServices = decoder0.decodeServiceInterface(12, true, service_provider_mojom.ServiceProviderProxy.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterfaceRequest(services, 8, true); + + encoder0.encodeInterface(exposedServices, 12, true); + } + + String toString() { + return "ViewProviderCreateViewParams(" + "services: $services" ", " + "exposedServices: $exposedServices" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class ViewProviderCreateViewResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + views_mojom.ViewToken viewToken = null; + + ViewProviderCreateViewResponseParams() : super(kVersions.last.size); + + static ViewProviderCreateViewResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewProviderCreateViewResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewProviderCreateViewResponseParams result = new ViewProviderCreateViewResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.viewToken = views_mojom.ViewToken.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(viewToken, 8, false); + } + + String toString() { + return "ViewProviderCreateViewResponseParams(" + "viewToken: $viewToken" ")"; + } + + Map toJson() { + Map map = new Map(); + map["viewToken"] = viewToken; + return map; + } +} + +const int kViewProvider_createView_name = 0; + +const String ViewProviderName = + 'mojo::ui::ViewProvider'; + +abstract class ViewProvider { + dynamic createView(Object services,Object exposedServices,[Function responseFactory = null]); + +} + + +class ViewProviderProxyImpl extends bindings.Proxy { + ViewProviderProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + ViewProviderProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + ViewProviderProxyImpl.unbound() : super.unbound(); + + static ViewProviderProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ViewProviderProxyImpl")); + return new ViewProviderProxyImpl.fromEndpoint(endpoint); + } + + String get name => ViewProviderName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kViewProvider_createView_name: + var r = ViewProviderCreateViewResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "ViewProviderProxyImpl($superString)"; + } +} + + +class _ViewProviderProxyCalls implements ViewProvider { + ViewProviderProxyImpl _proxyImpl; + + _ViewProviderProxyCalls(this._proxyImpl); + dynamic createView(Object services,Object exposedServices,[Function responseFactory = null]) { + var params = new ViewProviderCreateViewParams(); + params.services = services; + params.exposedServices = exposedServices; + return _proxyImpl.sendMessageWithRequestId( + params, + kViewProvider_createView_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class ViewProviderProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + ViewProvider ptr; + final String name = ViewProviderName; + + ViewProviderProxy(ViewProviderProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _ViewProviderProxyCalls(proxyImpl); + + ViewProviderProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new ViewProviderProxyImpl.fromEndpoint(endpoint) { + ptr = new _ViewProviderProxyCalls(impl); + } + + ViewProviderProxy.fromHandle(core.MojoHandle handle) : + impl = new ViewProviderProxyImpl.fromHandle(handle) { + ptr = new _ViewProviderProxyCalls(impl); + } + + ViewProviderProxy.unbound() : + impl = new ViewProviderProxyImpl.unbound() { + ptr = new _ViewProviderProxyCalls(impl); + } + + factory ViewProviderProxy.connectToService( + bindings.ServiceConnector s, String url) { + ViewProviderProxy p = new ViewProviderProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static ViewProviderProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ViewProviderProxy")); + return new ViewProviderProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "ViewProviderProxy($impl)"; + } +} + + +class ViewProviderStub extends bindings.Stub { + ViewProvider _impl = null; + + ViewProviderStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + ViewProviderStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + ViewProviderStub.unbound() : super.unbound(); + + static ViewProviderStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ViewProviderStub")); + return new ViewProviderStub.fromEndpoint(endpoint); + } + + static const String name = ViewProviderName; + + + ViewProviderCreateViewResponseParams _ViewProviderCreateViewResponseParamsFactory(views_mojom.ViewToken viewToken) { + var result = new ViewProviderCreateViewResponseParams(); + result.viewToken = viewToken; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kViewProvider_createView_name: + var params = ViewProviderCreateViewParams.deserialize( + message.payload); + var response = _impl.createView(params.services,params.exposedServices,_ViewProviderCreateViewResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kViewProvider_createView_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kViewProvider_createView_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + ViewProvider get impl => _impl; + set impl(ViewProvider d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "ViewProviderStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/ui/view_trees.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/ui/view_trees.mojom.dart new file mode 100644 index 0000000..ba28e2c --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/ui/view_trees.mojom.dart
@@ -0,0 +1,1122 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library view_trees_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo_services/mojo/ui/layouts.mojom.dart' as layouts_mojom; +import 'package:mojo_services/mojo/ui/views.mojom.dart' as views_mojom; + + + +class ViewTreeOnLayoutParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + ViewTreeOnLayoutParams() : super(kVersions.last.size); + + static ViewTreeOnLayoutParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewTreeOnLayoutParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewTreeOnLayoutParams result = new ViewTreeOnLayoutParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "ViewTreeOnLayoutParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class ViewTreeOnLayoutResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + ViewTreeOnLayoutResponseParams() : super(kVersions.last.size); + + static ViewTreeOnLayoutResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewTreeOnLayoutResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewTreeOnLayoutResponseParams result = new ViewTreeOnLayoutResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "ViewTreeOnLayoutResponseParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class ViewTreeOnRootUnavailableParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int rootKey = 0; + + ViewTreeOnRootUnavailableParams() : super(kVersions.last.size); + + static ViewTreeOnRootUnavailableParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewTreeOnRootUnavailableParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewTreeOnRootUnavailableParams result = new ViewTreeOnRootUnavailableParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.rootKey = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(rootKey, 8); + } + + String toString() { + return "ViewTreeOnRootUnavailableParams(" + "rootKey: $rootKey" ")"; + } + + Map toJson() { + Map map = new Map(); + map["rootKey"] = rootKey; + return map; + } +} + + +class ViewTreeOnRootUnavailableResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + ViewTreeOnRootUnavailableResponseParams() : super(kVersions.last.size); + + static ViewTreeOnRootUnavailableResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewTreeOnRootUnavailableResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewTreeOnRootUnavailableResponseParams result = new ViewTreeOnRootUnavailableResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "ViewTreeOnRootUnavailableResponseParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class ViewTreeHostRequestLayoutParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + ViewTreeHostRequestLayoutParams() : super(kVersions.last.size); + + static ViewTreeHostRequestLayoutParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewTreeHostRequestLayoutParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewTreeHostRequestLayoutParams result = new ViewTreeHostRequestLayoutParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "ViewTreeHostRequestLayoutParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class ViewTreeHostSetRootParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int rootKey = 0; + views_mojom.ViewToken rootViewToken = null; + + ViewTreeHostSetRootParams() : super(kVersions.last.size); + + static ViewTreeHostSetRootParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewTreeHostSetRootParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewTreeHostSetRootParams result = new ViewTreeHostSetRootParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.rootKey = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + result.rootViewToken = views_mojom.ViewToken.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(rootKey, 8); + + encoder0.encodeStruct(rootViewToken, 16, false); + } + + String toString() { + return "ViewTreeHostSetRootParams(" + "rootKey: $rootKey" ", " + "rootViewToken: $rootViewToken" ")"; + } + + Map toJson() { + Map map = new Map(); + map["rootKey"] = rootKey; + map["rootViewToken"] = rootViewToken; + return map; + } +} + + +class ViewTreeHostResetRootParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + ViewTreeHostResetRootParams() : super(kVersions.last.size); + + static ViewTreeHostResetRootParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewTreeHostResetRootParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewTreeHostResetRootParams result = new ViewTreeHostResetRootParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "ViewTreeHostResetRootParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class ViewTreeHostLayoutRootParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + layouts_mojom.ViewLayoutParams rootLayoutParams = null; + + ViewTreeHostLayoutRootParams() : super(kVersions.last.size); + + static ViewTreeHostLayoutRootParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewTreeHostLayoutRootParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewTreeHostLayoutRootParams result = new ViewTreeHostLayoutRootParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.rootLayoutParams = layouts_mojom.ViewLayoutParams.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(rootLayoutParams, 8, false); + } + + String toString() { + return "ViewTreeHostLayoutRootParams(" + "rootLayoutParams: $rootLayoutParams" ")"; + } + + Map toJson() { + Map map = new Map(); + map["rootLayoutParams"] = rootLayoutParams; + return map; + } +} + + +class ViewTreeHostLayoutRootResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + layouts_mojom.ViewLayoutInfo info = null; + + ViewTreeHostLayoutRootResponseParams() : super(kVersions.last.size); + + static ViewTreeHostLayoutRootResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewTreeHostLayoutRootResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewTreeHostLayoutRootResponseParams result = new ViewTreeHostLayoutRootResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, true); + result.info = layouts_mojom.ViewLayoutInfo.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(info, 8, true); + } + + String toString() { + return "ViewTreeHostLayoutRootResponseParams(" + "info: $info" ")"; + } + + Map toJson() { + Map map = new Map(); + map["info"] = info; + return map; + } +} + +const int kViewTree_onLayout_name = 0; +const int kViewTree_onRootUnavailable_name = 1; + +const String ViewTreeName = + 'mojo::ui::ViewTree'; + +abstract class ViewTree { + dynamic onLayout([Function responseFactory = null]); + dynamic onRootUnavailable(int rootKey,[Function responseFactory = null]); + +} + + +class ViewTreeProxyImpl extends bindings.Proxy { + ViewTreeProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + ViewTreeProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + ViewTreeProxyImpl.unbound() : super.unbound(); + + static ViewTreeProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ViewTreeProxyImpl")); + return new ViewTreeProxyImpl.fromEndpoint(endpoint); + } + + String get name => ViewTreeName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kViewTree_onLayout_name: + var r = ViewTreeOnLayoutResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kViewTree_onRootUnavailable_name: + var r = ViewTreeOnRootUnavailableResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "ViewTreeProxyImpl($superString)"; + } +} + + +class _ViewTreeProxyCalls implements ViewTree { + ViewTreeProxyImpl _proxyImpl; + + _ViewTreeProxyCalls(this._proxyImpl); + dynamic onLayout([Function responseFactory = null]) { + var params = new ViewTreeOnLayoutParams(); + return _proxyImpl.sendMessageWithRequestId( + params, + kViewTree_onLayout_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic onRootUnavailable(int rootKey,[Function responseFactory = null]) { + var params = new ViewTreeOnRootUnavailableParams(); + params.rootKey = rootKey; + return _proxyImpl.sendMessageWithRequestId( + params, + kViewTree_onRootUnavailable_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class ViewTreeProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + ViewTree ptr; + final String name = ViewTreeName; + + ViewTreeProxy(ViewTreeProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _ViewTreeProxyCalls(proxyImpl); + + ViewTreeProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new ViewTreeProxyImpl.fromEndpoint(endpoint) { + ptr = new _ViewTreeProxyCalls(impl); + } + + ViewTreeProxy.fromHandle(core.MojoHandle handle) : + impl = new ViewTreeProxyImpl.fromHandle(handle) { + ptr = new _ViewTreeProxyCalls(impl); + } + + ViewTreeProxy.unbound() : + impl = new ViewTreeProxyImpl.unbound() { + ptr = new _ViewTreeProxyCalls(impl); + } + + factory ViewTreeProxy.connectToService( + bindings.ServiceConnector s, String url) { + ViewTreeProxy p = new ViewTreeProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static ViewTreeProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ViewTreeProxy")); + return new ViewTreeProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "ViewTreeProxy($impl)"; + } +} + + +class ViewTreeStub extends bindings.Stub { + ViewTree _impl = null; + + ViewTreeStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + ViewTreeStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + ViewTreeStub.unbound() : super.unbound(); + + static ViewTreeStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ViewTreeStub")); + return new ViewTreeStub.fromEndpoint(endpoint); + } + + static const String name = ViewTreeName; + + + ViewTreeOnLayoutResponseParams _ViewTreeOnLayoutResponseParamsFactory() { + var result = new ViewTreeOnLayoutResponseParams(); + return result; + } + ViewTreeOnRootUnavailableResponseParams _ViewTreeOnRootUnavailableResponseParamsFactory() { + var result = new ViewTreeOnRootUnavailableResponseParams(); + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kViewTree_onLayout_name: + var params = ViewTreeOnLayoutParams.deserialize( + message.payload); + var response = _impl.onLayout(_ViewTreeOnLayoutResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kViewTree_onLayout_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kViewTree_onLayout_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kViewTree_onRootUnavailable_name: + var params = ViewTreeOnRootUnavailableParams.deserialize( + message.payload); + var response = _impl.onRootUnavailable(params.rootKey,_ViewTreeOnRootUnavailableResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kViewTree_onRootUnavailable_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kViewTree_onRootUnavailable_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + ViewTree get impl => _impl; + set impl(ViewTree d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "ViewTreeStub($superString)"; + } + + int get version => 0; +} + +const int kViewTreeHost_requestLayout_name = 0; +const int kViewTreeHost_setRoot_name = 1; +const int kViewTreeHost_resetRoot_name = 2; +const int kViewTreeHost_layoutRoot_name = 3; + +const String ViewTreeHostName = + 'mojo::ui::ViewTreeHost'; + +abstract class ViewTreeHost { + void requestLayout(); + void setRoot(int rootKey, views_mojom.ViewToken rootViewToken); + void resetRoot(); + dynamic layoutRoot(layouts_mojom.ViewLayoutParams rootLayoutParams,[Function responseFactory = null]); + +} + + +class ViewTreeHostProxyImpl extends bindings.Proxy { + ViewTreeHostProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + ViewTreeHostProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + ViewTreeHostProxyImpl.unbound() : super.unbound(); + + static ViewTreeHostProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ViewTreeHostProxyImpl")); + return new ViewTreeHostProxyImpl.fromEndpoint(endpoint); + } + + String get name => ViewTreeHostName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kViewTreeHost_layoutRoot_name: + var r = ViewTreeHostLayoutRootResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "ViewTreeHostProxyImpl($superString)"; + } +} + + +class _ViewTreeHostProxyCalls implements ViewTreeHost { + ViewTreeHostProxyImpl _proxyImpl; + + _ViewTreeHostProxyCalls(this._proxyImpl); + void requestLayout() { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new ViewTreeHostRequestLayoutParams(); + _proxyImpl.sendMessage(params, kViewTreeHost_requestLayout_name); + } + + void setRoot(int rootKey, views_mojom.ViewToken rootViewToken) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new ViewTreeHostSetRootParams(); + params.rootKey = rootKey; + params.rootViewToken = rootViewToken; + _proxyImpl.sendMessage(params, kViewTreeHost_setRoot_name); + } + + void resetRoot() { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new ViewTreeHostResetRootParams(); + _proxyImpl.sendMessage(params, kViewTreeHost_resetRoot_name); + } + + dynamic layoutRoot(layouts_mojom.ViewLayoutParams rootLayoutParams,[Function responseFactory = null]) { + var params = new ViewTreeHostLayoutRootParams(); + params.rootLayoutParams = rootLayoutParams; + return _proxyImpl.sendMessageWithRequestId( + params, + kViewTreeHost_layoutRoot_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class ViewTreeHostProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + ViewTreeHost ptr; + final String name = ViewTreeHostName; + + ViewTreeHostProxy(ViewTreeHostProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _ViewTreeHostProxyCalls(proxyImpl); + + ViewTreeHostProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new ViewTreeHostProxyImpl.fromEndpoint(endpoint) { + ptr = new _ViewTreeHostProxyCalls(impl); + } + + ViewTreeHostProxy.fromHandle(core.MojoHandle handle) : + impl = new ViewTreeHostProxyImpl.fromHandle(handle) { + ptr = new _ViewTreeHostProxyCalls(impl); + } + + ViewTreeHostProxy.unbound() : + impl = new ViewTreeHostProxyImpl.unbound() { + ptr = new _ViewTreeHostProxyCalls(impl); + } + + factory ViewTreeHostProxy.connectToService( + bindings.ServiceConnector s, String url) { + ViewTreeHostProxy p = new ViewTreeHostProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static ViewTreeHostProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ViewTreeHostProxy")); + return new ViewTreeHostProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "ViewTreeHostProxy($impl)"; + } +} + + +class ViewTreeHostStub extends bindings.Stub { + ViewTreeHost _impl = null; + + ViewTreeHostStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + ViewTreeHostStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + ViewTreeHostStub.unbound() : super.unbound(); + + static ViewTreeHostStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ViewTreeHostStub")); + return new ViewTreeHostStub.fromEndpoint(endpoint); + } + + static const String name = ViewTreeHostName; + + + ViewTreeHostLayoutRootResponseParams _ViewTreeHostLayoutRootResponseParamsFactory(layouts_mojom.ViewLayoutInfo info) { + var result = new ViewTreeHostLayoutRootResponseParams(); + result.info = info; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kViewTreeHost_requestLayout_name: + var params = ViewTreeHostRequestLayoutParams.deserialize( + message.payload); + _impl.requestLayout(); + break; + case kViewTreeHost_setRoot_name: + var params = ViewTreeHostSetRootParams.deserialize( + message.payload); + _impl.setRoot(params.rootKey, params.rootViewToken); + break; + case kViewTreeHost_resetRoot_name: + var params = ViewTreeHostResetRootParams.deserialize( + message.payload); + _impl.resetRoot(); + break; + case kViewTreeHost_layoutRoot_name: + var params = ViewTreeHostLayoutRootParams.deserialize( + message.payload); + var response = _impl.layoutRoot(params.rootLayoutParams,_ViewTreeHostLayoutRootResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kViewTreeHost_layoutRoot_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kViewTreeHost_layoutRoot_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + ViewTreeHost get impl => _impl; + set impl(ViewTreeHost d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "ViewTreeHostStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/ui/views.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/ui/views.mojom.dart new file mode 100644 index 0000000..00a33d1 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/ui/views.mojom.dart
@@ -0,0 +1,1324 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library views_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo/mojo/service_provider.mojom.dart' as service_provider_mojom; +import 'package:mojo_services/mojo/ui/layouts.mojom.dart' as layouts_mojom; + + + +class ViewToken extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int value = 0; + + ViewToken() : super(kVersions.last.size); + + static ViewToken deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewToken decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewToken result = new ViewToken(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.value = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(value, 8); + } + + String toString() { + return "ViewToken(" + "value: $value" ")"; + } + + Map toJson() { + Map map = new Map(); + map["value"] = value; + return map; + } +} + + +class ViewOnLayoutParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + layouts_mojom.ViewLayoutParams layoutParams = null; + List<int> childrenNeedingLayout = null; + + ViewOnLayoutParams() : super(kVersions.last.size); + + static ViewOnLayoutParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewOnLayoutParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewOnLayoutParams result = new ViewOnLayoutParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.layoutParams = layouts_mojom.ViewLayoutParams.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + result.childrenNeedingLayout = decoder0.decodeUint32Array(16, bindings.kNothingNullable, bindings.kUnspecifiedArrayLength); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(layoutParams, 8, false); + + encoder0.encodeUint32Array(childrenNeedingLayout, 16, bindings.kNothingNullable, bindings.kUnspecifiedArrayLength); + } + + String toString() { + return "ViewOnLayoutParams(" + "layoutParams: $layoutParams" ", " + "childrenNeedingLayout: $childrenNeedingLayout" ")"; + } + + Map toJson() { + Map map = new Map(); + map["layoutParams"] = layoutParams; + map["childrenNeedingLayout"] = childrenNeedingLayout; + return map; + } +} + + +class ViewOnLayoutResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + layouts_mojom.ViewLayoutInfo info = null; + + ViewOnLayoutResponseParams() : super(kVersions.last.size); + + static ViewOnLayoutResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewOnLayoutResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewOnLayoutResponseParams result = new ViewOnLayoutResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.info = layouts_mojom.ViewLayoutInfo.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(info, 8, false); + } + + String toString() { + return "ViewOnLayoutResponseParams(" + "info: $info" ")"; + } + + Map toJson() { + Map map = new Map(); + map["info"] = info; + return map; + } +} + + +class ViewOnChildUnavailableParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int childKey = 0; + + ViewOnChildUnavailableParams() : super(kVersions.last.size); + + static ViewOnChildUnavailableParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewOnChildUnavailableParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewOnChildUnavailableParams result = new ViewOnChildUnavailableParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.childKey = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(childKey, 8); + } + + String toString() { + return "ViewOnChildUnavailableParams(" + "childKey: $childKey" ")"; + } + + Map toJson() { + Map map = new Map(); + map["childKey"] = childKey; + return map; + } +} + + +class ViewOnChildUnavailableResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + ViewOnChildUnavailableResponseParams() : super(kVersions.last.size); + + static ViewOnChildUnavailableResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewOnChildUnavailableResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewOnChildUnavailableResponseParams result = new ViewOnChildUnavailableResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "ViewOnChildUnavailableResponseParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class ViewHostGetServiceProviderParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + Object serviceProvider = null; + + ViewHostGetServiceProviderParams() : super(kVersions.last.size); + + static ViewHostGetServiceProviderParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewHostGetServiceProviderParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewHostGetServiceProviderParams result = new ViewHostGetServiceProviderParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.serviceProvider = decoder0.decodeInterfaceRequest(8, false, service_provider_mojom.ServiceProviderStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterfaceRequest(serviceProvider, 8, false); + } + + String toString() { + return "ViewHostGetServiceProviderParams(" + "serviceProvider: $serviceProvider" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class ViewHostRequestLayoutParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + ViewHostRequestLayoutParams() : super(kVersions.last.size); + + static ViewHostRequestLayoutParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewHostRequestLayoutParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewHostRequestLayoutParams result = new ViewHostRequestLayoutParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "ViewHostRequestLayoutParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class ViewHostAddChildParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int childKey = 0; + ViewToken childViewToken = null; + + ViewHostAddChildParams() : super(kVersions.last.size); + + static ViewHostAddChildParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewHostAddChildParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewHostAddChildParams result = new ViewHostAddChildParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.childKey = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + result.childViewToken = ViewToken.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(childKey, 8); + + encoder0.encodeStruct(childViewToken, 16, false); + } + + String toString() { + return "ViewHostAddChildParams(" + "childKey: $childKey" ", " + "childViewToken: $childViewToken" ")"; + } + + Map toJson() { + Map map = new Map(); + map["childKey"] = childKey; + map["childViewToken"] = childViewToken; + return map; + } +} + + +class ViewHostRemoveChildParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int childKey = 0; + + ViewHostRemoveChildParams() : super(kVersions.last.size); + + static ViewHostRemoveChildParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewHostRemoveChildParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewHostRemoveChildParams result = new ViewHostRemoveChildParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.childKey = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(childKey, 8); + } + + String toString() { + return "ViewHostRemoveChildParams(" + "childKey: $childKey" ")"; + } + + Map toJson() { + Map map = new Map(); + map["childKey"] = childKey; + return map; + } +} + + +class ViewHostLayoutChildParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int childKey = 0; + layouts_mojom.ViewLayoutParams childLayoutParams = null; + + ViewHostLayoutChildParams() : super(kVersions.last.size); + + static ViewHostLayoutChildParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewHostLayoutChildParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewHostLayoutChildParams result = new ViewHostLayoutChildParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.childKey = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + result.childLayoutParams = layouts_mojom.ViewLayoutParams.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(childKey, 8); + + encoder0.encodeStruct(childLayoutParams, 16, false); + } + + String toString() { + return "ViewHostLayoutChildParams(" + "childKey: $childKey" ", " + "childLayoutParams: $childLayoutParams" ")"; + } + + Map toJson() { + Map map = new Map(); + map["childKey"] = childKey; + map["childLayoutParams"] = childLayoutParams; + return map; + } +} + + +class ViewHostLayoutChildResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + layouts_mojom.ViewLayoutInfo info = null; + + ViewHostLayoutChildResponseParams() : super(kVersions.last.size); + + static ViewHostLayoutChildResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewHostLayoutChildResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewHostLayoutChildResponseParams result = new ViewHostLayoutChildResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, true); + result.info = layouts_mojom.ViewLayoutInfo.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(info, 8, true); + } + + String toString() { + return "ViewHostLayoutChildResponseParams(" + "info: $info" ")"; + } + + Map toJson() { + Map map = new Map(); + map["info"] = info; + return map; + } +} + +const int kView_onLayout_name = 0; +const int kView_onChildUnavailable_name = 1; + +const String ViewName = + 'mojo::ui::View'; + +abstract class View { + dynamic onLayout(layouts_mojom.ViewLayoutParams layoutParams,List<int> childrenNeedingLayout,[Function responseFactory = null]); + dynamic onChildUnavailable(int childKey,[Function responseFactory = null]); + +} + + +class ViewProxyImpl extends bindings.Proxy { + ViewProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + ViewProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + ViewProxyImpl.unbound() : super.unbound(); + + static ViewProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ViewProxyImpl")); + return new ViewProxyImpl.fromEndpoint(endpoint); + } + + String get name => ViewName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kView_onLayout_name: + var r = ViewOnLayoutResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kView_onChildUnavailable_name: + var r = ViewOnChildUnavailableResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "ViewProxyImpl($superString)"; + } +} + + +class _ViewProxyCalls implements View { + ViewProxyImpl _proxyImpl; + + _ViewProxyCalls(this._proxyImpl); + dynamic onLayout(layouts_mojom.ViewLayoutParams layoutParams,List<int> childrenNeedingLayout,[Function responseFactory = null]) { + var params = new ViewOnLayoutParams(); + params.layoutParams = layoutParams; + params.childrenNeedingLayout = childrenNeedingLayout; + return _proxyImpl.sendMessageWithRequestId( + params, + kView_onLayout_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic onChildUnavailable(int childKey,[Function responseFactory = null]) { + var params = new ViewOnChildUnavailableParams(); + params.childKey = childKey; + return _proxyImpl.sendMessageWithRequestId( + params, + kView_onChildUnavailable_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class ViewProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + View ptr; + final String name = ViewName; + + ViewProxy(ViewProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _ViewProxyCalls(proxyImpl); + + ViewProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new ViewProxyImpl.fromEndpoint(endpoint) { + ptr = new _ViewProxyCalls(impl); + } + + ViewProxy.fromHandle(core.MojoHandle handle) : + impl = new ViewProxyImpl.fromHandle(handle) { + ptr = new _ViewProxyCalls(impl); + } + + ViewProxy.unbound() : + impl = new ViewProxyImpl.unbound() { + ptr = new _ViewProxyCalls(impl); + } + + factory ViewProxy.connectToService( + bindings.ServiceConnector s, String url) { + ViewProxy p = new ViewProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static ViewProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ViewProxy")); + return new ViewProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "ViewProxy($impl)"; + } +} + + +class ViewStub extends bindings.Stub { + View _impl = null; + + ViewStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + ViewStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + ViewStub.unbound() : super.unbound(); + + static ViewStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ViewStub")); + return new ViewStub.fromEndpoint(endpoint); + } + + static const String name = ViewName; + + + ViewOnLayoutResponseParams _ViewOnLayoutResponseParamsFactory(layouts_mojom.ViewLayoutInfo info) { + var result = new ViewOnLayoutResponseParams(); + result.info = info; + return result; + } + ViewOnChildUnavailableResponseParams _ViewOnChildUnavailableResponseParamsFactory() { + var result = new ViewOnChildUnavailableResponseParams(); + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kView_onLayout_name: + var params = ViewOnLayoutParams.deserialize( + message.payload); + var response = _impl.onLayout(params.layoutParams,params.childrenNeedingLayout,_ViewOnLayoutResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kView_onLayout_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kView_onLayout_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kView_onChildUnavailable_name: + var params = ViewOnChildUnavailableParams.deserialize( + message.payload); + var response = _impl.onChildUnavailable(params.childKey,_ViewOnChildUnavailableResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kView_onChildUnavailable_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kView_onChildUnavailable_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + View get impl => _impl; + set impl(View d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "ViewStub($superString)"; + } + + int get version => 0; +} + +const int kViewHost_getServiceProvider_name = 0; +const int kViewHost_requestLayout_name = 1; +const int kViewHost_addChild_name = 2; +const int kViewHost_removeChild_name = 3; +const int kViewHost_layoutChild_name = 4; + +const String ViewHostName = + 'mojo::ui::ViewHost'; + +abstract class ViewHost { + void getServiceProvider(Object serviceProvider); + void requestLayout(); + void addChild(int childKey, ViewToken childViewToken); + void removeChild(int childKey); + dynamic layoutChild(int childKey,layouts_mojom.ViewLayoutParams childLayoutParams,[Function responseFactory = null]); + +} + + +class ViewHostProxyImpl extends bindings.Proxy { + ViewHostProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + ViewHostProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + ViewHostProxyImpl.unbound() : super.unbound(); + + static ViewHostProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ViewHostProxyImpl")); + return new ViewHostProxyImpl.fromEndpoint(endpoint); + } + + String get name => ViewHostName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kViewHost_layoutChild_name: + var r = ViewHostLayoutChildResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "ViewHostProxyImpl($superString)"; + } +} + + +class _ViewHostProxyCalls implements ViewHost { + ViewHostProxyImpl _proxyImpl; + + _ViewHostProxyCalls(this._proxyImpl); + void getServiceProvider(Object serviceProvider) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new ViewHostGetServiceProviderParams(); + params.serviceProvider = serviceProvider; + _proxyImpl.sendMessage(params, kViewHost_getServiceProvider_name); + } + + void requestLayout() { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new ViewHostRequestLayoutParams(); + _proxyImpl.sendMessage(params, kViewHost_requestLayout_name); + } + + void addChild(int childKey, ViewToken childViewToken) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new ViewHostAddChildParams(); + params.childKey = childKey; + params.childViewToken = childViewToken; + _proxyImpl.sendMessage(params, kViewHost_addChild_name); + } + + void removeChild(int childKey) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new ViewHostRemoveChildParams(); + params.childKey = childKey; + _proxyImpl.sendMessage(params, kViewHost_removeChild_name); + } + + dynamic layoutChild(int childKey,layouts_mojom.ViewLayoutParams childLayoutParams,[Function responseFactory = null]) { + var params = new ViewHostLayoutChildParams(); + params.childKey = childKey; + params.childLayoutParams = childLayoutParams; + return _proxyImpl.sendMessageWithRequestId( + params, + kViewHost_layoutChild_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class ViewHostProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + ViewHost ptr; + final String name = ViewHostName; + + ViewHostProxy(ViewHostProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _ViewHostProxyCalls(proxyImpl); + + ViewHostProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new ViewHostProxyImpl.fromEndpoint(endpoint) { + ptr = new _ViewHostProxyCalls(impl); + } + + ViewHostProxy.fromHandle(core.MojoHandle handle) : + impl = new ViewHostProxyImpl.fromHandle(handle) { + ptr = new _ViewHostProxyCalls(impl); + } + + ViewHostProxy.unbound() : + impl = new ViewHostProxyImpl.unbound() { + ptr = new _ViewHostProxyCalls(impl); + } + + factory ViewHostProxy.connectToService( + bindings.ServiceConnector s, String url) { + ViewHostProxy p = new ViewHostProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static ViewHostProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ViewHostProxy")); + return new ViewHostProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "ViewHostProxy($impl)"; + } +} + + +class ViewHostStub extends bindings.Stub { + ViewHost _impl = null; + + ViewHostStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + ViewHostStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + ViewHostStub.unbound() : super.unbound(); + + static ViewHostStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ViewHostStub")); + return new ViewHostStub.fromEndpoint(endpoint); + } + + static const String name = ViewHostName; + + + ViewHostLayoutChildResponseParams _ViewHostLayoutChildResponseParamsFactory(layouts_mojom.ViewLayoutInfo info) { + var result = new ViewHostLayoutChildResponseParams(); + result.info = info; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kViewHost_getServiceProvider_name: + var params = ViewHostGetServiceProviderParams.deserialize( + message.payload); + _impl.getServiceProvider(params.serviceProvider); + break; + case kViewHost_requestLayout_name: + var params = ViewHostRequestLayoutParams.deserialize( + message.payload); + _impl.requestLayout(); + break; + case kViewHost_addChild_name: + var params = ViewHostAddChildParams.deserialize( + message.payload); + _impl.addChild(params.childKey, params.childViewToken); + break; + case kViewHost_removeChild_name: + var params = ViewHostRemoveChildParams.deserialize( + message.payload); + _impl.removeChild(params.childKey); + break; + case kViewHost_layoutChild_name: + var params = ViewHostLayoutChildParams.deserialize( + message.payload); + var response = _impl.layoutChild(params.childKey,params.childLayoutParams,_ViewHostLayoutChildResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kViewHost_layoutChild_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kViewHost_layoutChild_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + ViewHost get impl => _impl; + set impl(ViewHost d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "ViewHostStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/url_loader.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/url_loader.mojom.dart new file mode 100644 index 0000000..0fc15ee --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/url_loader.mojom.dart
@@ -0,0 +1,808 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library url_loader_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo/mojo/network_error.mojom.dart' as network_error_mojom; +import 'package:mojo/mojo/url_request.mojom.dart' as url_request_mojom; +import 'package:mojo/mojo/url_response.mojom.dart' as url_response_mojom; + + + +class UrlLoaderStatus extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + network_error_mojom.NetworkError error = null; + bool isLoading = false; + + UrlLoaderStatus() : super(kVersions.last.size); + + static UrlLoaderStatus deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UrlLoaderStatus decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UrlLoaderStatus result = new UrlLoaderStatus(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, true); + result.error = network_error_mojom.NetworkError.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + result.isLoading = decoder0.decodeBool(16, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(error, 8, true); + + encoder0.encodeBool(isLoading, 16, 0); + } + + String toString() { + return "UrlLoaderStatus(" + "error: $error" ", " + "isLoading: $isLoading" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + map["isLoading"] = isLoading; + return map; + } +} + + +class UrlLoaderStartParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + url_request_mojom.UrlRequest request = null; + + UrlLoaderStartParams() : super(kVersions.last.size); + + static UrlLoaderStartParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UrlLoaderStartParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UrlLoaderStartParams result = new UrlLoaderStartParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.request = url_request_mojom.UrlRequest.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(request, 8, false); + } + + String toString() { + return "UrlLoaderStartParams(" + "request: $request" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class UrlLoaderStartResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + url_response_mojom.UrlResponse response = null; + + UrlLoaderStartResponseParams() : super(kVersions.last.size); + + static UrlLoaderStartResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UrlLoaderStartResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UrlLoaderStartResponseParams result = new UrlLoaderStartResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.response = url_response_mojom.UrlResponse.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(response, 8, false); + } + + String toString() { + return "UrlLoaderStartResponseParams(" + "response: $response" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class UrlLoaderFollowRedirectParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + UrlLoaderFollowRedirectParams() : super(kVersions.last.size); + + static UrlLoaderFollowRedirectParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UrlLoaderFollowRedirectParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UrlLoaderFollowRedirectParams result = new UrlLoaderFollowRedirectParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "UrlLoaderFollowRedirectParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class UrlLoaderFollowRedirectResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + url_response_mojom.UrlResponse response = null; + + UrlLoaderFollowRedirectResponseParams() : super(kVersions.last.size); + + static UrlLoaderFollowRedirectResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UrlLoaderFollowRedirectResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UrlLoaderFollowRedirectResponseParams result = new UrlLoaderFollowRedirectResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.response = url_response_mojom.UrlResponse.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(response, 8, false); + } + + String toString() { + return "UrlLoaderFollowRedirectResponseParams(" + "response: $response" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class UrlLoaderQueryStatusParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + UrlLoaderQueryStatusParams() : super(kVersions.last.size); + + static UrlLoaderQueryStatusParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UrlLoaderQueryStatusParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UrlLoaderQueryStatusParams result = new UrlLoaderQueryStatusParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "UrlLoaderQueryStatusParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class UrlLoaderQueryStatusResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + UrlLoaderStatus status = null; + + UrlLoaderQueryStatusResponseParams() : super(kVersions.last.size); + + static UrlLoaderQueryStatusResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UrlLoaderQueryStatusResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UrlLoaderQueryStatusResponseParams result = new UrlLoaderQueryStatusResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.status = UrlLoaderStatus.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(status, 8, false); + } + + String toString() { + return "UrlLoaderQueryStatusResponseParams(" + "status: $status" ")"; + } + + Map toJson() { + Map map = new Map(); + map["status"] = status; + return map; + } +} + +const int kUrlLoader_start_name = 0; +const int kUrlLoader_followRedirect_name = 1; +const int kUrlLoader_queryStatus_name = 2; + +const String UrlLoaderName = + 'mojo::URLLoader'; + +abstract class UrlLoader { + dynamic start(url_request_mojom.UrlRequest request,[Function responseFactory = null]); + dynamic followRedirect([Function responseFactory = null]); + dynamic queryStatus([Function responseFactory = null]); + +} + + +class UrlLoaderProxyImpl extends bindings.Proxy { + UrlLoaderProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + UrlLoaderProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + UrlLoaderProxyImpl.unbound() : super.unbound(); + + static UrlLoaderProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For UrlLoaderProxyImpl")); + return new UrlLoaderProxyImpl.fromEndpoint(endpoint); + } + + String get name => UrlLoaderName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kUrlLoader_start_name: + var r = UrlLoaderStartResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kUrlLoader_followRedirect_name: + var r = UrlLoaderFollowRedirectResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kUrlLoader_queryStatus_name: + var r = UrlLoaderQueryStatusResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "UrlLoaderProxyImpl($superString)"; + } +} + + +class _UrlLoaderProxyCalls implements UrlLoader { + UrlLoaderProxyImpl _proxyImpl; + + _UrlLoaderProxyCalls(this._proxyImpl); + dynamic start(url_request_mojom.UrlRequest request,[Function responseFactory = null]) { + var params = new UrlLoaderStartParams(); + params.request = request; + return _proxyImpl.sendMessageWithRequestId( + params, + kUrlLoader_start_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic followRedirect([Function responseFactory = null]) { + var params = new UrlLoaderFollowRedirectParams(); + return _proxyImpl.sendMessageWithRequestId( + params, + kUrlLoader_followRedirect_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic queryStatus([Function responseFactory = null]) { + var params = new UrlLoaderQueryStatusParams(); + return _proxyImpl.sendMessageWithRequestId( + params, + kUrlLoader_queryStatus_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class UrlLoaderProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + UrlLoader ptr; + final String name = UrlLoaderName; + + UrlLoaderProxy(UrlLoaderProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _UrlLoaderProxyCalls(proxyImpl); + + UrlLoaderProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new UrlLoaderProxyImpl.fromEndpoint(endpoint) { + ptr = new _UrlLoaderProxyCalls(impl); + } + + UrlLoaderProxy.fromHandle(core.MojoHandle handle) : + impl = new UrlLoaderProxyImpl.fromHandle(handle) { + ptr = new _UrlLoaderProxyCalls(impl); + } + + UrlLoaderProxy.unbound() : + impl = new UrlLoaderProxyImpl.unbound() { + ptr = new _UrlLoaderProxyCalls(impl); + } + + factory UrlLoaderProxy.connectToService( + bindings.ServiceConnector s, String url) { + UrlLoaderProxy p = new UrlLoaderProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static UrlLoaderProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For UrlLoaderProxy")); + return new UrlLoaderProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "UrlLoaderProxy($impl)"; + } +} + + +class UrlLoaderStub extends bindings.Stub { + UrlLoader _impl = null; + + UrlLoaderStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + UrlLoaderStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + UrlLoaderStub.unbound() : super.unbound(); + + static UrlLoaderStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For UrlLoaderStub")); + return new UrlLoaderStub.fromEndpoint(endpoint); + } + + static const String name = UrlLoaderName; + + + UrlLoaderStartResponseParams _UrlLoaderStartResponseParamsFactory(url_response_mojom.UrlResponse response) { + var result = new UrlLoaderStartResponseParams(); + result.response = response; + return result; + } + UrlLoaderFollowRedirectResponseParams _UrlLoaderFollowRedirectResponseParamsFactory(url_response_mojom.UrlResponse response) { + var result = new UrlLoaderFollowRedirectResponseParams(); + result.response = response; + return result; + } + UrlLoaderQueryStatusResponseParams _UrlLoaderQueryStatusResponseParamsFactory(UrlLoaderStatus status) { + var result = new UrlLoaderQueryStatusResponseParams(); + result.status = status; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kUrlLoader_start_name: + var params = UrlLoaderStartParams.deserialize( + message.payload); + var response = _impl.start(params.request,_UrlLoaderStartResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kUrlLoader_start_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kUrlLoader_start_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kUrlLoader_followRedirect_name: + var params = UrlLoaderFollowRedirectParams.deserialize( + message.payload); + var response = _impl.followRedirect(_UrlLoaderFollowRedirectResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kUrlLoader_followRedirect_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kUrlLoader_followRedirect_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kUrlLoader_queryStatus_name: + var params = UrlLoaderQueryStatusParams.deserialize( + message.payload); + var response = _impl.queryStatus(_UrlLoaderQueryStatusResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kUrlLoader_queryStatus_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kUrlLoader_queryStatus_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + UrlLoader get impl => _impl; + set impl(UrlLoader d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "UrlLoaderStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/url_loader_interceptor.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/url_loader_interceptor.mojom.dart new file mode 100644 index 0000000..a98f3a3 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/url_loader_interceptor.mojom.dart
@@ -0,0 +1,1056 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library url_loader_interceptor_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo/mojo/url_request.mojom.dart' as url_request_mojom; +import 'package:mojo/mojo/url_response.mojom.dart' as url_response_mojom; + + + +class UrlLoaderInterceptorResponse extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + url_request_mojom.UrlRequest request = null; + url_response_mojom.UrlResponse response = null; + + UrlLoaderInterceptorResponse() : super(kVersions.last.size); + + static UrlLoaderInterceptorResponse deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UrlLoaderInterceptorResponse decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UrlLoaderInterceptorResponse result = new UrlLoaderInterceptorResponse(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, true); + result.request = url_request_mojom.UrlRequest.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, true); + result.response = url_response_mojom.UrlResponse.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(request, 8, true); + + encoder0.encodeStruct(response, 16, true); + } + + String toString() { + return "UrlLoaderInterceptorResponse(" + "request: $request" ", " + "response: $response" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class UrlLoaderInterceptorFactoryCreateParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + Object interceptor = null; + + UrlLoaderInterceptorFactoryCreateParams() : super(kVersions.last.size); + + static UrlLoaderInterceptorFactoryCreateParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UrlLoaderInterceptorFactoryCreateParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UrlLoaderInterceptorFactoryCreateParams result = new UrlLoaderInterceptorFactoryCreateParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.interceptor = decoder0.decodeInterfaceRequest(8, false, UrlLoaderInterceptorStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterfaceRequest(interceptor, 8, false); + } + + String toString() { + return "UrlLoaderInterceptorFactoryCreateParams(" + "interceptor: $interceptor" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class UrlLoaderInterceptorInterceptRequestParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + url_request_mojom.UrlRequest request = null; + + UrlLoaderInterceptorInterceptRequestParams() : super(kVersions.last.size); + + static UrlLoaderInterceptorInterceptRequestParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UrlLoaderInterceptorInterceptRequestParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UrlLoaderInterceptorInterceptRequestParams result = new UrlLoaderInterceptorInterceptRequestParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.request = url_request_mojom.UrlRequest.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(request, 8, false); + } + + String toString() { + return "UrlLoaderInterceptorInterceptRequestParams(" + "request: $request" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class UrlLoaderInterceptorInterceptRequestResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + UrlLoaderInterceptorResponse response = null; + + UrlLoaderInterceptorInterceptRequestResponseParams() : super(kVersions.last.size); + + static UrlLoaderInterceptorInterceptRequestResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UrlLoaderInterceptorInterceptRequestResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UrlLoaderInterceptorInterceptRequestResponseParams result = new UrlLoaderInterceptorInterceptRequestResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.response = UrlLoaderInterceptorResponse.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(response, 8, false); + } + + String toString() { + return "UrlLoaderInterceptorInterceptRequestResponseParams(" + "response: $response" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class UrlLoaderInterceptorInterceptFollowRedirectParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + UrlLoaderInterceptorInterceptFollowRedirectParams() : super(kVersions.last.size); + + static UrlLoaderInterceptorInterceptFollowRedirectParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UrlLoaderInterceptorInterceptFollowRedirectParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UrlLoaderInterceptorInterceptFollowRedirectParams result = new UrlLoaderInterceptorInterceptFollowRedirectParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "UrlLoaderInterceptorInterceptFollowRedirectParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class UrlLoaderInterceptorInterceptFollowRedirectResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + UrlLoaderInterceptorResponse response = null; + + UrlLoaderInterceptorInterceptFollowRedirectResponseParams() : super(kVersions.last.size); + + static UrlLoaderInterceptorInterceptFollowRedirectResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UrlLoaderInterceptorInterceptFollowRedirectResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UrlLoaderInterceptorInterceptFollowRedirectResponseParams result = new UrlLoaderInterceptorInterceptFollowRedirectResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, true); + result.response = UrlLoaderInterceptorResponse.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(response, 8, true); + } + + String toString() { + return "UrlLoaderInterceptorInterceptFollowRedirectResponseParams(" + "response: $response" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class UrlLoaderInterceptorInterceptResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + url_response_mojom.UrlResponse response = null; + + UrlLoaderInterceptorInterceptResponseParams() : super(kVersions.last.size); + + static UrlLoaderInterceptorInterceptResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UrlLoaderInterceptorInterceptResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UrlLoaderInterceptorInterceptResponseParams result = new UrlLoaderInterceptorInterceptResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.response = url_response_mojom.UrlResponse.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(response, 8, false); + } + + String toString() { + return "UrlLoaderInterceptorInterceptResponseParams(" + "response: $response" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class UrlLoaderInterceptorInterceptResponseResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + UrlLoaderInterceptorResponse response = null; + + UrlLoaderInterceptorInterceptResponseResponseParams() : super(kVersions.last.size); + + static UrlLoaderInterceptorInterceptResponseResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UrlLoaderInterceptorInterceptResponseResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UrlLoaderInterceptorInterceptResponseResponseParams result = new UrlLoaderInterceptorInterceptResponseResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, true); + result.response = UrlLoaderInterceptorResponse.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(response, 8, true); + } + + String toString() { + return "UrlLoaderInterceptorInterceptResponseResponseParams(" + "response: $response" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + +const int kUrlLoaderInterceptorFactory_create_name = 0; + +const String UrlLoaderInterceptorFactoryName = + 'mojo::URLLoaderInterceptorFactory'; + +abstract class UrlLoaderInterceptorFactory { + void create(Object interceptor); + +} + + +class UrlLoaderInterceptorFactoryProxyImpl extends bindings.Proxy { + UrlLoaderInterceptorFactoryProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + UrlLoaderInterceptorFactoryProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + UrlLoaderInterceptorFactoryProxyImpl.unbound() : super.unbound(); + + static UrlLoaderInterceptorFactoryProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For UrlLoaderInterceptorFactoryProxyImpl")); + return new UrlLoaderInterceptorFactoryProxyImpl.fromEndpoint(endpoint); + } + + String get name => UrlLoaderInterceptorFactoryName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "UrlLoaderInterceptorFactoryProxyImpl($superString)"; + } +} + + +class _UrlLoaderInterceptorFactoryProxyCalls implements UrlLoaderInterceptorFactory { + UrlLoaderInterceptorFactoryProxyImpl _proxyImpl; + + _UrlLoaderInterceptorFactoryProxyCalls(this._proxyImpl); + void create(Object interceptor) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new UrlLoaderInterceptorFactoryCreateParams(); + params.interceptor = interceptor; + _proxyImpl.sendMessage(params, kUrlLoaderInterceptorFactory_create_name); + } + +} + + +class UrlLoaderInterceptorFactoryProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + UrlLoaderInterceptorFactory ptr; + final String name = UrlLoaderInterceptorFactoryName; + + UrlLoaderInterceptorFactoryProxy(UrlLoaderInterceptorFactoryProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _UrlLoaderInterceptorFactoryProxyCalls(proxyImpl); + + UrlLoaderInterceptorFactoryProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new UrlLoaderInterceptorFactoryProxyImpl.fromEndpoint(endpoint) { + ptr = new _UrlLoaderInterceptorFactoryProxyCalls(impl); + } + + UrlLoaderInterceptorFactoryProxy.fromHandle(core.MojoHandle handle) : + impl = new UrlLoaderInterceptorFactoryProxyImpl.fromHandle(handle) { + ptr = new _UrlLoaderInterceptorFactoryProxyCalls(impl); + } + + UrlLoaderInterceptorFactoryProxy.unbound() : + impl = new UrlLoaderInterceptorFactoryProxyImpl.unbound() { + ptr = new _UrlLoaderInterceptorFactoryProxyCalls(impl); + } + + factory UrlLoaderInterceptorFactoryProxy.connectToService( + bindings.ServiceConnector s, String url) { + UrlLoaderInterceptorFactoryProxy p = new UrlLoaderInterceptorFactoryProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static UrlLoaderInterceptorFactoryProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For UrlLoaderInterceptorFactoryProxy")); + return new UrlLoaderInterceptorFactoryProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "UrlLoaderInterceptorFactoryProxy($impl)"; + } +} + + +class UrlLoaderInterceptorFactoryStub extends bindings.Stub { + UrlLoaderInterceptorFactory _impl = null; + + UrlLoaderInterceptorFactoryStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + UrlLoaderInterceptorFactoryStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + UrlLoaderInterceptorFactoryStub.unbound() : super.unbound(); + + static UrlLoaderInterceptorFactoryStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For UrlLoaderInterceptorFactoryStub")); + return new UrlLoaderInterceptorFactoryStub.fromEndpoint(endpoint); + } + + static const String name = UrlLoaderInterceptorFactoryName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kUrlLoaderInterceptorFactory_create_name: + var params = UrlLoaderInterceptorFactoryCreateParams.deserialize( + message.payload); + _impl.create(params.interceptor); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + UrlLoaderInterceptorFactory get impl => _impl; + set impl(UrlLoaderInterceptorFactory d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "UrlLoaderInterceptorFactoryStub($superString)"; + } + + int get version => 0; +} + +const int kUrlLoaderInterceptor_interceptRequest_name = 0; +const int kUrlLoaderInterceptor_interceptFollowRedirect_name = 1; +const int kUrlLoaderInterceptor_interceptResponse_name = 2; + +const String UrlLoaderInterceptorName = + 'mojo::URLLoaderInterceptor'; + +abstract class UrlLoaderInterceptor { + dynamic interceptRequest(url_request_mojom.UrlRequest request,[Function responseFactory = null]); + dynamic interceptFollowRedirect([Function responseFactory = null]); + dynamic interceptResponse(url_response_mojom.UrlResponse response,[Function responseFactory = null]); + +} + + +class UrlLoaderInterceptorProxyImpl extends bindings.Proxy { + UrlLoaderInterceptorProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + UrlLoaderInterceptorProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + UrlLoaderInterceptorProxyImpl.unbound() : super.unbound(); + + static UrlLoaderInterceptorProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For UrlLoaderInterceptorProxyImpl")); + return new UrlLoaderInterceptorProxyImpl.fromEndpoint(endpoint); + } + + String get name => UrlLoaderInterceptorName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kUrlLoaderInterceptor_interceptRequest_name: + var r = UrlLoaderInterceptorInterceptRequestResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kUrlLoaderInterceptor_interceptFollowRedirect_name: + var r = UrlLoaderInterceptorInterceptFollowRedirectResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kUrlLoaderInterceptor_interceptResponse_name: + var r = UrlLoaderInterceptorInterceptResponseResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "UrlLoaderInterceptorProxyImpl($superString)"; + } +} + + +class _UrlLoaderInterceptorProxyCalls implements UrlLoaderInterceptor { + UrlLoaderInterceptorProxyImpl _proxyImpl; + + _UrlLoaderInterceptorProxyCalls(this._proxyImpl); + dynamic interceptRequest(url_request_mojom.UrlRequest request,[Function responseFactory = null]) { + var params = new UrlLoaderInterceptorInterceptRequestParams(); + params.request = request; + return _proxyImpl.sendMessageWithRequestId( + params, + kUrlLoaderInterceptor_interceptRequest_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic interceptFollowRedirect([Function responseFactory = null]) { + var params = new UrlLoaderInterceptorInterceptFollowRedirectParams(); + return _proxyImpl.sendMessageWithRequestId( + params, + kUrlLoaderInterceptor_interceptFollowRedirect_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic interceptResponse(url_response_mojom.UrlResponse response,[Function responseFactory = null]) { + var params = new UrlLoaderInterceptorInterceptResponseParams(); + params.response = response; + return _proxyImpl.sendMessageWithRequestId( + params, + kUrlLoaderInterceptor_interceptResponse_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class UrlLoaderInterceptorProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + UrlLoaderInterceptor ptr; + final String name = UrlLoaderInterceptorName; + + UrlLoaderInterceptorProxy(UrlLoaderInterceptorProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _UrlLoaderInterceptorProxyCalls(proxyImpl); + + UrlLoaderInterceptorProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new UrlLoaderInterceptorProxyImpl.fromEndpoint(endpoint) { + ptr = new _UrlLoaderInterceptorProxyCalls(impl); + } + + UrlLoaderInterceptorProxy.fromHandle(core.MojoHandle handle) : + impl = new UrlLoaderInterceptorProxyImpl.fromHandle(handle) { + ptr = new _UrlLoaderInterceptorProxyCalls(impl); + } + + UrlLoaderInterceptorProxy.unbound() : + impl = new UrlLoaderInterceptorProxyImpl.unbound() { + ptr = new _UrlLoaderInterceptorProxyCalls(impl); + } + + factory UrlLoaderInterceptorProxy.connectToService( + bindings.ServiceConnector s, String url) { + UrlLoaderInterceptorProxy p = new UrlLoaderInterceptorProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static UrlLoaderInterceptorProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For UrlLoaderInterceptorProxy")); + return new UrlLoaderInterceptorProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "UrlLoaderInterceptorProxy($impl)"; + } +} + + +class UrlLoaderInterceptorStub extends bindings.Stub { + UrlLoaderInterceptor _impl = null; + + UrlLoaderInterceptorStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + UrlLoaderInterceptorStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + UrlLoaderInterceptorStub.unbound() : super.unbound(); + + static UrlLoaderInterceptorStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For UrlLoaderInterceptorStub")); + return new UrlLoaderInterceptorStub.fromEndpoint(endpoint); + } + + static const String name = UrlLoaderInterceptorName; + + + UrlLoaderInterceptorInterceptRequestResponseParams _UrlLoaderInterceptorInterceptRequestResponseParamsFactory(UrlLoaderInterceptorResponse response) { + var result = new UrlLoaderInterceptorInterceptRequestResponseParams(); + result.response = response; + return result; + } + UrlLoaderInterceptorInterceptFollowRedirectResponseParams _UrlLoaderInterceptorInterceptFollowRedirectResponseParamsFactory(UrlLoaderInterceptorResponse response) { + var result = new UrlLoaderInterceptorInterceptFollowRedirectResponseParams(); + result.response = response; + return result; + } + UrlLoaderInterceptorInterceptResponseResponseParams _UrlLoaderInterceptorInterceptResponseResponseParamsFactory(UrlLoaderInterceptorResponse response) { + var result = new UrlLoaderInterceptorInterceptResponseResponseParams(); + result.response = response; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kUrlLoaderInterceptor_interceptRequest_name: + var params = UrlLoaderInterceptorInterceptRequestParams.deserialize( + message.payload); + var response = _impl.interceptRequest(params.request,_UrlLoaderInterceptorInterceptRequestResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kUrlLoaderInterceptor_interceptRequest_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kUrlLoaderInterceptor_interceptRequest_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kUrlLoaderInterceptor_interceptFollowRedirect_name: + var params = UrlLoaderInterceptorInterceptFollowRedirectParams.deserialize( + message.payload); + var response = _impl.interceptFollowRedirect(_UrlLoaderInterceptorInterceptFollowRedirectResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kUrlLoaderInterceptor_interceptFollowRedirect_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kUrlLoaderInterceptor_interceptFollowRedirect_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kUrlLoaderInterceptor_interceptResponse_name: + var params = UrlLoaderInterceptorInterceptResponseParams.deserialize( + message.payload); + var response = _impl.interceptResponse(params.response,_UrlLoaderInterceptorInterceptResponseResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kUrlLoaderInterceptor_interceptResponse_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kUrlLoaderInterceptor_interceptResponse_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + UrlLoaderInterceptor get impl => _impl; + set impl(UrlLoaderInterceptor d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "UrlLoaderInterceptorStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/url_response_disk_cache.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/url_response_disk_cache.mojom.dart new file mode 100644 index 0000000..a8d9a58 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/url_response_disk_cache.mojom.dart
@@ -0,0 +1,954 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library url_response_disk_cache_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo/mojo/url_response.mojom.dart' as url_response_mojom; + + + +class UrlResponseDiskCacheGetParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + String url = null; + + UrlResponseDiskCacheGetParams() : super(kVersions.last.size); + + static UrlResponseDiskCacheGetParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UrlResponseDiskCacheGetParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UrlResponseDiskCacheGetParams result = new UrlResponseDiskCacheGetParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.url = decoder0.decodeString(8, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(url, 8, false); + } + + String toString() { + return "UrlResponseDiskCacheGetParams(" + "url: $url" ")"; + } + + Map toJson() { + Map map = new Map(); + map["url"] = url; + return map; + } +} + + +class UrlResponseDiskCacheGetResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(32, 0) + ]; + url_response_mojom.UrlResponse response = null; + List<int> filePath = null; + List<int> cacheDirPath = null; + + UrlResponseDiskCacheGetResponseParams() : super(kVersions.last.size); + + static UrlResponseDiskCacheGetResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UrlResponseDiskCacheGetResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UrlResponseDiskCacheGetResponseParams result = new UrlResponseDiskCacheGetResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, true); + result.response = url_response_mojom.UrlResponse.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + result.filePath = decoder0.decodeUint8Array(16, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + } + if (mainDataHeader.version >= 0) { + + result.cacheDirPath = decoder0.decodeUint8Array(24, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(response, 8, true); + + encoder0.encodeUint8Array(filePath, 16, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + + encoder0.encodeUint8Array(cacheDirPath, 24, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + } + + String toString() { + return "UrlResponseDiskCacheGetResponseParams(" + "response: $response" ", " + "filePath: $filePath" ", " + "cacheDirPath: $cacheDirPath" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class UrlResponseDiskCacheValidateParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + String url = null; + + UrlResponseDiskCacheValidateParams() : super(kVersions.last.size); + + static UrlResponseDiskCacheValidateParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UrlResponseDiskCacheValidateParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UrlResponseDiskCacheValidateParams result = new UrlResponseDiskCacheValidateParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.url = decoder0.decodeString(8, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(url, 8, false); + } + + String toString() { + return "UrlResponseDiskCacheValidateParams(" + "url: $url" ")"; + } + + Map toJson() { + Map map = new Map(); + map["url"] = url; + return map; + } +} + + +class UrlResponseDiskCacheUpdateParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + url_response_mojom.UrlResponse response = null; + + UrlResponseDiskCacheUpdateParams() : super(kVersions.last.size); + + static UrlResponseDiskCacheUpdateParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UrlResponseDiskCacheUpdateParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UrlResponseDiskCacheUpdateParams result = new UrlResponseDiskCacheUpdateParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.response = url_response_mojom.UrlResponse.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(response, 8, false); + } + + String toString() { + return "UrlResponseDiskCacheUpdateParams(" + "response: $response" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class UrlResponseDiskCacheUpdateAndGetParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + url_response_mojom.UrlResponse response = null; + + UrlResponseDiskCacheUpdateAndGetParams() : super(kVersions.last.size); + + static UrlResponseDiskCacheUpdateAndGetParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UrlResponseDiskCacheUpdateAndGetParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UrlResponseDiskCacheUpdateAndGetParams result = new UrlResponseDiskCacheUpdateAndGetParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.response = url_response_mojom.UrlResponse.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(response, 8, false); + } + + String toString() { + return "UrlResponseDiskCacheUpdateAndGetParams(" + "response: $response" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class UrlResponseDiskCacheUpdateAndGetResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + List<int> filePath = null; + List<int> cacheDirPath = null; + + UrlResponseDiskCacheUpdateAndGetResponseParams() : super(kVersions.last.size); + + static UrlResponseDiskCacheUpdateAndGetResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UrlResponseDiskCacheUpdateAndGetResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UrlResponseDiskCacheUpdateAndGetResponseParams result = new UrlResponseDiskCacheUpdateAndGetResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.filePath = decoder0.decodeUint8Array(8, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + } + if (mainDataHeader.version >= 0) { + + result.cacheDirPath = decoder0.decodeUint8Array(16, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint8Array(filePath, 8, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + + encoder0.encodeUint8Array(cacheDirPath, 16, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + } + + String toString() { + return "UrlResponseDiskCacheUpdateAndGetResponseParams(" + "filePath: $filePath" ", " + "cacheDirPath: $cacheDirPath" ")"; + } + + Map toJson() { + Map map = new Map(); + map["filePath"] = filePath; + map["cacheDirPath"] = cacheDirPath; + return map; + } +} + + +class UrlResponseDiskCacheUpdateAndGetExtractedParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + url_response_mojom.UrlResponse response = null; + + UrlResponseDiskCacheUpdateAndGetExtractedParams() : super(kVersions.last.size); + + static UrlResponseDiskCacheUpdateAndGetExtractedParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UrlResponseDiskCacheUpdateAndGetExtractedParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UrlResponseDiskCacheUpdateAndGetExtractedParams result = new UrlResponseDiskCacheUpdateAndGetExtractedParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.response = url_response_mojom.UrlResponse.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(response, 8, false); + } + + String toString() { + return "UrlResponseDiskCacheUpdateAndGetExtractedParams(" + "response: $response" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class UrlResponseDiskCacheUpdateAndGetExtractedResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + List<int> extractedDirPath = null; + List<int> cacheDirPath = null; + + UrlResponseDiskCacheUpdateAndGetExtractedResponseParams() : super(kVersions.last.size); + + static UrlResponseDiskCacheUpdateAndGetExtractedResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UrlResponseDiskCacheUpdateAndGetExtractedResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UrlResponseDiskCacheUpdateAndGetExtractedResponseParams result = new UrlResponseDiskCacheUpdateAndGetExtractedResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.extractedDirPath = decoder0.decodeUint8Array(8, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + } + if (mainDataHeader.version >= 0) { + + result.cacheDirPath = decoder0.decodeUint8Array(16, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint8Array(extractedDirPath, 8, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + + encoder0.encodeUint8Array(cacheDirPath, 16, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + } + + String toString() { + return "UrlResponseDiskCacheUpdateAndGetExtractedResponseParams(" + "extractedDirPath: $extractedDirPath" ", " + "cacheDirPath: $cacheDirPath" ")"; + } + + Map toJson() { + Map map = new Map(); + map["extractedDirPath"] = extractedDirPath; + map["cacheDirPath"] = cacheDirPath; + return map; + } +} + +const int kUrlResponseDiskCache_get_name = 0; +const int kUrlResponseDiskCache_validate_name = 1; +const int kUrlResponseDiskCache_update_name = 2; +const int kUrlResponseDiskCache_updateAndGet_name = 3; +const int kUrlResponseDiskCache_updateAndGetExtracted_name = 4; + +const String UrlResponseDiskCacheName = + 'mojo::URLResponseDiskCache'; + +abstract class UrlResponseDiskCache { + dynamic get(String url,[Function responseFactory = null]); + void validate(String url); + void update(url_response_mojom.UrlResponse response); + dynamic updateAndGet(url_response_mojom.UrlResponse response,[Function responseFactory = null]); + dynamic updateAndGetExtracted(url_response_mojom.UrlResponse response,[Function responseFactory = null]); + +} + + +class UrlResponseDiskCacheProxyImpl extends bindings.Proxy { + UrlResponseDiskCacheProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + UrlResponseDiskCacheProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + UrlResponseDiskCacheProxyImpl.unbound() : super.unbound(); + + static UrlResponseDiskCacheProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For UrlResponseDiskCacheProxyImpl")); + return new UrlResponseDiskCacheProxyImpl.fromEndpoint(endpoint); + } + + String get name => UrlResponseDiskCacheName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kUrlResponseDiskCache_get_name: + var r = UrlResponseDiskCacheGetResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kUrlResponseDiskCache_updateAndGet_name: + var r = UrlResponseDiskCacheUpdateAndGetResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kUrlResponseDiskCache_updateAndGetExtracted_name: + var r = UrlResponseDiskCacheUpdateAndGetExtractedResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "UrlResponseDiskCacheProxyImpl($superString)"; + } +} + + +class _UrlResponseDiskCacheProxyCalls implements UrlResponseDiskCache { + UrlResponseDiskCacheProxyImpl _proxyImpl; + + _UrlResponseDiskCacheProxyCalls(this._proxyImpl); + dynamic get(String url,[Function responseFactory = null]) { + var params = new UrlResponseDiskCacheGetParams(); + params.url = url; + return _proxyImpl.sendMessageWithRequestId( + params, + kUrlResponseDiskCache_get_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + void validate(String url) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new UrlResponseDiskCacheValidateParams(); + params.url = url; + _proxyImpl.sendMessage(params, kUrlResponseDiskCache_validate_name); + } + + void update(url_response_mojom.UrlResponse response) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new UrlResponseDiskCacheUpdateParams(); + params.response = response; + _proxyImpl.sendMessage(params, kUrlResponseDiskCache_update_name); + } + + dynamic updateAndGet(url_response_mojom.UrlResponse response,[Function responseFactory = null]) { + var params = new UrlResponseDiskCacheUpdateAndGetParams(); + params.response = response; + return _proxyImpl.sendMessageWithRequestId( + params, + kUrlResponseDiskCache_updateAndGet_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic updateAndGetExtracted(url_response_mojom.UrlResponse response,[Function responseFactory = null]) { + var params = new UrlResponseDiskCacheUpdateAndGetExtractedParams(); + params.response = response; + return _proxyImpl.sendMessageWithRequestId( + params, + kUrlResponseDiskCache_updateAndGetExtracted_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class UrlResponseDiskCacheProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + UrlResponseDiskCache ptr; + final String name = UrlResponseDiskCacheName; + + UrlResponseDiskCacheProxy(UrlResponseDiskCacheProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _UrlResponseDiskCacheProxyCalls(proxyImpl); + + UrlResponseDiskCacheProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new UrlResponseDiskCacheProxyImpl.fromEndpoint(endpoint) { + ptr = new _UrlResponseDiskCacheProxyCalls(impl); + } + + UrlResponseDiskCacheProxy.fromHandle(core.MojoHandle handle) : + impl = new UrlResponseDiskCacheProxyImpl.fromHandle(handle) { + ptr = new _UrlResponseDiskCacheProxyCalls(impl); + } + + UrlResponseDiskCacheProxy.unbound() : + impl = new UrlResponseDiskCacheProxyImpl.unbound() { + ptr = new _UrlResponseDiskCacheProxyCalls(impl); + } + + factory UrlResponseDiskCacheProxy.connectToService( + bindings.ServiceConnector s, String url) { + UrlResponseDiskCacheProxy p = new UrlResponseDiskCacheProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static UrlResponseDiskCacheProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For UrlResponseDiskCacheProxy")); + return new UrlResponseDiskCacheProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "UrlResponseDiskCacheProxy($impl)"; + } +} + + +class UrlResponseDiskCacheStub extends bindings.Stub { + UrlResponseDiskCache _impl = null; + + UrlResponseDiskCacheStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + UrlResponseDiskCacheStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + UrlResponseDiskCacheStub.unbound() : super.unbound(); + + static UrlResponseDiskCacheStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For UrlResponseDiskCacheStub")); + return new UrlResponseDiskCacheStub.fromEndpoint(endpoint); + } + + static const String name = UrlResponseDiskCacheName; + + + UrlResponseDiskCacheGetResponseParams _UrlResponseDiskCacheGetResponseParamsFactory(url_response_mojom.UrlResponse response, List<int> filePath, List<int> cacheDirPath) { + var result = new UrlResponseDiskCacheGetResponseParams(); + result.response = response; + result.filePath = filePath; + result.cacheDirPath = cacheDirPath; + return result; + } + UrlResponseDiskCacheUpdateAndGetResponseParams _UrlResponseDiskCacheUpdateAndGetResponseParamsFactory(List<int> filePath, List<int> cacheDirPath) { + var result = new UrlResponseDiskCacheUpdateAndGetResponseParams(); + result.filePath = filePath; + result.cacheDirPath = cacheDirPath; + return result; + } + UrlResponseDiskCacheUpdateAndGetExtractedResponseParams _UrlResponseDiskCacheUpdateAndGetExtractedResponseParamsFactory(List<int> extractedDirPath, List<int> cacheDirPath) { + var result = new UrlResponseDiskCacheUpdateAndGetExtractedResponseParams(); + result.extractedDirPath = extractedDirPath; + result.cacheDirPath = cacheDirPath; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kUrlResponseDiskCache_get_name: + var params = UrlResponseDiskCacheGetParams.deserialize( + message.payload); + var response = _impl.get(params.url,_UrlResponseDiskCacheGetResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kUrlResponseDiskCache_get_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kUrlResponseDiskCache_get_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kUrlResponseDiskCache_validate_name: + var params = UrlResponseDiskCacheValidateParams.deserialize( + message.payload); + _impl.validate(params.url); + break; + case kUrlResponseDiskCache_update_name: + var params = UrlResponseDiskCacheUpdateParams.deserialize( + message.payload); + _impl.update(params.response); + break; + case kUrlResponseDiskCache_updateAndGet_name: + var params = UrlResponseDiskCacheUpdateAndGetParams.deserialize( + message.payload); + var response = _impl.updateAndGet(params.response,_UrlResponseDiskCacheUpdateAndGetResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kUrlResponseDiskCache_updateAndGet_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kUrlResponseDiskCache_updateAndGet_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kUrlResponseDiskCache_updateAndGetExtracted_name: + var params = UrlResponseDiskCacheUpdateAndGetExtractedParams.deserialize( + message.payload); + var response = _impl.updateAndGetExtracted(params.response,_UrlResponseDiskCacheUpdateAndGetExtractedResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kUrlResponseDiskCache_updateAndGetExtracted_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kUrlResponseDiskCache_updateAndGetExtracted_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + UrlResponseDiskCache get impl => _impl; + set impl(UrlResponseDiskCache d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "UrlResponseDiskCacheStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/view_manager.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/view_manager.mojom.dart new file mode 100644 index 0000000..de0dbc6 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/view_manager.mojom.dart
@@ -0,0 +1,4649 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library view_manager_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo_services/mojo/geometry.mojom.dart' as geometry_mojom; +import 'package:mojo_services/mojo/input_events.mojom.dart' as input_events_mojom; +import 'package:mojo/mojo/service_provider.mojom.dart' as service_provider_mojom; +import 'package:mojo_services/mojo/native_viewport.mojom.dart' as native_viewport_mojom; +import 'package:mojo_services/mojo/surface_id.mojom.dart' as surface_id_mojom; +import 'package:mojo_services/mojo/view_manager_constants.mojom.dart' as view_manager_constants_mojom; +class ErrorCode extends bindings.MojoEnum { + static const NONE = const ErrorCode._(0); + static const VALUE_IN_USE = const ErrorCode._(1); + static const ILLEGAL_ARGUMENT = const ErrorCode._(2); + + const ErrorCode._(int v) : super(v); + + static const Map<String, ErrorCode> valuesMap = const { + "NONE": NONE, + "VALUE_IN_USE": VALUE_IN_USE, + "ILLEGAL_ARGUMENT": ILLEGAL_ARGUMENT, + }; + static const List<ErrorCode> values = const [ + NONE, + VALUE_IN_USE, + ILLEGAL_ARGUMENT, + ]; + + static ErrorCode valueOf(String name) => valuesMap[name]; + + factory ErrorCode(int v) { + switch (v) { + case 0: + return NONE; + case 1: + return VALUE_IN_USE; + case 2: + return ILLEGAL_ARGUMENT; + default: + return null; + } + } + + static ErrorCode decode(bindings.Decoder decoder0, int offset) { + int v = decoder0.decodeUint32(offset); + ErrorCode result = new ErrorCode(v); + if (result == null) { + throw new bindings.MojoCodecError( + 'Bad value $v for enum ErrorCode.'); + } + return result; + } + + String toString() { + switch(this) { + case NONE: + return 'ErrorCode.NONE'; + case VALUE_IN_USE: + return 'ErrorCode.VALUE_IN_USE'; + case ILLEGAL_ARGUMENT: + return 'ErrorCode.ILLEGAL_ARGUMENT'; + } + } + + int toJson() => value; +} + + + +class ViewData extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(48, 0) + ]; + int parentId = 0; + int viewId = 0; + geometry_mojom.Rect bounds = null; + Map<String, List<int>> properties = null; + bool visible = false; + bool drawn = false; + native_viewport_mojom.ViewportMetrics viewportMetrics = null; + + ViewData() : super(kVersions.last.size); + + static ViewData deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewData decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewData result = new ViewData(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.parentId = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + result.viewId = decoder0.decodeUint32(12); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + result.bounds = geometry_mojom.Rect.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(24, false); + { + decoder1.decodeDataHeaderForMap(); + List<String> keys0; + List<List<int>> values0; + { + + var decoder2 = decoder1.decodePointer(bindings.ArrayDataHeader.kHeaderSize, false); + { + var si2 = decoder2.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + keys0 = new List<String>(si2.numElements); + for (int i2 = 0; i2 < si2.numElements; ++i2) { + + keys0[i2] = decoder2.decodeString(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i2, false); + } + } + } + { + + var decoder2 = decoder1.decodePointer(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize, false); + { + var si2 = decoder2.decodeDataHeaderForPointerArray(keys0.length); + values0 = new List<List<int>>(si2.numElements); + for (int i2 = 0; i2 < si2.numElements; ++i2) { + + values0[i2] = decoder2.decodeUint8Array(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i2, bindings.kNothingNullable, bindings.kUnspecifiedArrayLength); + } + } + } + result.properties = new Map<String, List<int>>.fromIterables( + keys0, values0); + } + } + if (mainDataHeader.version >= 0) { + + result.visible = decoder0.decodeBool(32, 0); + } + if (mainDataHeader.version >= 0) { + + result.drawn = decoder0.decodeBool(32, 1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(40, false); + result.viewportMetrics = native_viewport_mojom.ViewportMetrics.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(parentId, 8); + + encoder0.encodeUint32(viewId, 12); + + encoder0.encodeStruct(bounds, 16, false); + + if (properties == null) { + encoder0.encodeNullPointer(24, false); + } else { + var encoder1 = encoder0.encoderForMap(24); + int size0 = properties.length; + var keys0 = properties.keys.toList(); + var values0 = properties.values.toList(); + + { + var encoder2 = encoder1.encodePointerArray(keys0.length, bindings.ArrayDataHeader.kHeaderSize, bindings.kUnspecifiedArrayLength); + for (int i1 = 0; i1 < keys0.length; ++i1) { + + encoder2.encodeString(keys0[i1], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + } + } + + { + var encoder2 = encoder1.encodePointerArray(values0.length, bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize, bindings.kUnspecifiedArrayLength); + for (int i1 = 0; i1 < values0.length; ++i1) { + + encoder2.encodeUint8Array(values0[i1], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, bindings.kNothingNullable, bindings.kUnspecifiedArrayLength); + } + } + } + + encoder0.encodeBool(visible, 32, 0); + + encoder0.encodeBool(drawn, 32, 1); + + encoder0.encodeStruct(viewportMetrics, 40, false); + } + + String toString() { + return "ViewData(" + "parentId: $parentId" ", " + "viewId: $viewId" ", " + "bounds: $bounds" ", " + "properties: $properties" ", " + "visible: $visible" ", " + "drawn: $drawn" ", " + "viewportMetrics: $viewportMetrics" ")"; + } + + Map toJson() { + Map map = new Map(); + map["parentId"] = parentId; + map["viewId"] = viewId; + map["bounds"] = bounds; + map["properties"] = properties; + map["visible"] = visible; + map["drawn"] = drawn; + map["viewportMetrics"] = viewportMetrics; + return map; + } +} + + +class ViewManagerServiceCreateViewParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int viewId = 0; + + ViewManagerServiceCreateViewParams() : super(kVersions.last.size); + + static ViewManagerServiceCreateViewParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerServiceCreateViewParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerServiceCreateViewParams result = new ViewManagerServiceCreateViewParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.viewId = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(viewId, 8); + } + + String toString() { + return "ViewManagerServiceCreateViewParams(" + "viewId: $viewId" ")"; + } + + Map toJson() { + Map map = new Map(); + map["viewId"] = viewId; + return map; + } +} + + +class ViewManagerServiceCreateViewResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + ErrorCode errorCode = null; + + ViewManagerServiceCreateViewResponseParams() : super(kVersions.last.size); + + static ViewManagerServiceCreateViewResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerServiceCreateViewResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerServiceCreateViewResponseParams result = new ViewManagerServiceCreateViewResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.errorCode = ErrorCode.decode(decoder0, 8); + if (result.errorCode == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable ErrorCode.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(errorCode, 8); + } + + String toString() { + return "ViewManagerServiceCreateViewResponseParams(" + "errorCode: $errorCode" ")"; + } + + Map toJson() { + Map map = new Map(); + map["errorCode"] = errorCode; + return map; + } +} + + +class ViewManagerServiceDeleteViewParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int viewId = 0; + + ViewManagerServiceDeleteViewParams() : super(kVersions.last.size); + + static ViewManagerServiceDeleteViewParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerServiceDeleteViewParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerServiceDeleteViewParams result = new ViewManagerServiceDeleteViewParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.viewId = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(viewId, 8); + } + + String toString() { + return "ViewManagerServiceDeleteViewParams(" + "viewId: $viewId" ")"; + } + + Map toJson() { + Map map = new Map(); + map["viewId"] = viewId; + return map; + } +} + + +class ViewManagerServiceDeleteViewResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + bool success = false; + + ViewManagerServiceDeleteViewResponseParams() : super(kVersions.last.size); + + static ViewManagerServiceDeleteViewResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerServiceDeleteViewResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerServiceDeleteViewResponseParams result = new ViewManagerServiceDeleteViewResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.success = decoder0.decodeBool(8, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeBool(success, 8, 0); + } + + String toString() { + return "ViewManagerServiceDeleteViewResponseParams(" + "success: $success" ")"; + } + + Map toJson() { + Map map = new Map(); + map["success"] = success; + return map; + } +} + + +class ViewManagerServiceSetViewBoundsParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int viewId = 0; + geometry_mojom.Rect bounds = null; + + ViewManagerServiceSetViewBoundsParams() : super(kVersions.last.size); + + static ViewManagerServiceSetViewBoundsParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerServiceSetViewBoundsParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerServiceSetViewBoundsParams result = new ViewManagerServiceSetViewBoundsParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.viewId = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + result.bounds = geometry_mojom.Rect.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(viewId, 8); + + encoder0.encodeStruct(bounds, 16, false); + } + + String toString() { + return "ViewManagerServiceSetViewBoundsParams(" + "viewId: $viewId" ", " + "bounds: $bounds" ")"; + } + + Map toJson() { + Map map = new Map(); + map["viewId"] = viewId; + map["bounds"] = bounds; + return map; + } +} + + +class ViewManagerServiceSetViewBoundsResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + bool success = false; + + ViewManagerServiceSetViewBoundsResponseParams() : super(kVersions.last.size); + + static ViewManagerServiceSetViewBoundsResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerServiceSetViewBoundsResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerServiceSetViewBoundsResponseParams result = new ViewManagerServiceSetViewBoundsResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.success = decoder0.decodeBool(8, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeBool(success, 8, 0); + } + + String toString() { + return "ViewManagerServiceSetViewBoundsResponseParams(" + "success: $success" ")"; + } + + Map toJson() { + Map map = new Map(); + map["success"] = success; + return map; + } +} + + +class ViewManagerServiceSetViewVisibilityParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int viewId = 0; + bool visible = false; + + ViewManagerServiceSetViewVisibilityParams() : super(kVersions.last.size); + + static ViewManagerServiceSetViewVisibilityParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerServiceSetViewVisibilityParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerServiceSetViewVisibilityParams result = new ViewManagerServiceSetViewVisibilityParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.viewId = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + result.visible = decoder0.decodeBool(12, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(viewId, 8); + + encoder0.encodeBool(visible, 12, 0); + } + + String toString() { + return "ViewManagerServiceSetViewVisibilityParams(" + "viewId: $viewId" ", " + "visible: $visible" ")"; + } + + Map toJson() { + Map map = new Map(); + map["viewId"] = viewId; + map["visible"] = visible; + return map; + } +} + + +class ViewManagerServiceSetViewVisibilityResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + bool success = false; + + ViewManagerServiceSetViewVisibilityResponseParams() : super(kVersions.last.size); + + static ViewManagerServiceSetViewVisibilityResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerServiceSetViewVisibilityResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerServiceSetViewVisibilityResponseParams result = new ViewManagerServiceSetViewVisibilityResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.success = decoder0.decodeBool(8, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeBool(success, 8, 0); + } + + String toString() { + return "ViewManagerServiceSetViewVisibilityResponseParams(" + "success: $success" ")"; + } + + Map toJson() { + Map map = new Map(); + map["success"] = success; + return map; + } +} + + +class ViewManagerServiceSetViewPropertyParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(32, 0) + ]; + int viewId = 0; + String name = null; + List<int> value = null; + + ViewManagerServiceSetViewPropertyParams() : super(kVersions.last.size); + + static ViewManagerServiceSetViewPropertyParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerServiceSetViewPropertyParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerServiceSetViewPropertyParams result = new ViewManagerServiceSetViewPropertyParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.viewId = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + result.name = decoder0.decodeString(16, false); + } + if (mainDataHeader.version >= 0) { + + result.value = decoder0.decodeUint8Array(24, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(viewId, 8); + + encoder0.encodeString(name, 16, false); + + encoder0.encodeUint8Array(value, 24, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + } + + String toString() { + return "ViewManagerServiceSetViewPropertyParams(" + "viewId: $viewId" ", " + "name: $name" ", " + "value: $value" ")"; + } + + Map toJson() { + Map map = new Map(); + map["viewId"] = viewId; + map["name"] = name; + map["value"] = value; + return map; + } +} + + +class ViewManagerServiceSetViewPropertyResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + bool success = false; + + ViewManagerServiceSetViewPropertyResponseParams() : super(kVersions.last.size); + + static ViewManagerServiceSetViewPropertyResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerServiceSetViewPropertyResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerServiceSetViewPropertyResponseParams result = new ViewManagerServiceSetViewPropertyResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.success = decoder0.decodeBool(8, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeBool(success, 8, 0); + } + + String toString() { + return "ViewManagerServiceSetViewPropertyResponseParams(" + "success: $success" ")"; + } + + Map toJson() { + Map map = new Map(); + map["success"] = success; + return map; + } +} + + +class ViewManagerServiceAddViewParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int parent = 0; + int child = 0; + + ViewManagerServiceAddViewParams() : super(kVersions.last.size); + + static ViewManagerServiceAddViewParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerServiceAddViewParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerServiceAddViewParams result = new ViewManagerServiceAddViewParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.parent = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + result.child = decoder0.decodeUint32(12); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(parent, 8); + + encoder0.encodeUint32(child, 12); + } + + String toString() { + return "ViewManagerServiceAddViewParams(" + "parent: $parent" ", " + "child: $child" ")"; + } + + Map toJson() { + Map map = new Map(); + map["parent"] = parent; + map["child"] = child; + return map; + } +} + + +class ViewManagerServiceAddViewResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + bool success = false; + + ViewManagerServiceAddViewResponseParams() : super(kVersions.last.size); + + static ViewManagerServiceAddViewResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerServiceAddViewResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerServiceAddViewResponseParams result = new ViewManagerServiceAddViewResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.success = decoder0.decodeBool(8, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeBool(success, 8, 0); + } + + String toString() { + return "ViewManagerServiceAddViewResponseParams(" + "success: $success" ")"; + } + + Map toJson() { + Map map = new Map(); + map["success"] = success; + return map; + } +} + + +class ViewManagerServiceRemoveViewFromParentParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int viewId = 0; + + ViewManagerServiceRemoveViewFromParentParams() : super(kVersions.last.size); + + static ViewManagerServiceRemoveViewFromParentParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerServiceRemoveViewFromParentParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerServiceRemoveViewFromParentParams result = new ViewManagerServiceRemoveViewFromParentParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.viewId = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(viewId, 8); + } + + String toString() { + return "ViewManagerServiceRemoveViewFromParentParams(" + "viewId: $viewId" ")"; + } + + Map toJson() { + Map map = new Map(); + map["viewId"] = viewId; + return map; + } +} + + +class ViewManagerServiceRemoveViewFromParentResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + bool success = false; + + ViewManagerServiceRemoveViewFromParentResponseParams() : super(kVersions.last.size); + + static ViewManagerServiceRemoveViewFromParentResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerServiceRemoveViewFromParentResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerServiceRemoveViewFromParentResponseParams result = new ViewManagerServiceRemoveViewFromParentResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.success = decoder0.decodeBool(8, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeBool(success, 8, 0); + } + + String toString() { + return "ViewManagerServiceRemoveViewFromParentResponseParams(" + "success: $success" ")"; + } + + Map toJson() { + Map map = new Map(); + map["success"] = success; + return map; + } +} + + +class ViewManagerServiceReorderViewParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int viewId = 0; + int relativeViewId = 0; + view_manager_constants_mojom.OrderDirection direction = null; + + ViewManagerServiceReorderViewParams() : super(kVersions.last.size); + + static ViewManagerServiceReorderViewParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerServiceReorderViewParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerServiceReorderViewParams result = new ViewManagerServiceReorderViewParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.viewId = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + result.relativeViewId = decoder0.decodeUint32(12); + } + if (mainDataHeader.version >= 0) { + + result.direction = view_manager_constants_mojom.OrderDirection.decode(decoder0, 16); + if (result.direction == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable view_manager_constants_mojom.OrderDirection.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(viewId, 8); + + encoder0.encodeUint32(relativeViewId, 12); + + encoder0.encodeEnum(direction, 16); + } + + String toString() { + return "ViewManagerServiceReorderViewParams(" + "viewId: $viewId" ", " + "relativeViewId: $relativeViewId" ", " + "direction: $direction" ")"; + } + + Map toJson() { + Map map = new Map(); + map["viewId"] = viewId; + map["relativeViewId"] = relativeViewId; + map["direction"] = direction; + return map; + } +} + + +class ViewManagerServiceReorderViewResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + bool success = false; + + ViewManagerServiceReorderViewResponseParams() : super(kVersions.last.size); + + static ViewManagerServiceReorderViewResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerServiceReorderViewResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerServiceReorderViewResponseParams result = new ViewManagerServiceReorderViewResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.success = decoder0.decodeBool(8, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeBool(success, 8, 0); + } + + String toString() { + return "ViewManagerServiceReorderViewResponseParams(" + "success: $success" ")"; + } + + Map toJson() { + Map map = new Map(); + map["success"] = success; + return map; + } +} + + +class ViewManagerServiceGetViewTreeParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int viewId = 0; + + ViewManagerServiceGetViewTreeParams() : super(kVersions.last.size); + + static ViewManagerServiceGetViewTreeParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerServiceGetViewTreeParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerServiceGetViewTreeParams result = new ViewManagerServiceGetViewTreeParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.viewId = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(viewId, 8); + } + + String toString() { + return "ViewManagerServiceGetViewTreeParams(" + "viewId: $viewId" ")"; + } + + Map toJson() { + Map map = new Map(); + map["viewId"] = viewId; + return map; + } +} + + +class ViewManagerServiceGetViewTreeResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + List<ViewData> views = null; + + ViewManagerServiceGetViewTreeResponseParams() : super(kVersions.last.size); + + static ViewManagerServiceGetViewTreeResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerServiceGetViewTreeResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerServiceGetViewTreeResponseParams result = new ViewManagerServiceGetViewTreeResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.views = new List<ViewData>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + var decoder2 = decoder1.decodePointer(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + result.views[i1] = ViewData.decode(decoder2); + } + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + if (views == null) { + encoder0.encodeNullPointer(8, false); + } else { + var encoder1 = encoder0.encodePointerArray(views.length, 8, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < views.length; ++i0) { + + encoder1.encodeStruct(views[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + } + + String toString() { + return "ViewManagerServiceGetViewTreeResponseParams(" + "views: $views" ")"; + } + + Map toJson() { + Map map = new Map(); + map["views"] = views; + return map; + } +} + + +class ViewManagerServiceSetViewSurfaceIdParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int viewId = 0; + surface_id_mojom.SurfaceId surfaceId = null; + + ViewManagerServiceSetViewSurfaceIdParams() : super(kVersions.last.size); + + static ViewManagerServiceSetViewSurfaceIdParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerServiceSetViewSurfaceIdParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerServiceSetViewSurfaceIdParams result = new ViewManagerServiceSetViewSurfaceIdParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.viewId = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + result.surfaceId = surface_id_mojom.SurfaceId.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(viewId, 8); + + encoder0.encodeStruct(surfaceId, 16, false); + } + + String toString() { + return "ViewManagerServiceSetViewSurfaceIdParams(" + "viewId: $viewId" ", " + "surfaceId: $surfaceId" ")"; + } + + Map toJson() { + Map map = new Map(); + map["viewId"] = viewId; + map["surfaceId"] = surfaceId; + return map; + } +} + + +class ViewManagerServiceSetViewSurfaceIdResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + bool success = false; + + ViewManagerServiceSetViewSurfaceIdResponseParams() : super(kVersions.last.size); + + static ViewManagerServiceSetViewSurfaceIdResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerServiceSetViewSurfaceIdResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerServiceSetViewSurfaceIdResponseParams result = new ViewManagerServiceSetViewSurfaceIdResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.success = decoder0.decodeBool(8, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeBool(success, 8, 0); + } + + String toString() { + return "ViewManagerServiceSetViewSurfaceIdResponseParams(" + "success: $success" ")"; + } + + Map toJson() { + Map map = new Map(); + map["success"] = success; + return map; + } +} + + +class ViewManagerServiceEmbedUrlParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(32, 0) + ]; + String url = null; + int viewId = 0; + Object services = null; + Object exposedServices = null; + + ViewManagerServiceEmbedUrlParams() : super(kVersions.last.size); + + static ViewManagerServiceEmbedUrlParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerServiceEmbedUrlParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerServiceEmbedUrlParams result = new ViewManagerServiceEmbedUrlParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.url = decoder0.decodeString(8, false); + } + if (mainDataHeader.version >= 0) { + + result.viewId = decoder0.decodeUint32(16); + } + if (mainDataHeader.version >= 0) { + + result.services = decoder0.decodeInterfaceRequest(20, true, service_provider_mojom.ServiceProviderStub.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.exposedServices = decoder0.decodeServiceInterface(24, true, service_provider_mojom.ServiceProviderProxy.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(url, 8, false); + + encoder0.encodeUint32(viewId, 16); + + encoder0.encodeInterfaceRequest(services, 20, true); + + encoder0.encodeInterface(exposedServices, 24, true); + } + + String toString() { + return "ViewManagerServiceEmbedUrlParams(" + "url: $url" ", " + "viewId: $viewId" ", " + "services: $services" ", " + "exposedServices: $exposedServices" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class ViewManagerServiceEmbedUrlResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + bool success = false; + + ViewManagerServiceEmbedUrlResponseParams() : super(kVersions.last.size); + + static ViewManagerServiceEmbedUrlResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerServiceEmbedUrlResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerServiceEmbedUrlResponseParams result = new ViewManagerServiceEmbedUrlResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.success = decoder0.decodeBool(8, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeBool(success, 8, 0); + } + + String toString() { + return "ViewManagerServiceEmbedUrlResponseParams(" + "success: $success" ")"; + } + + Map toJson() { + Map map = new Map(); + map["success"] = success; + return map; + } +} + + +class ViewManagerServiceEmbedParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int viewId = 0; + Object client = null; + + ViewManagerServiceEmbedParams() : super(kVersions.last.size); + + static ViewManagerServiceEmbedParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerServiceEmbedParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerServiceEmbedParams result = new ViewManagerServiceEmbedParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.viewId = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + result.client = decoder0.decodeServiceInterface(12, false, ViewManagerClientProxy.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(viewId, 8); + + encoder0.encodeInterface(client, 12, false); + } + + String toString() { + return "ViewManagerServiceEmbedParams(" + "viewId: $viewId" ", " + "client: $client" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class ViewManagerServiceEmbedResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + bool success = false; + + ViewManagerServiceEmbedResponseParams() : super(kVersions.last.size); + + static ViewManagerServiceEmbedResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerServiceEmbedResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerServiceEmbedResponseParams result = new ViewManagerServiceEmbedResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.success = decoder0.decodeBool(8, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeBool(success, 8, 0); + } + + String toString() { + return "ViewManagerServiceEmbedResponseParams(" + "success: $success" ")"; + } + + Map toJson() { + Map map = new Map(); + map["success"] = success; + return map; + } +} + + +class ViewManagerServicePerformActionParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int viewId = 0; + String action = null; + + ViewManagerServicePerformActionParams() : super(kVersions.last.size); + + static ViewManagerServicePerformActionParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerServicePerformActionParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerServicePerformActionParams result = new ViewManagerServicePerformActionParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.viewId = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + result.action = decoder0.decodeString(16, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(viewId, 8); + + encoder0.encodeString(action, 16, false); + } + + String toString() { + return "ViewManagerServicePerformActionParams(" + "viewId: $viewId" ", " + "action: $action" ")"; + } + + Map toJson() { + Map map = new Map(); + map["viewId"] = viewId; + map["action"] = action; + return map; + } +} + + +class ViewManagerServicePerformActionResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + bool success = false; + + ViewManagerServicePerformActionResponseParams() : super(kVersions.last.size); + + static ViewManagerServicePerformActionResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerServicePerformActionResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerServicePerformActionResponseParams result = new ViewManagerServicePerformActionResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.success = decoder0.decodeBool(8, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeBool(success, 8, 0); + } + + String toString() { + return "ViewManagerServicePerformActionResponseParams(" + "success: $success" ")"; + } + + Map toJson() { + Map map = new Map(); + map["success"] = success; + return map; + } +} + + +class ViewManagerClientOnEmbedParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(56, 0) + ]; + int connectionId = 0; + Object services = null; + String embedderUrl = null; + ViewData root = null; + Object viewManagerService = null; + Object exposedServices = null; + core.MojoMessagePipeEndpoint windowManagerPipe = null; + + ViewManagerClientOnEmbedParams() : super(kVersions.last.size); + + static ViewManagerClientOnEmbedParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerClientOnEmbedParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerClientOnEmbedParams result = new ViewManagerClientOnEmbedParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.connectionId = decoder0.decodeUint16(8); + } + if (mainDataHeader.version >= 0) { + + result.services = decoder0.decodeInterfaceRequest(12, true, service_provider_mojom.ServiceProviderStub.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.embedderUrl = decoder0.decodeString(16, false); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(24, false); + result.root = ViewData.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + result.viewManagerService = decoder0.decodeServiceInterface(32, true, ViewManagerServiceProxy.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.exposedServices = decoder0.decodeServiceInterface(40, true, service_provider_mojom.ServiceProviderProxy.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.windowManagerPipe = decoder0.decodeMessagePipeHandle(48, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint16(connectionId, 8); + + encoder0.encodeInterfaceRequest(services, 12, true); + + encoder0.encodeString(embedderUrl, 16, false); + + encoder0.encodeStruct(root, 24, false); + + encoder0.encodeInterface(viewManagerService, 32, true); + + encoder0.encodeInterface(exposedServices, 40, true); + + encoder0.encodeMessagePipeHandle(windowManagerPipe, 48, false); + } + + String toString() { + return "ViewManagerClientOnEmbedParams(" + "connectionId: $connectionId" ", " + "services: $services" ", " + "embedderUrl: $embedderUrl" ", " + "root: $root" ", " + "viewManagerService: $viewManagerService" ", " + "exposedServices: $exposedServices" ", " + "windowManagerPipe: $windowManagerPipe" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class ViewManagerClientOnEmbeddedAppDisconnectedParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int view = 0; + + ViewManagerClientOnEmbeddedAppDisconnectedParams() : super(kVersions.last.size); + + static ViewManagerClientOnEmbeddedAppDisconnectedParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerClientOnEmbeddedAppDisconnectedParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerClientOnEmbeddedAppDisconnectedParams result = new ViewManagerClientOnEmbeddedAppDisconnectedParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.view = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(view, 8); + } + + String toString() { + return "ViewManagerClientOnEmbeddedAppDisconnectedParams(" + "view: $view" ")"; + } + + Map toJson() { + Map map = new Map(); + map["view"] = view; + return map; + } +} + + +class ViewManagerClientOnViewBoundsChangedParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(32, 0) + ]; + int view = 0; + geometry_mojom.Rect oldBounds = null; + geometry_mojom.Rect newBounds = null; + + ViewManagerClientOnViewBoundsChangedParams() : super(kVersions.last.size); + + static ViewManagerClientOnViewBoundsChangedParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerClientOnViewBoundsChangedParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerClientOnViewBoundsChangedParams result = new ViewManagerClientOnViewBoundsChangedParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.view = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + result.oldBounds = geometry_mojom.Rect.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(24, false); + result.newBounds = geometry_mojom.Rect.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(view, 8); + + encoder0.encodeStruct(oldBounds, 16, false); + + encoder0.encodeStruct(newBounds, 24, false); + } + + String toString() { + return "ViewManagerClientOnViewBoundsChangedParams(" + "view: $view" ", " + "oldBounds: $oldBounds" ", " + "newBounds: $newBounds" ")"; + } + + Map toJson() { + Map map = new Map(); + map["view"] = view; + map["oldBounds"] = oldBounds; + map["newBounds"] = newBounds; + return map; + } +} + + +class ViewManagerClientOnViewViewportMetricsChangedParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + native_viewport_mojom.ViewportMetrics oldMetrics = null; + native_viewport_mojom.ViewportMetrics newMetrics = null; + + ViewManagerClientOnViewViewportMetricsChangedParams() : super(kVersions.last.size); + + static ViewManagerClientOnViewViewportMetricsChangedParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerClientOnViewViewportMetricsChangedParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerClientOnViewViewportMetricsChangedParams result = new ViewManagerClientOnViewViewportMetricsChangedParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.oldMetrics = native_viewport_mojom.ViewportMetrics.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + result.newMetrics = native_viewport_mojom.ViewportMetrics.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(oldMetrics, 8, false); + + encoder0.encodeStruct(newMetrics, 16, false); + } + + String toString() { + return "ViewManagerClientOnViewViewportMetricsChangedParams(" + "oldMetrics: $oldMetrics" ", " + "newMetrics: $newMetrics" ")"; + } + + Map toJson() { + Map map = new Map(); + map["oldMetrics"] = oldMetrics; + map["newMetrics"] = newMetrics; + return map; + } +} + + +class ViewManagerClientOnViewHierarchyChangedParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(32, 0) + ]; + int view = 0; + int newParent = 0; + int oldParent = 0; + List<ViewData> views = null; + + ViewManagerClientOnViewHierarchyChangedParams() : super(kVersions.last.size); + + static ViewManagerClientOnViewHierarchyChangedParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerClientOnViewHierarchyChangedParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerClientOnViewHierarchyChangedParams result = new ViewManagerClientOnViewHierarchyChangedParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.view = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + result.newParent = decoder0.decodeUint32(12); + } + if (mainDataHeader.version >= 0) { + + result.oldParent = decoder0.decodeUint32(16); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(24, false); + { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.views = new List<ViewData>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + var decoder2 = decoder1.decodePointer(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + result.views[i1] = ViewData.decode(decoder2); + } + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(view, 8); + + encoder0.encodeUint32(newParent, 12); + + encoder0.encodeUint32(oldParent, 16); + + if (views == null) { + encoder0.encodeNullPointer(24, false); + } else { + var encoder1 = encoder0.encodePointerArray(views.length, 24, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < views.length; ++i0) { + + encoder1.encodeStruct(views[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + } + + String toString() { + return "ViewManagerClientOnViewHierarchyChangedParams(" + "view: $view" ", " + "newParent: $newParent" ", " + "oldParent: $oldParent" ", " + "views: $views" ")"; + } + + Map toJson() { + Map map = new Map(); + map["view"] = view; + map["newParent"] = newParent; + map["oldParent"] = oldParent; + map["views"] = views; + return map; + } +} + + +class ViewManagerClientOnViewReorderedParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int viewId = 0; + int relativeViewId = 0; + view_manager_constants_mojom.OrderDirection direction = null; + + ViewManagerClientOnViewReorderedParams() : super(kVersions.last.size); + + static ViewManagerClientOnViewReorderedParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerClientOnViewReorderedParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerClientOnViewReorderedParams result = new ViewManagerClientOnViewReorderedParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.viewId = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + result.relativeViewId = decoder0.decodeUint32(12); + } + if (mainDataHeader.version >= 0) { + + result.direction = view_manager_constants_mojom.OrderDirection.decode(decoder0, 16); + if (result.direction == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable view_manager_constants_mojom.OrderDirection.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(viewId, 8); + + encoder0.encodeUint32(relativeViewId, 12); + + encoder0.encodeEnum(direction, 16); + } + + String toString() { + return "ViewManagerClientOnViewReorderedParams(" + "viewId: $viewId" ", " + "relativeViewId: $relativeViewId" ", " + "direction: $direction" ")"; + } + + Map toJson() { + Map map = new Map(); + map["viewId"] = viewId; + map["relativeViewId"] = relativeViewId; + map["direction"] = direction; + return map; + } +} + + +class ViewManagerClientOnViewDeletedParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int view = 0; + + ViewManagerClientOnViewDeletedParams() : super(kVersions.last.size); + + static ViewManagerClientOnViewDeletedParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerClientOnViewDeletedParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerClientOnViewDeletedParams result = new ViewManagerClientOnViewDeletedParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.view = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(view, 8); + } + + String toString() { + return "ViewManagerClientOnViewDeletedParams(" + "view: $view" ")"; + } + + Map toJson() { + Map map = new Map(); + map["view"] = view; + return map; + } +} + + +class ViewManagerClientOnViewVisibilityChangedParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int view = 0; + bool visible = false; + + ViewManagerClientOnViewVisibilityChangedParams() : super(kVersions.last.size); + + static ViewManagerClientOnViewVisibilityChangedParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerClientOnViewVisibilityChangedParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerClientOnViewVisibilityChangedParams result = new ViewManagerClientOnViewVisibilityChangedParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.view = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + result.visible = decoder0.decodeBool(12, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(view, 8); + + encoder0.encodeBool(visible, 12, 0); + } + + String toString() { + return "ViewManagerClientOnViewVisibilityChangedParams(" + "view: $view" ", " + "visible: $visible" ")"; + } + + Map toJson() { + Map map = new Map(); + map["view"] = view; + map["visible"] = visible; + return map; + } +} + + +class ViewManagerClientOnViewDrawnStateChangedParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int view = 0; + bool drawn = false; + + ViewManagerClientOnViewDrawnStateChangedParams() : super(kVersions.last.size); + + static ViewManagerClientOnViewDrawnStateChangedParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerClientOnViewDrawnStateChangedParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerClientOnViewDrawnStateChangedParams result = new ViewManagerClientOnViewDrawnStateChangedParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.view = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + result.drawn = decoder0.decodeBool(12, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(view, 8); + + encoder0.encodeBool(drawn, 12, 0); + } + + String toString() { + return "ViewManagerClientOnViewDrawnStateChangedParams(" + "view: $view" ", " + "drawn: $drawn" ")"; + } + + Map toJson() { + Map map = new Map(); + map["view"] = view; + map["drawn"] = drawn; + return map; + } +} + + +class ViewManagerClientOnViewSharedPropertyChangedParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(32, 0) + ]; + int view = 0; + String name = null; + List<int> newData = null; + + ViewManagerClientOnViewSharedPropertyChangedParams() : super(kVersions.last.size); + + static ViewManagerClientOnViewSharedPropertyChangedParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerClientOnViewSharedPropertyChangedParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerClientOnViewSharedPropertyChangedParams result = new ViewManagerClientOnViewSharedPropertyChangedParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.view = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + result.name = decoder0.decodeString(16, false); + } + if (mainDataHeader.version >= 0) { + + result.newData = decoder0.decodeUint8Array(24, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(view, 8); + + encoder0.encodeString(name, 16, false); + + encoder0.encodeUint8Array(newData, 24, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + } + + String toString() { + return "ViewManagerClientOnViewSharedPropertyChangedParams(" + "view: $view" ", " + "name: $name" ", " + "newData: $newData" ")"; + } + + Map toJson() { + Map map = new Map(); + map["view"] = view; + map["name"] = name; + map["newData"] = newData; + return map; + } +} + + +class ViewManagerClientOnViewInputEventParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int view = 0; + input_events_mojom.Event event = null; + + ViewManagerClientOnViewInputEventParams() : super(kVersions.last.size); + + static ViewManagerClientOnViewInputEventParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerClientOnViewInputEventParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerClientOnViewInputEventParams result = new ViewManagerClientOnViewInputEventParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.view = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + result.event = input_events_mojom.Event.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(view, 8); + + encoder0.encodeStruct(event, 16, false); + } + + String toString() { + return "ViewManagerClientOnViewInputEventParams(" + "view: $view" ", " + "event: $event" ")"; + } + + Map toJson() { + Map map = new Map(); + map["view"] = view; + map["event"] = event; + return map; + } +} + + +class ViewManagerClientOnViewInputEventResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + ViewManagerClientOnViewInputEventResponseParams() : super(kVersions.last.size); + + static ViewManagerClientOnViewInputEventResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerClientOnViewInputEventResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerClientOnViewInputEventResponseParams result = new ViewManagerClientOnViewInputEventResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "ViewManagerClientOnViewInputEventResponseParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class ViewManagerClientOnPerformActionParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int viewId = 0; + String action = null; + + ViewManagerClientOnPerformActionParams() : super(kVersions.last.size); + + static ViewManagerClientOnPerformActionParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerClientOnPerformActionParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerClientOnPerformActionParams result = new ViewManagerClientOnPerformActionParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.viewId = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + result.action = decoder0.decodeString(16, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(viewId, 8); + + encoder0.encodeString(action, 16, false); + } + + String toString() { + return "ViewManagerClientOnPerformActionParams(" + "viewId: $viewId" ", " + "action: $action" ")"; + } + + Map toJson() { + Map map = new Map(); + map["viewId"] = viewId; + map["action"] = action; + return map; + } +} + + +class ViewManagerClientOnPerformActionResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + bool success = false; + + ViewManagerClientOnPerformActionResponseParams() : super(kVersions.last.size); + + static ViewManagerClientOnPerformActionResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewManagerClientOnPerformActionResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewManagerClientOnPerformActionResponseParams result = new ViewManagerClientOnPerformActionResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.success = decoder0.decodeBool(8, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeBool(success, 8, 0); + } + + String toString() { + return "ViewManagerClientOnPerformActionResponseParams(" + "success: $success" ")"; + } + + Map toJson() { + Map map = new Map(); + map["success"] = success; + return map; + } +} + +const int kViewManagerService_createView_name = 0; +const int kViewManagerService_deleteView_name = 1; +const int kViewManagerService_setViewBounds_name = 2; +const int kViewManagerService_setViewVisibility_name = 3; +const int kViewManagerService_setViewProperty_name = 4; +const int kViewManagerService_addView_name = 5; +const int kViewManagerService_removeViewFromParent_name = 6; +const int kViewManagerService_reorderView_name = 7; +const int kViewManagerService_getViewTree_name = 8; +const int kViewManagerService_setViewSurfaceId_name = 9; +const int kViewManagerService_embedUrl_name = 10; +const int kViewManagerService_embed_name = 11; +const int kViewManagerService_performAction_name = 12; + +const String ViewManagerServiceName = + 'mojo::ViewManagerService'; + +abstract class ViewManagerService { + dynamic createView(int viewId,[Function responseFactory = null]); + dynamic deleteView(int viewId,[Function responseFactory = null]); + dynamic setViewBounds(int viewId,geometry_mojom.Rect bounds,[Function responseFactory = null]); + dynamic setViewVisibility(int viewId,bool visible,[Function responseFactory = null]); + dynamic setViewProperty(int viewId,String name,List<int> value,[Function responseFactory = null]); + dynamic addView(int parent,int child,[Function responseFactory = null]); + dynamic removeViewFromParent(int viewId,[Function responseFactory = null]); + dynamic reorderView(int viewId,int relativeViewId,view_manager_constants_mojom.OrderDirection direction,[Function responseFactory = null]); + dynamic getViewTree(int viewId,[Function responseFactory = null]); + dynamic setViewSurfaceId(int viewId,surface_id_mojom.SurfaceId surfaceId,[Function responseFactory = null]); + dynamic embedUrl(String url,int viewId,Object services,Object exposedServices,[Function responseFactory = null]); + dynamic embed(int viewId,Object client,[Function responseFactory = null]); + dynamic performAction(int viewId,String action,[Function responseFactory = null]); + +} + + +class ViewManagerServiceProxyImpl extends bindings.Proxy { + ViewManagerServiceProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + ViewManagerServiceProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + ViewManagerServiceProxyImpl.unbound() : super.unbound(); + + static ViewManagerServiceProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ViewManagerServiceProxyImpl")); + return new ViewManagerServiceProxyImpl.fromEndpoint(endpoint); + } + + String get name => ViewManagerServiceName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kViewManagerService_createView_name: + var r = ViewManagerServiceCreateViewResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kViewManagerService_deleteView_name: + var r = ViewManagerServiceDeleteViewResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kViewManagerService_setViewBounds_name: + var r = ViewManagerServiceSetViewBoundsResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kViewManagerService_setViewVisibility_name: + var r = ViewManagerServiceSetViewVisibilityResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kViewManagerService_setViewProperty_name: + var r = ViewManagerServiceSetViewPropertyResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kViewManagerService_addView_name: + var r = ViewManagerServiceAddViewResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kViewManagerService_removeViewFromParent_name: + var r = ViewManagerServiceRemoveViewFromParentResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kViewManagerService_reorderView_name: + var r = ViewManagerServiceReorderViewResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kViewManagerService_getViewTree_name: + var r = ViewManagerServiceGetViewTreeResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kViewManagerService_setViewSurfaceId_name: + var r = ViewManagerServiceSetViewSurfaceIdResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kViewManagerService_embedUrl_name: + var r = ViewManagerServiceEmbedUrlResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kViewManagerService_embed_name: + var r = ViewManagerServiceEmbedResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kViewManagerService_performAction_name: + var r = ViewManagerServicePerformActionResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "ViewManagerServiceProxyImpl($superString)"; + } +} + + +class _ViewManagerServiceProxyCalls implements ViewManagerService { + ViewManagerServiceProxyImpl _proxyImpl; + + _ViewManagerServiceProxyCalls(this._proxyImpl); + dynamic createView(int viewId,[Function responseFactory = null]) { + var params = new ViewManagerServiceCreateViewParams(); + params.viewId = viewId; + return _proxyImpl.sendMessageWithRequestId( + params, + kViewManagerService_createView_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic deleteView(int viewId,[Function responseFactory = null]) { + var params = new ViewManagerServiceDeleteViewParams(); + params.viewId = viewId; + return _proxyImpl.sendMessageWithRequestId( + params, + kViewManagerService_deleteView_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic setViewBounds(int viewId,geometry_mojom.Rect bounds,[Function responseFactory = null]) { + var params = new ViewManagerServiceSetViewBoundsParams(); + params.viewId = viewId; + params.bounds = bounds; + return _proxyImpl.sendMessageWithRequestId( + params, + kViewManagerService_setViewBounds_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic setViewVisibility(int viewId,bool visible,[Function responseFactory = null]) { + var params = new ViewManagerServiceSetViewVisibilityParams(); + params.viewId = viewId; + params.visible = visible; + return _proxyImpl.sendMessageWithRequestId( + params, + kViewManagerService_setViewVisibility_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic setViewProperty(int viewId,String name,List<int> value,[Function responseFactory = null]) { + var params = new ViewManagerServiceSetViewPropertyParams(); + params.viewId = viewId; + params.name = name; + params.value = value; + return _proxyImpl.sendMessageWithRequestId( + params, + kViewManagerService_setViewProperty_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic addView(int parent,int child,[Function responseFactory = null]) { + var params = new ViewManagerServiceAddViewParams(); + params.parent = parent; + params.child = child; + return _proxyImpl.sendMessageWithRequestId( + params, + kViewManagerService_addView_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic removeViewFromParent(int viewId,[Function responseFactory = null]) { + var params = new ViewManagerServiceRemoveViewFromParentParams(); + params.viewId = viewId; + return _proxyImpl.sendMessageWithRequestId( + params, + kViewManagerService_removeViewFromParent_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic reorderView(int viewId,int relativeViewId,view_manager_constants_mojom.OrderDirection direction,[Function responseFactory = null]) { + var params = new ViewManagerServiceReorderViewParams(); + params.viewId = viewId; + params.relativeViewId = relativeViewId; + params.direction = direction; + return _proxyImpl.sendMessageWithRequestId( + params, + kViewManagerService_reorderView_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic getViewTree(int viewId,[Function responseFactory = null]) { + var params = new ViewManagerServiceGetViewTreeParams(); + params.viewId = viewId; + return _proxyImpl.sendMessageWithRequestId( + params, + kViewManagerService_getViewTree_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic setViewSurfaceId(int viewId,surface_id_mojom.SurfaceId surfaceId,[Function responseFactory = null]) { + var params = new ViewManagerServiceSetViewSurfaceIdParams(); + params.viewId = viewId; + params.surfaceId = surfaceId; + return _proxyImpl.sendMessageWithRequestId( + params, + kViewManagerService_setViewSurfaceId_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic embedUrl(String url,int viewId,Object services,Object exposedServices,[Function responseFactory = null]) { + var params = new ViewManagerServiceEmbedUrlParams(); + params.url = url; + params.viewId = viewId; + params.services = services; + params.exposedServices = exposedServices; + return _proxyImpl.sendMessageWithRequestId( + params, + kViewManagerService_embedUrl_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic embed(int viewId,Object client,[Function responseFactory = null]) { + var params = new ViewManagerServiceEmbedParams(); + params.viewId = viewId; + params.client = client; + return _proxyImpl.sendMessageWithRequestId( + params, + kViewManagerService_embed_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic performAction(int viewId,String action,[Function responseFactory = null]) { + var params = new ViewManagerServicePerformActionParams(); + params.viewId = viewId; + params.action = action; + return _proxyImpl.sendMessageWithRequestId( + params, + kViewManagerService_performAction_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class ViewManagerServiceProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + ViewManagerService ptr; + final String name = ViewManagerServiceName; + + ViewManagerServiceProxy(ViewManagerServiceProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _ViewManagerServiceProxyCalls(proxyImpl); + + ViewManagerServiceProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new ViewManagerServiceProxyImpl.fromEndpoint(endpoint) { + ptr = new _ViewManagerServiceProxyCalls(impl); + } + + ViewManagerServiceProxy.fromHandle(core.MojoHandle handle) : + impl = new ViewManagerServiceProxyImpl.fromHandle(handle) { + ptr = new _ViewManagerServiceProxyCalls(impl); + } + + ViewManagerServiceProxy.unbound() : + impl = new ViewManagerServiceProxyImpl.unbound() { + ptr = new _ViewManagerServiceProxyCalls(impl); + } + + factory ViewManagerServiceProxy.connectToService( + bindings.ServiceConnector s, String url) { + ViewManagerServiceProxy p = new ViewManagerServiceProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static ViewManagerServiceProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ViewManagerServiceProxy")); + return new ViewManagerServiceProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "ViewManagerServiceProxy($impl)"; + } +} + + +class ViewManagerServiceStub extends bindings.Stub { + ViewManagerService _impl = null; + + ViewManagerServiceStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + ViewManagerServiceStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + ViewManagerServiceStub.unbound() : super.unbound(); + + static ViewManagerServiceStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ViewManagerServiceStub")); + return new ViewManagerServiceStub.fromEndpoint(endpoint); + } + + static const String name = ViewManagerServiceName; + + + ViewManagerServiceCreateViewResponseParams _ViewManagerServiceCreateViewResponseParamsFactory(ErrorCode errorCode) { + var result = new ViewManagerServiceCreateViewResponseParams(); + result.errorCode = errorCode; + return result; + } + ViewManagerServiceDeleteViewResponseParams _ViewManagerServiceDeleteViewResponseParamsFactory(bool success) { + var result = new ViewManagerServiceDeleteViewResponseParams(); + result.success = success; + return result; + } + ViewManagerServiceSetViewBoundsResponseParams _ViewManagerServiceSetViewBoundsResponseParamsFactory(bool success) { + var result = new ViewManagerServiceSetViewBoundsResponseParams(); + result.success = success; + return result; + } + ViewManagerServiceSetViewVisibilityResponseParams _ViewManagerServiceSetViewVisibilityResponseParamsFactory(bool success) { + var result = new ViewManagerServiceSetViewVisibilityResponseParams(); + result.success = success; + return result; + } + ViewManagerServiceSetViewPropertyResponseParams _ViewManagerServiceSetViewPropertyResponseParamsFactory(bool success) { + var result = new ViewManagerServiceSetViewPropertyResponseParams(); + result.success = success; + return result; + } + ViewManagerServiceAddViewResponseParams _ViewManagerServiceAddViewResponseParamsFactory(bool success) { + var result = new ViewManagerServiceAddViewResponseParams(); + result.success = success; + return result; + } + ViewManagerServiceRemoveViewFromParentResponseParams _ViewManagerServiceRemoveViewFromParentResponseParamsFactory(bool success) { + var result = new ViewManagerServiceRemoveViewFromParentResponseParams(); + result.success = success; + return result; + } + ViewManagerServiceReorderViewResponseParams _ViewManagerServiceReorderViewResponseParamsFactory(bool success) { + var result = new ViewManagerServiceReorderViewResponseParams(); + result.success = success; + return result; + } + ViewManagerServiceGetViewTreeResponseParams _ViewManagerServiceGetViewTreeResponseParamsFactory(List<ViewData> views) { + var result = new ViewManagerServiceGetViewTreeResponseParams(); + result.views = views; + return result; + } + ViewManagerServiceSetViewSurfaceIdResponseParams _ViewManagerServiceSetViewSurfaceIdResponseParamsFactory(bool success) { + var result = new ViewManagerServiceSetViewSurfaceIdResponseParams(); + result.success = success; + return result; + } + ViewManagerServiceEmbedUrlResponseParams _ViewManagerServiceEmbedUrlResponseParamsFactory(bool success) { + var result = new ViewManagerServiceEmbedUrlResponseParams(); + result.success = success; + return result; + } + ViewManagerServiceEmbedResponseParams _ViewManagerServiceEmbedResponseParamsFactory(bool success) { + var result = new ViewManagerServiceEmbedResponseParams(); + result.success = success; + return result; + } + ViewManagerServicePerformActionResponseParams _ViewManagerServicePerformActionResponseParamsFactory(bool success) { + var result = new ViewManagerServicePerformActionResponseParams(); + result.success = success; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kViewManagerService_createView_name: + var params = ViewManagerServiceCreateViewParams.deserialize( + message.payload); + var response = _impl.createView(params.viewId,_ViewManagerServiceCreateViewResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kViewManagerService_createView_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kViewManagerService_createView_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kViewManagerService_deleteView_name: + var params = ViewManagerServiceDeleteViewParams.deserialize( + message.payload); + var response = _impl.deleteView(params.viewId,_ViewManagerServiceDeleteViewResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kViewManagerService_deleteView_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kViewManagerService_deleteView_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kViewManagerService_setViewBounds_name: + var params = ViewManagerServiceSetViewBoundsParams.deserialize( + message.payload); + var response = _impl.setViewBounds(params.viewId,params.bounds,_ViewManagerServiceSetViewBoundsResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kViewManagerService_setViewBounds_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kViewManagerService_setViewBounds_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kViewManagerService_setViewVisibility_name: + var params = ViewManagerServiceSetViewVisibilityParams.deserialize( + message.payload); + var response = _impl.setViewVisibility(params.viewId,params.visible,_ViewManagerServiceSetViewVisibilityResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kViewManagerService_setViewVisibility_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kViewManagerService_setViewVisibility_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kViewManagerService_setViewProperty_name: + var params = ViewManagerServiceSetViewPropertyParams.deserialize( + message.payload); + var response = _impl.setViewProperty(params.viewId,params.name,params.value,_ViewManagerServiceSetViewPropertyResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kViewManagerService_setViewProperty_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kViewManagerService_setViewProperty_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kViewManagerService_addView_name: + var params = ViewManagerServiceAddViewParams.deserialize( + message.payload); + var response = _impl.addView(params.parent,params.child,_ViewManagerServiceAddViewResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kViewManagerService_addView_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kViewManagerService_addView_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kViewManagerService_removeViewFromParent_name: + var params = ViewManagerServiceRemoveViewFromParentParams.deserialize( + message.payload); + var response = _impl.removeViewFromParent(params.viewId,_ViewManagerServiceRemoveViewFromParentResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kViewManagerService_removeViewFromParent_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kViewManagerService_removeViewFromParent_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kViewManagerService_reorderView_name: + var params = ViewManagerServiceReorderViewParams.deserialize( + message.payload); + var response = _impl.reorderView(params.viewId,params.relativeViewId,params.direction,_ViewManagerServiceReorderViewResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kViewManagerService_reorderView_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kViewManagerService_reorderView_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kViewManagerService_getViewTree_name: + var params = ViewManagerServiceGetViewTreeParams.deserialize( + message.payload); + var response = _impl.getViewTree(params.viewId,_ViewManagerServiceGetViewTreeResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kViewManagerService_getViewTree_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kViewManagerService_getViewTree_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kViewManagerService_setViewSurfaceId_name: + var params = ViewManagerServiceSetViewSurfaceIdParams.deserialize( + message.payload); + var response = _impl.setViewSurfaceId(params.viewId,params.surfaceId,_ViewManagerServiceSetViewSurfaceIdResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kViewManagerService_setViewSurfaceId_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kViewManagerService_setViewSurfaceId_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kViewManagerService_embedUrl_name: + var params = ViewManagerServiceEmbedUrlParams.deserialize( + message.payload); + var response = _impl.embedUrl(params.url,params.viewId,params.services,params.exposedServices,_ViewManagerServiceEmbedUrlResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kViewManagerService_embedUrl_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kViewManagerService_embedUrl_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kViewManagerService_embed_name: + var params = ViewManagerServiceEmbedParams.deserialize( + message.payload); + var response = _impl.embed(params.viewId,params.client,_ViewManagerServiceEmbedResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kViewManagerService_embed_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kViewManagerService_embed_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kViewManagerService_performAction_name: + var params = ViewManagerServicePerformActionParams.deserialize( + message.payload); + var response = _impl.performAction(params.viewId,params.action,_ViewManagerServicePerformActionResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kViewManagerService_performAction_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kViewManagerService_performAction_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + ViewManagerService get impl => _impl; + set impl(ViewManagerService d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "ViewManagerServiceStub($superString)"; + } + + int get version => 0; +} + +const int kViewManagerClient_onEmbed_name = 0; +const int kViewManagerClient_onEmbeddedAppDisconnected_name = 1; +const int kViewManagerClient_onViewBoundsChanged_name = 2; +const int kViewManagerClient_onViewViewportMetricsChanged_name = 3; +const int kViewManagerClient_onViewHierarchyChanged_name = 4; +const int kViewManagerClient_onViewReordered_name = 5; +const int kViewManagerClient_onViewDeleted_name = 6; +const int kViewManagerClient_onViewVisibilityChanged_name = 7; +const int kViewManagerClient_onViewDrawnStateChanged_name = 8; +const int kViewManagerClient_onViewSharedPropertyChanged_name = 9; +const int kViewManagerClient_onViewInputEvent_name = 10; +const int kViewManagerClient_onPerformAction_name = 11; + +const String ViewManagerClientName = + 'mojo::ViewManagerClient'; + +abstract class ViewManagerClient { + void onEmbed(int connectionId, String embedderUrl, ViewData root, Object viewManagerService, Object services, Object exposedServices, core.MojoMessagePipeEndpoint windowManagerPipe); + void onEmbeddedAppDisconnected(int view); + void onViewBoundsChanged(int view, geometry_mojom.Rect oldBounds, geometry_mojom.Rect newBounds); + void onViewViewportMetricsChanged(native_viewport_mojom.ViewportMetrics oldMetrics, native_viewport_mojom.ViewportMetrics newMetrics); + void onViewHierarchyChanged(int view, int newParent, int oldParent, List<ViewData> views); + void onViewReordered(int viewId, int relativeViewId, view_manager_constants_mojom.OrderDirection direction); + void onViewDeleted(int view); + void onViewVisibilityChanged(int view, bool visible); + void onViewDrawnStateChanged(int view, bool drawn); + void onViewSharedPropertyChanged(int view, String name, List<int> newData); + dynamic onViewInputEvent(int view,input_events_mojom.Event event,[Function responseFactory = null]); + dynamic onPerformAction(int viewId,String action,[Function responseFactory = null]); + +} + + +class ViewManagerClientProxyImpl extends bindings.Proxy { + ViewManagerClientProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + ViewManagerClientProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + ViewManagerClientProxyImpl.unbound() : super.unbound(); + + static ViewManagerClientProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ViewManagerClientProxyImpl")); + return new ViewManagerClientProxyImpl.fromEndpoint(endpoint); + } + + String get name => ViewManagerClientName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kViewManagerClient_onViewInputEvent_name: + var r = ViewManagerClientOnViewInputEventResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kViewManagerClient_onPerformAction_name: + var r = ViewManagerClientOnPerformActionResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "ViewManagerClientProxyImpl($superString)"; + } +} + + +class _ViewManagerClientProxyCalls implements ViewManagerClient { + ViewManagerClientProxyImpl _proxyImpl; + + _ViewManagerClientProxyCalls(this._proxyImpl); + void onEmbed(int connectionId, String embedderUrl, ViewData root, Object viewManagerService, Object services, Object exposedServices, core.MojoMessagePipeEndpoint windowManagerPipe) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new ViewManagerClientOnEmbedParams(); + params.connectionId = connectionId; + params.embedderUrl = embedderUrl; + params.root = root; + params.viewManagerService = viewManagerService; + params.services = services; + params.exposedServices = exposedServices; + params.windowManagerPipe = windowManagerPipe; + _proxyImpl.sendMessage(params, kViewManagerClient_onEmbed_name); + } + + void onEmbeddedAppDisconnected(int view) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new ViewManagerClientOnEmbeddedAppDisconnectedParams(); + params.view = view; + _proxyImpl.sendMessage(params, kViewManagerClient_onEmbeddedAppDisconnected_name); + } + + void onViewBoundsChanged(int view, geometry_mojom.Rect oldBounds, geometry_mojom.Rect newBounds) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new ViewManagerClientOnViewBoundsChangedParams(); + params.view = view; + params.oldBounds = oldBounds; + params.newBounds = newBounds; + _proxyImpl.sendMessage(params, kViewManagerClient_onViewBoundsChanged_name); + } + + void onViewViewportMetricsChanged(native_viewport_mojom.ViewportMetrics oldMetrics, native_viewport_mojom.ViewportMetrics newMetrics) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new ViewManagerClientOnViewViewportMetricsChangedParams(); + params.oldMetrics = oldMetrics; + params.newMetrics = newMetrics; + _proxyImpl.sendMessage(params, kViewManagerClient_onViewViewportMetricsChanged_name); + } + + void onViewHierarchyChanged(int view, int newParent, int oldParent, List<ViewData> views) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new ViewManagerClientOnViewHierarchyChangedParams(); + params.view = view; + params.newParent = newParent; + params.oldParent = oldParent; + params.views = views; + _proxyImpl.sendMessage(params, kViewManagerClient_onViewHierarchyChanged_name); + } + + void onViewReordered(int viewId, int relativeViewId, view_manager_constants_mojom.OrderDirection direction) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new ViewManagerClientOnViewReorderedParams(); + params.viewId = viewId; + params.relativeViewId = relativeViewId; + params.direction = direction; + _proxyImpl.sendMessage(params, kViewManagerClient_onViewReordered_name); + } + + void onViewDeleted(int view) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new ViewManagerClientOnViewDeletedParams(); + params.view = view; + _proxyImpl.sendMessage(params, kViewManagerClient_onViewDeleted_name); + } + + void onViewVisibilityChanged(int view, bool visible) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new ViewManagerClientOnViewVisibilityChangedParams(); + params.view = view; + params.visible = visible; + _proxyImpl.sendMessage(params, kViewManagerClient_onViewVisibilityChanged_name); + } + + void onViewDrawnStateChanged(int view, bool drawn) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new ViewManagerClientOnViewDrawnStateChangedParams(); + params.view = view; + params.drawn = drawn; + _proxyImpl.sendMessage(params, kViewManagerClient_onViewDrawnStateChanged_name); + } + + void onViewSharedPropertyChanged(int view, String name, List<int> newData) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new ViewManagerClientOnViewSharedPropertyChangedParams(); + params.view = view; + params.name = name; + params.newData = newData; + _proxyImpl.sendMessage(params, kViewManagerClient_onViewSharedPropertyChanged_name); + } + + dynamic onViewInputEvent(int view,input_events_mojom.Event event,[Function responseFactory = null]) { + var params = new ViewManagerClientOnViewInputEventParams(); + params.view = view; + params.event = event; + return _proxyImpl.sendMessageWithRequestId( + params, + kViewManagerClient_onViewInputEvent_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic onPerformAction(int viewId,String action,[Function responseFactory = null]) { + var params = new ViewManagerClientOnPerformActionParams(); + params.viewId = viewId; + params.action = action; + return _proxyImpl.sendMessageWithRequestId( + params, + kViewManagerClient_onPerformAction_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class ViewManagerClientProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + ViewManagerClient ptr; + final String name = ViewManagerClientName; + + ViewManagerClientProxy(ViewManagerClientProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _ViewManagerClientProxyCalls(proxyImpl); + + ViewManagerClientProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new ViewManagerClientProxyImpl.fromEndpoint(endpoint) { + ptr = new _ViewManagerClientProxyCalls(impl); + } + + ViewManagerClientProxy.fromHandle(core.MojoHandle handle) : + impl = new ViewManagerClientProxyImpl.fromHandle(handle) { + ptr = new _ViewManagerClientProxyCalls(impl); + } + + ViewManagerClientProxy.unbound() : + impl = new ViewManagerClientProxyImpl.unbound() { + ptr = new _ViewManagerClientProxyCalls(impl); + } + + factory ViewManagerClientProxy.connectToService( + bindings.ServiceConnector s, String url) { + ViewManagerClientProxy p = new ViewManagerClientProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static ViewManagerClientProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ViewManagerClientProxy")); + return new ViewManagerClientProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "ViewManagerClientProxy($impl)"; + } +} + + +class ViewManagerClientStub extends bindings.Stub { + ViewManagerClient _impl = null; + + ViewManagerClientStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + ViewManagerClientStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + ViewManagerClientStub.unbound() : super.unbound(); + + static ViewManagerClientStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ViewManagerClientStub")); + return new ViewManagerClientStub.fromEndpoint(endpoint); + } + + static const String name = ViewManagerClientName; + + + ViewManagerClientOnViewInputEventResponseParams _ViewManagerClientOnViewInputEventResponseParamsFactory() { + var result = new ViewManagerClientOnViewInputEventResponseParams(); + return result; + } + ViewManagerClientOnPerformActionResponseParams _ViewManagerClientOnPerformActionResponseParamsFactory(bool success) { + var result = new ViewManagerClientOnPerformActionResponseParams(); + result.success = success; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kViewManagerClient_onEmbed_name: + var params = ViewManagerClientOnEmbedParams.deserialize( + message.payload); + _impl.onEmbed(params.connectionId, params.embedderUrl, params.root, params.viewManagerService, params.services, params.exposedServices, params.windowManagerPipe); + break; + case kViewManagerClient_onEmbeddedAppDisconnected_name: + var params = ViewManagerClientOnEmbeddedAppDisconnectedParams.deserialize( + message.payload); + _impl.onEmbeddedAppDisconnected(params.view); + break; + case kViewManagerClient_onViewBoundsChanged_name: + var params = ViewManagerClientOnViewBoundsChangedParams.deserialize( + message.payload); + _impl.onViewBoundsChanged(params.view, params.oldBounds, params.newBounds); + break; + case kViewManagerClient_onViewViewportMetricsChanged_name: + var params = ViewManagerClientOnViewViewportMetricsChangedParams.deserialize( + message.payload); + _impl.onViewViewportMetricsChanged(params.oldMetrics, params.newMetrics); + break; + case kViewManagerClient_onViewHierarchyChanged_name: + var params = ViewManagerClientOnViewHierarchyChangedParams.deserialize( + message.payload); + _impl.onViewHierarchyChanged(params.view, params.newParent, params.oldParent, params.views); + break; + case kViewManagerClient_onViewReordered_name: + var params = ViewManagerClientOnViewReorderedParams.deserialize( + message.payload); + _impl.onViewReordered(params.viewId, params.relativeViewId, params.direction); + break; + case kViewManagerClient_onViewDeleted_name: + var params = ViewManagerClientOnViewDeletedParams.deserialize( + message.payload); + _impl.onViewDeleted(params.view); + break; + case kViewManagerClient_onViewVisibilityChanged_name: + var params = ViewManagerClientOnViewVisibilityChangedParams.deserialize( + message.payload); + _impl.onViewVisibilityChanged(params.view, params.visible); + break; + case kViewManagerClient_onViewDrawnStateChanged_name: + var params = ViewManagerClientOnViewDrawnStateChangedParams.deserialize( + message.payload); + _impl.onViewDrawnStateChanged(params.view, params.drawn); + break; + case kViewManagerClient_onViewSharedPropertyChanged_name: + var params = ViewManagerClientOnViewSharedPropertyChangedParams.deserialize( + message.payload); + _impl.onViewSharedPropertyChanged(params.view, params.name, params.newData); + break; + case kViewManagerClient_onViewInputEvent_name: + var params = ViewManagerClientOnViewInputEventParams.deserialize( + message.payload); + var response = _impl.onViewInputEvent(params.view,params.event,_ViewManagerClientOnViewInputEventResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kViewManagerClient_onViewInputEvent_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kViewManagerClient_onViewInputEvent_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kViewManagerClient_onPerformAction_name: + var params = ViewManagerClientOnPerformActionParams.deserialize( + message.payload); + var response = _impl.onPerformAction(params.viewId,params.action,_ViewManagerClientOnPerformActionResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kViewManagerClient_onPerformAction_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kViewManagerClient_onPerformAction_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + ViewManagerClient get impl => _impl; + set impl(ViewManagerClient d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "ViewManagerClientStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/view_manager_constants.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/view_manager_constants.mojom.dart new file mode 100644 index 0000000..0f45bf4 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/view_manager_constants.mojom.dart
@@ -0,0 +1,62 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library view_manager_constants_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +class OrderDirection extends bindings.MojoEnum { + static const ABOVE = const OrderDirection._(1); + static const BELOW = const OrderDirection._(2); + + const OrderDirection._(int v) : super(v); + + static const Map<String, OrderDirection> valuesMap = const { + "ABOVE": ABOVE, + "BELOW": BELOW, + }; + static const List<OrderDirection> values = const [ + ABOVE, + BELOW, + ]; + + static OrderDirection valueOf(String name) => valuesMap[name]; + + factory OrderDirection(int v) { + switch (v) { + case 1: + return ABOVE; + case 2: + return BELOW; + default: + return null; + } + } + + static OrderDirection decode(bindings.Decoder decoder0, int offset) { + int v = decoder0.decodeUint32(offset); + OrderDirection result = new OrderDirection(v); + if (result == null) { + throw new bindings.MojoCodecError( + 'Bad value $v for enum OrderDirection.'); + } + return result; + } + + String toString() { + switch(this) { + case ABOVE: + return 'OrderDirection.ABOVE'; + case BELOW: + return 'OrderDirection.BELOW'; + } + } + + int toJson() => value; +} + + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/viewport_parameter_listener.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/viewport_parameter_listener.mojom.dart new file mode 100644 index 0000000..095f21c --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/viewport_parameter_listener.mojom.dart
@@ -0,0 +1,265 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library viewport_parameter_listener_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; + + + +class ViewportParameterListenerOnVSyncParametersUpdatedParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int timebase = 0; + int interval = 0; + + ViewportParameterListenerOnVSyncParametersUpdatedParams() : super(kVersions.last.size); + + static ViewportParameterListenerOnVSyncParametersUpdatedParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ViewportParameterListenerOnVSyncParametersUpdatedParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ViewportParameterListenerOnVSyncParametersUpdatedParams result = new ViewportParameterListenerOnVSyncParametersUpdatedParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.timebase = decoder0.decodeInt64(8); + } + if (mainDataHeader.version >= 0) { + + result.interval = decoder0.decodeInt64(16); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt64(timebase, 8); + + encoder0.encodeInt64(interval, 16); + } + + String toString() { + return "ViewportParameterListenerOnVSyncParametersUpdatedParams(" + "timebase: $timebase" ", " + "interval: $interval" ")"; + } + + Map toJson() { + Map map = new Map(); + map["timebase"] = timebase; + map["interval"] = interval; + return map; + } +} + +const int kViewportParameterListener_onVSyncParametersUpdated_name = 0; + +const String ViewportParameterListenerName = + 'mojo::ViewportParameterListener'; + +abstract class ViewportParameterListener { + void onVSyncParametersUpdated(int timebase, int interval); + +} + + +class ViewportParameterListenerProxyImpl extends bindings.Proxy { + ViewportParameterListenerProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + ViewportParameterListenerProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + ViewportParameterListenerProxyImpl.unbound() : super.unbound(); + + static ViewportParameterListenerProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ViewportParameterListenerProxyImpl")); + return new ViewportParameterListenerProxyImpl.fromEndpoint(endpoint); + } + + String get name => ViewportParameterListenerName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "ViewportParameterListenerProxyImpl($superString)"; + } +} + + +class _ViewportParameterListenerProxyCalls implements ViewportParameterListener { + ViewportParameterListenerProxyImpl _proxyImpl; + + _ViewportParameterListenerProxyCalls(this._proxyImpl); + void onVSyncParametersUpdated(int timebase, int interval) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new ViewportParameterListenerOnVSyncParametersUpdatedParams(); + params.timebase = timebase; + params.interval = interval; + _proxyImpl.sendMessage(params, kViewportParameterListener_onVSyncParametersUpdated_name); + } + +} + + +class ViewportParameterListenerProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + ViewportParameterListener ptr; + final String name = ViewportParameterListenerName; + + ViewportParameterListenerProxy(ViewportParameterListenerProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _ViewportParameterListenerProxyCalls(proxyImpl); + + ViewportParameterListenerProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new ViewportParameterListenerProxyImpl.fromEndpoint(endpoint) { + ptr = new _ViewportParameterListenerProxyCalls(impl); + } + + ViewportParameterListenerProxy.fromHandle(core.MojoHandle handle) : + impl = new ViewportParameterListenerProxyImpl.fromHandle(handle) { + ptr = new _ViewportParameterListenerProxyCalls(impl); + } + + ViewportParameterListenerProxy.unbound() : + impl = new ViewportParameterListenerProxyImpl.unbound() { + ptr = new _ViewportParameterListenerProxyCalls(impl); + } + + factory ViewportParameterListenerProxy.connectToService( + bindings.ServiceConnector s, String url) { + ViewportParameterListenerProxy p = new ViewportParameterListenerProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static ViewportParameterListenerProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ViewportParameterListenerProxy")); + return new ViewportParameterListenerProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "ViewportParameterListenerProxy($impl)"; + } +} + + +class ViewportParameterListenerStub extends bindings.Stub { + ViewportParameterListener _impl = null; + + ViewportParameterListenerStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + ViewportParameterListenerStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + ViewportParameterListenerStub.unbound() : super.unbound(); + + static ViewportParameterListenerStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ViewportParameterListenerStub")); + return new ViewportParameterListenerStub.fromEndpoint(endpoint); + } + + static const String name = ViewportParameterListenerName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kViewportParameterListener_onVSyncParametersUpdated_name: + var params = ViewportParameterListenerOnVSyncParametersUpdatedParams.deserialize( + message.payload); + _impl.onVSyncParametersUpdated(params.timebase, params.interval); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + ViewportParameterListener get impl => _impl; + set impl(ViewportParameterListener d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "ViewportParameterListenerStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/web_socket.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/web_socket.mojom.dart new file mode 100644 index 0000000..53ddcaa --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/web_socket.mojom.dart
@@ -0,0 +1,1289 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library web_socket_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo/mojo/network_error.mojom.dart' as network_error_mojom; + + + +class WebSocketConnectParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(48, 0) + ]; + String url = null; + List<String> protocols = null; + String origin = null; + core.MojoDataPipeConsumer sendStream = null; + Object client = null; + + WebSocketConnectParams() : super(kVersions.last.size); + + static WebSocketConnectParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static WebSocketConnectParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + WebSocketConnectParams result = new WebSocketConnectParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.url = decoder0.decodeString(8, false); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.protocols = new List<String>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + result.protocols[i1] = decoder1.decodeString(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + } + } + } + if (mainDataHeader.version >= 0) { + + result.origin = decoder0.decodeString(24, false); + } + if (mainDataHeader.version >= 0) { + + result.sendStream = decoder0.decodeConsumerHandle(32, false); + } + if (mainDataHeader.version >= 0) { + + result.client = decoder0.decodeServiceInterface(36, false, WebSocketClientProxy.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(url, 8, false); + + if (protocols == null) { + encoder0.encodeNullPointer(16, false); + } else { + var encoder1 = encoder0.encodePointerArray(protocols.length, 16, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < protocols.length; ++i0) { + + encoder1.encodeString(protocols[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + + encoder0.encodeString(origin, 24, false); + + encoder0.encodeConsumerHandle(sendStream, 32, false); + + encoder0.encodeInterface(client, 36, false); + } + + String toString() { + return "WebSocketConnectParams(" + "url: $url" ", " + "protocols: $protocols" ", " + "origin: $origin" ", " + "sendStream: $sendStream" ", " + "client: $client" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class WebSocketSendParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + bool fin = false; + WebSocketMessageType type = null; + int numBytes = 0; + + WebSocketSendParams() : super(kVersions.last.size); + + static WebSocketSendParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static WebSocketSendParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + WebSocketSendParams result = new WebSocketSendParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.fin = decoder0.decodeBool(8, 0); + } + if (mainDataHeader.version >= 0) { + + result.type = WebSocketMessageType.decode(decoder0, 12); + if (result.type == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable WebSocketMessageType.'); + } + } + if (mainDataHeader.version >= 0) { + + result.numBytes = decoder0.decodeUint32(16); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeBool(fin, 8, 0); + + encoder0.encodeEnum(type, 12); + + encoder0.encodeUint32(numBytes, 16); + } + + String toString() { + return "WebSocketSendParams(" + "fin: $fin" ", " + "type: $type" ", " + "numBytes: $numBytes" ")"; + } + + Map toJson() { + Map map = new Map(); + map["fin"] = fin; + map["type"] = type; + map["numBytes"] = numBytes; + return map; + } +} + + +class WebSocketFlowControlParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int quota = 0; + + WebSocketFlowControlParams() : super(kVersions.last.size); + + static WebSocketFlowControlParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static WebSocketFlowControlParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + WebSocketFlowControlParams result = new WebSocketFlowControlParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.quota = decoder0.decodeInt64(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt64(quota, 8); + } + + String toString() { + return "WebSocketFlowControlParams(" + "quota: $quota" ")"; + } + + Map toJson() { + Map map = new Map(); + map["quota"] = quota; + return map; + } +} + + +class WebSocketCloseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int code = 0; + String reason = null; + + WebSocketCloseParams() : super(kVersions.last.size); + + static WebSocketCloseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static WebSocketCloseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + WebSocketCloseParams result = new WebSocketCloseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.code = decoder0.decodeUint16(8); + } + if (mainDataHeader.version >= 0) { + + result.reason = decoder0.decodeString(16, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint16(code, 8); + + encoder0.encodeString(reason, 16, false); + } + + String toString() { + return "WebSocketCloseParams(" + "code: $code" ", " + "reason: $reason" ")"; + } + + Map toJson() { + Map map = new Map(); + map["code"] = code; + map["reason"] = reason; + return map; + } +} + + +class WebSocketClientDidConnectParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(32, 0) + ]; + String selectedSubprotocol = null; + String extensions = null; + core.MojoDataPipeConsumer receiveStream = null; + + WebSocketClientDidConnectParams() : super(kVersions.last.size); + + static WebSocketClientDidConnectParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static WebSocketClientDidConnectParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + WebSocketClientDidConnectParams result = new WebSocketClientDidConnectParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.selectedSubprotocol = decoder0.decodeString(8, false); + } + if (mainDataHeader.version >= 0) { + + result.extensions = decoder0.decodeString(16, false); + } + if (mainDataHeader.version >= 0) { + + result.receiveStream = decoder0.decodeConsumerHandle(24, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(selectedSubprotocol, 8, false); + + encoder0.encodeString(extensions, 16, false); + + encoder0.encodeConsumerHandle(receiveStream, 24, false); + } + + String toString() { + return "WebSocketClientDidConnectParams(" + "selectedSubprotocol: $selectedSubprotocol" ", " + "extensions: $extensions" ", " + "receiveStream: $receiveStream" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class WebSocketClientDidReceiveDataParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + bool fin = false; + WebSocketMessageType type = null; + int numBytes = 0; + + WebSocketClientDidReceiveDataParams() : super(kVersions.last.size); + + static WebSocketClientDidReceiveDataParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static WebSocketClientDidReceiveDataParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + WebSocketClientDidReceiveDataParams result = new WebSocketClientDidReceiveDataParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.fin = decoder0.decodeBool(8, 0); + } + if (mainDataHeader.version >= 0) { + + result.type = WebSocketMessageType.decode(decoder0, 12); + if (result.type == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable WebSocketMessageType.'); + } + } + if (mainDataHeader.version >= 0) { + + result.numBytes = decoder0.decodeUint32(16); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeBool(fin, 8, 0); + + encoder0.encodeEnum(type, 12); + + encoder0.encodeUint32(numBytes, 16); + } + + String toString() { + return "WebSocketClientDidReceiveDataParams(" + "fin: $fin" ", " + "type: $type" ", " + "numBytes: $numBytes" ")"; + } + + Map toJson() { + Map map = new Map(); + map["fin"] = fin; + map["type"] = type; + map["numBytes"] = numBytes; + return map; + } +} + + +class WebSocketClientDidReceiveFlowControlParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int quota = 0; + + WebSocketClientDidReceiveFlowControlParams() : super(kVersions.last.size); + + static WebSocketClientDidReceiveFlowControlParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static WebSocketClientDidReceiveFlowControlParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + WebSocketClientDidReceiveFlowControlParams result = new WebSocketClientDidReceiveFlowControlParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.quota = decoder0.decodeInt64(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt64(quota, 8); + } + + String toString() { + return "WebSocketClientDidReceiveFlowControlParams(" + "quota: $quota" ")"; + } + + Map toJson() { + Map map = new Map(); + map["quota"] = quota; + return map; + } +} + + +class WebSocketClientDidFailParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + String message = null; + + WebSocketClientDidFailParams() : super(kVersions.last.size); + + static WebSocketClientDidFailParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static WebSocketClientDidFailParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + WebSocketClientDidFailParams result = new WebSocketClientDidFailParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.message = decoder0.decodeString(8, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(message, 8, false); + } + + String toString() { + return "WebSocketClientDidFailParams(" + "message: $message" ")"; + } + + Map toJson() { + Map map = new Map(); + map["message"] = message; + return map; + } +} + + +class WebSocketClientDidCloseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + bool wasClean = false; + int code = 0; + String reason = null; + + WebSocketClientDidCloseParams() : super(kVersions.last.size); + + static WebSocketClientDidCloseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static WebSocketClientDidCloseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + WebSocketClientDidCloseParams result = new WebSocketClientDidCloseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.wasClean = decoder0.decodeBool(8, 0); + } + if (mainDataHeader.version >= 0) { + + result.code = decoder0.decodeUint16(10); + } + if (mainDataHeader.version >= 0) { + + result.reason = decoder0.decodeString(16, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeBool(wasClean, 8, 0); + + encoder0.encodeUint16(code, 10); + + encoder0.encodeString(reason, 16, false); + } + + String toString() { + return "WebSocketClientDidCloseParams(" + "wasClean: $wasClean" ", " + "code: $code" ", " + "reason: $reason" ")"; + } + + Map toJson() { + Map map = new Map(); + map["wasClean"] = wasClean; + map["code"] = code; + map["reason"] = reason; + return map; + } +} + +const int kWebSocket_connect_name = 0; +const int kWebSocket_send_name = 1; +const int kWebSocket_flowControl_name = 2; +const int kWebSocket_close_name = 3; + +const String WebSocketName = + 'mojo::WebSocket'; + class WebSocketMessageType extends bindings.MojoEnum { + static const CONTINUATION = const WebSocketMessageType._(0); + static const TEXT = const WebSocketMessageType._(1); + static const BINARY = const WebSocketMessageType._(2); + + const WebSocketMessageType._(int v) : super(v); + + static const Map<String, WebSocketMessageType> valuesMap = const { + "CONTINUATION": CONTINUATION, + "TEXT": TEXT, + "BINARY": BINARY, + }; + static const List<WebSocketMessageType> values = const [ + CONTINUATION, + TEXT, + BINARY, + ]; + + static WebSocketMessageType valueOf(String name) => valuesMap[name]; + + factory WebSocketMessageType(int v) { + switch (v) { + case 0: + return CONTINUATION; + case 1: + return TEXT; + case 2: + return BINARY; + default: + return null; + } + } + + static WebSocketMessageType decode(bindings.Decoder decoder0, int offset) { + int v = decoder0.decodeUint32(offset); + WebSocketMessageType result = new WebSocketMessageType(v); + if (result == null) { + throw new bindings.MojoCodecError( + 'Bad value $v for enum WebSocketMessageType.'); + } + return result; + } + + String toString() { + switch(this) { + case CONTINUATION: + return 'WebSocketMessageType.CONTINUATION'; + case TEXT: + return 'WebSocketMessageType.TEXT'; + case BINARY: + return 'WebSocketMessageType.BINARY'; + } + } + + int toJson() => value; +} + +abstract class WebSocket { + void connect(String url, List<String> protocols, String origin, core.MojoDataPipeConsumer sendStream, Object client); + void send(bool fin, WebSocketMessageType type, int numBytes); + void flowControl(int quota); + void close(int code, String reason); + + static const ABNORMAL_CLOSE_CODE = 1006; +} + + +class WebSocketProxyImpl extends bindings.Proxy { + WebSocketProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + WebSocketProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + WebSocketProxyImpl.unbound() : super.unbound(); + + static WebSocketProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For WebSocketProxyImpl")); + return new WebSocketProxyImpl.fromEndpoint(endpoint); + } + + String get name => WebSocketName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "WebSocketProxyImpl($superString)"; + } +} + + +class _WebSocketProxyCalls implements WebSocket { + WebSocketProxyImpl _proxyImpl; + + _WebSocketProxyCalls(this._proxyImpl); + void connect(String url, List<String> protocols, String origin, core.MojoDataPipeConsumer sendStream, Object client) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new WebSocketConnectParams(); + params.url = url; + params.protocols = protocols; + params.origin = origin; + params.sendStream = sendStream; + params.client = client; + _proxyImpl.sendMessage(params, kWebSocket_connect_name); + } + + void send(bool fin, WebSocketMessageType type, int numBytes) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new WebSocketSendParams(); + params.fin = fin; + params.type = type; + params.numBytes = numBytes; + _proxyImpl.sendMessage(params, kWebSocket_send_name); + } + + void flowControl(int quota) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new WebSocketFlowControlParams(); + params.quota = quota; + _proxyImpl.sendMessage(params, kWebSocket_flowControl_name); + } + + void close(int code, String reason) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new WebSocketCloseParams(); + params.code = code; + params.reason = reason; + _proxyImpl.sendMessage(params, kWebSocket_close_name); + } + +} + + +class WebSocketProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + WebSocket ptr; + final String name = WebSocketName; + + WebSocketProxy(WebSocketProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _WebSocketProxyCalls(proxyImpl); + + WebSocketProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new WebSocketProxyImpl.fromEndpoint(endpoint) { + ptr = new _WebSocketProxyCalls(impl); + } + + WebSocketProxy.fromHandle(core.MojoHandle handle) : + impl = new WebSocketProxyImpl.fromHandle(handle) { + ptr = new _WebSocketProxyCalls(impl); + } + + WebSocketProxy.unbound() : + impl = new WebSocketProxyImpl.unbound() { + ptr = new _WebSocketProxyCalls(impl); + } + + factory WebSocketProxy.connectToService( + bindings.ServiceConnector s, String url) { + WebSocketProxy p = new WebSocketProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static WebSocketProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For WebSocketProxy")); + return new WebSocketProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "WebSocketProxy($impl)"; + } +} + + +class WebSocketStub extends bindings.Stub { + WebSocket _impl = null; + + WebSocketStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + WebSocketStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + WebSocketStub.unbound() : super.unbound(); + + static WebSocketStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For WebSocketStub")); + return new WebSocketStub.fromEndpoint(endpoint); + } + + static const String name = WebSocketName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kWebSocket_connect_name: + var params = WebSocketConnectParams.deserialize( + message.payload); + _impl.connect(params.url, params.protocols, params.origin, params.sendStream, params.client); + break; + case kWebSocket_send_name: + var params = WebSocketSendParams.deserialize( + message.payload); + _impl.send(params.fin, params.type, params.numBytes); + break; + case kWebSocket_flowControl_name: + var params = WebSocketFlowControlParams.deserialize( + message.payload); + _impl.flowControl(params.quota); + break; + case kWebSocket_close_name: + var params = WebSocketCloseParams.deserialize( + message.payload); + _impl.close(params.code, params.reason); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + WebSocket get impl => _impl; + set impl(WebSocket d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "WebSocketStub($superString)"; + } + + int get version => 0; +} + +const int kWebSocketClient_didConnect_name = 0; +const int kWebSocketClient_didReceiveData_name = 1; +const int kWebSocketClient_didReceiveFlowControl_name = 2; +const int kWebSocketClient_didFail_name = 3; +const int kWebSocketClient_didClose_name = 4; + +const String WebSocketClientName = + 'mojo::WebSocketClient'; + +abstract class WebSocketClient { + void didConnect(String selectedSubprotocol, String extensions, core.MojoDataPipeConsumer receiveStream); + void didReceiveData(bool fin, WebSocketMessageType type, int numBytes); + void didReceiveFlowControl(int quota); + void didFail(String message); + void didClose(bool wasClean, int code, String reason); + +} + + +class WebSocketClientProxyImpl extends bindings.Proxy { + WebSocketClientProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + WebSocketClientProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + WebSocketClientProxyImpl.unbound() : super.unbound(); + + static WebSocketClientProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For WebSocketClientProxyImpl")); + return new WebSocketClientProxyImpl.fromEndpoint(endpoint); + } + + String get name => WebSocketClientName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "WebSocketClientProxyImpl($superString)"; + } +} + + +class _WebSocketClientProxyCalls implements WebSocketClient { + WebSocketClientProxyImpl _proxyImpl; + + _WebSocketClientProxyCalls(this._proxyImpl); + void didConnect(String selectedSubprotocol, String extensions, core.MojoDataPipeConsumer receiveStream) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new WebSocketClientDidConnectParams(); + params.selectedSubprotocol = selectedSubprotocol; + params.extensions = extensions; + params.receiveStream = receiveStream; + _proxyImpl.sendMessage(params, kWebSocketClient_didConnect_name); + } + + void didReceiveData(bool fin, WebSocketMessageType type, int numBytes) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new WebSocketClientDidReceiveDataParams(); + params.fin = fin; + params.type = type; + params.numBytes = numBytes; + _proxyImpl.sendMessage(params, kWebSocketClient_didReceiveData_name); + } + + void didReceiveFlowControl(int quota) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new WebSocketClientDidReceiveFlowControlParams(); + params.quota = quota; + _proxyImpl.sendMessage(params, kWebSocketClient_didReceiveFlowControl_name); + } + + void didFail(String message) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new WebSocketClientDidFailParams(); + params.message = message; + _proxyImpl.sendMessage(params, kWebSocketClient_didFail_name); + } + + void didClose(bool wasClean, int code, String reason) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new WebSocketClientDidCloseParams(); + params.wasClean = wasClean; + params.code = code; + params.reason = reason; + _proxyImpl.sendMessage(params, kWebSocketClient_didClose_name); + } + +} + + +class WebSocketClientProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + WebSocketClient ptr; + final String name = WebSocketClientName; + + WebSocketClientProxy(WebSocketClientProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _WebSocketClientProxyCalls(proxyImpl); + + WebSocketClientProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new WebSocketClientProxyImpl.fromEndpoint(endpoint) { + ptr = new _WebSocketClientProxyCalls(impl); + } + + WebSocketClientProxy.fromHandle(core.MojoHandle handle) : + impl = new WebSocketClientProxyImpl.fromHandle(handle) { + ptr = new _WebSocketClientProxyCalls(impl); + } + + WebSocketClientProxy.unbound() : + impl = new WebSocketClientProxyImpl.unbound() { + ptr = new _WebSocketClientProxyCalls(impl); + } + + factory WebSocketClientProxy.connectToService( + bindings.ServiceConnector s, String url) { + WebSocketClientProxy p = new WebSocketClientProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static WebSocketClientProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For WebSocketClientProxy")); + return new WebSocketClientProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "WebSocketClientProxy($impl)"; + } +} + + +class WebSocketClientStub extends bindings.Stub { + WebSocketClient _impl = null; + + WebSocketClientStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + WebSocketClientStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + WebSocketClientStub.unbound() : super.unbound(); + + static WebSocketClientStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For WebSocketClientStub")); + return new WebSocketClientStub.fromEndpoint(endpoint); + } + + static const String name = WebSocketClientName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kWebSocketClient_didConnect_name: + var params = WebSocketClientDidConnectParams.deserialize( + message.payload); + _impl.didConnect(params.selectedSubprotocol, params.extensions, params.receiveStream); + break; + case kWebSocketClient_didReceiveData_name: + var params = WebSocketClientDidReceiveDataParams.deserialize( + message.payload); + _impl.didReceiveData(params.fin, params.type, params.numBytes); + break; + case kWebSocketClient_didReceiveFlowControl_name: + var params = WebSocketClientDidReceiveFlowControlParams.deserialize( + message.payload); + _impl.didReceiveFlowControl(params.quota); + break; + case kWebSocketClient_didFail_name: + var params = WebSocketClientDidFailParams.deserialize( + message.payload); + _impl.didFail(params.message); + break; + case kWebSocketClient_didClose_name: + var params = WebSocketClientDidCloseParams.deserialize( + message.payload); + _impl.didClose(params.wasClean, params.code, params.reason); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + WebSocketClient get impl => _impl; + set impl(WebSocketClient d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "WebSocketClientStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/window_manager.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/window_manager.mojom.dart new file mode 100644 index 0000000..df1b4e7 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/window_manager.mojom.dart
@@ -0,0 +1,1471 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library window_manager_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo_services/mojo/input_events.mojom.dart' as input_events_mojom; +import 'package:mojo/mojo/service_provider.mojom.dart' as service_provider_mojom; + + + +class WindowManagerEmbedParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(32, 0) + ]; + String url = null; + Object services = null; + Object exposedServices = null; + + WindowManagerEmbedParams() : super(kVersions.last.size); + + static WindowManagerEmbedParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static WindowManagerEmbedParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + WindowManagerEmbedParams result = new WindowManagerEmbedParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.url = decoder0.decodeString(8, false); + } + if (mainDataHeader.version >= 0) { + + result.services = decoder0.decodeInterfaceRequest(16, true, service_provider_mojom.ServiceProviderStub.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.exposedServices = decoder0.decodeServiceInterface(20, true, service_provider_mojom.ServiceProviderProxy.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(url, 8, false); + + encoder0.encodeInterfaceRequest(services, 16, true); + + encoder0.encodeInterface(exposedServices, 20, true); + } + + String toString() { + return "WindowManagerEmbedParams(" + "url: $url" ", " + "services: $services" ", " + "exposedServices: $exposedServices" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class WindowManagerSetCaptureParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int viewId = 0; + + WindowManagerSetCaptureParams() : super(kVersions.last.size); + + static WindowManagerSetCaptureParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static WindowManagerSetCaptureParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + WindowManagerSetCaptureParams result = new WindowManagerSetCaptureParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.viewId = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(viewId, 8); + } + + String toString() { + return "WindowManagerSetCaptureParams(" + "viewId: $viewId" ")"; + } + + Map toJson() { + Map map = new Map(); + map["viewId"] = viewId; + return map; + } +} + + +class WindowManagerSetCaptureResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + bool success = false; + + WindowManagerSetCaptureResponseParams() : super(kVersions.last.size); + + static WindowManagerSetCaptureResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static WindowManagerSetCaptureResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + WindowManagerSetCaptureResponseParams result = new WindowManagerSetCaptureResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.success = decoder0.decodeBool(8, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeBool(success, 8, 0); + } + + String toString() { + return "WindowManagerSetCaptureResponseParams(" + "success: $success" ")"; + } + + Map toJson() { + Map map = new Map(); + map["success"] = success; + return map; + } +} + + +class WindowManagerFocusWindowParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int viewId = 0; + + WindowManagerFocusWindowParams() : super(kVersions.last.size); + + static WindowManagerFocusWindowParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static WindowManagerFocusWindowParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + WindowManagerFocusWindowParams result = new WindowManagerFocusWindowParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.viewId = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(viewId, 8); + } + + String toString() { + return "WindowManagerFocusWindowParams(" + "viewId: $viewId" ")"; + } + + Map toJson() { + Map map = new Map(); + map["viewId"] = viewId; + return map; + } +} + + +class WindowManagerFocusWindowResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + bool success = false; + + WindowManagerFocusWindowResponseParams() : super(kVersions.last.size); + + static WindowManagerFocusWindowResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static WindowManagerFocusWindowResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + WindowManagerFocusWindowResponseParams result = new WindowManagerFocusWindowResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.success = decoder0.decodeBool(8, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeBool(success, 8, 0); + } + + String toString() { + return "WindowManagerFocusWindowResponseParams(" + "success: $success" ")"; + } + + Map toJson() { + Map map = new Map(); + map["success"] = success; + return map; + } +} + + +class WindowManagerActivateWindowParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int viewId = 0; + + WindowManagerActivateWindowParams() : super(kVersions.last.size); + + static WindowManagerActivateWindowParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static WindowManagerActivateWindowParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + WindowManagerActivateWindowParams result = new WindowManagerActivateWindowParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.viewId = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(viewId, 8); + } + + String toString() { + return "WindowManagerActivateWindowParams(" + "viewId: $viewId" ")"; + } + + Map toJson() { + Map map = new Map(); + map["viewId"] = viewId; + return map; + } +} + + +class WindowManagerActivateWindowResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + bool success = false; + + WindowManagerActivateWindowResponseParams() : super(kVersions.last.size); + + static WindowManagerActivateWindowResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static WindowManagerActivateWindowResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + WindowManagerActivateWindowResponseParams result = new WindowManagerActivateWindowResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.success = decoder0.decodeBool(8, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeBool(success, 8, 0); + } + + String toString() { + return "WindowManagerActivateWindowResponseParams(" + "success: $success" ")"; + } + + Map toJson() { + Map map = new Map(); + map["success"] = success; + return map; + } +} + + +class WindowManagerGetFocusedAndActiveViewsParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + Object observer = null; + + WindowManagerGetFocusedAndActiveViewsParams() : super(kVersions.last.size); + + static WindowManagerGetFocusedAndActiveViewsParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static WindowManagerGetFocusedAndActiveViewsParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + WindowManagerGetFocusedAndActiveViewsParams result = new WindowManagerGetFocusedAndActiveViewsParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.observer = decoder0.decodeServiceInterface(8, true, WindowManagerObserverProxy.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInterface(observer, 8, true); + } + + String toString() { + return "WindowManagerGetFocusedAndActiveViewsParams(" + "observer: $observer" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class WindowManagerGetFocusedAndActiveViewsResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int captureViewId = 0; + int focusedViewId = 0; + int activeViewId = 0; + + WindowManagerGetFocusedAndActiveViewsResponseParams() : super(kVersions.last.size); + + static WindowManagerGetFocusedAndActiveViewsResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static WindowManagerGetFocusedAndActiveViewsResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + WindowManagerGetFocusedAndActiveViewsResponseParams result = new WindowManagerGetFocusedAndActiveViewsResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.captureViewId = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + result.focusedViewId = decoder0.decodeUint32(12); + } + if (mainDataHeader.version >= 0) { + + result.activeViewId = decoder0.decodeUint32(16); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(captureViewId, 8); + + encoder0.encodeUint32(focusedViewId, 12); + + encoder0.encodeUint32(activeViewId, 16); + } + + String toString() { + return "WindowManagerGetFocusedAndActiveViewsResponseParams(" + "captureViewId: $captureViewId" ", " + "focusedViewId: $focusedViewId" ", " + "activeViewId: $activeViewId" ")"; + } + + Map toJson() { + Map map = new Map(); + map["captureViewId"] = captureViewId; + map["focusedViewId"] = focusedViewId; + map["activeViewId"] = activeViewId; + return map; + } +} + + +class WindowManagerObserverOnCaptureChangedParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int captureViewId = 0; + + WindowManagerObserverOnCaptureChangedParams() : super(kVersions.last.size); + + static WindowManagerObserverOnCaptureChangedParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static WindowManagerObserverOnCaptureChangedParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + WindowManagerObserverOnCaptureChangedParams result = new WindowManagerObserverOnCaptureChangedParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.captureViewId = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(captureViewId, 8); + } + + String toString() { + return "WindowManagerObserverOnCaptureChangedParams(" + "captureViewId: $captureViewId" ")"; + } + + Map toJson() { + Map map = new Map(); + map["captureViewId"] = captureViewId; + return map; + } +} + + +class WindowManagerObserverOnFocusChangedParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int focusedViewId = 0; + + WindowManagerObserverOnFocusChangedParams() : super(kVersions.last.size); + + static WindowManagerObserverOnFocusChangedParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static WindowManagerObserverOnFocusChangedParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + WindowManagerObserverOnFocusChangedParams result = new WindowManagerObserverOnFocusChangedParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.focusedViewId = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(focusedViewId, 8); + } + + String toString() { + return "WindowManagerObserverOnFocusChangedParams(" + "focusedViewId: $focusedViewId" ")"; + } + + Map toJson() { + Map map = new Map(); + map["focusedViewId"] = focusedViewId; + return map; + } +} + + +class WindowManagerObserverOnActiveWindowChangedParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int focusedViewId = 0; + + WindowManagerObserverOnActiveWindowChangedParams() : super(kVersions.last.size); + + static WindowManagerObserverOnActiveWindowChangedParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static WindowManagerObserverOnActiveWindowChangedParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + WindowManagerObserverOnActiveWindowChangedParams result = new WindowManagerObserverOnActiveWindowChangedParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.focusedViewId = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(focusedViewId, 8); + } + + String toString() { + return "WindowManagerObserverOnActiveWindowChangedParams(" + "focusedViewId: $focusedViewId" ")"; + } + + Map toJson() { + Map map = new Map(); + map["focusedViewId"] = focusedViewId; + return map; + } +} + +const int kWindowManager_embed_name = 0; +const int kWindowManager_setCapture_name = 1; +const int kWindowManager_focusWindow_name = 2; +const int kWindowManager_activateWindow_name = 3; +const int kWindowManager_getFocusedAndActiveViews_name = 4; + +const String WindowManagerName = + 'mojo::WindowManager'; + +abstract class WindowManager { + void embed(String url, Object services, Object exposedServices); + dynamic setCapture(int viewId,[Function responseFactory = null]); + dynamic focusWindow(int viewId,[Function responseFactory = null]); + dynamic activateWindow(int viewId,[Function responseFactory = null]); + dynamic getFocusedAndActiveViews(Object observer,[Function responseFactory = null]); + +} + + +class WindowManagerProxyImpl extends bindings.Proxy { + WindowManagerProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + WindowManagerProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + WindowManagerProxyImpl.unbound() : super.unbound(); + + static WindowManagerProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For WindowManagerProxyImpl")); + return new WindowManagerProxyImpl.fromEndpoint(endpoint); + } + + String get name => WindowManagerName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kWindowManager_setCapture_name: + var r = WindowManagerSetCaptureResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kWindowManager_focusWindow_name: + var r = WindowManagerFocusWindowResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kWindowManager_activateWindow_name: + var r = WindowManagerActivateWindowResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kWindowManager_getFocusedAndActiveViews_name: + var r = WindowManagerGetFocusedAndActiveViewsResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "WindowManagerProxyImpl($superString)"; + } +} + + +class _WindowManagerProxyCalls implements WindowManager { + WindowManagerProxyImpl _proxyImpl; + + _WindowManagerProxyCalls(this._proxyImpl); + void embed(String url, Object services, Object exposedServices) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new WindowManagerEmbedParams(); + params.url = url; + params.services = services; + params.exposedServices = exposedServices; + _proxyImpl.sendMessage(params, kWindowManager_embed_name); + } + + dynamic setCapture(int viewId,[Function responseFactory = null]) { + var params = new WindowManagerSetCaptureParams(); + params.viewId = viewId; + return _proxyImpl.sendMessageWithRequestId( + params, + kWindowManager_setCapture_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic focusWindow(int viewId,[Function responseFactory = null]) { + var params = new WindowManagerFocusWindowParams(); + params.viewId = viewId; + return _proxyImpl.sendMessageWithRequestId( + params, + kWindowManager_focusWindow_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic activateWindow(int viewId,[Function responseFactory = null]) { + var params = new WindowManagerActivateWindowParams(); + params.viewId = viewId; + return _proxyImpl.sendMessageWithRequestId( + params, + kWindowManager_activateWindow_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic getFocusedAndActiveViews(Object observer,[Function responseFactory = null]) { + var params = new WindowManagerGetFocusedAndActiveViewsParams(); + params.observer = observer; + return _proxyImpl.sendMessageWithRequestId( + params, + kWindowManager_getFocusedAndActiveViews_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class WindowManagerProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + WindowManager ptr; + final String name = WindowManagerName; + + WindowManagerProxy(WindowManagerProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _WindowManagerProxyCalls(proxyImpl); + + WindowManagerProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new WindowManagerProxyImpl.fromEndpoint(endpoint) { + ptr = new _WindowManagerProxyCalls(impl); + } + + WindowManagerProxy.fromHandle(core.MojoHandle handle) : + impl = new WindowManagerProxyImpl.fromHandle(handle) { + ptr = new _WindowManagerProxyCalls(impl); + } + + WindowManagerProxy.unbound() : + impl = new WindowManagerProxyImpl.unbound() { + ptr = new _WindowManagerProxyCalls(impl); + } + + factory WindowManagerProxy.connectToService( + bindings.ServiceConnector s, String url) { + WindowManagerProxy p = new WindowManagerProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static WindowManagerProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For WindowManagerProxy")); + return new WindowManagerProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "WindowManagerProxy($impl)"; + } +} + + +class WindowManagerStub extends bindings.Stub { + WindowManager _impl = null; + + WindowManagerStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + WindowManagerStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + WindowManagerStub.unbound() : super.unbound(); + + static WindowManagerStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For WindowManagerStub")); + return new WindowManagerStub.fromEndpoint(endpoint); + } + + static const String name = WindowManagerName; + + + WindowManagerSetCaptureResponseParams _WindowManagerSetCaptureResponseParamsFactory(bool success) { + var result = new WindowManagerSetCaptureResponseParams(); + result.success = success; + return result; + } + WindowManagerFocusWindowResponseParams _WindowManagerFocusWindowResponseParamsFactory(bool success) { + var result = new WindowManagerFocusWindowResponseParams(); + result.success = success; + return result; + } + WindowManagerActivateWindowResponseParams _WindowManagerActivateWindowResponseParamsFactory(bool success) { + var result = new WindowManagerActivateWindowResponseParams(); + result.success = success; + return result; + } + WindowManagerGetFocusedAndActiveViewsResponseParams _WindowManagerGetFocusedAndActiveViewsResponseParamsFactory(int captureViewId, int focusedViewId, int activeViewId) { + var result = new WindowManagerGetFocusedAndActiveViewsResponseParams(); + result.captureViewId = captureViewId; + result.focusedViewId = focusedViewId; + result.activeViewId = activeViewId; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kWindowManager_embed_name: + var params = WindowManagerEmbedParams.deserialize( + message.payload); + _impl.embed(params.url, params.services, params.exposedServices); + break; + case kWindowManager_setCapture_name: + var params = WindowManagerSetCaptureParams.deserialize( + message.payload); + var response = _impl.setCapture(params.viewId,_WindowManagerSetCaptureResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kWindowManager_setCapture_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kWindowManager_setCapture_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kWindowManager_focusWindow_name: + var params = WindowManagerFocusWindowParams.deserialize( + message.payload); + var response = _impl.focusWindow(params.viewId,_WindowManagerFocusWindowResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kWindowManager_focusWindow_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kWindowManager_focusWindow_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kWindowManager_activateWindow_name: + var params = WindowManagerActivateWindowParams.deserialize( + message.payload); + var response = _impl.activateWindow(params.viewId,_WindowManagerActivateWindowResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kWindowManager_activateWindow_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kWindowManager_activateWindow_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kWindowManager_getFocusedAndActiveViews_name: + var params = WindowManagerGetFocusedAndActiveViewsParams.deserialize( + message.payload); + var response = _impl.getFocusedAndActiveViews(params.observer,_WindowManagerGetFocusedAndActiveViewsResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kWindowManager_getFocusedAndActiveViews_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kWindowManager_getFocusedAndActiveViews_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + WindowManager get impl => _impl; + set impl(WindowManager d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "WindowManagerStub($superString)"; + } + + int get version => 0; +} + +const int kWindowManagerObserver_onCaptureChanged_name = 0; +const int kWindowManagerObserver_onFocusChanged_name = 1; +const int kWindowManagerObserver_onActiveWindowChanged_name = 2; + +const String WindowManagerObserverName = + 'mojo::WindowManagerObserver'; + +abstract class WindowManagerObserver { + void onCaptureChanged(int captureViewId); + void onFocusChanged(int focusedViewId); + void onActiveWindowChanged(int focusedViewId); + +} + + +class WindowManagerObserverProxyImpl extends bindings.Proxy { + WindowManagerObserverProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + WindowManagerObserverProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + WindowManagerObserverProxyImpl.unbound() : super.unbound(); + + static WindowManagerObserverProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For WindowManagerObserverProxyImpl")); + return new WindowManagerObserverProxyImpl.fromEndpoint(endpoint); + } + + String get name => WindowManagerObserverName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "WindowManagerObserverProxyImpl($superString)"; + } +} + + +class _WindowManagerObserverProxyCalls implements WindowManagerObserver { + WindowManagerObserverProxyImpl _proxyImpl; + + _WindowManagerObserverProxyCalls(this._proxyImpl); + void onCaptureChanged(int captureViewId) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new WindowManagerObserverOnCaptureChangedParams(); + params.captureViewId = captureViewId; + _proxyImpl.sendMessage(params, kWindowManagerObserver_onCaptureChanged_name); + } + + void onFocusChanged(int focusedViewId) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new WindowManagerObserverOnFocusChangedParams(); + params.focusedViewId = focusedViewId; + _proxyImpl.sendMessage(params, kWindowManagerObserver_onFocusChanged_name); + } + + void onActiveWindowChanged(int focusedViewId) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new WindowManagerObserverOnActiveWindowChangedParams(); + params.focusedViewId = focusedViewId; + _proxyImpl.sendMessage(params, kWindowManagerObserver_onActiveWindowChanged_name); + } + +} + + +class WindowManagerObserverProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + WindowManagerObserver ptr; + final String name = WindowManagerObserverName; + + WindowManagerObserverProxy(WindowManagerObserverProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _WindowManagerObserverProxyCalls(proxyImpl); + + WindowManagerObserverProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new WindowManagerObserverProxyImpl.fromEndpoint(endpoint) { + ptr = new _WindowManagerObserverProxyCalls(impl); + } + + WindowManagerObserverProxy.fromHandle(core.MojoHandle handle) : + impl = new WindowManagerObserverProxyImpl.fromHandle(handle) { + ptr = new _WindowManagerObserverProxyCalls(impl); + } + + WindowManagerObserverProxy.unbound() : + impl = new WindowManagerObserverProxyImpl.unbound() { + ptr = new _WindowManagerObserverProxyCalls(impl); + } + + factory WindowManagerObserverProxy.connectToService( + bindings.ServiceConnector s, String url) { + WindowManagerObserverProxy p = new WindowManagerObserverProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static WindowManagerObserverProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For WindowManagerObserverProxy")); + return new WindowManagerObserverProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "WindowManagerObserverProxy($impl)"; + } +} + + +class WindowManagerObserverStub extends bindings.Stub { + WindowManagerObserver _impl = null; + + WindowManagerObserverStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + WindowManagerObserverStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + WindowManagerObserverStub.unbound() : super.unbound(); + + static WindowManagerObserverStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For WindowManagerObserverStub")); + return new WindowManagerObserverStub.fromEndpoint(endpoint); + } + + static const String name = WindowManagerObserverName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kWindowManagerObserver_onCaptureChanged_name: + var params = WindowManagerObserverOnCaptureChangedParams.deserialize( + message.payload); + _impl.onCaptureChanged(params.captureViewId); + break; + case kWindowManagerObserver_onFocusChanged_name: + var params = WindowManagerObserverOnFocusChangedParams.deserialize( + message.payload); + _impl.onFocusChanged(params.focusedViewId); + break; + case kWindowManagerObserver_onActiveWindowChanged_name: + var params = WindowManagerObserverOnActiveWindowChangedParams.deserialize( + message.payload); + _impl.onActiveWindowChanged(params.focusedViewId); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + WindowManagerObserver get impl => _impl; + set impl(WindowManagerObserver d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "WindowManagerObserverStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/mojo/window_manager_internal.mojom.dart b/mojo/dart/packages/mojo_services/lib/mojo/window_manager_internal.mojom.dart new file mode 100644 index 0000000..16645a4 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/mojo/window_manager_internal.mojom.dart
@@ -0,0 +1,770 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library window_manager_internal_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo_services/mojo/geometry.mojom.dart' as geometry_mojom; +import 'package:mojo_services/mojo/input_events.mojom.dart' as input_events_mojom; + + + +class WindowManagerInternalCreateWindowManagerForViewManagerClientParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int connectionId = 0; + core.MojoMessagePipeEndpoint windowManagerPipe = null; + + WindowManagerInternalCreateWindowManagerForViewManagerClientParams() : super(kVersions.last.size); + + static WindowManagerInternalCreateWindowManagerForViewManagerClientParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static WindowManagerInternalCreateWindowManagerForViewManagerClientParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + WindowManagerInternalCreateWindowManagerForViewManagerClientParams result = new WindowManagerInternalCreateWindowManagerForViewManagerClientParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.connectionId = decoder0.decodeUint16(8); + } + if (mainDataHeader.version >= 0) { + + result.windowManagerPipe = decoder0.decodeMessagePipeHandle(12, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint16(connectionId, 8); + + encoder0.encodeMessagePipeHandle(windowManagerPipe, 12, false); + } + + String toString() { + return "WindowManagerInternalCreateWindowManagerForViewManagerClientParams(" + "connectionId: $connectionId" ", " + "windowManagerPipe: $windowManagerPipe" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class WindowManagerInternalSetViewManagerClientParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + core.MojoMessagePipeEndpoint viewManagerClientRequest = null; + + WindowManagerInternalSetViewManagerClientParams() : super(kVersions.last.size); + + static WindowManagerInternalSetViewManagerClientParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static WindowManagerInternalSetViewManagerClientParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + WindowManagerInternalSetViewManagerClientParams result = new WindowManagerInternalSetViewManagerClientParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.viewManagerClientRequest = decoder0.decodeMessagePipeHandle(8, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeMessagePipeHandle(viewManagerClientRequest, 8, false); + } + + String toString() { + return "WindowManagerInternalSetViewManagerClientParams(" + "viewManagerClientRequest: $viewManagerClientRequest" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class WindowManagerInternalClientDispatchInputEventToViewParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + int viewId = 0; + input_events_mojom.Event event = null; + + WindowManagerInternalClientDispatchInputEventToViewParams() : super(kVersions.last.size); + + static WindowManagerInternalClientDispatchInputEventToViewParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static WindowManagerInternalClientDispatchInputEventToViewParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + WindowManagerInternalClientDispatchInputEventToViewParams result = new WindowManagerInternalClientDispatchInputEventToViewParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.viewId = decoder0.decodeUint32(8); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, false); + result.event = input_events_mojom.Event.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(viewId, 8); + + encoder0.encodeStruct(event, 16, false); + } + + String toString() { + return "WindowManagerInternalClientDispatchInputEventToViewParams(" + "viewId: $viewId" ", " + "event: $event" ")"; + } + + Map toJson() { + Map map = new Map(); + map["viewId"] = viewId; + map["event"] = event; + return map; + } +} + + +class WindowManagerInternalClientSetViewportSizeParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + geometry_mojom.Size size = null; + + WindowManagerInternalClientSetViewportSizeParams() : super(kVersions.last.size); + + static WindowManagerInternalClientSetViewportSizeParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static WindowManagerInternalClientSetViewportSizeParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + WindowManagerInternalClientSetViewportSizeParams result = new WindowManagerInternalClientSetViewportSizeParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.size = geometry_mojom.Size.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(size, 8, false); + } + + String toString() { + return "WindowManagerInternalClientSetViewportSizeParams(" + "size: $size" ")"; + } + + Map toJson() { + Map map = new Map(); + map["size"] = size; + return map; + } +} + + +class WindowManagerInternalClientCloneAndAnimateParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int viewId = 0; + + WindowManagerInternalClientCloneAndAnimateParams() : super(kVersions.last.size); + + static WindowManagerInternalClientCloneAndAnimateParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static WindowManagerInternalClientCloneAndAnimateParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + WindowManagerInternalClientCloneAndAnimateParams result = new WindowManagerInternalClientCloneAndAnimateParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.viewId = decoder0.decodeUint32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint32(viewId, 8); + } + + String toString() { + return "WindowManagerInternalClientCloneAndAnimateParams(" + "viewId: $viewId" ")"; + } + + Map toJson() { + Map map = new Map(); + map["viewId"] = viewId; + return map; + } +} + +const int kWindowManagerInternal_createWindowManagerForViewManagerClient_name = 0; +const int kWindowManagerInternal_setViewManagerClient_name = 1; + +const String WindowManagerInternalName = + 'mojo::WindowManagerInternal'; + +abstract class WindowManagerInternal { + void createWindowManagerForViewManagerClient(int connectionId, core.MojoMessagePipeEndpoint windowManagerPipe); + void setViewManagerClient(core.MojoMessagePipeEndpoint viewManagerClientRequest); + +} + + +class WindowManagerInternalProxyImpl extends bindings.Proxy { + WindowManagerInternalProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + WindowManagerInternalProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + WindowManagerInternalProxyImpl.unbound() : super.unbound(); + + static WindowManagerInternalProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For WindowManagerInternalProxyImpl")); + return new WindowManagerInternalProxyImpl.fromEndpoint(endpoint); + } + + String get name => WindowManagerInternalName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "WindowManagerInternalProxyImpl($superString)"; + } +} + + +class _WindowManagerInternalProxyCalls implements WindowManagerInternal { + WindowManagerInternalProxyImpl _proxyImpl; + + _WindowManagerInternalProxyCalls(this._proxyImpl); + void createWindowManagerForViewManagerClient(int connectionId, core.MojoMessagePipeEndpoint windowManagerPipe) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new WindowManagerInternalCreateWindowManagerForViewManagerClientParams(); + params.connectionId = connectionId; + params.windowManagerPipe = windowManagerPipe; + _proxyImpl.sendMessage(params, kWindowManagerInternal_createWindowManagerForViewManagerClient_name); + } + + void setViewManagerClient(core.MojoMessagePipeEndpoint viewManagerClientRequest) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new WindowManagerInternalSetViewManagerClientParams(); + params.viewManagerClientRequest = viewManagerClientRequest; + _proxyImpl.sendMessage(params, kWindowManagerInternal_setViewManagerClient_name); + } + +} + + +class WindowManagerInternalProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + WindowManagerInternal ptr; + final String name = WindowManagerInternalName; + + WindowManagerInternalProxy(WindowManagerInternalProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _WindowManagerInternalProxyCalls(proxyImpl); + + WindowManagerInternalProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new WindowManagerInternalProxyImpl.fromEndpoint(endpoint) { + ptr = new _WindowManagerInternalProxyCalls(impl); + } + + WindowManagerInternalProxy.fromHandle(core.MojoHandle handle) : + impl = new WindowManagerInternalProxyImpl.fromHandle(handle) { + ptr = new _WindowManagerInternalProxyCalls(impl); + } + + WindowManagerInternalProxy.unbound() : + impl = new WindowManagerInternalProxyImpl.unbound() { + ptr = new _WindowManagerInternalProxyCalls(impl); + } + + factory WindowManagerInternalProxy.connectToService( + bindings.ServiceConnector s, String url) { + WindowManagerInternalProxy p = new WindowManagerInternalProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static WindowManagerInternalProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For WindowManagerInternalProxy")); + return new WindowManagerInternalProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "WindowManagerInternalProxy($impl)"; + } +} + + +class WindowManagerInternalStub extends bindings.Stub { + WindowManagerInternal _impl = null; + + WindowManagerInternalStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + WindowManagerInternalStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + WindowManagerInternalStub.unbound() : super.unbound(); + + static WindowManagerInternalStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For WindowManagerInternalStub")); + return new WindowManagerInternalStub.fromEndpoint(endpoint); + } + + static const String name = WindowManagerInternalName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kWindowManagerInternal_createWindowManagerForViewManagerClient_name: + var params = WindowManagerInternalCreateWindowManagerForViewManagerClientParams.deserialize( + message.payload); + _impl.createWindowManagerForViewManagerClient(params.connectionId, params.windowManagerPipe); + break; + case kWindowManagerInternal_setViewManagerClient_name: + var params = WindowManagerInternalSetViewManagerClientParams.deserialize( + message.payload); + _impl.setViewManagerClient(params.viewManagerClientRequest); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + WindowManagerInternal get impl => _impl; + set impl(WindowManagerInternal d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "WindowManagerInternalStub($superString)"; + } + + int get version => 0; +} + +const int kWindowManagerInternalClient_dispatchInputEventToView_name = 0; +const int kWindowManagerInternalClient_setViewportSize_name = 1; +const int kWindowManagerInternalClient_cloneAndAnimate_name = 2; + +const String WindowManagerInternalClientName = + 'mojo::WindowManagerInternalClient'; + +abstract class WindowManagerInternalClient { + void dispatchInputEventToView(int viewId, input_events_mojom.Event event); + void setViewportSize(geometry_mojom.Size size); + void cloneAndAnimate(int viewId); + +} + + +class WindowManagerInternalClientProxyImpl extends bindings.Proxy { + WindowManagerInternalClientProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + WindowManagerInternalClientProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + WindowManagerInternalClientProxyImpl.unbound() : super.unbound(); + + static WindowManagerInternalClientProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For WindowManagerInternalClientProxyImpl")); + return new WindowManagerInternalClientProxyImpl.fromEndpoint(endpoint); + } + + String get name => WindowManagerInternalClientName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "WindowManagerInternalClientProxyImpl($superString)"; + } +} + + +class _WindowManagerInternalClientProxyCalls implements WindowManagerInternalClient { + WindowManagerInternalClientProxyImpl _proxyImpl; + + _WindowManagerInternalClientProxyCalls(this._proxyImpl); + void dispatchInputEventToView(int viewId, input_events_mojom.Event event) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new WindowManagerInternalClientDispatchInputEventToViewParams(); + params.viewId = viewId; + params.event = event; + _proxyImpl.sendMessage(params, kWindowManagerInternalClient_dispatchInputEventToView_name); + } + + void setViewportSize(geometry_mojom.Size size) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new WindowManagerInternalClientSetViewportSizeParams(); + params.size = size; + _proxyImpl.sendMessage(params, kWindowManagerInternalClient_setViewportSize_name); + } + + void cloneAndAnimate(int viewId) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new WindowManagerInternalClientCloneAndAnimateParams(); + params.viewId = viewId; + _proxyImpl.sendMessage(params, kWindowManagerInternalClient_cloneAndAnimate_name); + } + +} + + +class WindowManagerInternalClientProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + WindowManagerInternalClient ptr; + final String name = WindowManagerInternalClientName; + + WindowManagerInternalClientProxy(WindowManagerInternalClientProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _WindowManagerInternalClientProxyCalls(proxyImpl); + + WindowManagerInternalClientProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new WindowManagerInternalClientProxyImpl.fromEndpoint(endpoint) { + ptr = new _WindowManagerInternalClientProxyCalls(impl); + } + + WindowManagerInternalClientProxy.fromHandle(core.MojoHandle handle) : + impl = new WindowManagerInternalClientProxyImpl.fromHandle(handle) { + ptr = new _WindowManagerInternalClientProxyCalls(impl); + } + + WindowManagerInternalClientProxy.unbound() : + impl = new WindowManagerInternalClientProxyImpl.unbound() { + ptr = new _WindowManagerInternalClientProxyCalls(impl); + } + + factory WindowManagerInternalClientProxy.connectToService( + bindings.ServiceConnector s, String url) { + WindowManagerInternalClientProxy p = new WindowManagerInternalClientProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static WindowManagerInternalClientProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For WindowManagerInternalClientProxy")); + return new WindowManagerInternalClientProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "WindowManagerInternalClientProxy($impl)"; + } +} + + +class WindowManagerInternalClientStub extends bindings.Stub { + WindowManagerInternalClient _impl = null; + + WindowManagerInternalClientStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + WindowManagerInternalClientStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + WindowManagerInternalClientStub.unbound() : super.unbound(); + + static WindowManagerInternalClientStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For WindowManagerInternalClientStub")); + return new WindowManagerInternalClientStub.fromEndpoint(endpoint); + } + + static const String name = WindowManagerInternalClientName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kWindowManagerInternalClient_dispatchInputEventToView_name: + var params = WindowManagerInternalClientDispatchInputEventToViewParams.deserialize( + message.payload); + _impl.dispatchInputEventToView(params.viewId, params.event); + break; + case kWindowManagerInternalClient_setViewportSize_name: + var params = WindowManagerInternalClientSetViewportSizeParams.deserialize( + message.payload); + _impl.setViewportSize(params.size); + break; + case kWindowManagerInternalClient_cloneAndAnimate_name: + var params = WindowManagerInternalClientCloneAndAnimateParams.deserialize( + message.payload); + _impl.cloneAndAnimate(params.viewId); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + WindowManagerInternalClient get impl => _impl; + set impl(WindowManagerInternalClient d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "WindowManagerInternalClientStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/native_support/process.mojom.dart b/mojo/dart/packages/mojo_services/lib/native_support/process.mojom.dart new file mode 100644 index 0000000..a469c9d --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/native_support/process.mojom.dart
@@ -0,0 +1,1275 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library process_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +import 'package:mojo_services/mojo/files/file.mojom.dart' as file_mojom; +import 'package:mojo_services/mojo/files/types.mojom.dart' as types_mojom; + + + +class ProcessSpawnParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(64, 0) + ]; + String path = null; + List<String> argv = null; + List<String> envp = null; + Object stdinFile = null; + Object stdoutFile = null; + Object stderrFile = null; + Object processController = null; + + ProcessSpawnParams() : super(kVersions.last.size); + + static ProcessSpawnParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ProcessSpawnParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ProcessSpawnParams result = new ProcessSpawnParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.path = decoder0.decodeString(8, false); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, true); + if (decoder1 == null) { + result.argv = null; + } else { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.argv = new List<String>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + result.argv[i1] = decoder1.decodeString(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + } + } + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(24, true); + if (decoder1 == null) { + result.envp = null; + } else { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.envp = new List<String>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + result.envp[i1] = decoder1.decodeString(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + } + } + } + if (mainDataHeader.version >= 0) { + + result.stdinFile = decoder0.decodeServiceInterface(32, true, file_mojom.FileProxy.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.stdoutFile = decoder0.decodeServiceInterface(40, true, file_mojom.FileProxy.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.stderrFile = decoder0.decodeServiceInterface(48, true, file_mojom.FileProxy.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.processController = decoder0.decodeInterfaceRequest(56, false, ProcessControllerStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(path, 8, false); + + if (argv == null) { + encoder0.encodeNullPointer(16, true); + } else { + var encoder1 = encoder0.encodePointerArray(argv.length, 16, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < argv.length; ++i0) { + + encoder1.encodeString(argv[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + + if (envp == null) { + encoder0.encodeNullPointer(24, true); + } else { + var encoder1 = encoder0.encodePointerArray(envp.length, 24, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < envp.length; ++i0) { + + encoder1.encodeString(envp[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + + encoder0.encodeInterface(stdinFile, 32, true); + + encoder0.encodeInterface(stdoutFile, 40, true); + + encoder0.encodeInterface(stderrFile, 48, true); + + encoder0.encodeInterfaceRequest(processController, 56, false); + } + + String toString() { + return "ProcessSpawnParams(" + "path: $path" ", " + "argv: $argv" ", " + "envp: $envp" ", " + "stdinFile: $stdinFile" ", " + "stdoutFile: $stdoutFile" ", " + "stderrFile: $stderrFile" ", " + "processController: $processController" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class ProcessSpawnResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + types_mojom.Error error = null; + + ProcessSpawnResponseParams() : super(kVersions.last.size); + + static ProcessSpawnResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ProcessSpawnResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ProcessSpawnResponseParams result = new ProcessSpawnResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + } + + String toString() { + return "ProcessSpawnResponseParams(" + "error: $error" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + return map; + } +} + + +class ProcessSpawnWithTerminalParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(48, 0) + ]; + String path = null; + List<String> argv = null; + List<String> envp = null; + Object terminalFile = null; + Object processController = null; + + ProcessSpawnWithTerminalParams() : super(kVersions.last.size); + + static ProcessSpawnWithTerminalParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ProcessSpawnWithTerminalParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ProcessSpawnWithTerminalParams result = new ProcessSpawnWithTerminalParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.path = decoder0.decodeString(8, false); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(16, true); + if (decoder1 == null) { + result.argv = null; + } else { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.argv = new List<String>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + result.argv[i1] = decoder1.decodeString(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + } + } + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(24, true); + if (decoder1 == null) { + result.envp = null; + } else { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.envp = new List<String>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + result.envp[i1] = decoder1.decodeString(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + } + } + } + if (mainDataHeader.version >= 0) { + + result.terminalFile = decoder0.decodeServiceInterface(32, false, file_mojom.FileProxy.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.processController = decoder0.decodeInterfaceRequest(40, false, ProcessControllerStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(path, 8, false); + + if (argv == null) { + encoder0.encodeNullPointer(16, true); + } else { + var encoder1 = encoder0.encodePointerArray(argv.length, 16, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < argv.length; ++i0) { + + encoder1.encodeString(argv[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + + if (envp == null) { + encoder0.encodeNullPointer(24, true); + } else { + var encoder1 = encoder0.encodePointerArray(envp.length, 24, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < envp.length; ++i0) { + + encoder1.encodeString(envp[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + + encoder0.encodeInterface(terminalFile, 32, false); + + encoder0.encodeInterfaceRequest(processController, 40, false); + } + + String toString() { + return "ProcessSpawnWithTerminalParams(" + "path: $path" ", " + "argv: $argv" ", " + "envp: $envp" ", " + "terminalFile: $terminalFile" ", " + "processController: $processController" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class ProcessSpawnWithTerminalResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + types_mojom.Error error = null; + + ProcessSpawnWithTerminalResponseParams() : super(kVersions.last.size); + + static ProcessSpawnWithTerminalResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ProcessSpawnWithTerminalResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ProcessSpawnWithTerminalResponseParams result = new ProcessSpawnWithTerminalResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + } + + String toString() { + return "ProcessSpawnWithTerminalResponseParams(" + "error: $error" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + return map; + } +} + + +class ProcessControllerWaitParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + ProcessControllerWaitParams() : super(kVersions.last.size); + + static ProcessControllerWaitParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ProcessControllerWaitParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ProcessControllerWaitParams result = new ProcessControllerWaitParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "ProcessControllerWaitParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class ProcessControllerWaitResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + types_mojom.Error error = null; + int exitStatus = 0; + + ProcessControllerWaitResponseParams() : super(kVersions.last.size); + + static ProcessControllerWaitResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ProcessControllerWaitResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ProcessControllerWaitResponseParams result = new ProcessControllerWaitResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + if (mainDataHeader.version >= 0) { + + result.exitStatus = decoder0.decodeInt32(12); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + + encoder0.encodeInt32(exitStatus, 12); + } + + String toString() { + return "ProcessControllerWaitResponseParams(" + "error: $error" ", " + "exitStatus: $exitStatus" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + map["exitStatus"] = exitStatus; + return map; + } +} + + +class ProcessControllerKillParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int signal = 0; + + ProcessControllerKillParams() : super(kVersions.last.size); + + static ProcessControllerKillParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ProcessControllerKillParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ProcessControllerKillParams result = new ProcessControllerKillParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.signal = decoder0.decodeInt32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt32(signal, 8); + } + + String toString() { + return "ProcessControllerKillParams(" + "signal: $signal" ")"; + } + + Map toJson() { + Map map = new Map(); + map["signal"] = signal; + return map; + } +} + + +class ProcessControllerKillResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + types_mojom.Error error = null; + + ProcessControllerKillResponseParams() : super(kVersions.last.size); + + static ProcessControllerKillResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static ProcessControllerKillResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + ProcessControllerKillResponseParams result = new ProcessControllerKillResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.error = types_mojom.Error.decode(decoder0, 8); + if (result.error == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable types_mojom.Error.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(error, 8); + } + + String toString() { + return "ProcessControllerKillResponseParams(" + "error: $error" ")"; + } + + Map toJson() { + Map map = new Map(); + map["error"] = error; + return map; + } +} + +const int kProcess_spawn_name = 0; +const int kProcess_spawnWithTerminal_name = 1; + +const String ProcessName = + 'native_support::Process'; + +abstract class Process { + dynamic spawn(String path,List<String> argv,List<String> envp,Object stdinFile,Object stdoutFile,Object stderrFile,Object processController,[Function responseFactory = null]); + dynamic spawnWithTerminal(String path,List<String> argv,List<String> envp,Object terminalFile,Object processController,[Function responseFactory = null]); + +} + + +class ProcessProxyImpl extends bindings.Proxy { + ProcessProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + ProcessProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + ProcessProxyImpl.unbound() : super.unbound(); + + static ProcessProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ProcessProxyImpl")); + return new ProcessProxyImpl.fromEndpoint(endpoint); + } + + String get name => ProcessName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kProcess_spawn_name: + var r = ProcessSpawnResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kProcess_spawnWithTerminal_name: + var r = ProcessSpawnWithTerminalResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "ProcessProxyImpl($superString)"; + } +} + + +class _ProcessProxyCalls implements Process { + ProcessProxyImpl _proxyImpl; + + _ProcessProxyCalls(this._proxyImpl); + dynamic spawn(String path,List<String> argv,List<String> envp,Object stdinFile,Object stdoutFile,Object stderrFile,Object processController,[Function responseFactory = null]) { + var params = new ProcessSpawnParams(); + params.path = path; + params.argv = argv; + params.envp = envp; + params.stdinFile = stdinFile; + params.stdoutFile = stdoutFile; + params.stderrFile = stderrFile; + params.processController = processController; + return _proxyImpl.sendMessageWithRequestId( + params, + kProcess_spawn_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic spawnWithTerminal(String path,List<String> argv,List<String> envp,Object terminalFile,Object processController,[Function responseFactory = null]) { + var params = new ProcessSpawnWithTerminalParams(); + params.path = path; + params.argv = argv; + params.envp = envp; + params.terminalFile = terminalFile; + params.processController = processController; + return _proxyImpl.sendMessageWithRequestId( + params, + kProcess_spawnWithTerminal_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class ProcessProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + Process ptr; + final String name = ProcessName; + + ProcessProxy(ProcessProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _ProcessProxyCalls(proxyImpl); + + ProcessProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new ProcessProxyImpl.fromEndpoint(endpoint) { + ptr = new _ProcessProxyCalls(impl); + } + + ProcessProxy.fromHandle(core.MojoHandle handle) : + impl = new ProcessProxyImpl.fromHandle(handle) { + ptr = new _ProcessProxyCalls(impl); + } + + ProcessProxy.unbound() : + impl = new ProcessProxyImpl.unbound() { + ptr = new _ProcessProxyCalls(impl); + } + + factory ProcessProxy.connectToService( + bindings.ServiceConnector s, String url) { + ProcessProxy p = new ProcessProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static ProcessProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ProcessProxy")); + return new ProcessProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "ProcessProxy($impl)"; + } +} + + +class ProcessStub extends bindings.Stub { + Process _impl = null; + + ProcessStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + ProcessStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + ProcessStub.unbound() : super.unbound(); + + static ProcessStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ProcessStub")); + return new ProcessStub.fromEndpoint(endpoint); + } + + static const String name = ProcessName; + + + ProcessSpawnResponseParams _ProcessSpawnResponseParamsFactory(types_mojom.Error error) { + var result = new ProcessSpawnResponseParams(); + result.error = error; + return result; + } + ProcessSpawnWithTerminalResponseParams _ProcessSpawnWithTerminalResponseParamsFactory(types_mojom.Error error) { + var result = new ProcessSpawnWithTerminalResponseParams(); + result.error = error; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kProcess_spawn_name: + var params = ProcessSpawnParams.deserialize( + message.payload); + var response = _impl.spawn(params.path,params.argv,params.envp,params.stdinFile,params.stdoutFile,params.stderrFile,params.processController,_ProcessSpawnResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kProcess_spawn_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kProcess_spawn_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kProcess_spawnWithTerminal_name: + var params = ProcessSpawnWithTerminalParams.deserialize( + message.payload); + var response = _impl.spawnWithTerminal(params.path,params.argv,params.envp,params.terminalFile,params.processController,_ProcessSpawnWithTerminalResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kProcess_spawnWithTerminal_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kProcess_spawnWithTerminal_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + Process get impl => _impl; + set impl(Process d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "ProcessStub($superString)"; + } + + int get version => 0; +} + +const int kProcessController_wait_name = 0; +const int kProcessController_kill_name = 1; + +const String ProcessControllerName = + 'native_support::ProcessController'; + +abstract class ProcessController { + dynamic wait([Function responseFactory = null]); + dynamic kill(int signal,[Function responseFactory = null]); + +} + + +class ProcessControllerProxyImpl extends bindings.Proxy { + ProcessControllerProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + ProcessControllerProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + ProcessControllerProxyImpl.unbound() : super.unbound(); + + static ProcessControllerProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ProcessControllerProxyImpl")); + return new ProcessControllerProxyImpl.fromEndpoint(endpoint); + } + + String get name => ProcessControllerName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kProcessController_wait_name: + var r = ProcessControllerWaitResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + case kProcessController_kill_name: + var r = ProcessControllerKillResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "ProcessControllerProxyImpl($superString)"; + } +} + + +class _ProcessControllerProxyCalls implements ProcessController { + ProcessControllerProxyImpl _proxyImpl; + + _ProcessControllerProxyCalls(this._proxyImpl); + dynamic wait([Function responseFactory = null]) { + var params = new ProcessControllerWaitParams(); + return _proxyImpl.sendMessageWithRequestId( + params, + kProcessController_wait_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + dynamic kill(int signal,[Function responseFactory = null]) { + var params = new ProcessControllerKillParams(); + params.signal = signal; + return _proxyImpl.sendMessageWithRequestId( + params, + kProcessController_kill_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class ProcessControllerProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + ProcessController ptr; + final String name = ProcessControllerName; + + ProcessControllerProxy(ProcessControllerProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _ProcessControllerProxyCalls(proxyImpl); + + ProcessControllerProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new ProcessControllerProxyImpl.fromEndpoint(endpoint) { + ptr = new _ProcessControllerProxyCalls(impl); + } + + ProcessControllerProxy.fromHandle(core.MojoHandle handle) : + impl = new ProcessControllerProxyImpl.fromHandle(handle) { + ptr = new _ProcessControllerProxyCalls(impl); + } + + ProcessControllerProxy.unbound() : + impl = new ProcessControllerProxyImpl.unbound() { + ptr = new _ProcessControllerProxyCalls(impl); + } + + factory ProcessControllerProxy.connectToService( + bindings.ServiceConnector s, String url) { + ProcessControllerProxy p = new ProcessControllerProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static ProcessControllerProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ProcessControllerProxy")); + return new ProcessControllerProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "ProcessControllerProxy($impl)"; + } +} + + +class ProcessControllerStub extends bindings.Stub { + ProcessController _impl = null; + + ProcessControllerStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + ProcessControllerStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + ProcessControllerStub.unbound() : super.unbound(); + + static ProcessControllerStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For ProcessControllerStub")); + return new ProcessControllerStub.fromEndpoint(endpoint); + } + + static const String name = ProcessControllerName; + + + ProcessControllerWaitResponseParams _ProcessControllerWaitResponseParamsFactory(types_mojom.Error error, int exitStatus) { + var result = new ProcessControllerWaitResponseParams(); + result.error = error; + result.exitStatus = exitStatus; + return result; + } + ProcessControllerKillResponseParams _ProcessControllerKillResponseParamsFactory(types_mojom.Error error) { + var result = new ProcessControllerKillResponseParams(); + result.error = error; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kProcessController_wait_name: + var params = ProcessControllerWaitParams.deserialize( + message.payload); + var response = _impl.wait(_ProcessControllerWaitResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kProcessController_wait_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kProcessController_wait_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kProcessController_kill_name: + var params = ProcessControllerKillParams.deserialize( + message.payload); + var response = _impl.kill(params.signal,_ProcessControllerKillResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kProcessController_kill_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kProcessController_kill_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + ProcessController get impl => _impl; + set impl(ProcessController d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "ProcessControllerStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/nfc/nfc.mojom.dart b/mojo/dart/packages/mojo_services/lib/nfc/nfc.mojom.dart new file mode 100644 index 0000000..bd26fa2 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/nfc/nfc.mojom.dart
@@ -0,0 +1,1062 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library nfc_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; + + + +class NfcData extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + List<int> data = null; + + NfcData() : super(kVersions.last.size); + + static NfcData deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NfcData decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NfcData result = new NfcData(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.data = decoder0.decodeUint8Array(8, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUint8Array(data, 8, bindings.kArrayNullable, bindings.kUnspecifiedArrayLength); + } + + String toString() { + return "NfcData(" + "data: $data" ")"; + } + + Map toJson() { + Map map = new Map(); + map["data"] = data; + return map; + } +} + + +class NfcTransmissionCancelParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + NfcTransmissionCancelParams() : super(kVersions.last.size); + + static NfcTransmissionCancelParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NfcTransmissionCancelParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NfcTransmissionCancelParams result = new NfcTransmissionCancelParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "NfcTransmissionCancelParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class NfcReceiverOnReceivedNfcDataParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + NfcData nfcData = null; + + NfcReceiverOnReceivedNfcDataParams() : super(kVersions.last.size); + + static NfcReceiverOnReceivedNfcDataParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NfcReceiverOnReceivedNfcDataParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NfcReceiverOnReceivedNfcDataParams result = new NfcReceiverOnReceivedNfcDataParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.nfcData = NfcData.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(nfcData, 8, false); + } + + String toString() { + return "NfcReceiverOnReceivedNfcDataParams(" + "nfcData: $nfcData" ")"; + } + + Map toJson() { + Map map = new Map(); + map["nfcData"] = nfcData; + return map; + } +} + + +class NfcTransmitOnNextConnectionParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + NfcData nfcData = null; + Object transmission = null; + + NfcTransmitOnNextConnectionParams() : super(kVersions.last.size); + + static NfcTransmitOnNextConnectionParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NfcTransmitOnNextConnectionParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NfcTransmitOnNextConnectionParams result = new NfcTransmitOnNextConnectionParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.nfcData = NfcData.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + result.transmission = decoder0.decodeInterfaceRequest(16, true, NfcTransmissionStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(nfcData, 8, false); + + encoder0.encodeInterfaceRequest(transmission, 16, true); + } + + String toString() { + return "NfcTransmitOnNextConnectionParams(" + "nfcData: $nfcData" ", " + "transmission: $transmission" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class NfcTransmitOnNextConnectionResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + bool success = false; + + NfcTransmitOnNextConnectionResponseParams() : super(kVersions.last.size); + + static NfcTransmitOnNextConnectionResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NfcTransmitOnNextConnectionResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NfcTransmitOnNextConnectionResponseParams result = new NfcTransmitOnNextConnectionResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.success = decoder0.decodeBool(8, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeBool(success, 8, 0); + } + + String toString() { + return "NfcTransmitOnNextConnectionResponseParams(" + "success: $success" ")"; + } + + Map toJson() { + Map map = new Map(); + map["success"] = success; + return map; + } +} + + +class NfcRegisterParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + NfcRegisterParams() : super(kVersions.last.size); + + static NfcRegisterParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NfcRegisterParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NfcRegisterParams result = new NfcRegisterParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "NfcRegisterParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class NfcUnregisterParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + NfcUnregisterParams() : super(kVersions.last.size); + + static NfcUnregisterParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NfcUnregisterParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NfcUnregisterParams result = new NfcUnregisterParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "NfcUnregisterParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + +const int kNfcTransmission_cancel_name = 0; + +const String NfcTransmissionName = + 'nfc::NfcTransmission'; + +abstract class NfcTransmission { + void cancel(); + +} + + +class NfcTransmissionProxyImpl extends bindings.Proxy { + NfcTransmissionProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + NfcTransmissionProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + NfcTransmissionProxyImpl.unbound() : super.unbound(); + + static NfcTransmissionProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NfcTransmissionProxyImpl")); + return new NfcTransmissionProxyImpl.fromEndpoint(endpoint); + } + + String get name => NfcTransmissionName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "NfcTransmissionProxyImpl($superString)"; + } +} + + +class _NfcTransmissionProxyCalls implements NfcTransmission { + NfcTransmissionProxyImpl _proxyImpl; + + _NfcTransmissionProxyCalls(this._proxyImpl); + void cancel() { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new NfcTransmissionCancelParams(); + _proxyImpl.sendMessage(params, kNfcTransmission_cancel_name); + } + +} + + +class NfcTransmissionProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + NfcTransmission ptr; + final String name = NfcTransmissionName; + + NfcTransmissionProxy(NfcTransmissionProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _NfcTransmissionProxyCalls(proxyImpl); + + NfcTransmissionProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new NfcTransmissionProxyImpl.fromEndpoint(endpoint) { + ptr = new _NfcTransmissionProxyCalls(impl); + } + + NfcTransmissionProxy.fromHandle(core.MojoHandle handle) : + impl = new NfcTransmissionProxyImpl.fromHandle(handle) { + ptr = new _NfcTransmissionProxyCalls(impl); + } + + NfcTransmissionProxy.unbound() : + impl = new NfcTransmissionProxyImpl.unbound() { + ptr = new _NfcTransmissionProxyCalls(impl); + } + + factory NfcTransmissionProxy.connectToService( + bindings.ServiceConnector s, String url) { + NfcTransmissionProxy p = new NfcTransmissionProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static NfcTransmissionProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NfcTransmissionProxy")); + return new NfcTransmissionProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "NfcTransmissionProxy($impl)"; + } +} + + +class NfcTransmissionStub extends bindings.Stub { + NfcTransmission _impl = null; + + NfcTransmissionStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + NfcTransmissionStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + NfcTransmissionStub.unbound() : super.unbound(); + + static NfcTransmissionStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NfcTransmissionStub")); + return new NfcTransmissionStub.fromEndpoint(endpoint); + } + + static const String name = NfcTransmissionName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kNfcTransmission_cancel_name: + var params = NfcTransmissionCancelParams.deserialize( + message.payload); + _impl.cancel(); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + NfcTransmission get impl => _impl; + set impl(NfcTransmission d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "NfcTransmissionStub($superString)"; + } + + int get version => 0; +} + +const int kNfcReceiver_onReceivedNfcData_name = 0; + +const String NfcReceiverName = + 'nfc::NfcReceiver'; + +abstract class NfcReceiver { + void onReceivedNfcData(NfcData nfcData); + +} + + +class NfcReceiverProxyImpl extends bindings.Proxy { + NfcReceiverProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + NfcReceiverProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + NfcReceiverProxyImpl.unbound() : super.unbound(); + + static NfcReceiverProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NfcReceiverProxyImpl")); + return new NfcReceiverProxyImpl.fromEndpoint(endpoint); + } + + String get name => NfcReceiverName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "NfcReceiverProxyImpl($superString)"; + } +} + + +class _NfcReceiverProxyCalls implements NfcReceiver { + NfcReceiverProxyImpl _proxyImpl; + + _NfcReceiverProxyCalls(this._proxyImpl); + void onReceivedNfcData(NfcData nfcData) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new NfcReceiverOnReceivedNfcDataParams(); + params.nfcData = nfcData; + _proxyImpl.sendMessage(params, kNfcReceiver_onReceivedNfcData_name); + } + +} + + +class NfcReceiverProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + NfcReceiver ptr; + final String name = NfcReceiverName; + + NfcReceiverProxy(NfcReceiverProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _NfcReceiverProxyCalls(proxyImpl); + + NfcReceiverProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new NfcReceiverProxyImpl.fromEndpoint(endpoint) { + ptr = new _NfcReceiverProxyCalls(impl); + } + + NfcReceiverProxy.fromHandle(core.MojoHandle handle) : + impl = new NfcReceiverProxyImpl.fromHandle(handle) { + ptr = new _NfcReceiverProxyCalls(impl); + } + + NfcReceiverProxy.unbound() : + impl = new NfcReceiverProxyImpl.unbound() { + ptr = new _NfcReceiverProxyCalls(impl); + } + + factory NfcReceiverProxy.connectToService( + bindings.ServiceConnector s, String url) { + NfcReceiverProxy p = new NfcReceiverProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static NfcReceiverProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NfcReceiverProxy")); + return new NfcReceiverProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "NfcReceiverProxy($impl)"; + } +} + + +class NfcReceiverStub extends bindings.Stub { + NfcReceiver _impl = null; + + NfcReceiverStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + NfcReceiverStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + NfcReceiverStub.unbound() : super.unbound(); + + static NfcReceiverStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NfcReceiverStub")); + return new NfcReceiverStub.fromEndpoint(endpoint); + } + + static const String name = NfcReceiverName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kNfcReceiver_onReceivedNfcData_name: + var params = NfcReceiverOnReceivedNfcDataParams.deserialize( + message.payload); + _impl.onReceivedNfcData(params.nfcData); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + NfcReceiver get impl => _impl; + set impl(NfcReceiver d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "NfcReceiverStub($superString)"; + } + + int get version => 0; +} + +const int kNfc_transmitOnNextConnection_name = 0; +const int kNfc_register_name = 1; +const int kNfc_unregister_name = 2; + +const String NfcName = + 'nfc::Nfc'; + +abstract class Nfc { + dynamic transmitOnNextConnection(NfcData nfcData,Object transmission,[Function responseFactory = null]); + void register(); + void unregister(); + +} + + +class NfcProxyImpl extends bindings.Proxy { + NfcProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + NfcProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + NfcProxyImpl.unbound() : super.unbound(); + + static NfcProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NfcProxyImpl")); + return new NfcProxyImpl.fromEndpoint(endpoint); + } + + String get name => NfcName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kNfc_transmitOnNextConnection_name: + var r = NfcTransmitOnNextConnectionResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "NfcProxyImpl($superString)"; + } +} + + +class _NfcProxyCalls implements Nfc { + NfcProxyImpl _proxyImpl; + + _NfcProxyCalls(this._proxyImpl); + dynamic transmitOnNextConnection(NfcData nfcData,Object transmission,[Function responseFactory = null]) { + var params = new NfcTransmitOnNextConnectionParams(); + params.nfcData = nfcData; + params.transmission = transmission; + return _proxyImpl.sendMessageWithRequestId( + params, + kNfc_transmitOnNextConnection_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + void register() { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new NfcRegisterParams(); + _proxyImpl.sendMessage(params, kNfc_register_name); + } + + void unregister() { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new NfcUnregisterParams(); + _proxyImpl.sendMessage(params, kNfc_unregister_name); + } + +} + + +class NfcProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + Nfc ptr; + final String name = NfcName; + + NfcProxy(NfcProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _NfcProxyCalls(proxyImpl); + + NfcProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new NfcProxyImpl.fromEndpoint(endpoint) { + ptr = new _NfcProxyCalls(impl); + } + + NfcProxy.fromHandle(core.MojoHandle handle) : + impl = new NfcProxyImpl.fromHandle(handle) { + ptr = new _NfcProxyCalls(impl); + } + + NfcProxy.unbound() : + impl = new NfcProxyImpl.unbound() { + ptr = new _NfcProxyCalls(impl); + } + + factory NfcProxy.connectToService( + bindings.ServiceConnector s, String url) { + NfcProxy p = new NfcProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static NfcProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NfcProxy")); + return new NfcProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "NfcProxy($impl)"; + } +} + + +class NfcStub extends bindings.Stub { + Nfc _impl = null; + + NfcStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + NfcStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + NfcStub.unbound() : super.unbound(); + + static NfcStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NfcStub")); + return new NfcStub.fromEndpoint(endpoint); + } + + static const String name = NfcName; + + + NfcTransmitOnNextConnectionResponseParams _NfcTransmitOnNextConnectionResponseParamsFactory(bool success) { + var result = new NfcTransmitOnNextConnectionResponseParams(); + result.success = success; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kNfc_transmitOnNextConnection_name: + var params = NfcTransmitOnNextConnectionParams.deserialize( + message.payload); + var response = _impl.transmitOnNextConnection(params.nfcData,params.transmission,_NfcTransmitOnNextConnectionResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kNfc_transmitOnNextConnection_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kNfc_transmitOnNextConnection_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kNfc_register_name: + var params = NfcRegisterParams.deserialize( + message.payload); + _impl.register(); + break; + case kNfc_unregister_name: + var params = NfcUnregisterParams.deserialize( + message.payload); + _impl.unregister(); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + Nfc get impl => _impl; + set impl(Nfc d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "NfcStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/notifications/notifications.mojom.dart b/mojo/dart/packages/mojo_services/lib/notifications/notifications.mojom.dart new file mode 100644 index 0000000..037ca4b --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/notifications/notifications.mojom.dart
@@ -0,0 +1,972 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library notifications_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; + + + +class NotificationData extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + String title = null; + String text = null; + + NotificationData() : super(kVersions.last.size); + + static NotificationData deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NotificationData decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NotificationData result = new NotificationData(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.title = decoder0.decodeString(8, true); + } + if (mainDataHeader.version >= 0) { + + result.text = decoder0.decodeString(16, true); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(title, 8, true); + + encoder0.encodeString(text, 16, true); + } + + String toString() { + return "NotificationData(" + "title: $title" ", " + "text: $text" ")"; + } + + Map toJson() { + Map map = new Map(); + map["title"] = title; + map["text"] = text; + return map; + } +} + + +class NotificationClientOnSelectedParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + NotificationClientOnSelectedParams() : super(kVersions.last.size); + + static NotificationClientOnSelectedParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NotificationClientOnSelectedParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NotificationClientOnSelectedParams result = new NotificationClientOnSelectedParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "NotificationClientOnSelectedParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class NotificationClientOnDismissedParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + NotificationClientOnDismissedParams() : super(kVersions.last.size); + + static NotificationClientOnDismissedParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NotificationClientOnDismissedParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NotificationClientOnDismissedParams result = new NotificationClientOnDismissedParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "NotificationClientOnDismissedParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class NotificationUpdateParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + NotificationData notificationData = null; + + NotificationUpdateParams() : super(kVersions.last.size); + + static NotificationUpdateParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NotificationUpdateParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NotificationUpdateParams result = new NotificationUpdateParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.notificationData = NotificationData.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(notificationData, 8, false); + } + + String toString() { + return "NotificationUpdateParams(" + "notificationData: $notificationData" ")"; + } + + Map toJson() { + Map map = new Map(); + map["notificationData"] = notificationData; + return map; + } +} + + +class NotificationCancelParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + NotificationCancelParams() : super(kVersions.last.size); + + static NotificationCancelParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NotificationCancelParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NotificationCancelParams result = new NotificationCancelParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "NotificationCancelParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class NotificationServicePostParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(32, 0) + ]; + NotificationData notificationData = null; + Object client = null; + Object notification = null; + + NotificationServicePostParams() : super(kVersions.last.size); + + static NotificationServicePostParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static NotificationServicePostParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + NotificationServicePostParams result = new NotificationServicePostParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.notificationData = NotificationData.decode(decoder1); + } + if (mainDataHeader.version >= 0) { + + result.client = decoder0.decodeServiceInterface(16, true, NotificationClientProxy.newFromEndpoint); + } + if (mainDataHeader.version >= 0) { + + result.notification = decoder0.decodeInterfaceRequest(24, true, NotificationStub.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(notificationData, 8, false); + + encoder0.encodeInterface(client, 16, true); + + encoder0.encodeInterfaceRequest(notification, 24, true); + } + + String toString() { + return "NotificationServicePostParams(" + "notificationData: $notificationData" ", " + "client: $client" ", " + "notification: $notification" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + +const int kNotificationClient_onSelected_name = 0; +const int kNotificationClient_onDismissed_name = 1; + +const String NotificationClientName = + 'notifications::NotificationClient'; + +abstract class NotificationClient { + void onSelected(); + void onDismissed(); + +} + + +class NotificationClientProxyImpl extends bindings.Proxy { + NotificationClientProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + NotificationClientProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + NotificationClientProxyImpl.unbound() : super.unbound(); + + static NotificationClientProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NotificationClientProxyImpl")); + return new NotificationClientProxyImpl.fromEndpoint(endpoint); + } + + String get name => NotificationClientName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "NotificationClientProxyImpl($superString)"; + } +} + + +class _NotificationClientProxyCalls implements NotificationClient { + NotificationClientProxyImpl _proxyImpl; + + _NotificationClientProxyCalls(this._proxyImpl); + void onSelected() { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new NotificationClientOnSelectedParams(); + _proxyImpl.sendMessage(params, kNotificationClient_onSelected_name); + } + + void onDismissed() { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new NotificationClientOnDismissedParams(); + _proxyImpl.sendMessage(params, kNotificationClient_onDismissed_name); + } + +} + + +class NotificationClientProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + NotificationClient ptr; + final String name = NotificationClientName; + + NotificationClientProxy(NotificationClientProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _NotificationClientProxyCalls(proxyImpl); + + NotificationClientProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new NotificationClientProxyImpl.fromEndpoint(endpoint) { + ptr = new _NotificationClientProxyCalls(impl); + } + + NotificationClientProxy.fromHandle(core.MojoHandle handle) : + impl = new NotificationClientProxyImpl.fromHandle(handle) { + ptr = new _NotificationClientProxyCalls(impl); + } + + NotificationClientProxy.unbound() : + impl = new NotificationClientProxyImpl.unbound() { + ptr = new _NotificationClientProxyCalls(impl); + } + + factory NotificationClientProxy.connectToService( + bindings.ServiceConnector s, String url) { + NotificationClientProxy p = new NotificationClientProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static NotificationClientProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NotificationClientProxy")); + return new NotificationClientProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "NotificationClientProxy($impl)"; + } +} + + +class NotificationClientStub extends bindings.Stub { + NotificationClient _impl = null; + + NotificationClientStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + NotificationClientStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + NotificationClientStub.unbound() : super.unbound(); + + static NotificationClientStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NotificationClientStub")); + return new NotificationClientStub.fromEndpoint(endpoint); + } + + static const String name = NotificationClientName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kNotificationClient_onSelected_name: + var params = NotificationClientOnSelectedParams.deserialize( + message.payload); + _impl.onSelected(); + break; + case kNotificationClient_onDismissed_name: + var params = NotificationClientOnDismissedParams.deserialize( + message.payload); + _impl.onDismissed(); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + NotificationClient get impl => _impl; + set impl(NotificationClient d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "NotificationClientStub($superString)"; + } + + int get version => 0; +} + +const int kNotification_update_name = 0; +const int kNotification_cancel_name = 1; + +const String NotificationName = + 'notifications::Notification'; + +abstract class Notification { + void update(NotificationData notificationData); + void cancel(); + +} + + +class NotificationProxyImpl extends bindings.Proxy { + NotificationProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + NotificationProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + NotificationProxyImpl.unbound() : super.unbound(); + + static NotificationProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NotificationProxyImpl")); + return new NotificationProxyImpl.fromEndpoint(endpoint); + } + + String get name => NotificationName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "NotificationProxyImpl($superString)"; + } +} + + +class _NotificationProxyCalls implements Notification { + NotificationProxyImpl _proxyImpl; + + _NotificationProxyCalls(this._proxyImpl); + void update(NotificationData notificationData) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new NotificationUpdateParams(); + params.notificationData = notificationData; + _proxyImpl.sendMessage(params, kNotification_update_name); + } + + void cancel() { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new NotificationCancelParams(); + _proxyImpl.sendMessage(params, kNotification_cancel_name); + } + +} + + +class NotificationProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + Notification ptr; + final String name = NotificationName; + + NotificationProxy(NotificationProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _NotificationProxyCalls(proxyImpl); + + NotificationProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new NotificationProxyImpl.fromEndpoint(endpoint) { + ptr = new _NotificationProxyCalls(impl); + } + + NotificationProxy.fromHandle(core.MojoHandle handle) : + impl = new NotificationProxyImpl.fromHandle(handle) { + ptr = new _NotificationProxyCalls(impl); + } + + NotificationProxy.unbound() : + impl = new NotificationProxyImpl.unbound() { + ptr = new _NotificationProxyCalls(impl); + } + + factory NotificationProxy.connectToService( + bindings.ServiceConnector s, String url) { + NotificationProxy p = new NotificationProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static NotificationProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NotificationProxy")); + return new NotificationProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "NotificationProxy($impl)"; + } +} + + +class NotificationStub extends bindings.Stub { + Notification _impl = null; + + NotificationStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + NotificationStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + NotificationStub.unbound() : super.unbound(); + + static NotificationStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NotificationStub")); + return new NotificationStub.fromEndpoint(endpoint); + } + + static const String name = NotificationName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kNotification_update_name: + var params = NotificationUpdateParams.deserialize( + message.payload); + _impl.update(params.notificationData); + break; + case kNotification_cancel_name: + var params = NotificationCancelParams.deserialize( + message.payload); + _impl.cancel(); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + Notification get impl => _impl; + set impl(Notification d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "NotificationStub($superString)"; + } + + int get version => 0; +} + +const int kNotificationService_post_name = 0; + +const String NotificationServiceName = + 'notifications::NotificationService'; + +abstract class NotificationService { + void post(NotificationData notificationData, Object client, Object notification); + +} + + +class NotificationServiceProxyImpl extends bindings.Proxy { + NotificationServiceProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + NotificationServiceProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + NotificationServiceProxyImpl.unbound() : super.unbound(); + + static NotificationServiceProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NotificationServiceProxyImpl")); + return new NotificationServiceProxyImpl.fromEndpoint(endpoint); + } + + String get name => NotificationServiceName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "NotificationServiceProxyImpl($superString)"; + } +} + + +class _NotificationServiceProxyCalls implements NotificationService { + NotificationServiceProxyImpl _proxyImpl; + + _NotificationServiceProxyCalls(this._proxyImpl); + void post(NotificationData notificationData, Object client, Object notification) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new NotificationServicePostParams(); + params.notificationData = notificationData; + params.client = client; + params.notification = notification; + _proxyImpl.sendMessage(params, kNotificationService_post_name); + } + +} + + +class NotificationServiceProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + NotificationService ptr; + final String name = NotificationServiceName; + + NotificationServiceProxy(NotificationServiceProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _NotificationServiceProxyCalls(proxyImpl); + + NotificationServiceProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new NotificationServiceProxyImpl.fromEndpoint(endpoint) { + ptr = new _NotificationServiceProxyCalls(impl); + } + + NotificationServiceProxy.fromHandle(core.MojoHandle handle) : + impl = new NotificationServiceProxyImpl.fromHandle(handle) { + ptr = new _NotificationServiceProxyCalls(impl); + } + + NotificationServiceProxy.unbound() : + impl = new NotificationServiceProxyImpl.unbound() { + ptr = new _NotificationServiceProxyCalls(impl); + } + + factory NotificationServiceProxy.connectToService( + bindings.ServiceConnector s, String url) { + NotificationServiceProxy p = new NotificationServiceProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static NotificationServiceProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NotificationServiceProxy")); + return new NotificationServiceProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "NotificationServiceProxy($impl)"; + } +} + + +class NotificationServiceStub extends bindings.Stub { + NotificationService _impl = null; + + NotificationServiceStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + NotificationServiceStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + NotificationServiceStub.unbound() : super.unbound(); + + static NotificationServiceStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For NotificationServiceStub")); + return new NotificationServiceStub.fromEndpoint(endpoint); + } + + static const String name = NotificationServiceName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kNotificationService_post_name: + var params = NotificationServicePostParams.deserialize( + message.payload); + _impl.post(params.notificationData, params.client, params.notification); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + NotificationService get impl => _impl; + set impl(NotificationService d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "NotificationServiceStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/prediction/prediction.mojom.dart b/mojo/dart/packages/mojo_services/lib/prediction/prediction.mojom.dart new file mode 100644 index 0000000..200d6ec --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/prediction/prediction.mojom.dart
@@ -0,0 +1,551 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library prediction_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; + + + +class PrevWordInfo extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + String word = null; + bool isBeginningOfSentence = false; + + PrevWordInfo() : super(kVersions.last.size); + + static PrevWordInfo deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static PrevWordInfo decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + PrevWordInfo result = new PrevWordInfo(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.word = decoder0.decodeString(8, false); + } + if (mainDataHeader.version >= 0) { + + result.isBeginningOfSentence = decoder0.decodeBool(16, 0); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(word, 8, false); + + encoder0.encodeBool(isBeginningOfSentence, 16, 0); + } + + String toString() { + return "PrevWordInfo(" + "word: $word" ", " + "isBeginningOfSentence: $isBeginningOfSentence" ")"; + } + + Map toJson() { + Map map = new Map(); + map["word"] = word; + map["isBeginningOfSentence"] = isBeginningOfSentence; + return map; + } +} + + +class PredictionInfo extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + List<PrevWordInfo> previousWords = null; + String currentWord = null; + + PredictionInfo() : super(kVersions.last.size); + + static PredictionInfo deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static PredictionInfo decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + PredictionInfo result = new PredictionInfo(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.previousWords = new List<PrevWordInfo>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + var decoder2 = decoder1.decodePointer(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + result.previousWords[i1] = PrevWordInfo.decode(decoder2); + } + } + } + if (mainDataHeader.version >= 0) { + + result.currentWord = decoder0.decodeString(16, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + if (previousWords == null) { + encoder0.encodeNullPointer(8, false); + } else { + var encoder1 = encoder0.encodePointerArray(previousWords.length, 8, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < previousWords.length; ++i0) { + + encoder1.encodeStruct(previousWords[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + + encoder0.encodeString(currentWord, 16, false); + } + + String toString() { + return "PredictionInfo(" + "previousWords: $previousWords" ", " + "currentWord: $currentWord" ")"; + } + + Map toJson() { + Map map = new Map(); + map["previousWords"] = previousWords; + map["currentWord"] = currentWord; + return map; + } +} + + +class PredictionServiceGetPredictionListParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + PredictionInfo predictionInfo = null; + + PredictionServiceGetPredictionListParams() : super(kVersions.last.size); + + static PredictionServiceGetPredictionListParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static PredictionServiceGetPredictionListParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + PredictionServiceGetPredictionListParams result = new PredictionServiceGetPredictionListParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.predictionInfo = PredictionInfo.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(predictionInfo, 8, false); + } + + String toString() { + return "PredictionServiceGetPredictionListParams(" + "predictionInfo: $predictionInfo" ")"; + } + + Map toJson() { + Map map = new Map(); + map["predictionInfo"] = predictionInfo; + return map; + } +} + + +class PredictionServiceGetPredictionListResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + List<String> predictionList = null; + + PredictionServiceGetPredictionListResponseParams() : super(kVersions.last.size); + + static PredictionServiceGetPredictionListResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static PredictionServiceGetPredictionListResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + PredictionServiceGetPredictionListResponseParams result = new PredictionServiceGetPredictionListResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, true); + if (decoder1 == null) { + result.predictionList = null; + } else { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.predictionList = new List<String>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + result.predictionList[i1] = decoder1.decodeString(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + } + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + if (predictionList == null) { + encoder0.encodeNullPointer(8, true); + } else { + var encoder1 = encoder0.encodePointerArray(predictionList.length, 8, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < predictionList.length; ++i0) { + + encoder1.encodeString(predictionList[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + } + + String toString() { + return "PredictionServiceGetPredictionListResponseParams(" + "predictionList: $predictionList" ")"; + } + + Map toJson() { + Map map = new Map(); + map["predictionList"] = predictionList; + return map; + } +} + +const int kPredictionService_getPredictionList_name = 0; + +const String PredictionServiceName = + 'prediction::PredictionService'; + +abstract class PredictionService { + dynamic getPredictionList(PredictionInfo predictionInfo,[Function responseFactory = null]); + +} + + +class PredictionServiceProxyImpl extends bindings.Proxy { + PredictionServiceProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + PredictionServiceProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + PredictionServiceProxyImpl.unbound() : super.unbound(); + + static PredictionServiceProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For PredictionServiceProxyImpl")); + return new PredictionServiceProxyImpl.fromEndpoint(endpoint); + } + + String get name => PredictionServiceName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kPredictionService_getPredictionList_name: + var r = PredictionServiceGetPredictionListResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "PredictionServiceProxyImpl($superString)"; + } +} + + +class _PredictionServiceProxyCalls implements PredictionService { + PredictionServiceProxyImpl _proxyImpl; + + _PredictionServiceProxyCalls(this._proxyImpl); + dynamic getPredictionList(PredictionInfo predictionInfo,[Function responseFactory = null]) { + var params = new PredictionServiceGetPredictionListParams(); + params.predictionInfo = predictionInfo; + return _proxyImpl.sendMessageWithRequestId( + params, + kPredictionService_getPredictionList_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } +} + + +class PredictionServiceProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + PredictionService ptr; + final String name = PredictionServiceName; + + PredictionServiceProxy(PredictionServiceProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _PredictionServiceProxyCalls(proxyImpl); + + PredictionServiceProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new PredictionServiceProxyImpl.fromEndpoint(endpoint) { + ptr = new _PredictionServiceProxyCalls(impl); + } + + PredictionServiceProxy.fromHandle(core.MojoHandle handle) : + impl = new PredictionServiceProxyImpl.fromHandle(handle) { + ptr = new _PredictionServiceProxyCalls(impl); + } + + PredictionServiceProxy.unbound() : + impl = new PredictionServiceProxyImpl.unbound() { + ptr = new _PredictionServiceProxyCalls(impl); + } + + factory PredictionServiceProxy.connectToService( + bindings.ServiceConnector s, String url) { + PredictionServiceProxy p = new PredictionServiceProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static PredictionServiceProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For PredictionServiceProxy")); + return new PredictionServiceProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "PredictionServiceProxy($impl)"; + } +} + + +class PredictionServiceStub extends bindings.Stub { + PredictionService _impl = null; + + PredictionServiceStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + PredictionServiceStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + PredictionServiceStub.unbound() : super.unbound(); + + static PredictionServiceStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For PredictionServiceStub")); + return new PredictionServiceStub.fromEndpoint(endpoint); + } + + static const String name = PredictionServiceName; + + + PredictionServiceGetPredictionListResponseParams _PredictionServiceGetPredictionListResponseParamsFactory(List<String> predictionList) { + var result = new PredictionServiceGetPredictionListResponseParams(); + result.predictionList = predictionList; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kPredictionService_getPredictionList_name: + var params = PredictionServiceGetPredictionListParams.deserialize( + message.payload); + var response = _impl.getPredictionList(params.predictionInfo,_PredictionServiceGetPredictionListResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kPredictionService_getPredictionList_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kPredictionService_getPredictionList_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + PredictionService get impl => _impl; + set impl(PredictionService d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "PredictionServiceStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/sensors/sensors.mojom.dart b/mojo/dart/packages/mojo_services/lib/sensors/sensors.mojom.dart new file mode 100644 index 0000000..c461545 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/sensors/sensors.mojom.dart
@@ -0,0 +1,847 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library sensors_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +class SensorType extends bindings.MojoEnum { + static const ACCELEROMETER = const SensorType._(0); + static const AMBIENT_TEMPERATURE = const SensorType._(1); + static const GAME_ROTATION_VECTOR = const SensorType._(2); + static const GEOMAGNETIC_ROTATION_VECTOR = const SensorType._(3); + static const GRAVITY = const SensorType._(4); + static const GYROSCOPE = const SensorType._(5); + static const GYROSCOPE_UNCALIBRATED = const SensorType._(6); + static const HEART_RATE = const SensorType._(7); + static const LIGHT = const SensorType._(8); + static const LINEAR_ACCELERATION = const SensorType._(9); + static const MAGNETIC_FIELD = const SensorType._(10); + static const MAGNETIC_FIELD_UNCALIBRATED = const SensorType._(11); + static const PRESSURE = const SensorType._(12); + static const PROXIMITY = const SensorType._(13); + static const RELATIVE_HUMIDITY = const SensorType._(14); + static const ROTATION_VECTOR = const SensorType._(15); + static const SIGNIFICANT_MOTION = const SensorType._(16); + static const STEP_COUNTER = const SensorType._(17); + static const STEP_DETECTOR = const SensorType._(18); + + const SensorType._(int v) : super(v); + + static const Map<String, SensorType> valuesMap = const { + "ACCELEROMETER": ACCELEROMETER, + "AMBIENT_TEMPERATURE": AMBIENT_TEMPERATURE, + "GAME_ROTATION_VECTOR": GAME_ROTATION_VECTOR, + "GEOMAGNETIC_ROTATION_VECTOR": GEOMAGNETIC_ROTATION_VECTOR, + "GRAVITY": GRAVITY, + "GYROSCOPE": GYROSCOPE, + "GYROSCOPE_UNCALIBRATED": GYROSCOPE_UNCALIBRATED, + "HEART_RATE": HEART_RATE, + "LIGHT": LIGHT, + "LINEAR_ACCELERATION": LINEAR_ACCELERATION, + "MAGNETIC_FIELD": MAGNETIC_FIELD, + "MAGNETIC_FIELD_UNCALIBRATED": MAGNETIC_FIELD_UNCALIBRATED, + "PRESSURE": PRESSURE, + "PROXIMITY": PROXIMITY, + "RELATIVE_HUMIDITY": RELATIVE_HUMIDITY, + "ROTATION_VECTOR": ROTATION_VECTOR, + "SIGNIFICANT_MOTION": SIGNIFICANT_MOTION, + "STEP_COUNTER": STEP_COUNTER, + "STEP_DETECTOR": STEP_DETECTOR, + }; + static const List<SensorType> values = const [ + ACCELEROMETER, + AMBIENT_TEMPERATURE, + GAME_ROTATION_VECTOR, + GEOMAGNETIC_ROTATION_VECTOR, + GRAVITY, + GYROSCOPE, + GYROSCOPE_UNCALIBRATED, + HEART_RATE, + LIGHT, + LINEAR_ACCELERATION, + MAGNETIC_FIELD, + MAGNETIC_FIELD_UNCALIBRATED, + PRESSURE, + PROXIMITY, + RELATIVE_HUMIDITY, + ROTATION_VECTOR, + SIGNIFICANT_MOTION, + STEP_COUNTER, + STEP_DETECTOR, + ]; + + static SensorType valueOf(String name) => valuesMap[name]; + + factory SensorType(int v) { + switch (v) { + case 0: + return ACCELEROMETER; + case 1: + return AMBIENT_TEMPERATURE; + case 2: + return GAME_ROTATION_VECTOR; + case 3: + return GEOMAGNETIC_ROTATION_VECTOR; + case 4: + return GRAVITY; + case 5: + return GYROSCOPE; + case 6: + return GYROSCOPE_UNCALIBRATED; + case 7: + return HEART_RATE; + case 8: + return LIGHT; + case 9: + return LINEAR_ACCELERATION; + case 10: + return MAGNETIC_FIELD; + case 11: + return MAGNETIC_FIELD_UNCALIBRATED; + case 12: + return PRESSURE; + case 13: + return PROXIMITY; + case 14: + return RELATIVE_HUMIDITY; + case 15: + return ROTATION_VECTOR; + case 16: + return SIGNIFICANT_MOTION; + case 17: + return STEP_COUNTER; + case 18: + return STEP_DETECTOR; + default: + return null; + } + } + + static SensorType decode(bindings.Decoder decoder0, int offset) { + int v = decoder0.decodeUint32(offset); + SensorType result = new SensorType(v); + if (result == null) { + throw new bindings.MojoCodecError( + 'Bad value $v for enum SensorType.'); + } + return result; + } + + String toString() { + switch(this) { + case ACCELEROMETER: + return 'SensorType.ACCELEROMETER'; + case AMBIENT_TEMPERATURE: + return 'SensorType.AMBIENT_TEMPERATURE'; + case GAME_ROTATION_VECTOR: + return 'SensorType.GAME_ROTATION_VECTOR'; + case GEOMAGNETIC_ROTATION_VECTOR: + return 'SensorType.GEOMAGNETIC_ROTATION_VECTOR'; + case GRAVITY: + return 'SensorType.GRAVITY'; + case GYROSCOPE: + return 'SensorType.GYROSCOPE'; + case GYROSCOPE_UNCALIBRATED: + return 'SensorType.GYROSCOPE_UNCALIBRATED'; + case HEART_RATE: + return 'SensorType.HEART_RATE'; + case LIGHT: + return 'SensorType.LIGHT'; + case LINEAR_ACCELERATION: + return 'SensorType.LINEAR_ACCELERATION'; + case MAGNETIC_FIELD: + return 'SensorType.MAGNETIC_FIELD'; + case MAGNETIC_FIELD_UNCALIBRATED: + return 'SensorType.MAGNETIC_FIELD_UNCALIBRATED'; + case PRESSURE: + return 'SensorType.PRESSURE'; + case PROXIMITY: + return 'SensorType.PROXIMITY'; + case RELATIVE_HUMIDITY: + return 'SensorType.RELATIVE_HUMIDITY'; + case ROTATION_VECTOR: + return 'SensorType.ROTATION_VECTOR'; + case SIGNIFICANT_MOTION: + return 'SensorType.SIGNIFICANT_MOTION'; + case STEP_COUNTER: + return 'SensorType.STEP_COUNTER'; + case STEP_DETECTOR: + return 'SensorType.STEP_DETECTOR'; + } + } + + int toJson() => value; +} + + + +class SensorData extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(32, 0) + ]; + int accuracy = 0; + int timeStamp = 0; + List<double> values = null; + + SensorData() : super(kVersions.last.size); + + static SensorData deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static SensorData decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + SensorData result = new SensorData(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.accuracy = decoder0.decodeInt32(8); + } + if (mainDataHeader.version >= 0) { + + result.timeStamp = decoder0.decodeInt64(16); + } + if (mainDataHeader.version >= 0) { + + result.values = decoder0.decodeFloatArray(24, bindings.kNothingNullable, bindings.kUnspecifiedArrayLength); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt32(accuracy, 8); + + encoder0.encodeInt64(timeStamp, 16); + + encoder0.encodeFloatArray(values, 24, bindings.kNothingNullable, bindings.kUnspecifiedArrayLength); + } + + String toString() { + return "SensorData(" + "accuracy: $accuracy" ", " + "timeStamp: $timeStamp" ", " + "values: $values" ")"; + } + + Map toJson() { + Map map = new Map(); + map["accuracy"] = accuracy; + map["timeStamp"] = timeStamp; + map["values"] = values; + return map; + } +} + + +class SensorListenerOnAccuracyChangedParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + int accuracy = 0; + + SensorListenerOnAccuracyChangedParams() : super(kVersions.last.size); + + static SensorListenerOnAccuracyChangedParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static SensorListenerOnAccuracyChangedParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + SensorListenerOnAccuracyChangedParams result = new SensorListenerOnAccuracyChangedParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.accuracy = decoder0.decodeInt32(8); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeInt32(accuracy, 8); + } + + String toString() { + return "SensorListenerOnAccuracyChangedParams(" + "accuracy: $accuracy" ")"; + } + + Map toJson() { + Map map = new Map(); + map["accuracy"] = accuracy; + return map; + } +} + + +class SensorListenerOnSensorChangedParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + SensorData data = null; + + SensorListenerOnSensorChangedParams() : super(kVersions.last.size); + + static SensorListenerOnSensorChangedParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static SensorListenerOnSensorChangedParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + SensorListenerOnSensorChangedParams result = new SensorListenerOnSensorChangedParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + var decoder1 = decoder0.decodePointer(8, false); + result.data = SensorData.decode(decoder1); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeStruct(data, 8, false); + } + + String toString() { + return "SensorListenerOnSensorChangedParams(" + "data: $data" ")"; + } + + Map toJson() { + Map map = new Map(); + map["data"] = data; + return map; + } +} + + +class SensorServiceAddListenerParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + SensorType type = null; + Object listener = null; + + SensorServiceAddListenerParams() : super(kVersions.last.size); + + static SensorServiceAddListenerParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static SensorServiceAddListenerParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + SensorServiceAddListenerParams result = new SensorServiceAddListenerParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.type = SensorType.decode(decoder0, 8); + if (result.type == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable SensorType.'); + } + } + if (mainDataHeader.version >= 0) { + + result.listener = decoder0.decodeServiceInterface(12, false, SensorListenerProxy.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeEnum(type, 8); + + encoder0.encodeInterface(listener, 12, false); + } + + String toString() { + return "SensorServiceAddListenerParams(" + "type: $type" ", " + "listener: $listener" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + +const int kSensorListener_onAccuracyChanged_name = 0; +const int kSensorListener_onSensorChanged_name = 1; + +const String SensorListenerName = + 'sensors::SensorListener'; + +abstract class SensorListener { + void onAccuracyChanged(int accuracy); + void onSensorChanged(SensorData data); + +} + + +class SensorListenerProxyImpl extends bindings.Proxy { + SensorListenerProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + SensorListenerProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + SensorListenerProxyImpl.unbound() : super.unbound(); + + static SensorListenerProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For SensorListenerProxyImpl")); + return new SensorListenerProxyImpl.fromEndpoint(endpoint); + } + + String get name => SensorListenerName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "SensorListenerProxyImpl($superString)"; + } +} + + +class _SensorListenerProxyCalls implements SensorListener { + SensorListenerProxyImpl _proxyImpl; + + _SensorListenerProxyCalls(this._proxyImpl); + void onAccuracyChanged(int accuracy) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new SensorListenerOnAccuracyChangedParams(); + params.accuracy = accuracy; + _proxyImpl.sendMessage(params, kSensorListener_onAccuracyChanged_name); + } + + void onSensorChanged(SensorData data) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new SensorListenerOnSensorChangedParams(); + params.data = data; + _proxyImpl.sendMessage(params, kSensorListener_onSensorChanged_name); + } + +} + + +class SensorListenerProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + SensorListener ptr; + final String name = SensorListenerName; + + SensorListenerProxy(SensorListenerProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _SensorListenerProxyCalls(proxyImpl); + + SensorListenerProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new SensorListenerProxyImpl.fromEndpoint(endpoint) { + ptr = new _SensorListenerProxyCalls(impl); + } + + SensorListenerProxy.fromHandle(core.MojoHandle handle) : + impl = new SensorListenerProxyImpl.fromHandle(handle) { + ptr = new _SensorListenerProxyCalls(impl); + } + + SensorListenerProxy.unbound() : + impl = new SensorListenerProxyImpl.unbound() { + ptr = new _SensorListenerProxyCalls(impl); + } + + factory SensorListenerProxy.connectToService( + bindings.ServiceConnector s, String url) { + SensorListenerProxy p = new SensorListenerProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static SensorListenerProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For SensorListenerProxy")); + return new SensorListenerProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "SensorListenerProxy($impl)"; + } +} + + +class SensorListenerStub extends bindings.Stub { + SensorListener _impl = null; + + SensorListenerStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + SensorListenerStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + SensorListenerStub.unbound() : super.unbound(); + + static SensorListenerStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For SensorListenerStub")); + return new SensorListenerStub.fromEndpoint(endpoint); + } + + static const String name = SensorListenerName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kSensorListener_onAccuracyChanged_name: + var params = SensorListenerOnAccuracyChangedParams.deserialize( + message.payload); + _impl.onAccuracyChanged(params.accuracy); + break; + case kSensorListener_onSensorChanged_name: + var params = SensorListenerOnSensorChangedParams.deserialize( + message.payload); + _impl.onSensorChanged(params.data); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + SensorListener get impl => _impl; + set impl(SensorListener d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "SensorListenerStub($superString)"; + } + + int get version => 0; +} + +const int kSensorService_addListener_name = 0; + +const String SensorServiceName = + 'sensors::SensorService'; + +abstract class SensorService { + void addListener(SensorType type, Object listener); + +} + + +class SensorServiceProxyImpl extends bindings.Proxy { + SensorServiceProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + SensorServiceProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + SensorServiceProxyImpl.unbound() : super.unbound(); + + static SensorServiceProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For SensorServiceProxyImpl")); + return new SensorServiceProxyImpl.fromEndpoint(endpoint); + } + + String get name => SensorServiceName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "SensorServiceProxyImpl($superString)"; + } +} + + +class _SensorServiceProxyCalls implements SensorService { + SensorServiceProxyImpl _proxyImpl; + + _SensorServiceProxyCalls(this._proxyImpl); + void addListener(SensorType type, Object listener) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new SensorServiceAddListenerParams(); + params.type = type; + params.listener = listener; + _proxyImpl.sendMessage(params, kSensorService_addListener_name); + } + +} + + +class SensorServiceProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + SensorService ptr; + final String name = SensorServiceName; + + SensorServiceProxy(SensorServiceProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _SensorServiceProxyCalls(proxyImpl); + + SensorServiceProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new SensorServiceProxyImpl.fromEndpoint(endpoint) { + ptr = new _SensorServiceProxyCalls(impl); + } + + SensorServiceProxy.fromHandle(core.MojoHandle handle) : + impl = new SensorServiceProxyImpl.fromHandle(handle) { + ptr = new _SensorServiceProxyCalls(impl); + } + + SensorServiceProxy.unbound() : + impl = new SensorServiceProxyImpl.unbound() { + ptr = new _SensorServiceProxyCalls(impl); + } + + factory SensorServiceProxy.connectToService( + bindings.ServiceConnector s, String url) { + SensorServiceProxy p = new SensorServiceProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static SensorServiceProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For SensorServiceProxy")); + return new SensorServiceProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "SensorServiceProxy($impl)"; + } +} + + +class SensorServiceStub extends bindings.Stub { + SensorService _impl = null; + + SensorServiceStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + SensorServiceStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + SensorServiceStub.unbound() : super.unbound(); + + static SensorServiceStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For SensorServiceStub")); + return new SensorServiceStub.fromEndpoint(endpoint); + } + + static const String name = SensorServiceName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kSensorService_addListener_name: + var params = SensorServiceAddListenerParams.deserialize( + message.payload); + _impl.addListener(params.type, params.listener); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + SensorService get impl => _impl; + set impl(SensorService d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "SensorServiceStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/speech_recognizer/speech_recognizer.mojom.dart b/mojo/dart/packages/mojo_services/lib/speech_recognizer/speech_recognizer.mojom.dart new file mode 100644 index 0000000..401a5cd --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/speech_recognizer/speech_recognizer.mojom.dart
@@ -0,0 +1,727 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library speech_recognizer_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; +class Error extends bindings.MojoEnum { + static const NETWORK_TIMEOUT = const Error._(1); + static const NETWORK = const Error._(2); + static const AUDIO = const Error._(3); + static const SERVER = const Error._(4); + static const CLIENT = const Error._(5); + static const SPEECH_TIMEOUT = const Error._(6); + static const NO_MATCH = const Error._(7); + static const RECOGNIZER_BUSY = const Error._(8); + static const INSUFFICIENT_PERMISSIONS = const Error._(9); + + const Error._(int v) : super(v); + + static const Map<String, Error> valuesMap = const { + "NETWORK_TIMEOUT": NETWORK_TIMEOUT, + "NETWORK": NETWORK, + "AUDIO": AUDIO, + "SERVER": SERVER, + "CLIENT": CLIENT, + "SPEECH_TIMEOUT": SPEECH_TIMEOUT, + "NO_MATCH": NO_MATCH, + "RECOGNIZER_BUSY": RECOGNIZER_BUSY, + "INSUFFICIENT_PERMISSIONS": INSUFFICIENT_PERMISSIONS, + }; + static const List<Error> values = const [ + NETWORK_TIMEOUT, + NETWORK, + AUDIO, + SERVER, + CLIENT, + SPEECH_TIMEOUT, + NO_MATCH, + RECOGNIZER_BUSY, + INSUFFICIENT_PERMISSIONS, + ]; + + static Error valueOf(String name) => valuesMap[name]; + + factory Error(int v) { + switch (v) { + case 1: + return NETWORK_TIMEOUT; + case 2: + return NETWORK; + case 3: + return AUDIO; + case 4: + return SERVER; + case 5: + return CLIENT; + case 6: + return SPEECH_TIMEOUT; + case 7: + return NO_MATCH; + case 8: + return RECOGNIZER_BUSY; + case 9: + return INSUFFICIENT_PERMISSIONS; + default: + return null; + } + } + + static Error decode(bindings.Decoder decoder0, int offset) { + int v = decoder0.decodeUint32(offset); + Error result = new Error(v); + if (result == null) { + throw new bindings.MojoCodecError( + 'Bad value $v for enum Error.'); + } + return result; + } + + String toString() { + switch(this) { + case NETWORK_TIMEOUT: + return 'Error.NETWORK_TIMEOUT'; + case NETWORK: + return 'Error.NETWORK'; + case AUDIO: + return 'Error.AUDIO'; + case SERVER: + return 'Error.SERVER'; + case CLIENT: + return 'Error.CLIENT'; + case SPEECH_TIMEOUT: + return 'Error.SPEECH_TIMEOUT'; + case NO_MATCH: + return 'Error.NO_MATCH'; + case RECOGNIZER_BUSY: + return 'Error.RECOGNIZER_BUSY'; + case INSUFFICIENT_PERMISSIONS: + return 'Error.INSUFFICIENT_PERMISSIONS'; + } + } + + int toJson() => value; +} + + + +class UtteranceCandidate extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + String text = null; + double confidenceScore = 0.0; + + UtteranceCandidate() : super(kVersions.last.size); + + static UtteranceCandidate deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static UtteranceCandidate decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + UtteranceCandidate result = new UtteranceCandidate(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.text = decoder0.decodeString(8, false); + } + if (mainDataHeader.version >= 0) { + + result.confidenceScore = decoder0.decodeFloat(16); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(text, 8, false); + + encoder0.encodeFloat(confidenceScore, 16); + } + + String toString() { + return "UtteranceCandidate(" + "text: $text" ", " + "confidenceScore: $confidenceScore" ")"; + } + + Map toJson() { + Map map = new Map(); + map["text"] = text; + map["confidenceScore"] = confidenceScore; + return map; + } +} + + +class SpeechRecognizerServiceListenParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + SpeechRecognizerServiceListenParams() : super(kVersions.last.size); + + static SpeechRecognizerServiceListenParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static SpeechRecognizerServiceListenParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + SpeechRecognizerServiceListenParams result = new SpeechRecognizerServiceListenParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "SpeechRecognizerServiceListenParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class SpeechRecognizerServiceListenResponseParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + ResultOrError resultOrError = null; + + SpeechRecognizerServiceListenResponseParams() : super(kVersions.last.size); + + static SpeechRecognizerServiceListenResponseParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static SpeechRecognizerServiceListenResponseParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + SpeechRecognizerServiceListenResponseParams result = new SpeechRecognizerServiceListenResponseParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.resultOrError = ResultOrError.decode(decoder0, 8); + if (result.resultOrError == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable ResultOrError.'); + } + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeUnion(resultOrError, 8, false); + } + + String toString() { + return "SpeechRecognizerServiceListenResponseParams(" + "resultOrError: $resultOrError" ")"; + } + + Map toJson() { + Map map = new Map(); + map["resultOrError"] = resultOrError; + return map; + } +} + + +class SpeechRecognizerServiceStopListeningParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + SpeechRecognizerServiceStopListeningParams() : super(kVersions.last.size); + + static SpeechRecognizerServiceStopListeningParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static SpeechRecognizerServiceStopListeningParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + SpeechRecognizerServiceStopListeningParams result = new SpeechRecognizerServiceStopListeningParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "SpeechRecognizerServiceStopListeningParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + + +enum ResultOrErrorTag { + errorCode, + results, + unknown +} + +class ResultOrError extends bindings.Union { + static final _tag_to_int = const { + ResultOrErrorTag.errorCode: 0, + ResultOrErrorTag.results: 1, + }; + + static final _int_to_tag = const { + 0: ResultOrErrorTag.errorCode, + 1: ResultOrErrorTag.results, + }; + + var _data; + ResultOrErrorTag _tag = ResultOrErrorTag.unknown; + + ResultOrErrorTag get tag => _tag; + Error get errorCode { + if (_tag != ResultOrErrorTag.errorCode) { + throw new bindings.UnsetUnionTagError(_tag, ResultOrErrorTag.errorCode); + } + return _data; + } + + set errorCode(Error value) { + _tag = ResultOrErrorTag.errorCode; + _data = value; + } + List<UtteranceCandidate> get results { + if (_tag != ResultOrErrorTag.results) { + throw new bindings.UnsetUnionTagError(_tag, ResultOrErrorTag.results); + } + return _data; + } + + set results(List<UtteranceCandidate> value) { + _tag = ResultOrErrorTag.results; + _data = value; + } + + static ResultOrError decode(bindings.Decoder decoder0, int offset) { + int size = decoder0.decodeUint32(offset); + if (size == 0) { + return null; + } + ResultOrError result = new ResultOrError(); + + // TODO(azani): Handle unknown union member. + ResultOrErrorTag tag = _int_to_tag[decoder0.decodeUint32(offset + 4)]; + switch (tag) { + case ResultOrErrorTag.errorCode: + + result.errorCode = Error.decode(decoder0, offset + 8); + if (result.errorCode == null) { + throw new bindings.MojoCodecError( + 'Trying to decode null union for non-nullable Error.'); + } + break; + case ResultOrErrorTag.results: + + var decoder1 = decoder0.decodePointer(offset + 8, false); + { + var si1 = decoder1.decodeDataHeaderForPointerArray(bindings.kUnspecifiedArrayLength); + result.results = new List<UtteranceCandidate>(si1.numElements); + for (int i1 = 0; i1 < si1.numElements; ++i1) { + + var decoder2 = decoder1.decodePointer(bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i1, false); + result.results[i1] = UtteranceCandidate.decode(decoder2); + } + } + break; + } + + return result; + } + + void encode(bindings.Encoder encoder0, int offset) { + // TODO(azani): Error when trying to encode an unknown member. + encoder0.encodeUint32(16, offset); + encoder0.encodeUint32(_tag_to_int[_tag], offset + 4); + switch (_tag) { + case ResultOrErrorTag.errorCode: + + encoder0.encodeEnum(errorCode, offset + 8); + break; + case ResultOrErrorTag.results: + + if (results == null) { + encoder0.encodeNullPointer(offset + 8, false); + } else { + var encoder1 = encoder0.encodePointerArray(results.length, offset + 8, bindings.kUnspecifiedArrayLength); + for (int i0 = 0; i0 < results.length; ++i0) { + + encoder1.encodeStruct(results[i0], bindings.ArrayDataHeader.kHeaderSize + bindings.kPointerSize * i0, false); + } + } + break; + } + } + + String toString() { + String result = "ResultOrError("; + switch (_tag) { + case ResultOrErrorTag.errorCode: + result += "errorCode"; + break; + case ResultOrErrorTag.results: + result += "results"; + break; + default: + result += "unknown"; + } + result += ": $_data)"; + return result; + } +} +const int kSpeechRecognizerService_listen_name = 0; +const int kSpeechRecognizerService_stopListening_name = 1; + +const String SpeechRecognizerServiceName = + 'speech_recognizer::SpeechRecognizerService'; + +abstract class SpeechRecognizerService { + dynamic listen([Function responseFactory = null]); + void stopListening(); + +} + + +class SpeechRecognizerServiceProxyImpl extends bindings.Proxy { + SpeechRecognizerServiceProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + SpeechRecognizerServiceProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + SpeechRecognizerServiceProxyImpl.unbound() : super.unbound(); + + static SpeechRecognizerServiceProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For SpeechRecognizerServiceProxyImpl")); + return new SpeechRecognizerServiceProxyImpl.fromEndpoint(endpoint); + } + + String get name => SpeechRecognizerServiceName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + case kSpeechRecognizerService_listen_name: + var r = SpeechRecognizerServiceListenResponseParams.deserialize( + message.payload); + if (!message.header.hasRequestId) { + proxyError("Expected a message with a valid request Id."); + return; + } + Completer c = completerMap[message.header.requestId]; + if (c == null) { + proxyError( + "Message had unknown request Id: ${message.header.requestId}"); + return; + } + completerMap.remove(message.header.requestId); + if (c.isCompleted) { + proxyError("Response completer already completed"); + return; + } + c.complete(r); + break; + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "SpeechRecognizerServiceProxyImpl($superString)"; + } +} + + +class _SpeechRecognizerServiceProxyCalls implements SpeechRecognizerService { + SpeechRecognizerServiceProxyImpl _proxyImpl; + + _SpeechRecognizerServiceProxyCalls(this._proxyImpl); + dynamic listen([Function responseFactory = null]) { + var params = new SpeechRecognizerServiceListenParams(); + return _proxyImpl.sendMessageWithRequestId( + params, + kSpeechRecognizerService_listen_name, + -1, + bindings.MessageHeader.kMessageExpectsResponse); + } + void stopListening() { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new SpeechRecognizerServiceStopListeningParams(); + _proxyImpl.sendMessage(params, kSpeechRecognizerService_stopListening_name); + } + +} + + +class SpeechRecognizerServiceProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + SpeechRecognizerService ptr; + final String name = SpeechRecognizerServiceName; + + SpeechRecognizerServiceProxy(SpeechRecognizerServiceProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _SpeechRecognizerServiceProxyCalls(proxyImpl); + + SpeechRecognizerServiceProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new SpeechRecognizerServiceProxyImpl.fromEndpoint(endpoint) { + ptr = new _SpeechRecognizerServiceProxyCalls(impl); + } + + SpeechRecognizerServiceProxy.fromHandle(core.MojoHandle handle) : + impl = new SpeechRecognizerServiceProxyImpl.fromHandle(handle) { + ptr = new _SpeechRecognizerServiceProxyCalls(impl); + } + + SpeechRecognizerServiceProxy.unbound() : + impl = new SpeechRecognizerServiceProxyImpl.unbound() { + ptr = new _SpeechRecognizerServiceProxyCalls(impl); + } + + factory SpeechRecognizerServiceProxy.connectToService( + bindings.ServiceConnector s, String url) { + SpeechRecognizerServiceProxy p = new SpeechRecognizerServiceProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static SpeechRecognizerServiceProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For SpeechRecognizerServiceProxy")); + return new SpeechRecognizerServiceProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "SpeechRecognizerServiceProxy($impl)"; + } +} + + +class SpeechRecognizerServiceStub extends bindings.Stub { + SpeechRecognizerService _impl = null; + + SpeechRecognizerServiceStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + SpeechRecognizerServiceStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + SpeechRecognizerServiceStub.unbound() : super.unbound(); + + static SpeechRecognizerServiceStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For SpeechRecognizerServiceStub")); + return new SpeechRecognizerServiceStub.fromEndpoint(endpoint); + } + + static const String name = SpeechRecognizerServiceName; + + + SpeechRecognizerServiceListenResponseParams _SpeechRecognizerServiceListenResponseParamsFactory(ResultOrError resultOrError) { + var result = new SpeechRecognizerServiceListenResponseParams(); + result.resultOrError = resultOrError; + return result; + } + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kSpeechRecognizerService_listen_name: + var params = SpeechRecognizerServiceListenParams.deserialize( + message.payload); + var response = _impl.listen(_SpeechRecognizerServiceListenResponseParamsFactory); + if (response is Future) { + return response.then((response) { + if (response != null) { + return buildResponseWithId( + response, + kSpeechRecognizerService_listen_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + }); + } else if (response != null) { + return buildResponseWithId( + response, + kSpeechRecognizerService_listen_name, + message.header.requestId, + bindings.MessageHeader.kMessageIsResponse); + } + break; + case kSpeechRecognizerService_stopListening_name: + var params = SpeechRecognizerServiceStopListeningParams.deserialize( + message.payload); + _impl.stopListening(); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + SpeechRecognizerService get impl => _impl; + set impl(SpeechRecognizerService d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "SpeechRecognizerServiceStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/packages/mojo_services/lib/tracing/tracing.mojom.dart b/mojo/dart/packages/mojo_services/lib/tracing/tracing.mojom.dart new file mode 100644 index 0000000..40121a9 --- /dev/null +++ b/mojo/dart/packages/mojo_services/lib/tracing/tracing.mojom.dart
@@ -0,0 +1,903 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library tracing_mojom; + +import 'dart:async'; + +import 'package:mojo/bindings.dart' as bindings; +import 'package:mojo/core.dart' as core; + + + +class TraceProviderStartTracingParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + String categories = null; + Object recorder = null; + + TraceProviderStartTracingParams() : super(kVersions.last.size); + + static TraceProviderStartTracingParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static TraceProviderStartTracingParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + TraceProviderStartTracingParams result = new TraceProviderStartTracingParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.categories = decoder0.decodeString(8, false); + } + if (mainDataHeader.version >= 0) { + + result.recorder = decoder0.decodeServiceInterface(16, false, TraceRecorderProxy.newFromEndpoint); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(categories, 8, false); + + encoder0.encodeInterface(recorder, 16, false); + } + + String toString() { + return "TraceProviderStartTracingParams(" + "categories: $categories" ", " + "recorder: $recorder" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class TraceProviderStopTracingParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + TraceProviderStopTracingParams() : super(kVersions.last.size); + + static TraceProviderStopTracingParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static TraceProviderStopTracingParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + TraceProviderStopTracingParams result = new TraceProviderStopTracingParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "TraceProviderStopTracingParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + + +class TraceRecorderRecordParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(16, 0) + ]; + String json = null; + + TraceRecorderRecordParams() : super(kVersions.last.size); + + static TraceRecorderRecordParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static TraceRecorderRecordParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + TraceRecorderRecordParams result = new TraceRecorderRecordParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.json = decoder0.decodeString(8, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeString(json, 8, false); + } + + String toString() { + return "TraceRecorderRecordParams(" + "json: $json" ")"; + } + + Map toJson() { + Map map = new Map(); + map["json"] = json; + return map; + } +} + + +class TraceCollectorStartParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(24, 0) + ]; + core.MojoDataPipeProducer stream = null; + String categories = null; + + TraceCollectorStartParams() : super(kVersions.last.size); + + static TraceCollectorStartParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static TraceCollectorStartParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + TraceCollectorStartParams result = new TraceCollectorStartParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + if (mainDataHeader.version >= 0) { + + result.stream = decoder0.decodeProducerHandle(8, false); + } + if (mainDataHeader.version >= 0) { + + result.categories = decoder0.decodeString(16, false); + } + return result; + } + + void encode(bindings.Encoder encoder) { + var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); + + encoder0.encodeProducerHandle(stream, 8, false); + + encoder0.encodeString(categories, 16, false); + } + + String toString() { + return "TraceCollectorStartParams(" + "stream: $stream" ", " + "categories: $categories" ")"; + } + + Map toJson() { + throw new bindings.MojoCodecError( + 'Object containing handles cannot be encoded to JSON.'); + } +} + + +class TraceCollectorStopAndFlushParams extends bindings.Struct { + static const List<bindings.StructDataHeader> kVersions = const [ + const bindings.StructDataHeader(8, 0) + ]; + + TraceCollectorStopAndFlushParams() : super(kVersions.last.size); + + static TraceCollectorStopAndFlushParams deserialize(bindings.Message message) { + var decoder = new bindings.Decoder(message); + var result = decode(decoder); + if (decoder.excessHandles != null) { + decoder.excessHandles.forEach((h) => h.close()); + } + return result; + } + + static TraceCollectorStopAndFlushParams decode(bindings.Decoder decoder0) { + if (decoder0 == null) { + return null; + } + TraceCollectorStopAndFlushParams result = new TraceCollectorStopAndFlushParams(); + + var mainDataHeader = decoder0.decodeStructDataHeader(); + if (mainDataHeader.version <= kVersions.last.version) { + // Scan in reverse order to optimize for more recent versions. + for (int i = kVersions.length - 1; i >= 0; --i) { + if (mainDataHeader.version >= kVersions[i].version) { + if (mainDataHeader.size == kVersions[i].size) { + // Found a match. + break; + } + throw new bindings.MojoCodecError( + 'Header size doesn\'t correspond to known version size.'); + } + } + } else if (mainDataHeader.size < kVersions.last.size) { + throw new bindings.MojoCodecError( + 'Message newer than the last known version cannot be shorter than ' + 'required by the last known version.'); + } + return result; + } + + void encode(bindings.Encoder encoder) { + encoder.getStructEncoderAtOffset(kVersions.last); + } + + String toString() { + return "TraceCollectorStopAndFlushParams("")"; + } + + Map toJson() { + Map map = new Map(); + return map; + } +} + +const int kTraceProvider_startTracing_name = 0; +const int kTraceProvider_stopTracing_name = 1; + +const String TraceProviderName = + 'tracing::TraceProvider'; + +abstract class TraceProvider { + void startTracing(String categories, Object recorder); + void stopTracing(); + +} + + +class TraceProviderProxyImpl extends bindings.Proxy { + TraceProviderProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + TraceProviderProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + TraceProviderProxyImpl.unbound() : super.unbound(); + + static TraceProviderProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For TraceProviderProxyImpl")); + return new TraceProviderProxyImpl.fromEndpoint(endpoint); + } + + String get name => TraceProviderName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "TraceProviderProxyImpl($superString)"; + } +} + + +class _TraceProviderProxyCalls implements TraceProvider { + TraceProviderProxyImpl _proxyImpl; + + _TraceProviderProxyCalls(this._proxyImpl); + void startTracing(String categories, Object recorder) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new TraceProviderStartTracingParams(); + params.categories = categories; + params.recorder = recorder; + _proxyImpl.sendMessage(params, kTraceProvider_startTracing_name); + } + + void stopTracing() { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new TraceProviderStopTracingParams(); + _proxyImpl.sendMessage(params, kTraceProvider_stopTracing_name); + } + +} + + +class TraceProviderProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + TraceProvider ptr; + final String name = TraceProviderName; + + TraceProviderProxy(TraceProviderProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _TraceProviderProxyCalls(proxyImpl); + + TraceProviderProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new TraceProviderProxyImpl.fromEndpoint(endpoint) { + ptr = new _TraceProviderProxyCalls(impl); + } + + TraceProviderProxy.fromHandle(core.MojoHandle handle) : + impl = new TraceProviderProxyImpl.fromHandle(handle) { + ptr = new _TraceProviderProxyCalls(impl); + } + + TraceProviderProxy.unbound() : + impl = new TraceProviderProxyImpl.unbound() { + ptr = new _TraceProviderProxyCalls(impl); + } + + factory TraceProviderProxy.connectToService( + bindings.ServiceConnector s, String url) { + TraceProviderProxy p = new TraceProviderProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static TraceProviderProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For TraceProviderProxy")); + return new TraceProviderProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "TraceProviderProxy($impl)"; + } +} + + +class TraceProviderStub extends bindings.Stub { + TraceProvider _impl = null; + + TraceProviderStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + TraceProviderStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + TraceProviderStub.unbound() : super.unbound(); + + static TraceProviderStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For TraceProviderStub")); + return new TraceProviderStub.fromEndpoint(endpoint); + } + + static const String name = TraceProviderName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kTraceProvider_startTracing_name: + var params = TraceProviderStartTracingParams.deserialize( + message.payload); + _impl.startTracing(params.categories, params.recorder); + break; + case kTraceProvider_stopTracing_name: + var params = TraceProviderStopTracingParams.deserialize( + message.payload); + _impl.stopTracing(); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + TraceProvider get impl => _impl; + set impl(TraceProvider d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "TraceProviderStub($superString)"; + } + + int get version => 0; +} + +const int kTraceRecorder_record_name = 0; + +const String TraceRecorderName = + 'tracing::TraceRecorder'; + +abstract class TraceRecorder { + void record(String json); + +} + + +class TraceRecorderProxyImpl extends bindings.Proxy { + TraceRecorderProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + TraceRecorderProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + TraceRecorderProxyImpl.unbound() : super.unbound(); + + static TraceRecorderProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For TraceRecorderProxyImpl")); + return new TraceRecorderProxyImpl.fromEndpoint(endpoint); + } + + String get name => TraceRecorderName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "TraceRecorderProxyImpl($superString)"; + } +} + + +class _TraceRecorderProxyCalls implements TraceRecorder { + TraceRecorderProxyImpl _proxyImpl; + + _TraceRecorderProxyCalls(this._proxyImpl); + void record(String json) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new TraceRecorderRecordParams(); + params.json = json; + _proxyImpl.sendMessage(params, kTraceRecorder_record_name); + } + +} + + +class TraceRecorderProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + TraceRecorder ptr; + final String name = TraceRecorderName; + + TraceRecorderProxy(TraceRecorderProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _TraceRecorderProxyCalls(proxyImpl); + + TraceRecorderProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new TraceRecorderProxyImpl.fromEndpoint(endpoint) { + ptr = new _TraceRecorderProxyCalls(impl); + } + + TraceRecorderProxy.fromHandle(core.MojoHandle handle) : + impl = new TraceRecorderProxyImpl.fromHandle(handle) { + ptr = new _TraceRecorderProxyCalls(impl); + } + + TraceRecorderProxy.unbound() : + impl = new TraceRecorderProxyImpl.unbound() { + ptr = new _TraceRecorderProxyCalls(impl); + } + + factory TraceRecorderProxy.connectToService( + bindings.ServiceConnector s, String url) { + TraceRecorderProxy p = new TraceRecorderProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static TraceRecorderProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For TraceRecorderProxy")); + return new TraceRecorderProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "TraceRecorderProxy($impl)"; + } +} + + +class TraceRecorderStub extends bindings.Stub { + TraceRecorder _impl = null; + + TraceRecorderStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + TraceRecorderStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + TraceRecorderStub.unbound() : super.unbound(); + + static TraceRecorderStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For TraceRecorderStub")); + return new TraceRecorderStub.fromEndpoint(endpoint); + } + + static const String name = TraceRecorderName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kTraceRecorder_record_name: + var params = TraceRecorderRecordParams.deserialize( + message.payload); + _impl.record(params.json); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + TraceRecorder get impl => _impl; + set impl(TraceRecorder d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "TraceRecorderStub($superString)"; + } + + int get version => 0; +} + +const int kTraceCollector_start_name = 0; +const int kTraceCollector_stopAndFlush_name = 1; + +const String TraceCollectorName = + 'tracing::TraceCollector'; + +abstract class TraceCollector { + void start(core.MojoDataPipeProducer stream, String categories); + void stopAndFlush(); + +} + + +class TraceCollectorProxyImpl extends bindings.Proxy { + TraceCollectorProxyImpl.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); + + TraceCollectorProxyImpl.fromHandle(core.MojoHandle handle) : + super.fromHandle(handle); + + TraceCollectorProxyImpl.unbound() : super.unbound(); + + static TraceCollectorProxyImpl newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For TraceCollectorProxyImpl")); + return new TraceCollectorProxyImpl.fromEndpoint(endpoint); + } + + String get name => TraceCollectorName; + + void handleResponse(bindings.ServiceMessage message) { + switch (message.header.type) { + default: + proxyError("Unexpected message type: ${message.header.type}"); + close(immediate: true); + break; + } + } + + String toString() { + var superString = super.toString(); + return "TraceCollectorProxyImpl($superString)"; + } +} + + +class _TraceCollectorProxyCalls implements TraceCollector { + TraceCollectorProxyImpl _proxyImpl; + + _TraceCollectorProxyCalls(this._proxyImpl); + void start(core.MojoDataPipeProducer stream, String categories) { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new TraceCollectorStartParams(); + params.stream = stream; + params.categories = categories; + _proxyImpl.sendMessage(params, kTraceCollector_start_name); + } + + void stopAndFlush() { + if (!_proxyImpl.isBound) { + _proxyImpl.proxyError("The Proxy is closed."); + return; + } + var params = new TraceCollectorStopAndFlushParams(); + _proxyImpl.sendMessage(params, kTraceCollector_stopAndFlush_name); + } + +} + + +class TraceCollectorProxy implements bindings.ProxyBase { + final bindings.Proxy impl; + TraceCollector ptr; + final String name = TraceCollectorName; + + TraceCollectorProxy(TraceCollectorProxyImpl proxyImpl) : + impl = proxyImpl, + ptr = new _TraceCollectorProxyCalls(proxyImpl); + + TraceCollectorProxy.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint) : + impl = new TraceCollectorProxyImpl.fromEndpoint(endpoint) { + ptr = new _TraceCollectorProxyCalls(impl); + } + + TraceCollectorProxy.fromHandle(core.MojoHandle handle) : + impl = new TraceCollectorProxyImpl.fromHandle(handle) { + ptr = new _TraceCollectorProxyCalls(impl); + } + + TraceCollectorProxy.unbound() : + impl = new TraceCollectorProxyImpl.unbound() { + ptr = new _TraceCollectorProxyCalls(impl); + } + + factory TraceCollectorProxy.connectToService( + bindings.ServiceConnector s, String url) { + TraceCollectorProxy p = new TraceCollectorProxy.unbound(); + s.connectToService(url, p); + return p; + } + + static TraceCollectorProxy newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For TraceCollectorProxy")); + return new TraceCollectorProxy.fromEndpoint(endpoint); + } + + Future close({bool immediate: false}) => impl.close(immediate: immediate); + + Future responseOrError(Future f) => impl.responseOrError(f); + + Future get errorFuture => impl.errorFuture; + + int get version => impl.version; + + Future<int> queryVersion() => impl.queryVersion(); + + void requireVersion(int requiredVersion) { + impl.requireVersion(requiredVersion); + } + + String toString() { + return "TraceCollectorProxy($impl)"; + } +} + + +class TraceCollectorStub extends bindings.Stub { + TraceCollector _impl = null; + + TraceCollectorStub.fromEndpoint( + core.MojoMessagePipeEndpoint endpoint, [this._impl]) + : super.fromEndpoint(endpoint); + + TraceCollectorStub.fromHandle(core.MojoHandle handle, [this._impl]) + : super.fromHandle(handle); + + TraceCollectorStub.unbound() : super.unbound(); + + static TraceCollectorStub newFromEndpoint( + core.MojoMessagePipeEndpoint endpoint) { + assert(endpoint.setDescription("For TraceCollectorStub")); + return new TraceCollectorStub.fromEndpoint(endpoint); + } + + static const String name = TraceCollectorName; + + + + dynamic handleMessage(bindings.ServiceMessage message) { + if (bindings.ControlMessageHandler.isControlMessage(message)) { + return bindings.ControlMessageHandler.handleMessage(this, + 0, + message); + } + assert(_impl != null); + switch (message.header.type) { + case kTraceCollector_start_name: + var params = TraceCollectorStartParams.deserialize( + message.payload); + _impl.start(params.stream, params.categories); + break; + case kTraceCollector_stopAndFlush_name: + var params = TraceCollectorStopAndFlushParams.deserialize( + message.payload); + _impl.stopAndFlush(); + break; + default: + throw new bindings.MojoCodecError("Unexpected message name"); + break; + } + return null; + } + + TraceCollector get impl => _impl; + set impl(TraceCollector d) { + assert(_impl == null); + _impl = d; + } + + String toString() { + var superString = super.toString(); + return "TraceCollectorStub($superString)"; + } + + int get version => 0; +} + +
diff --git a/mojo/dart/mojo_services/pubspec.yaml b/mojo/dart/packages/mojo_services/pubspec.yaml similarity index 93% rename from mojo/dart/mojo_services/pubspec.yaml rename to mojo/dart/packages/mojo_services/pubspec.yaml index d60bbd7..afeb3dd 100644 --- a/mojo/dart/mojo_services/pubspec.yaml +++ b/mojo/dart/packages/mojo_services/pubspec.yaml
@@ -1,7 +1,6 @@ author: Chromium Authors <mojo-dev@googlegroups.com> dependencies: mojo: any - mojom: any description: Generated bindings for mojo services homepage: https://github.com/domokit/mojo name: mojo_services
diff --git a/mojo/dart/mojo_tools/CHANGELOG.md b/mojo/dart/packages/mojo_tools/CHANGELOG.md similarity index 100% rename from mojo/dart/mojo_tools/CHANGELOG.md rename to mojo/dart/packages/mojo_tools/CHANGELOG.md
diff --git a/mojo/dart/mojo_tools/LICENSE b/mojo/dart/packages/mojo_tools/LICENSE similarity index 100% rename from mojo/dart/mojo_tools/LICENSE rename to mojo/dart/packages/mojo_tools/LICENSE
diff --git a/mojo/dart/mojo_tools/README.md b/mojo/dart/packages/mojo_tools/README.md similarity index 100% rename from mojo/dart/mojo_tools/README.md rename to mojo/dart/packages/mojo_tools/README.md
diff --git a/mojo/dart/mojo_tools/pubspec.yaml b/mojo/dart/packages/mojo_tools/pubspec.yaml similarity index 100% rename from mojo/dart/mojo_tools/pubspec.yaml rename to mojo/dart/packages/mojo_tools/pubspec.yaml
diff --git a/mojo/dart/packages/mojom/.gitignore b/mojo/dart/packages/mojom/.gitignore new file mode 100644 index 0000000..f9ced93 --- /dev/null +++ b/mojo/dart/packages/mojom/.gitignore
@@ -0,0 +1 @@ +packages
diff --git a/mojo/dart/packages/mojom/lib/src/generate.dart b/mojo/dart/packages/mojom/lib/src/generate.dart index 5657bd9..0b9a1aa 100644 --- a/mojo/dart/packages/mojom/lib/src/generate.dart +++ b/mojo/dart/packages/mojom/lib/src/generate.dart
@@ -95,7 +95,9 @@ // Delete .mojom.dart files under [package] that are [olderThanThis]. _deleteOldMojomDart(Directory package, DateTime olderThanThis) async { Directory libDir = new Directory(path.join(package.path, 'lib')); - assert(await libDir.exists()); + if (!await libDir.exists()) { + return; + } await for (var file in libDir.list(recursive: true, followLinks: false)) { if (file is! File) continue; if (!isMojomDart(file.path)) continue; @@ -124,6 +126,24 @@ return result; } + // This is a hack until we can express import paths in .mojom files. + // This checks the mojom path for '/mojo/services/' and if found assumes + // this mojom needs //mojo/services as an import path when generating + // bindings. + String _sniffForMojoServicesInclude(String mojomPath) { + List<String> pathComponents = path.split(mojomPath); + while (pathComponents.length > 2) { + int last = pathComponents.length; + if ((pathComponents[last - 1] == 'services') && + (pathComponents[last - 2] == 'mojo')) { + return path.joinAll(pathComponents); + } + // Remove the last element and try again. + pathComponents.removeLast(); + } + return null; + } + _generateForMojom(File mojom, Directory importDir, Directory destination, String packageName) async { if (!isMojom(mojom.path)) return; @@ -134,19 +154,25 @@ final sdkInc = path.normalize(path.join(_mojoSdk.path, '..', '..')); final outputDir = await destination.createTemp(); final output = outputDir.path; + + final servicesPath = _sniffForMojoServicesInclude(mojom.path); + final arguments = [ '--use_bundled_pylibs', '-g', 'dart', '-o', output, - // TODO(zra): Are other include paths needed? '-I', sdkInc, '-I', - importDir.path, - mojom.path + importDir.path ]; + if (servicesPath != null) { + arguments.add('-I'); + arguments.add(servicesPath); + } + arguments.add(mojom.path); log.info('Generating $mojom'); log.info('$script ${arguments.join(" ")}'); @@ -164,10 +190,10 @@ log.info("bindings generation result = 0"); } - // Generated .mojom.dart is under $output/dart-pkg/$PACKAGE/lib/$X + // Generated .mojom.dart is under $output/dart-gen/$PACKAGE/lib/$X // Move $X to |destination|/lib/$X. // Throw an exception if $PACKGE != [packageName]. - final generatedDirName = path.join(output, 'dart-pkg'); + final generatedDirName = path.join(output, 'dart-gen'); final generatedDir = new Directory(generatedDirName); log.info("generatedDir= $generatedDir"); assert(await generatedDir.exists());
diff --git a/mojo/dart/test/core_test.dart b/mojo/dart/test/core_test.dart index 643a3ca..bec769c 100644 --- a/mojo/dart/test/core_test.dart +++ b/mojo/dart/test/core_test.dart
@@ -14,17 +14,17 @@ MojoHandle invalidHandle = new MojoHandle(MojoHandle.INVALID); // Close. - MojoResult result = invalidHandle.close(); - Expect.isTrue(result.isInvalidArgument); + int result = invalidHandle.close(); + Expect.isTrue(result == MojoResult.kInvalidArgument); // Wait. MojoWaitResult mwr = invalidHandle.wait(MojoHandleSignals.kReadWrite, 1000000); - Expect.isTrue(mwr.result.isInvalidArgument); + Expect.isTrue(mwr.result == MojoResult.kInvalidArgument); MojoWaitManyResult mwmr = MojoHandle.waitMany([invalidHandle.h], [MojoHandleSignals.kReadWrite], MojoHandle.DEADLINE_INDEFINITE); - Expect.isTrue(mwmr.result.isInvalidArgument); + Expect.isTrue(mwmr.result == MojoResult.kInvalidArgument); // Message pipe. MojoMessagePipe pipe = new MojoMessagePipe(); @@ -33,10 +33,10 @@ pipe.endpoints[0].handle.close(); pipe.endpoints[1].handle.close(); result = pipe.endpoints[0].write(bd); - Expect.isTrue(result.isInvalidArgument); + Expect.isTrue(result == MojoResult.kInvalidArgument); MojoMessagePipeReadResult readResult = pipe.endpoints[0].read(bd); - Expect.isTrue(pipe.endpoints[0].status.isInvalidArgument); + Expect.isTrue(pipe.endpoints[0].status == MojoResult.kInvalidArgument); // Data pipe. MojoDataPipe dataPipe = new MojoDataPipe(); @@ -45,22 +45,22 @@ dataPipe.consumer.handle.close(); int bytesWritten = dataPipe.producer.write(bd); - Expect.isTrue(dataPipe.producer.status.isInvalidArgument); + Expect.isTrue(dataPipe.producer.status == MojoResult.kInvalidArgument); ByteData writeData = dataPipe.producer.beginWrite(10); Expect.isNull(writeData); - Expect.isTrue(dataPipe.producer.status.isInvalidArgument); + Expect.isTrue(dataPipe.producer.status == MojoResult.kInvalidArgument); dataPipe.producer.endWrite(10); - Expect.isTrue(dataPipe.producer.status.isInvalidArgument); + Expect.isTrue(dataPipe.producer.status == MojoResult.kInvalidArgument); int read = dataPipe.consumer.read(bd); - Expect.isTrue(dataPipe.consumer.status.isInvalidArgument); + Expect.isTrue(dataPipe.consumer.status == MojoResult.kInvalidArgument); ByteData readData = dataPipe.consumer.beginRead(10); Expect.isNull(readData); - Expect.isTrue(dataPipe.consumer.status.isInvalidArgument); + Expect.isTrue(dataPipe.consumer.status == MojoResult.kInvalidArgument); dataPipe.consumer.endRead(10); - Expect.isTrue(dataPipe.consumer.status.isInvalidArgument); + Expect.isTrue(dataPipe.consumer.status == MojoResult.kInvalidArgument); // Shared buffer. MojoSharedBuffer sharedBuffer = new MojoSharedBuffer.create(10); @@ -73,13 +73,13 @@ Expect.isNotNull(sharedBuffer); sharedBuffer.close(); result = sharedBuffer.map(0, 10); - Expect.isTrue(result.isInvalidArgument); + Expect.isTrue(result == MojoResult.kInvalidArgument); } basicMessagePipeTest() { MojoMessagePipe pipe = new MojoMessagePipe(); Expect.isNotNull(pipe); - Expect.isTrue(pipe.status.isOk); + Expect.isTrue(pipe.status == MojoResult.kOk); Expect.isNotNull(pipe.endpoints); MojoMessagePipeEndpoint end0 = pipe.endpoints[0]; @@ -89,33 +89,33 @@ // Not readable, yet. MojoWaitResult mwr = end0.handle.wait(MojoHandleSignals.kReadable, 0); - Expect.isTrue(mwr.result.isDeadlineExceeded); + Expect.isTrue(mwr.result == MojoResult.kDeadlineExceeded); // Should be writable. mwr = end0.handle.wait(MojoHandleSignals.kWritable, 0); - Expect.isTrue(mwr.result.isOk); + Expect.isTrue(mwr.result == MojoResult.kOk); // Try to read. ByteData data = new ByteData(10); end0.read(data); - Expect.isTrue(end0.status.isShouldWait); + Expect.isTrue(end0.status == MojoResult.kShouldWait); // Write end1. String hello = "hello"; ByteData helloData = new ByteData.view((new Uint8List.fromList(hello.codeUnits)).buffer); - MojoResult result = end1.write(helloData); - Expect.isTrue(result.isOk); + int result = end1.write(helloData); + Expect.isTrue(result == MojoResult.kOk); // end0 should now be readable. MojoWaitManyResult mwmr = MojoHandle.waitMany([end0.handle.h], [MojoHandleSignals.kReadable], MojoHandle.DEADLINE_INDEFINITE); - Expect.isTrue(mwmr.result.isOk); + Expect.isTrue(mwmr.result == MojoResult.kOk); // Read from end0. MojoMessagePipeReadResult readResult = end0.read(data); Expect.isNotNull(readResult); - Expect.isTrue(readResult.status.isOk); + Expect.isTrue(readResult.status == MojoResult.kOk); Expect.equals(readResult.bytesRead, helloData.lengthInBytes); Expect.equals(readResult.handlesRead, 0); @@ -125,24 +125,24 @@ // end0 should no longer be readable. mwr = end0.handle.wait(MojoHandleSignals.kReadable, 10); - Expect.isTrue(mwr.result.isDeadlineExceeded); + Expect.isTrue(mwr.result == MojoResult.kDeadlineExceeded); // Close end0's handle. result = end0.handle.close(); - Expect.isTrue(result.isOk); + Expect.isTrue(result == MojoResult.kOk); // end1 should no longer be readable or writable. mwr = end1.handle.wait(MojoHandleSignals.kReadWrite, 1000); - Expect.isTrue(mwr.result.isFailedPrecondition); + Expect.isTrue(mwr.result == MojoResult.kFailedPrecondition); result = end1.handle.close(); - Expect.isTrue(result.isOk); + Expect.isTrue(result == MojoResult.kOk); } basicDataPipeTest() { MojoDataPipe pipe = new MojoDataPipe(); Expect.isNotNull(pipe); - Expect.isTrue(pipe.status.isOk); + Expect.isTrue(pipe.status == MojoResult.kOk); Expect.isTrue(pipe.consumer.handle.isValid); Expect.isTrue(pipe.producer.handle.isValid); @@ -153,21 +153,21 @@ // Consumer should not be readable. MojoWaitResult mwr = consumer.handle.wait(MojoHandleSignals.kReadable, 0); - Expect.isTrue(mwr.result.isDeadlineExceeded); + Expect.isTrue(mwr.result == MojoResult.kDeadlineExceeded); // Producer should be writable. mwr = producer.handle.wait(MojoHandleSignals.kWritable, 0); - Expect.isTrue(mwr.result.isOk); + Expect.isTrue(mwr.result == MojoResult.kOk); // Try to read from consumer. ByteData buffer = new ByteData(20); consumer.read(buffer, buffer.lengthInBytes, MojoDataPipeConsumer.FLAG_NONE); - Expect.isTrue(consumer.status.isShouldWait); + Expect.isTrue(consumer.status == MojoResult.kShouldWait); // Try to begin a two-phase read from consumer. ByteData b = consumer.beginRead(20, MojoDataPipeConsumer.FLAG_NONE); Expect.isNull(b); - Expect.isTrue(consumer.status.isShouldWait); + Expect.isTrue(consumer.status == MojoResult.kShouldWait); // Write to producer. String hello = "hello "; @@ -175,48 +175,48 @@ new ByteData.view((new Uint8List.fromList(hello.codeUnits)).buffer); int written = producer.write( helloData, helloData.lengthInBytes, MojoDataPipeProducer.FLAG_NONE); - Expect.isTrue(producer.status.isOk); + Expect.isTrue(producer.status == MojoResult.kOk); Expect.equals(written, helloData.lengthInBytes); // Now that we have written, the consumer should be readable. MojoWaitManyResult mwmr = MojoHandle.waitMany([consumer.handle.h], [MojoHandleSignals.kReadable], MojoHandle.DEADLINE_INDEFINITE); - Expect.isTrue(mwr.result.isOk); + Expect.isTrue(mwr.result == MojoResult.kOk); // Do a two-phase write to the producer. ByteData twoPhaseWrite = producer.beginWrite(20, MojoDataPipeProducer.FLAG_NONE); - Expect.isTrue(producer.status.isOk); + Expect.isTrue(producer.status == MojoResult.kOk); Expect.isNotNull(twoPhaseWrite); Expect.isTrue(twoPhaseWrite.lengthInBytes >= 20); String world = "world"; twoPhaseWrite.buffer.asUint8List().setAll(0, world.codeUnits); producer.endWrite(Uint8List.BYTES_PER_ELEMENT * world.codeUnits.length); - Expect.isTrue(producer.status.isOk); + Expect.isTrue(producer.status == MojoResult.kOk); // Read one character from consumer. int read = consumer.read(buffer, 1, MojoDataPipeConsumer.FLAG_NONE); - Expect.isTrue(consumer.status.isOk); + Expect.isTrue(consumer.status == MojoResult.kOk); Expect.equals(read, 1); // Close the producer. - MojoResult result = producer.handle.close(); - Expect.isTrue(result.isOk); + int result = producer.handle.close(); + Expect.isTrue(result == MojoResult.kOk); // Consumer should still be readable. mwr = consumer.handle.wait(MojoHandleSignals.kReadable, 0); - Expect.isTrue(mwr.result.isOk); + Expect.isTrue(mwr.result == MojoResult.kOk); // Get the number of remaining bytes. int remaining = consumer.read(null, 0, MojoDataPipeConsumer.FLAG_QUERY); - Expect.isTrue(consumer.status.isOk); + Expect.isTrue(consumer.status == MojoResult.kOk); Expect.equals(remaining, "hello world".length - 1); // Do a two-phase read. ByteData twoPhaseRead = consumer.beginRead(remaining, MojoDataPipeConsumer.FLAG_NONE); - Expect.isTrue(consumer.status.isOk); + Expect.isTrue(consumer.status == MojoResult.kOk); Expect.isNotNull(twoPhaseRead); Expect.isTrue(twoPhaseRead.lengthInBytes <= remaining); @@ -225,13 +225,13 @@ uint8_list = uint8_list.sublist(0, 1 + twoPhaseRead.lengthInBytes); consumer.endRead(twoPhaseRead.lengthInBytes); - Expect.isTrue(consumer.status.isOk); + Expect.isTrue(consumer.status == MojoResult.kOk); String helloWorld = new String.fromCharCodes(uint8_list.toList()); Expect.equals("hello world", helloWorld); result = consumer.handle.close(); - Expect.isTrue(result.isOk); + Expect.isTrue(result == MojoResult.kOk); } basicSharedBufferTest() { @@ -239,14 +239,14 @@ new MojoSharedBuffer.create(100, MojoSharedBuffer.CREATE_FLAG_NONE); Expect.isNotNull(mojoBuffer); Expect.isNotNull(mojoBuffer.status); - Expect.isTrue(mojoBuffer.status.isOk); + Expect.isTrue(mojoBuffer.status == MojoResult.kOk); Expect.isNotNull(mojoBuffer.handle); Expect.isTrue(mojoBuffer.handle is MojoHandle); Expect.isTrue(mojoBuffer.handle.isValid); mojoBuffer.map(0, 100, MojoSharedBuffer.MAP_FLAG_NONE); Expect.isNotNull(mojoBuffer.status); - Expect.isTrue(mojoBuffer.status.isOk); + Expect.isTrue(mojoBuffer.status == MojoResult.kOk); Expect.isNotNull(mojoBuffer.mapping); Expect.isTrue(mojoBuffer.mapping is ByteData); @@ -256,12 +256,12 @@ mojoBuffer, MojoSharedBuffer.DUPLICATE_FLAG_NONE); Expect.isNotNull(duplicate); Expect.isNotNull(duplicate.status); - Expect.isTrue(duplicate.status.isOk); + Expect.isTrue(duplicate.status == MojoResult.kOk); Expect.isTrue(duplicate.handle is MojoHandle); Expect.isTrue(duplicate.handle.isValid); duplicate.map(0, 100, MojoSharedBuffer.MAP_FLAG_NONE); - Expect.isTrue(duplicate.status.isOk); + Expect.isTrue(duplicate.status == MojoResult.kOk); Expect.isNotNull(duplicate.mapping); Expect.isTrue(duplicate.mapping is ByteData); @@ -272,12 +272,12 @@ duplicate.unmap(); Expect.isNotNull(duplicate.status); - Expect.isTrue(duplicate.status.isOk); + Expect.isTrue(duplicate.status == MojoResult.kOk); Expect.isNull(duplicate.mapping); duplicate.map(50, 50, MojoSharedBuffer.MAP_FLAG_NONE); Expect.isNotNull(duplicate.status); - Expect.isTrue(duplicate.status.isOk); + Expect.isTrue(duplicate.status == MojoResult.kOk); Expect.isNotNull(duplicate.mapping); Expect.isTrue(duplicate.mapping is ByteData); @@ -286,7 +286,7 @@ duplicate.unmap(); Expect.isNotNull(duplicate.status); - Expect.isTrue(duplicate.status.isOk); + Expect.isTrue(duplicate.status == MojoResult.kOk); Expect.isNull(duplicate.mapping); duplicate.close(); @@ -296,7 +296,7 @@ fillerDrainerTest() async { MojoDataPipe pipe = new MojoDataPipe(); Expect.isNotNull(pipe); - Expect.isTrue(pipe.status.isOk); + Expect.isTrue(pipe.status == MojoResult.kOk); Expect.isTrue(pipe.consumer.handle.isValid); Expect.isTrue(pipe.producer.handle.isValid); @@ -314,8 +314,8 @@ String receivedMessage = new String.fromCharCodes(receivedBytes); Expect.equals(sentMessage, receivedMessage); - Expect.isTrue(producer.status.isOk); - Expect.isTrue(consumer.status.isOk); + Expect.isTrue(producer.status == MojoResult.kOk); + Expect.isTrue(consumer.status == MojoResult.kOk); } utilsTest() { @@ -323,13 +323,15 @@ Expect.isTrue(1000 < ticksa); // Wait for the clock to advance. - MojoWaitResult mwr = (new MojoMessagePipe()).endpoints[0].handle.wait( - MojoHandleSignals.kReadable, 1); - Expect.isTrue(mwr.result.isDeadlineExceeded); + MojoWaitResult mwr = (new MojoMessagePipe()).endpoints[0] + .handle + .wait(MojoHandleSignals.kReadable, 1); + Expect.isTrue(mwr.result == MojoResult.kDeadlineExceeded); int ticksb = getTimeTicksNow(); Expect.isTrue(ticksa < ticksb); } + // TODO(rudominer) This probably belongs in a different file. processTest() { Expect.isTrue(pid > 0);
diff --git a/mojo/dart/test/handle_finalizer_test.dart b/mojo/dart/test/handle_finalizer_test.dart index 3c1e39f..a551cb7 100644 --- a/mojo/dart/test/handle_finalizer_test.dart +++ b/mojo/dart/test/handle_finalizer_test.dart
@@ -36,8 +36,8 @@ // The handle will be closed by the MojoHandle finalizer during GC, so the // attempt to close it again will fail. - MojoResult result = handle.close(); - Expect.isTrue(result.isInvalidArgument); + int result = handle.close(); + Expect.isTrue(result == MojoResult.kInvalidArgument); } main() {
diff --git a/mojo/dart/test/ping_pong_test.dart b/mojo/dart/test/ping_pong_test.dart index 7701419..5730c51 100644 --- a/mojo/dart/test/ping_pong_test.dart +++ b/mojo/dart/test/ping_pong_test.dart
@@ -38,16 +38,16 @@ void pipeTestIsolate(core.MojoMessagePipeEndpoint endpoint) { var eventSubscription = new core.MojoEventSubscription(endpoint.handle); eventSubscription.subscribe((List<int> event) { - var mojoSignals = new core.MojoHandleSignals(event[1]); - if (mojoSignals.isReadWrite) { + int mojoSignals = event[1]; + if (core.MojoHandleSignals.isReadWrite(mojoSignals)) { throw 'We should only be reading or writing, not both.'; - } else if (mojoSignals.isReadable) { + } else if (core.MojoHandleSignals.isReadable(mojoSignals)) { expectStringFromEndpoint("Ping", endpoint); eventSubscription.enableWriteEvents(); - } else if (mojoSignals.isWritable) { + } else if (core.MojoHandleSignals.isWritable(mojoSignals)) { endpoint.write(byteDataOfString("Pong")); eventSubscription.enableReadEvents(); - } else if (mojoSignals.isPeerClosed) { + } else if (core.MojoHandleSignals.isPeerClosed(mojoSignals)) { eventSubscription.close(); } else { throw 'Unexpected event.'; @@ -61,16 +61,16 @@ var eventSubscription = new core.MojoEventSubscription(endpoint.handle); Isolate.spawn(pipeTestIsolate, pipe.endpoints[1]).then((_) { eventSubscription.subscribe((List<int> event) { - var mojoSignals = new core.MojoHandleSignals(event[1]); - if (mojoSignals.isReadWrite) { + int mojoSignals = event[1]; + if (core.MojoHandleSignals.isReadWrite(mojoSignals)) { throw 'We should only be reading or writing, not both.'; - } else if (mojoSignals.isReadable) { + } else if (core.MojoHandleSignals.isReadable(mojoSignals)) { expectStringFromEndpoint("Pong", endpoint); eventSubscription.close(); - } else if (mojoSignals.isWritable) { + } else if (core.MojoHandleSignals.isWritable(mojoSignals)) { endpoint.write(byteDataOfString("Ping")); eventSubscription.enableReadEvents(); - } else if (mojoSignals.isPeerClosed) { + } else if (core.MojoHandleSignals.isPeerClosed(mojoSignals)) { throw 'This end should close first.'; } else { throw 'Unexpected event.';
diff --git a/mojo/dart/test/validation_test.dart b/mojo/dart/test/validation_test.dart index 0d344e2..2963774 100644 --- a/mojo/dart/test/validation_test.dart +++ b/mojo/dart/test/validation_test.dart
@@ -96,8 +96,8 @@ }); var length = (test.data == null) ? 0 : test.data.lengthInBytes; - var r = pipe.endpoints[1].write(test.data, length, handles); - assert(r.isOk); + int r = pipe.endpoints[1].write(test.data, length, handles); + assert(r == MojoResult.kOk); return completer.future.then((_) { assert(expected == "PASS");
diff --git a/mojo/dart/tools/bump_package_versions.py b/mojo/dart/tools/bump_package_versions.py index 4e5b14b..44e50f6 100755 --- a/mojo/dart/tools/bump_package_versions.py +++ b/mojo/dart/tools/bump_package_versions.py
@@ -10,9 +10,9 @@ import yaml PUBSPECS = [ - 'dart/mojo_services/pubspec.yaml', 'dart/packages/mojo/pubspec.yaml', 'dart/packages/mojo_apptest/pubspec.yaml', + 'dart/packages/mojo_services/pubspec.yaml', 'dart/packages/mojom/pubspec.yaml', ]
diff --git a/mojo/dart/tools/presubmit/check_mojom_dart.py b/mojo/dart/tools/presubmit/check_mojom_dart.py new file mode 100755 index 0000000..96ff593 --- /dev/null +++ b/mojo/dart/tools/presubmit/check_mojom_dart.py
@@ -0,0 +1,355 @@ +#!/usr/bin/env python +# Copyright 2015 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Checks that released mojom.dart files in the source tree are up to date""" + +import argparse +import os +import subprocess +import sys + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +SRC_DIR = os.path.dirname( + os.path.dirname( + os.path.dirname( + os.path.dirname(SCRIPT_DIR)))) + +# Insert path to mojom parsing library. +sys.path.insert(0, os.path.join(SRC_DIR, + 'mojo', + 'public', + 'tools', + 'bindings', + 'pylib')) + +from mojom.error import Error +from mojom.parse.parser import Parse +from mojom.parse.translate import Translate + +PACKAGES_DIR = os.path.join(SRC_DIR, 'mojo', 'dart', 'packages') + +# Script that calculates mojom output paths. +DART_OUTPUTS_SCRIPT = os.path.join(SRC_DIR, + 'mojo', + 'public', + 'tools', + 'bindings', + 'mojom_list_dart_outputs.py') + +# Runs command line in args from cwd. Returns the output as a string. +def run(cwd, args): + return subprocess.check_output(args, cwd=cwd) + + +# Given a parsed mojom, return the path of the .mojom.dart relative to its +# package directory. +def _mojom_output_path(mojom): + name = mojom['name'] + namespace = mojom['namespace'] + elements = ['lib'] + elements.extend(namespace.split('.')) + elements.append("%s.dart" % name) + return os.path.join(*elements) + + +# Given a parsed mojom, return the package or None. +def _mojom_package(mojom): + attributes = mojom['attributes'] + return attributes['DartPackage'] + + +# Load and parse a .mojom file. Returns the parsed mojom. +def _load_mojom(path_to_mojom): + filename = os.path.abspath(path_to_mojom) + name = os.path.basename(filename) + + # Read in mojom file. + with open(filename) as f: + source = f.read() + # Parse + tree = Parse(source, name) + mojom = Translate(tree, name) + return mojom + + +def _print_regenerate_message(package): + print(""" +*** Dart Generated Bindings Check Failed for package: %s + +To regenerate bindings, from the src directory, run: +./third_party/dart-sdk/dart-sdk/bin/dart mojo/dart/packages/mojom/bin/mojom.dart gen -m mojo/public -r mojo/ --output mojo/dart/packages/ +""" % (package)) + + +# Returns a map from package name to source directory. +def _build_package_map(): + packages = {} + for package in os.listdir(PACKAGES_DIR): + package_path = os.path.join(PACKAGES_DIR, package) + # Skip everything but directories. + if not os.path.isdir(package_path): + continue + packages[package] = package_path + return packages + + +# Returns a list of paths to .mojom files vended by package_name. +def _find_mojoms_for_package(package_name): + # Run git grep for all .mojom files with DartPackage="package_name" + try: + output = run(SRC_DIR, ['git', + 'grep', + '--name-only', + 'DartPackage="' + package_name + '"', + '--', + '*.mojom']) + except subprocess.CalledProcessError as e: + # git grep exits with code 1 if nothing was found. + if e.returncode == 1: + return [] + + # Process output + mojoms = [] + for line in output.splitlines(): + line = line.strip() + # Skip empty lines. + if not line: + continue + mojoms.append(line) + return mojoms + + +# Return the list of expected mojom.dart files for a package. +def _expected_mojom_darts_for_package(mojoms): + output = run(SRC_DIR, ['python', + DART_OUTPUTS_SCRIPT, + '--mojoms'] + mojoms) + mojom_darts = [] + for line in output.splitlines(): + line = line.strip() + # Skip empty lines. + if not line: + continue + mojom_darts.append(line) + return mojom_darts + + +# Returns a map indexed by output mojom.dart name with the value of +# the modification time of the .mojom file in the source tree. +def _build_expected_map(mojoms, mojom_darts): + assert(len(mojom_darts) == len(mojoms)) + expected = {} + for i in range(0, len(mojoms)): + mojom_path = os.path.join(SRC_DIR, mojoms[i]) + expected[mojom_darts[i]] = os.path.getmtime(mojom_path) + return expected + + +# Returns a map indexed by output mojom.dart name with the value of +# the modification time of the .mojom.dart file in the source tree. +def _build_current_map(package): + current = {} + package_path = os.path.join(PACKAGES_DIR, package) + for directory, _, files in os.walk(package_path): + for filename in files: + if filename.endswith('.mojom.dart'): + path = os.path.abspath(os.path.join(directory, filename)) + relpath = os.path.relpath(path, start=PACKAGES_DIR) + current[relpath] = os.path.getmtime(path) + return current + + +# Checks if a mojom.dart file we expected in the source tree isn't there. +def _check_new(package, expected, current): + check_failure = False + for mojom_dart in expected: + if not current.get(mojom_dart): + print("Package %s missing %s" % (package, mojom_dart)) + check_failure = True + return check_failure + + +# Checks if a mojom.dart file exists without an associated .mojom file. +def _check_delete(package, expected, current): + check_failure = False + for mojom_dart in current: + if not expected.get(mojom_dart): + print("Package %s no longer has %s." % (package, mojom_dart)) + print("Delete %s", os.path.join(PACKAGES_DIR, mojom_dart)) + check_failure = True + return check_failure + + +# Checks if a .mojom.dart file is older than the associated .mojom file. +# TODO(johnmccutchan): Handle the case where someone edited a .mojom.dart file +# directly instead of through the bindings generation script. +def _check_stale(package, expected, current): + check_failure = False + for mojom_dart in expected: + # Missing mojom.dart file in source tree case handled by _check_new. + source_mtime = expected[mojom_dart] + if not current.get(mojom_dart): + continue + generated_mtime = current[mojom_dart] + if generated_mtime < source_mtime: + print("Package %s has old %s" % (package, mojom_dart)) + check_failure = True + return check_failure + + +# Returns True if any checks fail. +def _check(package, expected, current): + check_failure = False + if _check_new(package, expected, current): + check_failure = True + if _check_stale(package, expected, current): + check_failure = True + if _check_delete(package, expected, current): + check_failure = True + return check_failure + + +def global_check(packages): + check_failure = False + for package in packages: + mojoms = _find_mojoms_for_package(package) + if not mojoms: + continue + mojom_darts = _expected_mojom_darts_for_package(mojoms) + # We only feed in mojom files with DartPackage annotations, therefore, we + # should have a 1:1 mapping from mojoms[i] to mojom_darts[i]. + assert(len(mojom_darts) == len(mojoms)) + expected = _build_expected_map(mojoms, mojom_darts) + current = _build_current_map(package) + if _check(package, expected, current): + _print_regenerate_message(package) + check_failure = True + return check_failure + + +def is_mojom_dart(path): + return path.endswith('.mojom.dart') + + +def is_mojom(path): + return path.endswith('.mojom') + + +def filter_paths(paths, path_filter): + result = [] + for path in paths: + path = os.path.abspath(os.path.join(SRC_DIR, path)) + if path_filter(path): + result.append(path) + return result + + +def safe_mtime(path): + try: + return os.path.getmtime(path) + except Exception: + pass + return 0 + + +def presubmit_check(packages, affected_files): + mojoms = filter_paths(affected_files, is_mojom) + mojom_darts = filter_paths(affected_files, is_mojom_dart) + updated_mojom_dart_files = [] + packages_with_failures = [] + check_failure = False + + # Check for updated .mojom without updated .mojom.dart + for mojom_file in mojoms: + try: + mojom = _load_mojom(mojom_file) + except Exception: + # Could not load .mojom file + return True + + package = _mojom_package(mojom) + # If a mojom doesn't have a package, ignore it. + if not package: + continue + package_dir = packages.get(package) + # If the package isn't a known package, ignore it. + if not package_dir: + continue + # Expected output path relative to src. + mojom_dart_path = os.path.relpath( + os.path.join(package_dir, _mojom_output_path(mojom)), start=SRC_DIR) + + mojom_mtime = safe_mtime(mojom_file) + mojom_dart_mtime = safe_mtime(os.path.join(SRC_DIR, mojom_dart_path)) + + if mojom_mtime > mojom_dart_mtime: + check_failure = True + print("Package %s has old %s" % (package, mojom_dart_path)) + if not (package in packages_with_failures): + packages_with_failures.append(package) + continue + # Remember that this .mojom.dart file was updated after the .mojom file. + # This list is used to verify that all updated .mojom.dart files were + # updated because their source .mojom file changed. + updated_mojom_dart_files.append(mojom_dart_path) + + # Check for updated .mojom.dart file without updated .mojom file. + for mojom_dart_file in mojom_darts: + # mojom_dart_file is not inside //mojo/dart/packages. + if not mojom_dart_file.startswith(PACKAGES_DIR): + continue + + # Path relative to //mojo/dart/packages/ + path_relative_to_packages = os.path.relpath(mojom_dart_file, + start=PACKAGES_DIR) + # Package name is first element of split path. + package = path_relative_to_packages.split(os.sep)[0] + # Path relative to src. + mojom_dart_path = os.path.relpath(mojom_dart_file, start=SRC_DIR) + # If mojom_dart_path is not in updated_mojom_dart_files, a .mojom.dart + # file was updated without updating the related .mojom file. + if not (mojom_dart_path in updated_mojom_dart_files): + check_failure = True + print("Package %s has new %s without updating source .mojom file." % + (package, mojom_dart_path)) + if not (package in packages_with_failures): + packages_with_failures.append(package) + + for package in packages_with_failures: + _print_regenerate_message(package) + + return check_failure + + +def main(): + parser = argparse.ArgumentParser(description='Generate a dart-pkg') + parser.add_argument('--affected-files', + action='store', + metavar='affected_files', + help='List of files that should be checked.', + nargs='+') + args = parser.parse_args() + packages = _build_package_map() + + # This script runs in two modes, the first mode is invoked by PRESUBMIT.py + # and passes the list of affected files. This checks for the following cases: + # 1) An updated .mojom file without an updated .mojom.dart file. + # 2) An updated .mojom.dart file without an updated .mojom file. + # NOTE: Case 1) also handles the case of a new .mojom file being added. + # + # The second mode does a global check of all packages under + # //mojo/dart/packages. This checks for the following cases: + # 1) An updated .mojom file without an updated .mojom.dart file. + # 2) A .mojom.dart file without an associated .mojom file (deletion case). + if args.affected_files: + check_failure = presubmit_check(packages, args.affected_files) + else: + check_failure = global_check(packages) + if check_failure: + return 2 + return 0 + +if __name__ == '__main__': + sys.exit(main()) \ No newline at end of file
diff --git a/mojo/devtools/common/devtoolslib/android_shell.py b/mojo/devtools/common/devtoolslib/android_shell.py index 20ec93c..5e70013 100644 --- a/mojo/devtools/common/devtoolslib/android_shell.py +++ b/mojo/devtools/common/devtoolslib/android_shell.py
@@ -30,12 +30,6 @@ 'MojoShellApplication', ] -# Tags used by native logging reflected in the logcat. -_LOGCAT_NATIVE_TAGS = [ - 'chromium', - 'sky', -] - _MOJO_SHELL_PACKAGE_NAME = 'org.chromium.mojo.shell' # Used to parse the output of `adb devices`. @@ -100,7 +94,6 @@ self.adb_path = adb_path self.target_device = target_device self.stop_shell_registered = False - self.adb_running_as_root = None self.additional_logcat_tags = logcat_tags self.verbose_stdout = sys.stdout if verbose else open(os.devnull, 'w') self.verbose_stderr = sys.stderr if verbose else self.verbose_stdout @@ -123,12 +116,13 @@ cannot find |fifo_path|, a exception will be raised. """ fifo_command = self._adb_command( - ['shell', 'test -e "%s"; echo $?' % fifo_path]) + ['shell', 'run-as', _MOJO_SHELL_PACKAGE_NAME, 'ls', fifo_path]) def _run(): def _wait_for_fifo(): for _ in xrange(max_attempts): - if subprocess.check_output(fifo_command)[0] == '0': + output = subprocess.check_output(fifo_command).strip() + if output == fifo_path: return time.sleep(1) if on_fifo_closed: @@ -136,7 +130,8 @@ raise Exception("Unable to find fifo.") _wait_for_fifo() stdout_cat = subprocess.Popen( - self._adb_command(['shell', 'cat', fifo_path]), stdout=pipe) + self._adb_command(['shell', 'run-as', _MOJO_SHELL_PACKAGE_NAME, + 'cat', fifo_path]), stdout=pipe) atexit.register(_exit_if_needed, stdout_cat) stdout_cat.wait() if on_fifo_closed: @@ -158,11 +153,6 @@ The device port. """ assert host_port - # Root is not required for `adb forward` (hence we don't check the return - # value), but if we can run adb as root, we have to do it now, because - # restarting adbd as root clears any port mappings. See - # https://github.com/domokit/devtools/issues/20. - self._run_adb_as_root() if device_port == 0: # TODO(ppi): Should we have a retry loop to handle the unlikely races? @@ -185,7 +175,6 @@ The host port. """ assert device_port - self._run_adb_as_root() if host_port == 0: # TODO(ppi): Should we have a retry loop to handle the unlikely races? @@ -200,22 +189,6 @@ atexit.register(_unmap_port) return host_port - def _run_adb_as_root(self): - if self.adb_running_as_root is not None: - return self.adb_running_as_root - - if ('cannot run as root' not in subprocess.check_output( - self._adb_command(['root']))): - # Wait for adbd to restart. - subprocess.check_call( - self._adb_command(['wait-for-device']), - stdout=self.verbose_stdout, stderr=self.verbose_stderr) - self.adb_running_as_root = True - else: - self.adb_running_as_root = False - - return self.adb_running_as_root - def _is_shell_package_installed(self): # Adb should print one line if the package is installed and return empty # string otherwise. @@ -237,7 +210,7 @@ subprocess.check_call(self._adb_command([ 'shell', 'rm', device_path])) - def check_device(self, require_root=False): + def check_device(self): """Verifies if the device configuration allows adb to run. If a target device was indicated in the constructor, it checks that the @@ -271,9 +244,6 @@ if not devices.itervalues().next() == 'device': return False, 'Connected device is not available.' - if require_root and not self._run_adb_as_root(): - return False, 'Cannot run on an unrooted device.' - return True, None def install_apk(self, shell_apk_path): @@ -337,18 +307,13 @@ parameters = [] if stdout or on_application_stop: - # We need to run as root to access the fifo file we use for stdout - # redirection. - if self._run_adb_as_root(): - # Remove any leftover fifo file after the previous run. - subprocess.check_call(self._adb_command( - ['shell', 'rm', '-f', STDOUT_PIPE])) + # Remove any leftover fifo file after the previous run. + subprocess.check_call(self._adb_command( + ['shell', 'run-as', _MOJO_SHELL_PACKAGE_NAME, + 'rm', '-f', STDOUT_PIPE])) - parameters.append('--fifo-path=%s' % STDOUT_PIPE) - self._read_fifo(STDOUT_PIPE, stdout, on_application_stop) - else: - _logger.warning("Running without root access, full stdout of the " - "shell won't be available.") + parameters.append('--fifo-path=%s' % STDOUT_PIPE) + self._read_fifo(STDOUT_PIPE, stdout, on_application_stop) parameters.extend(arguments) if parameters: @@ -382,15 +347,13 @@ """Cleans the logs on the device.""" subprocess.check_call(self._adb_command(['logcat', '-c'])) - def show_logs(self, include_native_logs=True): + def show_logs(self): """Displays the log for the mojo shell. Returns: The process responsible for reading the logs. """ tags = _LOGCAT_JAVA_TAGS - if include_native_logs: - tags.extend(_LOGCAT_NATIVE_TAGS) if self.additional_logcat_tags is not None: tags.extend(self.additional_logcat_tags.split(",")) logcat = subprocess.Popen( @@ -445,9 +408,7 @@ self.clean_logs() self.forward_observatory_ports() - # If we are running as root, don't carry over the native logs from logcat - - # we will have these in the stdout. - p = self.show_logs(include_native_logs=(not self._run_adb_as_root())) + p = self.show_logs(); self.start_shell(arguments, sys.stdout, p.terminate) p.wait() return None
diff --git a/mojo/devtools/common/devtoolslib/shell_arguments.py b/mojo/devtools/common/devtoolslib/shell_arguments.py index 5ee28b2..616615b 100644 --- a/mojo/devtools/common/devtoolslib/shell_arguments.py +++ b/mojo/devtools/common/devtoolslib/shell_arguments.py
@@ -198,8 +198,7 @@ logcat_tags=shell_config.logcat_tags, verbose=shell_config.verbose) - device_status, error = shell.check_device( - require_root=shell_config.require_root) + device_status, error = shell.check_device() if not device_status: raise ShellConfigurationException('Device check failed: ' + error) if shell_config.shell_path:
diff --git a/mojo/devtools/common/devtoolslib/shell_config.py b/mojo/devtools/common/devtoolslib/shell_config.py index fde356f..ace522b 100644 --- a/mojo/devtools/common/devtoolslib/shell_config.py +++ b/mojo/devtools/common/devtoolslib/shell_config.py
@@ -37,7 +37,6 @@ self.adb_path = None self.target_device = None self.logcat_tags = None - self.require_root = False # Desktop-only. self.use_osmesa = None
diff --git a/mojo/devtools/common/mojo_test b/mojo/devtools/common/mojo_test index f3fa0d0..b43e95a 100755 --- a/mojo/devtools/common/mojo_test +++ b/mojo/devtools/common/mojo_test
@@ -65,9 +65,6 @@ try: config = shell_config.get_shell_config(script_args) - if script_args.android: - # We need root to have the stdout of the shell available on the host. - config.require_root = True shell, common_shell_args = shell_arguments.get_shell(config, shell_args) # Tests must be reproducible, start with empty caches. common_shell_args.append(
diff --git a/mojo/go/tests/application_impl_test.go b/mojo/go/tests/application_impl_test.go index b28c95f..5335ae8 100644 --- a/mojo/go/tests/application_impl_test.go +++ b/mojo/go/tests/application_impl_test.go
@@ -14,6 +14,7 @@ "examples/echo/echo" mojoApp "mojo/public/interfaces/application/application" + ac "mojo/public/interfaces/application/application_connector" sp "mojo/public/interfaces/application/service_provider" "mojo/public/interfaces/application/shell" ) @@ -120,6 +121,11 @@ return nil } +func (s *shellImpl) CreateApplicationConnector(applicationConnectorRequest ac.ApplicationConnector_Request) error { + // TODO(vtl): https://github.com/domokit/mojo/issues/533 + panic("not implemented") +} + func TestApplication(t *testing.T) { var apps []*mojoApp.Application_Proxy var responsesSent, appsTerminated sync.WaitGroup
diff --git a/mojo/public/cpp/application/application_impl.h b/mojo/public/cpp/application/application_impl.h index e456de0..6fba0dd 100644 --- a/mojo/public/cpp/application/application_impl.h +++ b/mojo/public/cpp/application/application_impl.h
@@ -5,6 +5,7 @@ #ifndef MOJO_PUBLIC_APPLICATION_APPLICATION_IMPL_H_ #define MOJO_PUBLIC_APPLICATION_APPLICATION_IMPL_H_ +#include <memory> #include <string> #include <vector> @@ -12,6 +13,7 @@ #include "mojo/public/cpp/application/lib/service_registry.h" #include "mojo/public/cpp/system/core.h" #include "mojo/public/interfaces/application/application.mojom.h" +#include "mojo/public/interfaces/application/application_connector.mojom.h" #include "mojo/public/interfaces/application/shell.mojom.h" namespace mojo { @@ -39,6 +41,11 @@ InterfaceRequest<Application> request); ~ApplicationImpl() override; + // Quits the main run loop for this application. + // TODO(vtl): This is implemented in application_runner.cc (for example). Its + // presence here is pretty dubious. + static void Terminate(); + // The Mojo shell. This will return a valid pointer after Initialize() has // been invoked. It will remain valid until UnbindConnections() is invoked or // the ApplicationImpl is destroyed. @@ -50,27 +57,31 @@ const std::vector<std::string>& args() const { return args_; } bool HasArg(const std::string& arg) const; + // Creates a new |ApplicationConnector|. The result can be bound to an + // |ApplicationConnectorPtr| and used to connect to other applications. (It + // returns an |InterfacePtrInfo| instead of an |InterfacePtr| to facilitate + // passing it to another thread.) + InterfacePtrInfo<ApplicationConnector> CreateApplicationConnector(); + // Requests a new connection to an application. Returns a pointer to the // connection if the connection is permitted by this application's delegate, // or nullptr otherwise. Caller does not take ownership. The pointer remains // valid until an error occurs on the connection with the Shell, or until the // ApplicationImpl is destroyed, whichever occurs first. + // TODO(vtl): Deprecate/remove this. ApplicationConnection* ConnectToApplication(const String& application_url); // Connect to application identified by |application_url| and connect to the // service implementation of the interface identified by |Interface|. + // TODO(vtl): Deprecate/remove this. template <typename Interface> void ConnectToService(const std::string& application_url, InterfacePtr<Interface>* ptr) { ConnectToApplication(application_url)->ConnectToService(ptr); } - // Application implementation. - void Initialize(ShellPtr shell, - Array<String> args, - const mojo::String& url) override; - - // Block until the Application is initialized, if it is not already. + // Blocks until the |Application| is initialized (i.e., |Initialize()| is + // received), if it is not already. void WaitForInitialize(); // Unbinds the Shell and Application connections. Can be used to re-bind the @@ -79,30 +90,19 @@ void UnbindConnections(InterfaceRequest<Application>* application_request, ShellPtr* shell); - // Quits the main run loop for this application. - static void Terminate(); - - protected: - // Application implementation. + // |Application| implementation. + void Initialize(ShellPtr shell, + Array<String> args, + const mojo::String& url) override; void AcceptConnection(const String& requestor_url, InterfaceRequest<ServiceProvider> services, ServiceProviderPtr exposed_services, const String& url) override; - - private: - void ClearConnections(); - - void OnShellError() { - delegate_->Quit(); - ClearConnections(); - Terminate(); - } - - // Application implementation. void RequestQuit() override; - typedef std::vector<internal::ServiceRegistry*> ServiceRegistryList; - + private: + using ServiceRegistryList = + std::vector<std::unique_ptr<internal::ServiceRegistry>>; ServiceRegistryList incoming_service_registries_; ServiceRegistryList outgoing_service_registries_; ApplicationDelegate* delegate_;
diff --git a/mojo/public/cpp/application/connect.h b/mojo/public/cpp/application/connect.h index 964c55f..fb47f5e 100644 --- a/mojo/public/cpp/application/connect.h +++ b/mojo/public/cpp/application/connect.h
@@ -5,6 +5,7 @@ #ifndef MOJO_PUBLIC_CPP_APPLICATION_CONNECT_H_ #define MOJO_PUBLIC_CPP_APPLICATION_CONNECT_H_ +#include "mojo/public/interfaces/application/application_connector.mojom.h" #include "mojo/public/interfaces/application/service_provider.mojom.h" #include "mojo/public/interfaces/application/shell.mojom.h" @@ -30,6 +31,17 @@ ConnectToService(service_provider.get(), ptr); } +// Binds |ptr| to a remote implementation of Interface from |application_url|. +template <typename Interface> +inline void ConnectToService(ApplicationConnector* application_connector, + const std::string& application_url, + InterfacePtr<Interface>* ptr) { + ServiceProviderPtr service_provider; + application_connector->ConnectToApplication( + application_url, GetProxy(&service_provider), nullptr); + ConnectToService(service_provider.get(), ptr); +} + } // namespace mojo #endif // MOJO_PUBLIC_CPP_APPLICATION_CONNECT_H_
diff --git a/mojo/public/cpp/application/lib/application_impl.cc b/mojo/public/cpp/application/lib/application_impl.cc index 589159c..a468262 100644 --- a/mojo/public/cpp/application/lib/application_impl.cc +++ b/mojo/public/cpp/application/lib/application_impl.cc
@@ -4,37 +4,34 @@ #include "mojo/public/cpp/application/application_impl.h" +#include <utility> + #include "mojo/public/cpp/application/application_delegate.h" #include "mojo/public/cpp/application/lib/service_registry.h" #include "mojo/public/cpp/bindings/interface_ptr.h" +#include "mojo/public/cpp/bindings/interface_request.h" #include "mojo/public/cpp/environment/logging.h" +#include "mojo/public/cpp/system/message_pipe.h" namespace mojo { ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate, InterfaceRequest<Application> request) - : delegate_(delegate), binding_(this, request.Pass()) { -} + : delegate_(delegate), binding_(this, request.Pass()) {} + +ApplicationImpl::~ApplicationImpl() {} bool ApplicationImpl::HasArg(const std::string& arg) const { return std::find(args_.begin(), args_.end(), arg) != args_.end(); } -void ApplicationImpl::ClearConnections() { - for (ServiceRegistryList::iterator i(incoming_service_registries_.begin()); - i != incoming_service_registries_.end(); - ++i) - delete *i; - for (ServiceRegistryList::iterator i(outgoing_service_registries_.begin()); - i != outgoing_service_registries_.end(); - ++i) - delete *i; - incoming_service_registries_.clear(); - outgoing_service_registries_.clear(); -} - -ApplicationImpl::~ApplicationImpl() { - ClearConnections(); +InterfacePtrInfo<ApplicationConnector> +ApplicationImpl::CreateApplicationConnector() { + MOJO_CHECK(shell_); + MessagePipe pipe; + shell_->CreateApplicationConnector( + MakeRequest<ApplicationConnector>(pipe.handle1.Pass())); + return InterfacePtrInfo<ApplicationConnector>(pipe.handle0.Pass(), 0u); } ApplicationConnection* ApplicationImpl::ConnectToApplication( @@ -48,20 +45,10 @@ internal::ServiceRegistry* registry = new internal::ServiceRegistry( this, application_url, application_url, remote_services.Pass(), local_request.Pass()); - outgoing_service_registries_.push_back(registry); + outgoing_service_registries_.emplace_back(registry); return registry; } -void ApplicationImpl::Initialize(ShellPtr shell, - Array<String> args, - const mojo::String& url) { - shell_ = shell.Pass(); - shell_.set_connection_error_handler([this]() { OnShellError(); }); - url_ = url; - args_ = args.To<std::vector<std::string>>(); - delegate_->Initialize(this); -} - void ApplicationImpl::WaitForInitialize() { if (!shell_) binding_.WaitForIncomingMethodCall(); @@ -74,18 +61,32 @@ shell->Bind(shell_.PassInterface()); } +void ApplicationImpl::Initialize(ShellPtr shell, + Array<String> args, + const mojo::String& url) { + shell_ = shell.Pass(); + shell_.set_connection_error_handler([this]() { + delegate_->Quit(); + incoming_service_registries_.clear(); + outgoing_service_registries_.clear(); + Terminate(); + }); + url_ = url; + args_ = args.To<std::vector<std::string>>(); + delegate_->Initialize(this); +} + void ApplicationImpl::AcceptConnection( const String& requestor_url, InterfaceRequest<ServiceProvider> services, ServiceProviderPtr exposed_services, const String& url) { - internal::ServiceRegistry* registry = new internal::ServiceRegistry( - this, url, requestor_url, exposed_services.Pass(), services.Pass()); - if (!delegate_->ConfigureIncomingConnection(registry)) { - delete registry; + std::unique_ptr<internal::ServiceRegistry> registry( + new internal::ServiceRegistry(this, url, requestor_url, + exposed_services.Pass(), services.Pass())); + if (!delegate_->ConfigureIncomingConnection(registry.get())) return; - } - incoming_service_registries_.push_back(registry); + incoming_service_registries_.push_back(std::move(registry)); } void ApplicationImpl::RequestQuit() {
diff --git a/mojo/public/cpp/bindings/array.h b/mojo/public/cpp/bindings/array.h index a385e45..c03da87 100644 --- a/mojo/public/cpp/bindings/array.h +++ b/mojo/public/cpp/bindings/array.h
@@ -76,6 +76,9 @@ is_null_ = true; } + // Tests as true if non-null, false if null. + explicit operator bool() const { return !is_null_; } + // Indicates whether the array is null (which is distinct from empty). bool is_null() const { return is_null_; } @@ -238,12 +241,6 @@ Iterator end() { return Iterator(this, size()); } private: - typedef std::vector<T> Array::*Testable; - - public: - operator Testable() const { return is_null_ ? 0 : &Array::vec_; } - - private: void Take(Array* other) { reset(); Swap(other);
diff --git a/mojo/public/cpp/bindings/interface_ptr.h b/mojo/public/cpp/bindings/interface_ptr.h index fffd223..007bede 100644 --- a/mojo/public/cpp/bindings/interface_ptr.h +++ b/mojo/public/cpp/bindings/interface_ptr.h
@@ -111,6 +111,9 @@ internal_state_.Swap(&doomed); } + // Tests as true if bound, false if not. + explicit operator bool() const { return internal_state_.is_bound(); } + // Blocks the current thread until the next incoming response callback arrives // or an error occurs. Returns |true| if a response arrived, or |false| in // case of error. @@ -150,17 +153,6 @@ return &internal_state_; } - // Allow InterfacePtr<> to be used in boolean expressions, but not - // implicitly convertible to a real bool (which is dangerous). - private: - typedef internal::InterfacePtrState<Interface> InterfacePtr::*Testable; - - public: - operator Testable() const { - return internal_state_.is_bound() ? &InterfacePtr::internal_state_ - : nullptr; - } - private: typedef internal::InterfacePtrState<Interface> State; mutable State internal_state_;
diff --git a/mojo/public/cpp/bindings/lib/bindings_internal.h b/mojo/public/cpp/bindings/lib/bindings_internal.h index fcfcefa..275551a 100644 --- a/mojo/public/cpp/bindings/lib/bindings_internal.h +++ b/mojo/public/cpp/bindings/lib/bindings_internal.h
@@ -238,6 +238,17 @@ } }; +// |InterfacePtr|s hold message pipes uniquely, so they can only be equal if +// they're the same object or are both "invalid". +template <typename I> +struct ValueTraits<InterfacePtr<I>> { + static bool Equals(const InterfacePtr<I>& a, const InterfacePtr<I>& b) { + return (&a == &b) || (!a.is_bound() && !b.is_bound()); + } +}; + +// |InterfaceRequest|s hold message pipes uniquely, so they can only be equal if +// they're the same object or are both "invalid". template <typename I> struct ValueTraits<InterfaceRequest<I>> { static bool Equals(const InterfaceRequest<I>& a,
diff --git a/mojo/public/cpp/bindings/map.h b/mojo/public/cpp/bindings/map.h index 6702cab..0a0f805 100644 --- a/mojo/public/cpp/bindings/map.h +++ b/mojo/public/cpp/bindings/map.h
@@ -81,6 +81,9 @@ is_null_ = true; } + // Tests as true if non-null, false if null. + explicit operator bool() const { return !is_null_; } + bool is_null() const { return is_null_; } // Indicates the number of keys in the map. @@ -239,15 +242,6 @@ MapIterator find(const KeyType& key) { return MapIterator(map_.find(key)); } private: - typedef std::map<KeyType, ValueType> Map::*Testable; - - public: - // The Map may be used in boolean expressions to determine if it is non-null, - // but is not implicitly convertible to an actual bool value (which would be - // dangerous). - operator Testable() const { return is_null_ ? 0 : &Map::map_; } - - private: void Take(Map* other) { reset(); Swap(other);
diff --git a/mojo/public/cpp/bindings/string.h b/mojo/public/cpp/bindings/string.h index 4b5850b..4cf8631 100644 --- a/mojo/public/cpp/bindings/string.h +++ b/mojo/public/cpp/bindings/string.h
@@ -70,6 +70,9 @@ is_null_ = true; } + // Tests as true if non-null, false if null. + explicit operator bool() const { return !is_null_; } + bool is_null() const { return is_null_; } size_t size() const { return value_.size(); } @@ -96,12 +99,6 @@ } private: - typedef std::string String::*Testable; - - public: - operator Testable() const { return is_null_ ? 0 : &String::value_; } - - private: std::string value_; bool is_null_; };
diff --git a/mojo/public/cpp/bindings/struct_ptr.h b/mojo/public/cpp/bindings/struct_ptr.h index c6720b3..95aa581 100644 --- a/mojo/public/cpp/bindings/struct_ptr.h +++ b/mojo/public/cpp/bindings/struct_ptr.h
@@ -58,6 +58,9 @@ } } + // Tests as true if non-null, false if null. + explicit operator bool() const { return !!ptr_; } + bool is_null() const { return ptr_ == nullptr; } Struct& operator*() const { @@ -84,12 +87,6 @@ } private: - typedef Struct* StructPtr::*Testable; - - public: - operator Testable() const { return ptr_ ? &StructPtr::ptr_ : 0; } - - private: friend class internal::StructHelper<Struct>; void Initialize() { MOJO_DCHECK(!ptr_); @@ -138,6 +135,9 @@ new (&value_) Struct(); } + // Tests as true if non-null, false if null. + explicit operator bool() const { return !is_null_; } + bool is_null() const { return is_null_; } Struct& operator*() const { @@ -165,12 +165,6 @@ } private: - typedef Struct InlinedStructPtr::*Testable; - - public: - operator Testable() const { return is_null_ ? 0 : &InlinedStructPtr::value_; } - - private: friend class internal::StructHelper<Struct>; void Initialize() { is_null_ = false; }
diff --git a/mojo/public/cpp/bindings/tests/array_unittest.cc b/mojo/public/cpp/bindings/tests/array_unittest.cc index 3935783..55147d4 100644 --- a/mojo/public/cpp/bindings/tests/array_unittest.cc +++ b/mojo/public/cpp/bindings/tests/array_unittest.cc
@@ -44,17 +44,30 @@ EXPECT_EQ(4u, *(array.data() + 2)); } +TEST_F(ArrayTest, Testability) { + Array<int32_t> array; + EXPECT_FALSE(array); + EXPECT_TRUE(array.is_null()); + + array.push_back(123); + EXPECT_TRUE(array); + EXPECT_FALSE(array.is_null()); +} + void NullptrConstructorTestHelper(Array<int32_t> array) { + EXPECT_FALSE(array); EXPECT_TRUE(array.is_null()); EXPECT_EQ(0u, array.size()); } TEST_F(ArrayTest, NullptrConstructor) { Array<int32_t> array(nullptr); + EXPECT_FALSE(array); EXPECT_TRUE(array.is_null()); EXPECT_EQ(0u, array.size()); array.push_back(123); + EXPECT_TRUE(array); EXPECT_FALSE(array.is_null()); EXPECT_EQ(1u, array.size());
diff --git a/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc b/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc index 4324c0e..606e67b 100644 --- a/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc +++ b/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc
@@ -196,8 +196,10 @@ TEST_F(InterfacePtrTest, IsBound) { math::CalculatorPtr calc; EXPECT_FALSE(calc.is_bound()); + EXPECT_FALSE(calc); MathCalculatorImpl calc_impl(GetProxy(&calc)); EXPECT_TRUE(calc.is_bound()); + EXPECT_TRUE(calc); } TEST_F(InterfacePtrTest, EndToEnd) {
diff --git a/mojo/public/cpp/bindings/tests/map_unittest.cc b/mojo/public/cpp/bindings/tests/map_unittest.cc index b9215dc..6e297bc 100644 --- a/mojo/public/cpp/bindings/tests/map_unittest.cc +++ b/mojo/public/cpp/bindings/tests/map_unittest.cc
@@ -45,6 +45,16 @@ Environment env_; }; +TEST_F(MapTest, Testability) { + Map<int32_t, int32_t> map; + EXPECT_FALSE(map); + EXPECT_TRUE(map.is_null()); + + map[123] = 456; + EXPECT_TRUE(map); + EXPECT_FALSE(map.is_null()); +} + // Tests that basic Map operations work. TEST_F(MapTest, InsertWorks) { Map<String, int> map;
diff --git a/mojo/public/cpp/bindings/tests/struct_unittest.cc b/mojo/public/cpp/bindings/tests/struct_unittest.cc index f78b758..1c98a5e 100644 --- a/mojo/public/cpp/bindings/tests/struct_unittest.cc +++ b/mojo/public/cpp/bindings/tests/struct_unittest.cc
@@ -92,21 +92,25 @@ TEST_F(StructTest, Rect) { RectPtr rect; + EXPECT_FALSE(rect); EXPECT_TRUE(rect.is_null()); EXPECT_TRUE(!rect); EXPECT_FALSE(rect); rect = nullptr; + EXPECT_FALSE(rect); EXPECT_TRUE(rect.is_null()); EXPECT_TRUE(!rect); EXPECT_FALSE(rect); rect = MakeRect(); + EXPECT_TRUE(rect); EXPECT_FALSE(rect.is_null()); EXPECT_FALSE(!rect); EXPECT_TRUE(rect); RectPtr null_rect = nullptr; + EXPECT_FALSE(null_rect); EXPECT_TRUE(null_rect.is_null()); EXPECT_TRUE(!null_rect); EXPECT_FALSE(null_rect);
diff --git a/mojo/public/interfaces/application/BUILD.gn b/mojo/public/interfaces/application/BUILD.gn index 463df55..1d1a173 100644 --- a/mojo/public/interfaces/application/BUILD.gn +++ b/mojo/public/interfaces/application/BUILD.gn
@@ -8,6 +8,7 @@ mojom("application") { sources = [ "application.mojom", + "application_connector.mojom", "service_provider.mojom", "shell.mojom", ]
diff --git a/mojo/public/interfaces/application/application_connector.mojom b/mojo/public/interfaces/application/application_connector.mojom new file mode 100644 index 0000000..23df7f6 --- /dev/null +++ b/mojo/public/interfaces/application/application_connector.mojom
@@ -0,0 +1,40 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +[DartPackage="mojo"] +module mojo; + +import "mojo/public/interfaces/application/service_provider.mojom"; + +interface ApplicationConnector { + // Establishes a connection with another application (located at + // |application_url|) through which the calling application and the other + // application may request services from one another. + // + // If the calling application would like to request services from the other + // application, it should pass a valid interface request in the |services| + // parameter (i.e. one containing a valid message pipe endpoint). If the other + // application does not wish to offer services, it may either not bind an + // implementation to the interface request, or else bind an implementation + // that will reject some or all service requests. + // + // If the calling application would like to offer services to the other + // application, it should pass a bound interface through the + // |exposed_services| parameter. The other application may then request + // services through that interface. + // + // At least one of |services| or |exposed_services| should be valid/bound in + // the call. + // + // If the |application_url| does not contain a domain, but is of the form + // "mojo:{service}", it is up to the Mojo shell to select an appropriate + // application for the service. Currently, the shell does this based on the + // value of its --origin flag. + ConnectToApplication(string application_url, + ServiceProvider&? services, + ServiceProvider? exposed_services); + + // Creates a duplicate of this |ApplicationConnector|. + Duplicate(ApplicationConnector& application_connector_request); +};
diff --git a/mojo/public/interfaces/application/shell.mojom b/mojo/public/interfaces/application/shell.mojom index b2d8491..dc210c7 100644 --- a/mojo/public/interfaces/application/shell.mojom +++ b/mojo/public/interfaces/application/shell.mojom
@@ -5,35 +5,18 @@ [DartPackage="mojo"] module mojo; +import "mojo/public/interfaces/application/application_connector.mojom"; import "mojo/public/interfaces/application/service_provider.mojom"; // An interface through which a Mojo application may communicate with the Mojo // system and request connections to other applications. interface Shell { - // Establishes a connection with another application (located at - // |application_url|) through which the calling application and the other - // application may request services from one another. - // - // If the calling application would like to request services from the other - // application, it should pass a valid interface request in the |services| - // parameter (i.e. one containing a valid message pipe endpoint). If the other - // application does not wish to offer services, it may either not bind an - // implementation to the interface request, or else bind an implementation - // that will reject some or all service requests. - // - // If the calling application would like to offer services to the other - // application, it should pass a bound interface through the - // |exposed_services| parameter. The other application may then request - // services through that interface. - // - // At least one of |services| or |exposed_services| should be valid/bound in - // the call. - // - // If the |application_url| does not contain a domain, but is of the form - // "mojo:{service}", it is up to the Mojo shell to select an appropriate - // application for the service. Currently, the shell does this based on the - // value of its --origin flag. + // See |ApplicationConnector.ConnectToApplication()|. + // TODO(vtl): Maybe this should be deprecated/removed. ConnectToApplication(string application_url, ServiceProvider&? services, ServiceProvider? exposed_services); + + CreateApplicationConnector( + ApplicationConnector& application_connector_request); };
diff --git a/mojo/public/interfaces/bindings/mojom_types.mojom b/mojo/public/interfaces/bindings/mojom_types.mojom index e509c0e..f6e0c57 100644 --- a/mojo/public/interfaces/bindings/mojom_types.mojom +++ b/mojo/public/interfaces/bindings/mojom_types.mojom
@@ -406,6 +406,12 @@ // enums and constants may be declared. Some implementations may populate // this field in order to describe that containment. ContainedDeclarations? contained_declarations; + + // If this DeclarationData is for an enum or a constant that is contained + // in a struct or interface, then this field, if populated, is the type_key + // that refers to the containing struct or interface. This field plays a + // role inverse to that of |contained_declarations|. + string? container_type_key; }; struct SourceFileInfo {
diff --git a/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Interface.java b/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Interface.java index c2bbc8e..3167e87 100644 --- a/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Interface.java +++ b/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Interface.java
@@ -308,6 +308,23 @@ } /** + * Enables managing the bindings from an implementation to a message pipe. + */ + interface Binding { + /** + * Unbinds the implementation from the message pipe. Returns the handle that will be owned + * by the caller. + */ + public MessagePipeHandle unbind(); + + /** + * Registers an error handler on the binding. It will be called if an error happens on the + * underlying message pipe. + */ + public void registerErrorHandler(ConnectionErrorHandler errorHandler); + } + + /** * The |Manager| object enables building of proxies and stubs for a given interface. * * @param <I> the type of the interface the manager can handle. @@ -329,20 +346,21 @@ /** * Binds the given implementation to the handle. */ - public void bind(I impl, MessagePipeHandle handle) { + public Binding bind(I impl, MessagePipeHandle handle) { // The router (and by consequence the handle) is intentionally leaked. It will close // itself when the connected handle is closed and the proxy receives the connection // error. Router router = new RouterImpl(handle); - bind(handle.getCore(), impl, router); + Binding result = bind(handle.getCore(), impl, router); router.start(); + return result; } /** * Binds the given implementation to the InterfaceRequest. */ - public final void bind(I impl, InterfaceRequest<I> request) { - bind(impl, request.passHandle()); + public final Binding bind(I impl, InterfaceRequest<I> request) { + return bind(impl, request.passHandle()); } /** @@ -352,9 +370,10 @@ public final P attachProxy(MessagePipeHandle handle, int version) { RouterImpl router = new RouterImpl(handle); P proxy = attachProxy(handle.getCore(), router); - DelegatingConnectionErrorHandler handlers = new DelegatingConnectionErrorHandler(); - handlers.addConnectionErrorHandler(proxy); - router.setErrorHandler(handlers); + DelegatingConnectionErrorHandler delegatingHandler = + new DelegatingConnectionErrorHandler(); + delegatingHandler.addConnectionErrorHandler(proxy); + router.setErrorHandler(delegatingHandler); router.start(); ((HandlerImpl) proxy.getProxyHandler()).setVersion(version); return proxy; @@ -378,9 +397,24 @@ /** * Binds the implementation to the given |router|. */ - final void bind(Core core, I impl, Router router) { - router.setErrorHandler(impl); + final Binding bind(Core core, I impl, final Router router) { + final DelegatingConnectionErrorHandler delegatingHandler = + new DelegatingConnectionErrorHandler(); + delegatingHandler.addConnectionErrorHandler(impl); + router.setErrorHandler(delegatingHandler); router.setIncomingMessageReceiver(buildStub(core, impl)); + return new Binding() { + + @Override + public MessagePipeHandle unbind() { + return router.passHandle(); + } + + @Override + public void registerErrorHandler(ConnectionErrorHandler errorHandler) { + delegatingHandler.addConnectionErrorHandler(errorHandler); + } + }; } /**
diff --git a/mojo/public/platform/dart/mojo_natives.cc b/mojo/public/platform/dart/mojo_natives.cc index 5d08fd3..7b61d04 100644 --- a/mojo/public/platform/dart/mojo_natives.cc +++ b/mojo/public/platform/dart/mojo_natives.cc
@@ -127,13 +127,7 @@ CloserCallbackPeer* callback_peer = reinterpret_cast<CloserCallbackPeer*>(peer); if (callback_peer->handle != MOJO_HANDLE_INVALID) { - MojoResult res = MojoClose(callback_peer->handle); - if (res == MOJO_RESULT_OK) { - // If this finalizer callback successfully closes a handle, it means that - // the handle has leaked from the Dart code, which is an error. - MOJO_LOG(ERROR) << "Handle Finalizer closing handle:\n\tisolate: " - << "\n\thandle: " << callback_peer->handle; - } + MojoClose(callback_peer->handle); } delete callback_peer; }
diff --git a/mojo/public/tools/bindings/generators/mojom_dart_generator.py b/mojo/public/tools/bindings/generators/mojom_dart_generator.py index e5f86e1..bf2237a 100644 --- a/mojo/public/tools/bindings/generators/mojom_dart_generator.py +++ b/mojo/public/tools/bindings/generators/mojom_dart_generator.py
@@ -446,10 +446,22 @@ elements = self.module.namespace.split('.') elements.append("%s.dart" % self.module.name) - package_name = GetPackage(self.module) lib_module = self.GenerateLibModule(args) - pkg_path = os.path.join("dart-pkg", package_name, "lib", *elements) - self.Write(lib_module, pkg_path) + + # List of packages with checked in bindings. + # TODO(johnmccutchan): Stop generating bindings as part of build system + # and then remove this. + packages_with_checked_in_bindings = [ + 'mojo', + 'mojo_apptest', + 'mojo_services', + 'mojo_sdk' + 'mojom' + ] + package_name = GetPackage(self.module) + if not (package_name in packages_with_checked_in_bindings): + pkg_path = os.path.join("dart-pkg", package_name, "lib", *elements) + self.Write(lib_module, pkg_path) gen_path = os.path.join("dart-gen", package_name, "lib", *elements) full_gen_path = os.path.join(self.output_dir, gen_path)
diff --git a/mojo/public/tools/bindings/mojom_list_dart_outputs.py b/mojo/public/tools/bindings/mojom_list_dart_outputs.py new file mode 100755 index 0000000..3580cf1 --- /dev/null +++ b/mojo/public/tools/bindings/mojom_list_dart_outputs.py
@@ -0,0 +1,71 @@ +#!/usr/bin/env python +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Generates the list of dart source file outputs from a mojom.Module.""" + +import argparse +import os +import re +import shutil +import sys + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +sys.path.insert(0, os.path.join(SCRIPT_DIR, 'pylib')) + +from mojom.error import Error +from mojom.parse.parser import Parse +from mojom.parse.translate import Translate + +def mojom_path(name, namespace, attributes): + package_name = attributes['DartPackage'] + if package_name == None: + package_name = 'mojom' + elements = [package_name, 'lib'] + elements.extend(namespace.split('.')) + elements.append("%s.dart" % name) + return os.path.join(*elements) + + +def process_mojom(path_to_mojom): + filename = os.path.abspath(path_to_mojom) + name = os.path.basename(filename) + + # Read in mojom file. + try: + with open(filename) as f: + source = f.read() + except IOError: + print("Error reading %s" % filename) + sys.exit(2) + + # Parse + try: + tree = Parse(source, name) + except Error: + print("Error parsing %s" % filename) + sys.exit(2) + + mojom = Translate(tree, name) + + # Output path + print(mojom_path(mojom['name'], mojom['namespace'], mojom['attributes'])) + + +def main(): + parser = argparse.ArgumentParser(description='Output list of ') + parser.add_argument('--mojoms', + metavar='mojoms', + nargs='+', + required=True) + args = parser.parse_args() + + for mojom in args.mojoms: + process_mojom(mojom) + + return 0 + + +if __name__ == '__main__': + sys.exit(main()) \ No newline at end of file
diff --git a/mojo/public/tools/bindings/pylib/mojom/generate/generated/mojom_types_mojom.py b/mojo/public/tools/bindings/pylib/mojom/generate/generated/mojom_types_mojom.py index 610bc50..ffb7391 100644 --- a/mojo/public/tools/bindings/pylib/mojom/generate/generated/mojom_types_mojom.py +++ b/mojo/public/tools/bindings/pylib/mojom/generate/generated/mojom_types_mojom.py
@@ -216,6 +216,7 @@ _descriptor.SingleFieldGroup('declaration_order', _descriptor.TYPE_INT32, 5, 0, default_value=-1), _descriptor.SingleFieldGroup('source_file_info', _descriptor.StructType(lambda: SourceFileInfo, nullable=True), 6, 0), _descriptor.SingleFieldGroup('contained_declarations', _descriptor.StructType(lambda: ContainedDeclarations, nullable=True), 7, 0), + _descriptor.SingleFieldGroup('container_type_key', _descriptor.TYPE_NULLABLE_STRING, 8, 0), ], }
diff --git a/mojo/public/tools/bindings/pylib/mojom/generate/module.py b/mojo/public/tools/bindings/pylib/mojom/generate/module.py index e2aa250..446dc79 100644 --- a/mojo/public/tools/bindings/pylib/mojom/generate/module.py +++ b/mojo/public/tools/bindings/pylib/mojom/generate/module.py
@@ -134,9 +134,10 @@ class NamedValue(object): - def __init__(self, module, parent_kind, name): + def __init__(self, module=None, parent_kind=None, name=None): self.module = module - self.namespace = module.namespace + if module: + self.namespace = module.namespace self.parent_kind = parent_kind self.name = name self.imported_from = None @@ -153,14 +154,20 @@ class ConstantValue(NamedValue): - def __init__(self, module, parent_kind, constant): - NamedValue.__init__(self, module, parent_kind, constant.name) + def __init__(self, module=None, parent_kind=None, constant=None): + if constant: + NamedValue.__init__(self, module, parent_kind, constant.name) + else: + NamedValue.__init__(self, module, parent_kind) self.constant = constant class EnumValue(NamedValue): - def __init__(self, module, enum, field): - NamedValue.__init__(self, module, enum.parent_kind, field.name) + def __init__(self, module=None, enum=None, field=None): + if enum and field: + NamedValue.__init__(self, module, enum.parent_kind, field.name) + else: + NamedValue.__init__(self, module) self.enum = enum def GetSpec(self):
diff --git a/mojo/public/tools/bindings/pylib/mojom/generate/mojom_translator.py b/mojo/public/tools/bindings/pylib/mojom/generate/mojom_translator.py index 816f42c..669767b 100755 --- a/mojo/public/tools/bindings/pylib/mojom/generate/mojom_translator.py +++ b/mojo/public/tools/bindings/pylib/mojom/generate/mojom_translator.py
@@ -42,6 +42,8 @@ """ assert isinstance(graph, mojom_files_mojom.MojomFileGraph) self._type_cache = {} + self._value_cache = {} + self._constant_cache = {} self._graph = graph self._file_name = file_name self._types = {} @@ -70,8 +72,7 @@ if mojom_file.declared_mojom_objects: if mojom_file.declared_mojom_objects.top_level_constants: mod.constants = [ - self.ConstFromMojom( - self._graph.resolved_values[key].declared_constant, None) + self.ConstantFromValueKey(key) for key in mojom_file.declared_mojom_objects.top_level_constants] user_defined_types = ['interfaces', 'structs', 'unions'] @@ -180,7 +181,7 @@ mojom_types_mojom.DefaultFieldValue.Tags.default_keyword): struct_field.default = 'default' else: - struct_field.default = self.EvalValue( + struct_field.default = self.ValueFromMojom( mojom_field.default_value.value) return struct_field @@ -228,15 +229,11 @@ if contained_declarations.enums: for enum_key in contained_declarations.enums: enum = self.UserDefinedFromTypeKey(enum_key) - enum.name = '%s.%s' % (parent_kind.name, enum.name) - enum.parent_kind = parent_kind parent_kind.enums.append(enum) if contained_declarations.constants: for const_key in contained_declarations.constants: - const = self.ConstFromMojom( - self._graph.resolved_values[const_key].declared_constant, - parent_kind) + const = self.ConstantFromValueKey(const_key) parent_kind.constants.append(const) def EnumFromMojom(self, enum, mojom_type): @@ -250,31 +247,27 @@ assert mojom_type.tag == mojom_types_mojom.UserDefinedType.Tags.enum_type mojom_enum = mojom_type.enum_type self.PopulateUserDefinedType(enum, mojom_enum) + if mojom_enum.decl_data.container_type_key: + parent_kind = self.UserDefinedFromTypeKey( + mojom_enum.decl_data.container_type_key) + enum.parent_kind = parent_kind enum.fields = [self.EnumFieldFromMojom(value) for value in mojom_enum.values] - def EnumFieldFromMojom(self, mojom_field): + def EnumFieldFromMojom(self, mojom_enum_value): """Translates an mojom_types_mojom.EnumValue to a module.EnumField. - mojom_field: {mojom_types_mojom.EnumValue} to be translated. + mojom_enum_value: {mojom_types_mojom.EnumValue} to be translated. Returns: - {module.EnumField} translated from mojom_field. + {module.EnumField} translated from mojom_enum_value. """ field = module.EnumField() - field.name = mojom_field.decl_data.short_name - field.attributes = self.AttributesFromMojom(mojom_field) - field.numeric_value = mojom_field.int_value - if mojom_field.initializer_value is not None: - # TODO(rudominer) resolved_numeric_value will always be equal to - # field.numeric_value above, once mojom_field.int_value is implemented. - resolved_numeric_value = self.EvalValue(mojom_field.initializer_value) - assert isinstance(resolved_numeric_value, int) - # TODO(rudominer) Below we set field.value to a literal value even if in - # the .mojom file the enum value initializer was a value reference. - # Thus we are hiding some information from the code generators. We may - # wish to revisit this decision. - field.value = str(resolved_numeric_value) + field.name = mojom_enum_value.decl_data.short_name + field.attributes = self.AttributesFromMojom(mojom_enum_value) + field.numeric_value = mojom_enum_value.int_value + if mojom_enum_value.initializer_value is not None: + field.value = self.ValueFromMojom(mojom_enum_value.initializer_value) return field @@ -376,39 +369,64 @@ for param in mojom_method.response_params.fields] return method - def ConstFromMojom(self, mojom_const, parent_kind): - """Translates a mojom_types_mojom.DeclaredConstant to a module.Constant. + def ConstantFromValueKey(self, value_key): + """Takes a value key into a graph.resolved_values referring to a constant + and returns the module equivalent. Args: + value_key: {str} the value key referring to the value to be returned. + + Returns: + {module.Constant} translated. + """ + if value_key in self._constant_cache: + return self._constant_cache[value_key] + + mojom_const = self._graph.resolved_values[value_key].declared_constant + const = module.Constant() + self._constant_cache[value_key] = const + + self.ConstantFromMojom(const, mojom_const) + return const + + def ConstantFromMojom(self, const, mojom_const): + """Populates a module.Constant based on a DeclaredConstant. + + Args: + const: {module.Constant} to be populated. mojom_const: {mojom_types_mojom.DeclaredConstant} to be translated. - parent_kind: {module.Struct|Interface} if the constant is nested in a - struct or interface. Returns: {module.Constant} translated from mojom_const. """ - const = module.Constant() const.name = mojom_const.decl_data.short_name const.kind = self.KindFromMojom(mojom_const.type) - const.value = self.EvalValue(mojom_const.value) - const.parent_kind = parent_kind - return const + const.value = self.ValueFromMojom(mojom_const.value) + const.parent_kind = None + if mojom_const.decl_data.container_type_key: + const.parent_kind = self.UserDefinedFromTypeKey( + mojom_const.decl_data.container_type_key) - def EvalValue(self, value): - """Evaluates a mojom_types_mojom.Value. + def ValueFromMojom(self, value): + """Translates a mojom_types_mojom.Value. Args: - value: {mojom_types_mojom.Value} to be evaluated. + value: {mojom_types_mojom.Value} to be translated. Returns: - {int|float|str|bool|None} the literal value if value is a LiteralValue, - the string name of the built-in constant if value is a - BuiltinConstantValue, the result of invoking EvalValue() on the - resolved concrete value of the user value reference if value is a - UserValueReference and its concrete value is not None, or else None + {str|module.BuiltinValue|module.NamedValue} translated from the passed in + mojom_value. + If value is a literal value, a string is returned. If the value is itself + a string, the returned string is quoted. Otherwise it is a string + representation of the literal value. + If value is a built-in value, a module.BuiltinValue is returned. + If value is a user defined reference, a module.NamedValue is returned. """ if value.tag == mojom_types_mojom.Value.Tags.literal_value: - return value.literal_value.data + if (value.literal_value.tag + == mojom_types_mojom.LiteralValue.Tags.string_value): + return '"%s"' % value.literal_value.data + return str(value.literal_value.data) elif value.tag == mojom_types_mojom.Value.Tags.builtin_value: mojom_to_builtin = { mojom_types_mojom.BuiltinConstantValue.DOUBLE_INFINITY: @@ -426,12 +444,75 @@ return module.BuiltinValue(mojom_to_builtin[value.builtin_value]) assert value.tag == mojom_types_mojom.Value.Tags.user_value_reference - concrete_value = value.user_value_reference.resolved_concrete_value - if concrete_value == None: - return None - assert (concrete_value.tag != - mojom_types_mojom.Value.Tags.user_value_reference) - return self.EvalValue(concrete_value) + return self.UserDefinedFromValueKey(value.user_value_reference.value_key) + + def UserDefinedFromValueKey(self, value_key): + """Takes a value key into graph.resolved_values and returns the module + equivalent. + + Args: + value_key: {str} the value key referring to the value to be returned. + + Returns: + {module.EnumValue|module.ConstantValue} translated. + """ + if value_key in self._value_cache: + return self._value_cache[value_key] + + value = self._graph.resolved_values[value_key] + if value.tag == mojom_types_mojom.UserDefinedValue.Tags.enum_value: + return self.EnumValueFromMojom(value.enum_value) + return self.ConstantValueFromValueKey(value_key) + + def ConstantValueFromValueKey(self, value_key): + """Takes a value key into graph.resolved_values referring to a declared + constant and returns the module equivalent. + + Args: + value_key: {str} the value key referring to the value to be returned. + + Returns: + {module.ConstantValue} translated. + """ + const_value = module.ConstantValue() + self._value_cache[value_key] = const_value + + const = self.ConstantFromValueKey(value_key) + const_value.constant = const + const_value.name = const.name + const_value.parent_kind = const.parent_kind + self.PopulateModuleOrImportedFrom(const_value, + self._graph.resolved_values[value_key].declared_constant) + const_value.namespace = const_value.module.namespace + return const_value + + def EnumValueFromMojom(self, mojom_enum_value): + """Translates an mojom_types_mojom.EnumValue to a module.EnumValue. + + mojom_enum_value: {mojom_types_mojom.EnumValue} to be translated. + + Returns: + {module.EnumValue} translated from mojom_enum_value. + """ + enum_type_key = mojom_enum_value.enum_type_key + name = mojom_enum_value.decl_data.short_name + value_key = (enum_type_key, name) + if value_key in self._value_cache: + return self._value_cache[value_key] + + # We need to create and cache the EnumValue object just in case later calls + # require the creation of that same EnumValue object. + enum_value = module.EnumValue() + self._value_cache[value_key] = enum_value + + enum = self.UserDefinedFromTypeKey(enum_type_key) + enum_value.enum = enum + self.PopulateModuleOrImportedFrom(enum_value, mojom_enum_value) + enum_value.namespace = enum_value.module.namespace + enum_value.parent_kind = enum.parent_kind + enum_value.name = name + + return enum_value def KindFromMojom(self, mojom_type): """Translates a mojom_types_mojom.Type to its equivalent module type.
diff --git a/mojo/public/tools/bindings/pylib/mojom/generate/mojom_translator_unittest.py b/mojo/public/tools/bindings/pylib/mojom/generate/mojom_translator_unittest.py index c8a3ed8..a3769a5 100644 --- a/mojo/public/tools/bindings/pylib/mojom/generate/mojom_translator_unittest.py +++ b/mojo/public/tools/bindings/pylib/mojom/generate/mojom_translator_unittest.py
@@ -194,28 +194,39 @@ self.assertEquals(module.DOUBLE, struct.fields[1].kind) self.assertEquals(None, struct.fields[1].ordinal) - self.assertEquals(15, struct.fields[1].default) + self.assertEquals('15.0', struct.fields[1].default) def test_constant(self): + file_name = 'a.mojom' graph = mojom_files_mojom.MojomFileGraph() mojom_const = mojom_types_mojom.DeclaredConstant() mojom_const.decl_data = mojom_types_mojom.DeclarationData( - short_name='foo') + short_name='foo', container_type_key='struct_key') mojom_const.type = mojom_types_mojom.Type( simple_type=mojom_types_mojom.SimpleType.INT64) mojom_const.value = mojom_types_mojom.Value() mojom_const.value.literal_value = mojom_types_mojom.LiteralValue( int64_value=20) - struct = module.Struct() - const = mojom_translator.FileTranslator(graph, None).ConstFromMojom( - mojom_const, struct) + mojom_struct = mojom_types_mojom.MojomStruct( + fields=[], + decl_data=mojom_types_mojom.DeclarationData( + short_name='AStruct', + source_file_info =mojom_types_mojom.SourceFileInfo( + file_name=file_name))) + graph.resolved_types = {'struct_key': mojom_types_mojom.UserDefinedType( + struct_type=mojom_struct)} + + const = module.Constant() + translator = mojom_translator.FileTranslator(graph, file_name) + translator.ConstantFromMojom(const, mojom_const) self.assertEquals(mojom_const.decl_data.short_name, const.name) self.assertEquals(module.INT64, const.kind) - self.assertEquals(20, const.value) - self.assertEquals(struct, const.parent_kind) + self.assertEquals('20', const.value) + self.assertEquals(translator.UserDefinedFromTypeKey('struct_key'), + const.parent_kind) def test_enum(self): file_name = 'a.mojom' @@ -257,6 +268,33 @@ self.assertEquals(value2.int_value, enum.fields[1].numeric_value) + def test_child_enum(self): + file_name = 'a.mojom' + mojom_enum = mojom_types_mojom.MojomEnum() + mojom_enum.decl_data = mojom_types_mojom.DeclarationData( + short_name='AnEnum', + source_file_info=mojom_types_mojom.SourceFileInfo(file_name=file_name), + container_type_key='struct_key') + mojom_enum.values = [] + + graph = mojom_files_mojom.MojomFileGraph() + mojom_struct = mojom_types_mojom.MojomStruct( + fields=[], + decl_data=mojom_types_mojom.DeclarationData( + short_name='AStruct', + source_file_info =mojom_types_mojom.SourceFileInfo( + file_name=file_name))) + graph.resolved_types = {'struct_key': mojom_types_mojom.UserDefinedType( + struct_type=mojom_struct)} + + enum = module.Enum() + translator = mojom_translator.FileTranslator(graph, file_name) + translator.EnumFromMojom( + enum, mojom_types_mojom.UserDefinedType(enum_type=mojom_enum)) + + self.assertEquals(mojom_enum.decl_data.short_name, enum.name) + self.assertEquals(len(mojom_enum.values), len(enum.fields)) + def test_unions(self): file_name = 'a.mojom' mojom_union = mojom_types_mojom.MojomUnion() @@ -460,12 +498,15 @@ decl_data=mojom_types_mojom.DeclarationData( short_name='AnEnum', source_file_info=mojom_types_mojom.SourceFileInfo( - file_name=file_name))) + file_name=file_name), + container_type_key='parent_key')) graph.resolved_types = { 'enum_key': mojom_types_mojom.UserDefinedType(enum_type=mojom_enum)} mojom_const = mojom_types_mojom.DeclaredConstant( - decl_data=mojom_types_mojom.DeclarationData(short_name='AConst'), + decl_data=mojom_types_mojom.DeclarationData( + short_name='AConst', + container_type_key='parent_key'), type=mojom_types_mojom.Type( simple_type=mojom_types_mojom.SimpleType.INT64), value=mojom_types_mojom.Value( @@ -480,11 +521,12 @@ translator = mojom_translator.FileTranslator(graph, file_name) struct = module.Struct(name='parent') + translator._type_cache['parent_key'] = struct translator.PopulateContainedDeclarationsFromMojom( struct, contained_declarations) self.assertEquals( - 'parent.' + mojom_enum.decl_data.short_name, struct.enums[0].name) + mojom_enum.decl_data.short_name, struct.enums[0].name) self.assertEquals(struct, struct.enums[0].parent_kind) self.assertEquals( mojom_const.decl_data.short_name, struct.constants[0].name) @@ -492,20 +534,16 @@ @unittest.skipUnless(bindings_imported, 'Could not import python bindings.') -class TestEvalValue(unittest.TestCase): +class TestValueFromMojom(unittest.TestCase): def test_literal_value(self): mojom = mojom_types_mojom.Value() mojom.literal_value = mojom_types_mojom.LiteralValue(int64_value=20) graph = mojom_files_mojom.MojomFileGraph() - const = mojom_translator.FileTranslator(graph, None).EvalValue(mojom) + const = mojom_translator.FileTranslator(graph, None).ValueFromMojom(mojom) - self.assertEquals(20, const) - - def test_resolved_user_defined_values(self): - # TODO(azani): Write this. - pass + self.assertEquals('20', const) def test_builtin_const(self): mojom = mojom_types_mojom.Value() @@ -528,10 +566,80 @@ for mojom_builtin, string in gold: mojom.builtin_value = mojom_builtin - const = mojom_translator.FileTranslator(graph, None).EvalValue(mojom) + const = mojom_translator.FileTranslator(graph, None).ValueFromMojom(mojom) self.assertIsInstance(const, module.BuiltinValue) self.assertEquals(string, const.value) + def test_enum_value(self): + file_name = 'a.mojom' + mojom_enum = mojom_types_mojom.MojomEnum() + mojom_enum.decl_data = mojom_types_mojom.DeclarationData( + short_name='AnEnum', + source_file_info=mojom_types_mojom.SourceFileInfo(file_name=file_name)) + value1 = mojom_types_mojom.EnumValue( + decl_data=mojom_types_mojom.DeclarationData( + short_name='val1', + source_file_info=mojom_types_mojom.SourceFileInfo( + file_name=file_name)), + enum_type_key='enum_key', + initializer_value=mojom_types_mojom.Value( + literal_value=mojom_types_mojom.LiteralValue(uint64_value=20)), + int_value=20) + value2 = mojom_types_mojom.EnumValue( + decl_data=mojom_types_mojom.DeclarationData(short_name='val2'), + enum_type_key='enum_key', + int_value=70) + mojom_enum.values = [value1, value2] + + graph = mojom_files_mojom.MojomFileGraph() + graph.resolved_types = { + 'enum_key': mojom_types_mojom.UserDefinedType(enum_type=mojom_enum)} + graph.resolved_values = { + 'enum_value1': mojom_types_mojom.UserDefinedValue(enum_value=value1), + 'enum_value2': mojom_types_mojom.UserDefinedValue(enum_value=value2), + } + + mojom = mojom_types_mojom.Value( + user_value_reference=mojom_types_mojom.UserValueReference( + identifier='SOMEID', + value_key='enum_value1')) + + translator = mojom_translator.FileTranslator(graph, file_name) + enum_value = translator.ValueFromMojom(mojom) + enum = translator.UserDefinedFromTypeKey('enum_key') + + self.assertIs(enum, enum_value.enum) + self.assertIs(value1.decl_data.short_name, enum_value.name) + + def test_constant_value(self): + file_name = 'a.mojom' + mojom_const = mojom_types_mojom.DeclaredConstant( + decl_data=mojom_types_mojom.DeclarationData( + short_name='AConst', + source_file_info=mojom_types_mojom.SourceFileInfo( + file_name=file_name)), + type=mojom_types_mojom.Type( + simple_type=mojom_types_mojom.SimpleType.INT64), + value=mojom_types_mojom.Value( + literal_value=mojom_types_mojom.LiteralValue( + int64_value=30))) + user_defined_value = mojom_types_mojom.UserDefinedValue() + user_defined_value.declared_constant = mojom_const + + graph = mojom_files_mojom.MojomFileGraph() + graph.resolved_values = {'value_key': user_defined_value} + + mojom = mojom_types_mojom.Value( + user_value_reference=mojom_types_mojom.UserValueReference( + identifier='SOMEID', + value_key='value_key')) + + translator = mojom_translator.FileTranslator(graph, file_name) + const_value = translator.ValueFromMojom(mojom) + self.assertIs( + translator.ConstantFromValueKey('value_key'), const_value.constant) + self.assertIs(mojom_const.decl_data.short_name, const_value.name) + @unittest.skipUnless(bindings_imported, 'Could not import python bindings.') class TestKindFromMojom(unittest.TestCase):
diff --git a/mojo/services/media/common/cpp/circular_buffer_media_pipe_adapter.cc b/mojo/services/media/common/cpp/circular_buffer_media_pipe_adapter.cc index 240217e..00dac4e 100644 --- a/mojo/services/media/common/cpp/circular_buffer_media_pipe_adapter.cc +++ b/mojo/services/media/common/cpp/circular_buffer_media_pipe_adapter.cc
@@ -35,8 +35,8 @@ CircularBufferMediaPipeAdapter::CircularBufferMediaPipeAdapter( MediaPipePtr pipe) : pipe_(pipe.Pass()) { - MOJO_DCHECK(nullptr != pipe_); - MOJO_DCHECK(nullptr != RunLoop::current()); + MOJO_DCHECK(pipe_); + MOJO_DCHECK(RunLoop::current()); pipe_get_state_cbk_ = MediaPipe::GetStateCallback( [this] (MediaPipeStatePtr state) { @@ -304,8 +304,8 @@ } void CircularBufferMediaPipeAdapter::HandleGetState(MediaPipeStatePtr state) { - MOJO_DCHECK(nullptr != state); // We must have a state structure. - MOJO_DCHECK(nullptr == buffer_); // We must not have already mapped a buffer. + MOJO_DCHECK(state); // We must have a state structure. + MOJO_DCHECK(!buffer_); // We must not have already mapped a buffer. MOJO_DCHECK(get_state_in_progress_); // We should be waiting for our cbk. std::lock_guard<std::mutex> lock(signal_lock_);
diff --git a/mojo/services/view_manager/cpp/lib/view_manager_client_impl.h b/mojo/services/view_manager/cpp/lib/view_manager_client_impl.h index 347895a..906a7a6 100644 --- a/mojo/services/view_manager/cpp/lib/view_manager_client_impl.h +++ b/mojo/services/view_manager/cpp/lib/view_manager_client_impl.h
@@ -29,7 +29,7 @@ bool delete_on_error); ~ViewManagerClientImpl() override; - bool connected() const { return service_; } + bool connected() const { return !!service_; } ConnectionSpecificId connection_id() const { return connection_id_; } // API exposed to the view implementations that pushes local changes to the
diff --git a/mojo/services/vsync/interfaces/BUILD.gn b/mojo/services/vsync/interfaces/BUILD.gn new file mode 100644 index 0000000..087262b --- /dev/null +++ b/mojo/services/vsync/interfaces/BUILD.gn
@@ -0,0 +1,12 @@ +# Copyright 2015 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//build/module_args/mojo.gni") +import("$mojo_sdk_root/mojo/public/tools/bindings/mojom.gni") + +mojom("interfaces") { + sources = [ + "vsync.mojom", + ] +}
diff --git a/mojo/services/vsync/interfaces/vsync.mojom b/mojo/services/vsync/interfaces/vsync.mojom new file mode 100644 index 0000000..5cc66a1 --- /dev/null +++ b/mojo/services/vsync/interfaces/vsync.mojom
@@ -0,0 +1,13 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +[DartPackage="mojo_services"] +module vsync; + +interface VSyncProvider { + // Waits for the next vsync and returns its timestamp once it happens. The + // timestamps can only be compared with other calls of this method. + // Only one callback can be parked at a given time. + AwaitVSync() => (int64 time_stamp); +};
diff --git a/mojo/tools/data/nacl_nonsfi_apptests b/mojo/tools/data/nacl_nonsfi_apptests index ad79006..9560722 100644 --- a/mojo/tools/data/nacl_nonsfi_apptests +++ b/mojo/tools/data/nacl_nonsfi_apptests
@@ -28,6 +28,14 @@ "test": "mojo:files_apptests.pexe", "shell-args": ["--enable-multiprocess"], }, + { + # This test translates and executes multiple apptests at the same time. + # To pass, each intermediate nexe made by pexe content handling must be + # given a unique process, or this test will crash. + "test": "mojo:files_apptests.pexe", + "name": "Multiprocess files + http_server apptests (both run at once)", + "shell-args": ["--enable-multiprocess", "mojo:http_server_apptests.pexe"], + }, # TODO(smklein): Include "mojo_view_manager_client_apptests.pexe", # "window_manager_apptests.pexe", and "shell_apptests.pexe" once flake is # reduced on bots for the Non-NaCl multiprocess version of the test.
diff --git a/mojom/mojom_parser/bin/linux64/mojom_parser.sha1 b/mojom/mojom_parser/bin/linux64/mojom_parser.sha1 index 47c8c84..4a908a1 100644 --- a/mojom/mojom_parser/bin/linux64/mojom_parser.sha1 +++ b/mojom/mojom_parser/bin/linux64/mojom_parser.sha1
@@ -1 +1 @@ -7beb1e7f70341e673a707ce2f6305ce50b6250ba \ No newline at end of file +8ef917a5ce3236dd70348cbb04f8ac35918737b7 \ No newline at end of file
diff --git a/mojom/mojom_parser/generated/mojom_types/mojom_types.mojom.go b/mojom/mojom_parser/generated/mojom_types/mojom_types.mojom.go index 8d9dca1..bba78e1 100644 --- a/mojom/mojom_parser/generated/mojom_types/mojom_types.mojom.go +++ b/mojom/mojom_parser/generated/mojom_types/mojom_types.mojom.go
@@ -51,358 +51,426 @@ var ID_mojom_types_UserDefinedValue__ string = "mojom_types_UserDefinedValue__" var mojom_typesDesc__ = make(map[string]UserDefinedType) - func init() { - mojom_typesDesc__["mojom_types_SimpleType__"] = &UserDefinedTypeEnumType{ - Value: mojom_types_SimpleType__(), - } - mojom_typesDesc__["mojom_types_BuiltinConstantValue__"] = &UserDefinedTypeEnumType{ - Value: mojom_types_BuiltinConstantValue__(), - } - mojom_typesDesc__["mojom_types_Kind__"] = &UserDefinedTypeEnumType{ - Value: mojom_types_Kind__(), - } - mojom_typesDesc__["mojom_types_StringType__"] = &UserDefinedTypeStructType{ - Value: mojom_types_StringType__(), - } + mojom_typesDesc__["mojom_types_SimpleType__"] = &UserDefinedTypeEnumType{ + Value: mojom_types_SimpleType__(), + } + mojom_typesDesc__["mojom_types_BuiltinConstantValue__"] = &UserDefinedTypeEnumType{ + Value: mojom_types_BuiltinConstantValue__(), + } + mojom_typesDesc__["mojom_types_Kind__"] = &UserDefinedTypeEnumType{ + Value: mojom_types_Kind__(), + } + mojom_typesDesc__["mojom_types_StringType__"] = &UserDefinedTypeStructType{ + Value: mojom_types_StringType__(), + } - mojom_typesDesc__["mojom_types_HandleType__"] = &UserDefinedTypeStructType{ - Value: mojom_types_HandleType__(), - } + mojom_typesDesc__["mojom_types_HandleType__"] = &UserDefinedTypeStructType{ + Value: mojom_types_HandleType__(), + } - mojom_typesDesc__["mojom_types_ArrayType__"] = &UserDefinedTypeStructType{ - Value: mojom_types_ArrayType__(), - } - mojom_typesDesc__["mojom_types_Type__"] = &UserDefinedTypeUnionType{ - Value: mojom_types_Type__(), - } + mojom_typesDesc__["mojom_types_ArrayType__"] = &UserDefinedTypeStructType{ + Value: mojom_types_ArrayType__(), + } - mojom_typesDesc__["mojom_types_MapType__"] = &UserDefinedTypeStructType{ - Value: mojom_types_MapType__(), - } - mojom_typesDesc__["mojom_types_TypeReference__"] = &UserDefinedTypeStructType{ - Value: mojom_types_TypeReference__(), - } + mojom_typesDesc__["mojom_types_Type__"] = &UserDefinedTypeUnionType{ + Value: mojom_types_Type__(), + } - mojom_typesDesc__["mojom_types_StructField__"] = &UserDefinedTypeStructType{ - Value: mojom_types_StructField__(), - } - mojom_typesDesc__["mojom_types_DeclarationData__"] = &UserDefinedTypeStructType{ - Value: mojom_types_DeclarationData__(), - } - mojom_typesDesc__["mojom_types_SourceFileInfo__"] = &UserDefinedTypeStructType{ - Value: mojom_types_SourceFileInfo__(), - } - mojom_typesDesc__["mojom_types_ContainedDeclarations__"] = &UserDefinedTypeStructType{ - Value: mojom_types_ContainedDeclarations__(), - } + mojom_typesDesc__["mojom_types_MapType__"] = &UserDefinedTypeStructType{ + Value: mojom_types_MapType__(), + } - mojom_typesDesc__["mojom_types_DefaultFieldValue__"] = &UserDefinedTypeUnionType{ - Value: mojom_types_DefaultFieldValue__(), - } - mojom_typesDesc__["mojom_types_Value__"] = &UserDefinedTypeUnionType{ - Value: mojom_types_Value__(), - } - mojom_typesDesc__["mojom_types_LiteralValue__"] = &UserDefinedTypeUnionType{ - Value: mojom_types_LiteralValue__(), - } - mojom_typesDesc__["mojom_types_UserValueReference__"] = &UserDefinedTypeStructType{ - Value: mojom_types_UserValueReference__(), - } - mojom_typesDesc__["mojom_types_DefaultKeyword__"] = &UserDefinedTypeStructType{ - Value: mojom_types_DefaultKeyword__(), - } - mojom_typesDesc__["mojom_types_StructVersion__"] = &UserDefinedTypeStructType{ - Value: mojom_types_StructVersion__(), - } - mojom_typesDesc__["mojom_types_MojomStruct__"] = &UserDefinedTypeStructType{ - Value: mojom_types_MojomStruct__(), - } + mojom_typesDesc__["mojom_types_TypeReference__"] = &UserDefinedTypeStructType{ + Value: mojom_types_TypeReference__(), + } - mojom_typesDesc__["mojom_types_UnionField__"] = &UserDefinedTypeStructType{ - Value: mojom_types_UnionField__(), - } - mojom_typesDesc__["mojom_types_MojomUnion__"] = &UserDefinedTypeStructType{ - Value: mojom_types_MojomUnion__(), - } - mojom_typesDesc__["mojom_types_EnumValue__"] = &UserDefinedTypeStructType{ - Value: mojom_types_EnumValue__(), - } - mojom_typesDesc__["mojom_types_MojomEnum__"] = &UserDefinedTypeStructType{ - Value: mojom_types_MojomEnum__(), - } - mojom_typesDesc__["mojom_types_MojomMethod__"] = &UserDefinedTypeStructType{ - Value: mojom_types_MojomMethod__(), - } - mojom_typesDesc__["mojom_types_MojomInterface__"] = &UserDefinedTypeStructType{ - Value: mojom_types_MojomInterface__(), - } + mojom_typesDesc__["mojom_types_StructField__"] = &UserDefinedTypeStructType{ + Value: mojom_types_StructField__(), + } + mojom_typesDesc__["mojom_types_DeclarationData__"] = &UserDefinedTypeStructType{ + Value: mojom_types_DeclarationData__(), + } - mojom_typesDesc__["mojom_types_DeclaredConstant__"] = &UserDefinedTypeStructType{ - Value: mojom_types_DeclaredConstant__(), - } - mojom_typesDesc__["mojom_types_Attribute__"] = &UserDefinedTypeStructType{ - Value: mojom_types_Attribute__(), - } - mojom_typesDesc__["mojom_types_UserDefinedType__"] = &UserDefinedTypeUnionType{ - Value: mojom_types_UserDefinedType__(), - } - mojom_typesDesc__["mojom_types_UserDefinedValue__"] = &UserDefinedTypeUnionType{ - Value: mojom_types_UserDefinedValue__(), - } + + + mojom_typesDesc__["mojom_types_SourceFileInfo__"] = &UserDefinedTypeStructType{ + Value: mojom_types_SourceFileInfo__(), + } + + + + + mojom_typesDesc__["mojom_types_ContainedDeclarations__"] = &UserDefinedTypeStructType{ + Value: mojom_types_ContainedDeclarations__(), + } + + + + + + + mojom_typesDesc__["mojom_types_DefaultFieldValue__"] = &UserDefinedTypeUnionType{ + Value: mojom_types_DefaultFieldValue__(), + } + mojom_typesDesc__["mojom_types_Value__"] = &UserDefinedTypeUnionType{ + Value: mojom_types_Value__(), + } + mojom_typesDesc__["mojom_types_LiteralValue__"] = &UserDefinedTypeUnionType{ + Value: mojom_types_LiteralValue__(), + } + + + + + + + + + + + + + + mojom_typesDesc__["mojom_types_UserValueReference__"] = &UserDefinedTypeStructType{ + Value: mojom_types_UserValueReference__(), + } + + + + + + + mojom_typesDesc__["mojom_types_DefaultKeyword__"] = &UserDefinedTypeStructType{ + Value: mojom_types_DefaultKeyword__(), + } + + + + mojom_typesDesc__["mojom_types_StructVersion__"] = &UserDefinedTypeStructType{ + Value: mojom_types_StructVersion__(), + } + + + + mojom_typesDesc__["mojom_types_MojomStruct__"] = &UserDefinedTypeStructType{ + Value: mojom_types_MojomStruct__(), + } + + + + mojom_typesDesc__["mojom_types_UnionField__"] = &UserDefinedTypeStructType{ + Value: mojom_types_UnionField__(), + } + + + + mojom_typesDesc__["mojom_types_MojomUnion__"] = &UserDefinedTypeStructType{ + Value: mojom_types_MojomUnion__(), + } + + + mojom_typesDesc__["mojom_types_EnumValue__"] = &UserDefinedTypeStructType{ + Value: mojom_types_EnumValue__(), + } + + + + + mojom_typesDesc__["mojom_types_MojomEnum__"] = &UserDefinedTypeStructType{ + Value: mojom_types_MojomEnum__(), + } + + + mojom_typesDesc__["mojom_types_MojomMethod__"] = &UserDefinedTypeStructType{ + Value: mojom_types_MojomMethod__(), + } + + + + + mojom_typesDesc__["mojom_types_MojomInterface__"] = &UserDefinedTypeStructType{ + Value: mojom_types_MojomInterface__(), + } + + + + mojom_typesDesc__["mojom_types_DeclaredConstant__"] = &UserDefinedTypeStructType{ + Value: mojom_types_DeclaredConstant__(), + } + + + + mojom_typesDesc__["mojom_types_Attribute__"] = &UserDefinedTypeStructType{ + Value: mojom_types_Attribute__(), + } + + + mojom_typesDesc__["mojom_types_UserDefinedType__"] = &UserDefinedTypeUnionType{ + Value: mojom_types_UserDefinedType__(), + } + + + + + mojom_typesDesc__["mojom_types_UserDefinedValue__"] = &UserDefinedTypeUnionType{ + Value: mojom_types_UserDefinedValue__(), + } + + } func GetAllMojomTypeDefinitions() map[string]UserDefinedType { - return mojom_typesDesc__ + return mojom_typesDesc__ } type SimpleType int32 const ( - SimpleType_Bool = 0 - SimpleType_Double = SimpleType_Bool + 1 - SimpleType_Float = SimpleType_Double + 1 - SimpleType_InT8 = SimpleType_Float + 1 - SimpleType_InT16 = SimpleType_InT8 + 1 - SimpleType_InT32 = SimpleType_InT16 + 1 - SimpleType_InT64 = SimpleType_InT32 + 1 - SimpleType_UinT8 = SimpleType_InT64 + 1 - SimpleType_UinT16 = SimpleType_UinT8 + 1 - SimpleType_UinT32 = SimpleType_UinT16 + 1 - SimpleType_UinT64 = SimpleType_UinT32 + 1 + SimpleType_Bool = 0 + SimpleType_Double = SimpleType_Bool + 1; + SimpleType_Float = SimpleType_Double + 1; + SimpleType_InT8 = SimpleType_Float + 1; + SimpleType_InT16 = SimpleType_InT8 + 1; + SimpleType_InT32 = SimpleType_InT16 + 1; + SimpleType_InT64 = SimpleType_InT32 + 1; + SimpleType_UinT8 = SimpleType_InT64 + 1; + SimpleType_UinT16 = SimpleType_UinT8 + 1; + SimpleType_UinT32 = SimpleType_UinT16 + 1; + SimpleType_UinT64 = SimpleType_UinT32 + 1; ) // String names and labels used by the MojomEnum types. var ( - enumName_SimpleType = "SimpleType" - enumFieldName_SimpleType_Bool = "Bool" - enumFieldName_SimpleType_Double = "Double" - enumFieldName_SimpleType_Float = "Float" - enumFieldName_SimpleType_InT8 = "InT8" - enumFieldName_SimpleType_InT16 = "InT16" - enumFieldName_SimpleType_InT32 = "InT32" - enumFieldName_SimpleType_InT64 = "InT64" - enumFieldName_SimpleType_UinT8 = "UinT8" - enumFieldName_SimpleType_UinT16 = "UinT16" - enumFieldName_SimpleType_UinT32 = "UinT32" - enumFieldName_SimpleType_UinT64 = "UinT64" + enumName_SimpleType = "SimpleType" + enumFieldName_SimpleType_Bool = "Bool" + enumFieldName_SimpleType_Double = "Double" + enumFieldName_SimpleType_Float = "Float" + enumFieldName_SimpleType_InT8 = "InT8" + enumFieldName_SimpleType_InT16 = "InT16" + enumFieldName_SimpleType_InT32 = "InT32" + enumFieldName_SimpleType_InT64 = "InT64" + enumFieldName_SimpleType_UinT8 = "UinT8" + enumFieldName_SimpleType_UinT16 = "UinT16" + enumFieldName_SimpleType_UinT32 = "UinT32" + enumFieldName_SimpleType_UinT64 = "UinT64" ) func mojom_types_SimpleType__() MojomEnum { - return MojomEnum{ - DeclData: &DeclarationData{ - ShortName: &enumName_SimpleType, - }, - Values: []EnumValue{EnumValue{ - DeclData: &DeclarationData{ - ShortName: &enumFieldName_SimpleType_Bool, - }, - EnumTypeKey: ID_mojom_types_SimpleType__, - IntValue: int32(0), - }, EnumValue{ - DeclData: &DeclarationData{ - ShortName: &enumFieldName_SimpleType_Double, - }, - EnumTypeKey: ID_mojom_types_SimpleType__, - IntValue: int32(1), - }, EnumValue{ - DeclData: &DeclarationData{ - ShortName: &enumFieldName_SimpleType_Float, - }, - EnumTypeKey: ID_mojom_types_SimpleType__, - IntValue: int32(2), - }, EnumValue{ - DeclData: &DeclarationData{ - ShortName: &enumFieldName_SimpleType_InT8, - }, - EnumTypeKey: ID_mojom_types_SimpleType__, - IntValue: int32(3), - }, EnumValue{ - DeclData: &DeclarationData{ - ShortName: &enumFieldName_SimpleType_InT16, - }, - EnumTypeKey: ID_mojom_types_SimpleType__, - IntValue: int32(4), - }, EnumValue{ - DeclData: &DeclarationData{ - ShortName: &enumFieldName_SimpleType_InT32, - }, - EnumTypeKey: ID_mojom_types_SimpleType__, - IntValue: int32(5), - }, EnumValue{ - DeclData: &DeclarationData{ - ShortName: &enumFieldName_SimpleType_InT64, - }, - EnumTypeKey: ID_mojom_types_SimpleType__, - IntValue: int32(6), - }, EnumValue{ - DeclData: &DeclarationData{ - ShortName: &enumFieldName_SimpleType_UinT8, - }, - EnumTypeKey: ID_mojom_types_SimpleType__, - IntValue: int32(7), - }, EnumValue{ - DeclData: &DeclarationData{ - ShortName: &enumFieldName_SimpleType_UinT16, - }, - EnumTypeKey: ID_mojom_types_SimpleType__, - IntValue: int32(8), - }, EnumValue{ - DeclData: &DeclarationData{ - ShortName: &enumFieldName_SimpleType_UinT32, - }, - EnumTypeKey: ID_mojom_types_SimpleType__, - IntValue: int32(9), - }, EnumValue{ - DeclData: &DeclarationData{ - ShortName: &enumFieldName_SimpleType_UinT64, - }, - EnumTypeKey: ID_mojom_types_SimpleType__, - IntValue: int32(10), - }}, - } + return MojomEnum{ + DeclData: &DeclarationData{ + ShortName: &enumName_SimpleType, + }, + Values: []EnumValue{EnumValue{ + DeclData: &DeclarationData{ + ShortName: &enumFieldName_SimpleType_Bool, + }, + EnumTypeKey: ID_mojom_types_SimpleType__, + IntValue: int32(0), + },EnumValue{ + DeclData: &DeclarationData{ + ShortName: &enumFieldName_SimpleType_Double, + }, + EnumTypeKey: ID_mojom_types_SimpleType__, + IntValue: int32(1), + },EnumValue{ + DeclData: &DeclarationData{ + ShortName: &enumFieldName_SimpleType_Float, + }, + EnumTypeKey: ID_mojom_types_SimpleType__, + IntValue: int32(2), + },EnumValue{ + DeclData: &DeclarationData{ + ShortName: &enumFieldName_SimpleType_InT8, + }, + EnumTypeKey: ID_mojom_types_SimpleType__, + IntValue: int32(3), + },EnumValue{ + DeclData: &DeclarationData{ + ShortName: &enumFieldName_SimpleType_InT16, + }, + EnumTypeKey: ID_mojom_types_SimpleType__, + IntValue: int32(4), + },EnumValue{ + DeclData: &DeclarationData{ + ShortName: &enumFieldName_SimpleType_InT32, + }, + EnumTypeKey: ID_mojom_types_SimpleType__, + IntValue: int32(5), + },EnumValue{ + DeclData: &DeclarationData{ + ShortName: &enumFieldName_SimpleType_InT64, + }, + EnumTypeKey: ID_mojom_types_SimpleType__, + IntValue: int32(6), + },EnumValue{ + DeclData: &DeclarationData{ + ShortName: &enumFieldName_SimpleType_UinT8, + }, + EnumTypeKey: ID_mojom_types_SimpleType__, + IntValue: int32(7), + },EnumValue{ + DeclData: &DeclarationData{ + ShortName: &enumFieldName_SimpleType_UinT16, + }, + EnumTypeKey: ID_mojom_types_SimpleType__, + IntValue: int32(8), + },EnumValue{ + DeclData: &DeclarationData{ + ShortName: &enumFieldName_SimpleType_UinT32, + }, + EnumTypeKey: ID_mojom_types_SimpleType__, + IntValue: int32(9), + },EnumValue{ + DeclData: &DeclarationData{ + ShortName: &enumFieldName_SimpleType_UinT64, + }, + EnumTypeKey: ID_mojom_types_SimpleType__, + IntValue: int32(10), + },}, + } } type BuiltinConstantValue int32 const ( - BuiltinConstantValue_DoubleInfinity = 0 - BuiltinConstantValue_DoubleNegativeInfinity = BuiltinConstantValue_DoubleInfinity + 1 - BuiltinConstantValue_DoubleNan = BuiltinConstantValue_DoubleNegativeInfinity + 1 - BuiltinConstantValue_FloatInfinity = BuiltinConstantValue_DoubleNan + 1 - BuiltinConstantValue_FloatNegativeInfinity = BuiltinConstantValue_FloatInfinity + 1 - BuiltinConstantValue_FloatNan = BuiltinConstantValue_FloatNegativeInfinity + 1 + BuiltinConstantValue_DoubleInfinity = 0 + BuiltinConstantValue_DoubleNegativeInfinity = BuiltinConstantValue_DoubleInfinity + 1; + BuiltinConstantValue_DoubleNan = BuiltinConstantValue_DoubleNegativeInfinity + 1; + BuiltinConstantValue_FloatInfinity = BuiltinConstantValue_DoubleNan + 1; + BuiltinConstantValue_FloatNegativeInfinity = BuiltinConstantValue_FloatInfinity + 1; + BuiltinConstantValue_FloatNan = BuiltinConstantValue_FloatNegativeInfinity + 1; ) // String names and labels used by the MojomEnum types. var ( - enumName_BuiltinConstantValue = "BuiltinConstantValue" - enumFieldName_BuiltinConstantValue_DoubleInfinity = "DoubleInfinity" - enumFieldName_BuiltinConstantValue_DoubleNegativeInfinity = "DoubleNegativeInfinity" - enumFieldName_BuiltinConstantValue_DoubleNan = "DoubleNan" - enumFieldName_BuiltinConstantValue_FloatInfinity = "FloatInfinity" - enumFieldName_BuiltinConstantValue_FloatNegativeInfinity = "FloatNegativeInfinity" - enumFieldName_BuiltinConstantValue_FloatNan = "FloatNan" + enumName_BuiltinConstantValue = "BuiltinConstantValue" + enumFieldName_BuiltinConstantValue_DoubleInfinity = "DoubleInfinity" + enumFieldName_BuiltinConstantValue_DoubleNegativeInfinity = "DoubleNegativeInfinity" + enumFieldName_BuiltinConstantValue_DoubleNan = "DoubleNan" + enumFieldName_BuiltinConstantValue_FloatInfinity = "FloatInfinity" + enumFieldName_BuiltinConstantValue_FloatNegativeInfinity = "FloatNegativeInfinity" + enumFieldName_BuiltinConstantValue_FloatNan = "FloatNan" ) func mojom_types_BuiltinConstantValue__() MojomEnum { - return MojomEnum{ - DeclData: &DeclarationData{ - ShortName: &enumName_BuiltinConstantValue, - }, - Values: []EnumValue{EnumValue{ - DeclData: &DeclarationData{ - ShortName: &enumFieldName_BuiltinConstantValue_DoubleInfinity, - }, - EnumTypeKey: ID_mojom_types_BuiltinConstantValue__, - IntValue: int32(0), - }, EnumValue{ - DeclData: &DeclarationData{ - ShortName: &enumFieldName_BuiltinConstantValue_DoubleNegativeInfinity, - }, - EnumTypeKey: ID_mojom_types_BuiltinConstantValue__, - IntValue: int32(1), - }, EnumValue{ - DeclData: &DeclarationData{ - ShortName: &enumFieldName_BuiltinConstantValue_DoubleNan, - }, - EnumTypeKey: ID_mojom_types_BuiltinConstantValue__, - IntValue: int32(2), - }, EnumValue{ - DeclData: &DeclarationData{ - ShortName: &enumFieldName_BuiltinConstantValue_FloatInfinity, - }, - EnumTypeKey: ID_mojom_types_BuiltinConstantValue__, - IntValue: int32(3), - }, EnumValue{ - DeclData: &DeclarationData{ - ShortName: &enumFieldName_BuiltinConstantValue_FloatNegativeInfinity, - }, - EnumTypeKey: ID_mojom_types_BuiltinConstantValue__, - IntValue: int32(4), - }, EnumValue{ - DeclData: &DeclarationData{ - ShortName: &enumFieldName_BuiltinConstantValue_FloatNan, - }, - EnumTypeKey: ID_mojom_types_BuiltinConstantValue__, - IntValue: int32(5), - }}, - } + return MojomEnum{ + DeclData: &DeclarationData{ + ShortName: &enumName_BuiltinConstantValue, + }, + Values: []EnumValue{EnumValue{ + DeclData: &DeclarationData{ + ShortName: &enumFieldName_BuiltinConstantValue_DoubleInfinity, + }, + EnumTypeKey: ID_mojom_types_BuiltinConstantValue__, + IntValue: int32(0), + },EnumValue{ + DeclData: &DeclarationData{ + ShortName: &enumFieldName_BuiltinConstantValue_DoubleNegativeInfinity, + }, + EnumTypeKey: ID_mojom_types_BuiltinConstantValue__, + IntValue: int32(1), + },EnumValue{ + DeclData: &DeclarationData{ + ShortName: &enumFieldName_BuiltinConstantValue_DoubleNan, + }, + EnumTypeKey: ID_mojom_types_BuiltinConstantValue__, + IntValue: int32(2), + },EnumValue{ + DeclData: &DeclarationData{ + ShortName: &enumFieldName_BuiltinConstantValue_FloatInfinity, + }, + EnumTypeKey: ID_mojom_types_BuiltinConstantValue__, + IntValue: int32(3), + },EnumValue{ + DeclData: &DeclarationData{ + ShortName: &enumFieldName_BuiltinConstantValue_FloatNegativeInfinity, + }, + EnumTypeKey: ID_mojom_types_BuiltinConstantValue__, + IntValue: int32(4), + },EnumValue{ + DeclData: &DeclarationData{ + ShortName: &enumFieldName_BuiltinConstantValue_FloatNan, + }, + EnumTypeKey: ID_mojom_types_BuiltinConstantValue__, + IntValue: int32(5), + },}, + } } type HandleType_Kind int32 const ( - HandleType_Kind_Unspecified = 0 - HandleType_Kind_MessagePipe = HandleType_Kind_Unspecified + 1 - HandleType_Kind_DataPipeConsumer = HandleType_Kind_MessagePipe + 1 - HandleType_Kind_DataPipeProducer = HandleType_Kind_DataPipeConsumer + 1 - HandleType_Kind_SharedBuffer = HandleType_Kind_DataPipeProducer + 1 + HandleType_Kind_Unspecified = 0 + HandleType_Kind_MessagePipe = HandleType_Kind_Unspecified + 1; + HandleType_Kind_DataPipeConsumer = HandleType_Kind_MessagePipe + 1; + HandleType_Kind_DataPipeProducer = HandleType_Kind_DataPipeConsumer + 1; + HandleType_Kind_SharedBuffer = HandleType_Kind_DataPipeProducer + 1; ) // String names and labels used by the MojomEnum types. var ( - enumName_HandleType_Kind = "HandleType_Kind" - enumFieldName_HandleType_Kind_Unspecified = "Unspecified" - enumFieldName_HandleType_Kind_MessagePipe = "MessagePipe" - enumFieldName_HandleType_Kind_DataPipeConsumer = "DataPipeConsumer" - enumFieldName_HandleType_Kind_DataPipeProducer = "DataPipeProducer" - enumFieldName_HandleType_Kind_SharedBuffer = "SharedBuffer" + enumName_HandleType_Kind = "HandleType_Kind" + enumFieldName_HandleType_Kind_Unspecified = "Unspecified" + enumFieldName_HandleType_Kind_MessagePipe = "MessagePipe" + enumFieldName_HandleType_Kind_DataPipeConsumer = "DataPipeConsumer" + enumFieldName_HandleType_Kind_DataPipeProducer = "DataPipeProducer" + enumFieldName_HandleType_Kind_SharedBuffer = "SharedBuffer" ) func mojom_types_Kind__() MojomEnum { - return MojomEnum{ - DeclData: &DeclarationData{ - ShortName: &enumName_HandleType_Kind, - }, - Values: []EnumValue{EnumValue{ - DeclData: &DeclarationData{ - ShortName: &enumFieldName_HandleType_Kind_Unspecified, - }, - EnumTypeKey: ID_mojom_types_Kind__, - IntValue: int32(0), - }, EnumValue{ - DeclData: &DeclarationData{ - ShortName: &enumFieldName_HandleType_Kind_MessagePipe, - }, - EnumTypeKey: ID_mojom_types_Kind__, - IntValue: int32(1), - }, EnumValue{ - DeclData: &DeclarationData{ - ShortName: &enumFieldName_HandleType_Kind_DataPipeConsumer, - }, - EnumTypeKey: ID_mojom_types_Kind__, - IntValue: int32(2), - }, EnumValue{ - DeclData: &DeclarationData{ - ShortName: &enumFieldName_HandleType_Kind_DataPipeProducer, - }, - EnumTypeKey: ID_mojom_types_Kind__, - IntValue: int32(3), - }, EnumValue{ - DeclData: &DeclarationData{ - ShortName: &enumFieldName_HandleType_Kind_SharedBuffer, - }, - EnumTypeKey: ID_mojom_types_Kind__, - IntValue: int32(4), - }}, - } + return MojomEnum{ + DeclData: &DeclarationData{ + ShortName: &enumName_HandleType_Kind, + }, + Values: []EnumValue{EnumValue{ + DeclData: &DeclarationData{ + ShortName: &enumFieldName_HandleType_Kind_Unspecified, + }, + EnumTypeKey: ID_mojom_types_Kind__, + IntValue: int32(0), + },EnumValue{ + DeclData: &DeclarationData{ + ShortName: &enumFieldName_HandleType_Kind_MessagePipe, + }, + EnumTypeKey: ID_mojom_types_Kind__, + IntValue: int32(1), + },EnumValue{ + DeclData: &DeclarationData{ + ShortName: &enumFieldName_HandleType_Kind_DataPipeConsumer, + }, + EnumTypeKey: ID_mojom_types_Kind__, + IntValue: int32(2), + },EnumValue{ + DeclData: &DeclarationData{ + ShortName: &enumFieldName_HandleType_Kind_DataPipeProducer, + }, + EnumTypeKey: ID_mojom_types_Kind__, + IntValue: int32(3), + },EnumValue{ + DeclData: &DeclarationData{ + ShortName: &enumFieldName_HandleType_Kind_SharedBuffer, + }, + EnumTypeKey: ID_mojom_types_Kind__, + IntValue: int32(4), + },}, + } } type StringType struct { @@ -458,26 +526,26 @@ // String names and labels used by the MojomStruct types. var ( - structName_StringType = "StringType" - structFieldName_StringType_Nullable = "Nullable" + structName_StringType = "StringType" + structFieldName_StringType_Nullable = "Nullable" ) func mojom_types_StringType__() MojomStruct { - return MojomStruct{ - DeclData: &DeclarationData{ - ShortName: &structName_StringType, - }, Fields: []StructField{StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_StringType_Nullable, - }, - Type: &TypeSimpleType{SimpleType_Bool}, - }}, - } + return MojomStruct{ + DeclData: &DeclarationData{ + ShortName: &structName_StringType, + },Fields: []StructField{StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_StringType_Nullable, + }, + Type: &TypeSimpleType{SimpleType_Bool}, + },}, + } } type HandleType struct { Nullable bool - Kind HandleType_Kind + Kind HandleType_Kind } func (s *HandleType) Encode(encoder *bindings.Encoder) error { @@ -539,34 +607,34 @@ // String names and labels used by the MojomStruct types. var ( - structName_HandleType = "HandleType" - structFieldName_HandleType_Nullable = "Nullable" - structFieldName_HandleType_Kind = "Kind" + structName_HandleType = "HandleType" + structFieldName_HandleType_Nullable = "Nullable" + structFieldName_HandleType_Kind = "Kind" ) func mojom_types_HandleType__() MojomStruct { - return MojomStruct{ - DeclData: &DeclarationData{ - ShortName: &structName_HandleType, - }, Fields: []StructField{StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_HandleType_Nullable, - }, - Type: &TypeSimpleType{SimpleType_Bool}, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_HandleType_Kind, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_Kind__, - TypeKey: &ID_mojom_types_Kind__}, - }, - }}, - } + return MojomStruct{ + DeclData: &DeclarationData{ + ShortName: &structName_HandleType, + },Fields: []StructField{StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_HandleType_Nullable, + }, + Type: &TypeSimpleType{SimpleType_Bool}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_HandleType_Kind, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_Kind__, + TypeKey: &ID_mojom_types_Kind__,}, +}, + },}, + } } type ArrayType struct { - Nullable bool + Nullable bool FixedLength int32 ElementType Type } @@ -646,41 +714,41 @@ // String names and labels used by the MojomStruct types. var ( - structName_ArrayType = "ArrayType" - structFieldName_ArrayType_Nullable = "Nullable" - structFieldName_ArrayType_FixedLength = "FixedLength" - structFieldName_ArrayType_ElementType = "ElementType" + structName_ArrayType = "ArrayType" + structFieldName_ArrayType_Nullable = "Nullable" + structFieldName_ArrayType_FixedLength = "FixedLength" + structFieldName_ArrayType_ElementType = "ElementType" ) func mojom_types_ArrayType__() MojomStruct { - return MojomStruct{ - DeclData: &DeclarationData{ - ShortName: &structName_ArrayType, - }, Fields: []StructField{StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_ArrayType_Nullable, - }, - Type: &TypeSimpleType{SimpleType_Bool}, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_ArrayType_FixedLength, - }, - Type: &TypeSimpleType{SimpleType_InT32}, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_ArrayType_ElementType, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_Type__, - TypeKey: &ID_mojom_types_Type__}, - }, - }}, - } + return MojomStruct{ + DeclData: &DeclarationData{ + ShortName: &structName_ArrayType, + },Fields: []StructField{StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_ArrayType_Nullable, + }, + Type: &TypeSimpleType{SimpleType_Bool}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_ArrayType_FixedLength, + }, + Type: &TypeSimpleType{SimpleType_InT32}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_ArrayType_ElementType, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_Type__, + TypeKey: &ID_mojom_types_Type__,}, +}, + },}, + } } type MapType struct { - Nullable bool - KeyType Type + Nullable bool + KeyType Type ValueType Type } @@ -765,46 +833,46 @@ // String names and labels used by the MojomStruct types. var ( - structName_MapType = "MapType" - structFieldName_MapType_Nullable = "Nullable" - structFieldName_MapType_KeyType = "KeyType" - structFieldName_MapType_ValueType = "ValueType" + structName_MapType = "MapType" + structFieldName_MapType_Nullable = "Nullable" + structFieldName_MapType_KeyType = "KeyType" + structFieldName_MapType_ValueType = "ValueType" ) func mojom_types_MapType__() MojomStruct { - return MojomStruct{ - DeclData: &DeclarationData{ - ShortName: &structName_MapType, - }, Fields: []StructField{StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_MapType_Nullable, - }, - Type: &TypeSimpleType{SimpleType_Bool}, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_MapType_KeyType, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_Type__, - TypeKey: &ID_mojom_types_Type__}, - }, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_MapType_ValueType, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_Type__, - TypeKey: &ID_mojom_types_Type__}, - }, - }}, - } + return MojomStruct{ + DeclData: &DeclarationData{ + ShortName: &structName_MapType, + },Fields: []StructField{StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_MapType_Nullable, + }, + Type: &TypeSimpleType{SimpleType_Bool}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_MapType_KeyType, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_Type__, + TypeKey: &ID_mojom_types_Type__,}, +}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_MapType_ValueType, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_Type__, + TypeKey: &ID_mojom_types_Type__,}, +}, + },}, + } } type TypeReference struct { - Nullable bool + Nullable bool IsInterfaceRequest bool - Identifier *string - TypeKey *string + Identifier *string + TypeKey *string } func (s *TypeReference) Encode(encoder *bindings.Encoder) error { @@ -918,46 +986,46 @@ // String names and labels used by the MojomStruct types. var ( - structName_TypeReference = "TypeReference" - structFieldName_TypeReference_Nullable = "Nullable" - structFieldName_TypeReference_IsInterfaceRequest = "IsInterfaceRequest" - structFieldName_TypeReference_Identifier = "Identifier" - structFieldName_TypeReference_TypeKey = "TypeKey" + structName_TypeReference = "TypeReference" + structFieldName_TypeReference_Nullable = "Nullable" + structFieldName_TypeReference_IsInterfaceRequest = "IsInterfaceRequest" + structFieldName_TypeReference_Identifier = "Identifier" + structFieldName_TypeReference_TypeKey = "TypeKey" ) func mojom_types_TypeReference__() MojomStruct { - return MojomStruct{ - DeclData: &DeclarationData{ - ShortName: &structName_TypeReference, - }, Fields: []StructField{StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_TypeReference_Nullable, - }, - Type: &TypeSimpleType{SimpleType_Bool}, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_TypeReference_IsInterfaceRequest, - }, - Type: &TypeSimpleType{SimpleType_Bool}, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_TypeReference_Identifier, - }, - Type: &TypeStringType{StringType{true}}, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_TypeReference_TypeKey, - }, - Type: &TypeStringType{StringType{true}}, - }}, - } + return MojomStruct{ + DeclData: &DeclarationData{ + ShortName: &structName_TypeReference, + },Fields: []StructField{StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_TypeReference_Nullable, + }, + Type: &TypeSimpleType{SimpleType_Bool}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_TypeReference_IsInterfaceRequest, + }, + Type: &TypeSimpleType{SimpleType_Bool}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_TypeReference_Identifier, + }, + Type: &TypeStringType{StringType{true}}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_TypeReference_TypeKey, + }, + Type: &TypeStringType{StringType{true}}, + },}, + } } type StructField struct { - DeclData *DeclarationData - Type Type + DeclData *DeclarationData + Type Type DefaultValue DefaultFieldValue - Offset int32 + Offset int32 } func (s *StructField) Encode(encoder *bindings.Encoder) error { @@ -1063,48 +1131,48 @@ // String names and labels used by the MojomStruct types. var ( - structName_StructField = "StructField" - structFieldName_StructField_DeclData = "DeclData" - structFieldName_StructField_Type = "Type" - structFieldName_StructField_DefaultValue = "DefaultValue" - structFieldName_StructField_Offset = "Offset" + structName_StructField = "StructField" + structFieldName_StructField_DeclData = "DeclData" + structFieldName_StructField_Type = "Type" + structFieldName_StructField_DefaultValue = "DefaultValue" + structFieldName_StructField_Offset = "Offset" ) func mojom_types_StructField__() MojomStruct { - return MojomStruct{ - DeclData: &DeclarationData{ - ShortName: &structName_StructField, - }, Fields: []StructField{StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_StructField_DeclData, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Nullable: true, Identifier: &ID_mojom_types_DeclarationData__, - TypeKey: &ID_mojom_types_DeclarationData__}, - }, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_StructField_Type, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_Type__, - TypeKey: &ID_mojom_types_Type__}, - }, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_StructField_DefaultValue, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Nullable: true, Identifier: &ID_mojom_types_DefaultFieldValue__, - TypeKey: &ID_mojom_types_DefaultFieldValue__}, - }, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_StructField_Offset, - }, - Type: &TypeSimpleType{SimpleType_InT32}, - }}, - } + return MojomStruct{ + DeclData: &DeclarationData{ + ShortName: &structName_StructField, + },Fields: []StructField{StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_StructField_DeclData, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Nullable: true,Identifier: &ID_mojom_types_DeclarationData__, + TypeKey: &ID_mojom_types_DeclarationData__,}, +}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_StructField_Type, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_Type__, + TypeKey: &ID_mojom_types_Type__,}, +}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_StructField_DefaultValue, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Nullable: true,Identifier: &ID_mojom_types_DefaultFieldValue__, + TypeKey: &ID_mojom_types_DefaultFieldValue__,}, +}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_StructField_Offset, + }, + Type: &TypeSimpleType{SimpleType_InT32}, + },}, + } } type DefaultKeyword struct { @@ -1149,21 +1217,21 @@ // String names and labels used by the MojomStruct types. var ( - structName_DefaultKeyword = "DefaultKeyword" + structName_DefaultKeyword = "DefaultKeyword" ) func mojom_types_DefaultKeyword__() MojomStruct { - return MojomStruct{ - DeclData: &DeclarationData{ - ShortName: &structName_DefaultKeyword, - }, Fields: []StructField{}, - } + return MojomStruct{ + DeclData: &DeclarationData{ + ShortName: &structName_DefaultKeyword, + },Fields: []StructField{}, + } } type StructVersion struct { VersionNumber uint32 - NumFields uint32 - NumBytes uint32 + NumFields uint32 + NumBytes uint32 } func (s *StructVersion) Encode(encoder *bindings.Encoder) error { @@ -1235,38 +1303,38 @@ // String names and labels used by the MojomStruct types. var ( - structName_StructVersion = "StructVersion" - structFieldName_StructVersion_VersionNumber = "VersionNumber" - structFieldName_StructVersion_NumFields = "NumFields" - structFieldName_StructVersion_NumBytes = "NumBytes" + structName_StructVersion = "StructVersion" + structFieldName_StructVersion_VersionNumber = "VersionNumber" + structFieldName_StructVersion_NumFields = "NumFields" + structFieldName_StructVersion_NumBytes = "NumBytes" ) func mojom_types_StructVersion__() MojomStruct { - return MojomStruct{ - DeclData: &DeclarationData{ - ShortName: &structName_StructVersion, - }, Fields: []StructField{StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_StructVersion_VersionNumber, - }, - Type: &TypeSimpleType{SimpleType_UinT32}, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_StructVersion_NumFields, - }, - Type: &TypeSimpleType{SimpleType_UinT32}, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_StructVersion_NumBytes, - }, - Type: &TypeSimpleType{SimpleType_UinT32}, - }}, - } + return MojomStruct{ + DeclData: &DeclarationData{ + ShortName: &structName_StructVersion, + },Fields: []StructField{StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_StructVersion_VersionNumber, + }, + Type: &TypeSimpleType{SimpleType_UinT32}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_StructVersion_NumFields, + }, + Type: &TypeSimpleType{SimpleType_UinT32}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_StructVersion_NumBytes, + }, + Type: &TypeSimpleType{SimpleType_UinT32}, + },}, + } } type MojomStruct struct { - DeclData *DeclarationData - Fields []StructField + DeclData *DeclarationData + Fields []StructField VersionInfo *[]StructVersion } @@ -1304,7 +1372,7 @@ return err } encoder.StartArray(uint32(len((*s.VersionInfo))), 64) - for _, elem0 := range *s.VersionInfo { + for _, elem0 := range (*s.VersionInfo) { if err := encoder.WritePointer(); err != nil { return err } @@ -1430,54 +1498,54 @@ // String names and labels used by the MojomStruct types. var ( - structName_MojomStruct = "MojomStruct" - structFieldName_MojomStruct_DeclData = "DeclData" - structFieldName_MojomStruct_Fields = "Fields" - structFieldName_MojomStruct_VersionInfo = "VersionInfo" + structName_MojomStruct = "MojomStruct" + structFieldName_MojomStruct_DeclData = "DeclData" + structFieldName_MojomStruct_Fields = "Fields" + structFieldName_MojomStruct_VersionInfo = "VersionInfo" ) func mojom_types_MojomStruct__() MojomStruct { - return MojomStruct{ - DeclData: &DeclarationData{ - ShortName: &structName_MojomStruct, - }, Fields: []StructField{StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_MojomStruct_DeclData, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Nullable: true, Identifier: &ID_mojom_types_DeclarationData__, - TypeKey: &ID_mojom_types_DeclarationData__}, - }, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_MojomStruct_Fields, - }, - Type: &TypeArrayType{ - Value: ArrayType{ElementType: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_StructField__, - TypeKey: &ID_mojom_types_StructField__}, - }, - }, - }, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_MojomStruct_VersionInfo, - }, - Type: &TypeArrayType{ - Value: ArrayType{Nullable: true, ElementType: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_StructVersion__, - TypeKey: &ID_mojom_types_StructVersion__}, - }, - }, - }, - }}, - } + return MojomStruct{ + DeclData: &DeclarationData{ + ShortName: &structName_MojomStruct, + },Fields: []StructField{StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_MojomStruct_DeclData, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Nullable: true,Identifier: &ID_mojom_types_DeclarationData__, + TypeKey: &ID_mojom_types_DeclarationData__,}, +}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_MojomStruct_Fields, + }, + Type: &TypeArrayType{ + Value: ArrayType{ElementType: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_StructField__, + TypeKey: &ID_mojom_types_StructField__,}, +}, + }, + }, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_MojomStruct_VersionInfo, + }, + Type: &TypeArrayType{ + Value: ArrayType{Nullable: true,ElementType: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_StructVersion__, + TypeKey: &ID_mojom_types_StructVersion__,}, +}, + }, + }, + },}, + } } type UnionField struct { DeclData *DeclarationData - Type Type - Tag uint32 + Type Type + Tag uint32 } func (s *UnionField) Encode(encoder *bindings.Encoder) error { @@ -1569,44 +1637,44 @@ // String names and labels used by the MojomStruct types. var ( - structName_UnionField = "UnionField" - structFieldName_UnionField_DeclData = "DeclData" - structFieldName_UnionField_Type = "Type" - structFieldName_UnionField_Tag = "Tag" + structName_UnionField = "UnionField" + structFieldName_UnionField_DeclData = "DeclData" + structFieldName_UnionField_Type = "Type" + structFieldName_UnionField_Tag = "Tag" ) func mojom_types_UnionField__() MojomStruct { - return MojomStruct{ - DeclData: &DeclarationData{ - ShortName: &structName_UnionField, - }, Fields: []StructField{StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_UnionField_DeclData, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Nullable: true, Identifier: &ID_mojom_types_DeclarationData__, - TypeKey: &ID_mojom_types_DeclarationData__}, - }, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_UnionField_Type, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_Type__, - TypeKey: &ID_mojom_types_Type__}, - }, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_UnionField_Tag, - }, - Type: &TypeSimpleType{SimpleType_UinT32}, - }}, - } + return MojomStruct{ + DeclData: &DeclarationData{ + ShortName: &structName_UnionField, + },Fields: []StructField{StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_UnionField_DeclData, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Nullable: true,Identifier: &ID_mojom_types_DeclarationData__, + TypeKey: &ID_mojom_types_DeclarationData__,}, +}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_UnionField_Type, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_Type__, + TypeKey: &ID_mojom_types_Type__,}, +}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_UnionField_Tag, + }, + Type: &TypeSimpleType{SimpleType_UinT32}, + },}, + } } type MojomUnion struct { DeclData *DeclarationData - Fields []UnionField + Fields []UnionField } func (s *MojomUnion) Encode(encoder *bindings.Encoder) error { @@ -1718,43 +1786,43 @@ // String names and labels used by the MojomStruct types. var ( - structName_MojomUnion = "MojomUnion" - structFieldName_MojomUnion_DeclData = "DeclData" - structFieldName_MojomUnion_Fields = "Fields" + structName_MojomUnion = "MojomUnion" + structFieldName_MojomUnion_DeclData = "DeclData" + structFieldName_MojomUnion_Fields = "Fields" ) func mojom_types_MojomUnion__() MojomStruct { - return MojomStruct{ - DeclData: &DeclarationData{ - ShortName: &structName_MojomUnion, - }, Fields: []StructField{StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_MojomUnion_DeclData, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Nullable: true, Identifier: &ID_mojom_types_DeclarationData__, - TypeKey: &ID_mojom_types_DeclarationData__}, - }, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_MojomUnion_Fields, - }, - Type: &TypeArrayType{ - Value: ArrayType{ElementType: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_UnionField__, - TypeKey: &ID_mojom_types_UnionField__}, - }, - }, - }, - }}, - } + return MojomStruct{ + DeclData: &DeclarationData{ + ShortName: &structName_MojomUnion, + },Fields: []StructField{StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_MojomUnion_DeclData, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Nullable: true,Identifier: &ID_mojom_types_DeclarationData__, + TypeKey: &ID_mojom_types_DeclarationData__,}, +}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_MojomUnion_Fields, + }, + Type: &TypeArrayType{ + Value: ArrayType{ElementType: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_UnionField__, + TypeKey: &ID_mojom_types_UnionField__,}, +}, + }, + }, + },}, + } } type EnumValue struct { - DeclData *DeclarationData - EnumTypeKey string + DeclData *DeclarationData + EnumTypeKey string InitializerValue Value - IntValue int32 + IntValue int32 } func (s *EnumValue) Encode(encoder *bindings.Encoder) error { @@ -1865,50 +1933,50 @@ // String names and labels used by the MojomStruct types. var ( - structName_EnumValue = "EnumValue" - structFieldName_EnumValue_DeclData = "DeclData" - structFieldName_EnumValue_EnumTypeKey = "EnumTypeKey" - structFieldName_EnumValue_InitializerValue = "InitializerValue" - structFieldName_EnumValue_IntValue = "IntValue" + structName_EnumValue = "EnumValue" + structFieldName_EnumValue_DeclData = "DeclData" + structFieldName_EnumValue_EnumTypeKey = "EnumTypeKey" + structFieldName_EnumValue_InitializerValue = "InitializerValue" + structFieldName_EnumValue_IntValue = "IntValue" ) func mojom_types_EnumValue__() MojomStruct { - return MojomStruct{ - DeclData: &DeclarationData{ - ShortName: &structName_EnumValue, - }, Fields: []StructField{StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_EnumValue_DeclData, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Nullable: true, Identifier: &ID_mojom_types_DeclarationData__, - TypeKey: &ID_mojom_types_DeclarationData__}, - }, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_EnumValue_EnumTypeKey, - }, - Type: &TypeStringType{StringType{false}}, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_EnumValue_InitializerValue, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Nullable: true, Identifier: &ID_mojom_types_Value__, - TypeKey: &ID_mojom_types_Value__}, - }, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_EnumValue_IntValue, - }, - Type: &TypeSimpleType{SimpleType_InT32}, - }}, - } + return MojomStruct{ + DeclData: &DeclarationData{ + ShortName: &structName_EnumValue, + },Fields: []StructField{StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_EnumValue_DeclData, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Nullable: true,Identifier: &ID_mojom_types_DeclarationData__, + TypeKey: &ID_mojom_types_DeclarationData__,}, +}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_EnumValue_EnumTypeKey, + }, + Type: &TypeStringType{StringType{false}}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_EnumValue_InitializerValue, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Nullable: true,Identifier: &ID_mojom_types_Value__, + TypeKey: &ID_mojom_types_Value__,}, +}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_EnumValue_IntValue, + }, + Type: &TypeSimpleType{SimpleType_InT32}, + },}, + } } type MojomEnum struct { DeclData *DeclarationData - Values []EnumValue + Values []EnumValue } func (s *MojomEnum) Encode(encoder *bindings.Encoder) error { @@ -2020,43 +2088,43 @@ // String names and labels used by the MojomStruct types. var ( - structName_MojomEnum = "MojomEnum" - structFieldName_MojomEnum_DeclData = "DeclData" - structFieldName_MojomEnum_Values = "Values" + structName_MojomEnum = "MojomEnum" + structFieldName_MojomEnum_DeclData = "DeclData" + structFieldName_MojomEnum_Values = "Values" ) func mojom_types_MojomEnum__() MojomStruct { - return MojomStruct{ - DeclData: &DeclarationData{ - ShortName: &structName_MojomEnum, - }, Fields: []StructField{StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_MojomEnum_DeclData, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Nullable: true, Identifier: &ID_mojom_types_DeclarationData__, - TypeKey: &ID_mojom_types_DeclarationData__}, - }, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_MojomEnum_Values, - }, - Type: &TypeArrayType{ - Value: ArrayType{ElementType: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_EnumValue__, - TypeKey: &ID_mojom_types_EnumValue__}, - }, - }, - }, - }}, - } + return MojomStruct{ + DeclData: &DeclarationData{ + ShortName: &structName_MojomEnum, + },Fields: []StructField{StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_MojomEnum_DeclData, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Nullable: true,Identifier: &ID_mojom_types_DeclarationData__, + TypeKey: &ID_mojom_types_DeclarationData__,}, +}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_MojomEnum_Values, + }, + Type: &TypeArrayType{ + Value: ArrayType{ElementType: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_EnumValue__, + TypeKey: &ID_mojom_types_EnumValue__,}, +}, + }, + }, + },}, + } } type MojomMethod struct { - DeclData *DeclarationData - Parameters MojomStruct + DeclData *DeclarationData + Parameters MojomStruct ResponseParams *MojomStruct - Ordinal uint32 + Ordinal uint32 } func (s *MojomMethod) Encode(encoder *bindings.Encoder) error { @@ -2175,54 +2243,54 @@ // String names and labels used by the MojomStruct types. var ( - structName_MojomMethod = "MojomMethod" - structFieldName_MojomMethod_DeclData = "DeclData" - structFieldName_MojomMethod_Parameters = "Parameters" - structFieldName_MojomMethod_ResponseParams = "ResponseParams" - structFieldName_MojomMethod_Ordinal = "Ordinal" + structName_MojomMethod = "MojomMethod" + structFieldName_MojomMethod_DeclData = "DeclData" + structFieldName_MojomMethod_Parameters = "Parameters" + structFieldName_MojomMethod_ResponseParams = "ResponseParams" + structFieldName_MojomMethod_Ordinal = "Ordinal" ) func mojom_types_MojomMethod__() MojomStruct { - return MojomStruct{ - DeclData: &DeclarationData{ - ShortName: &structName_MojomMethod, - }, Fields: []StructField{StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_MojomMethod_DeclData, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Nullable: true, Identifier: &ID_mojom_types_DeclarationData__, - TypeKey: &ID_mojom_types_DeclarationData__}, - }, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_MojomMethod_Parameters, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_MojomStruct__, - TypeKey: &ID_mojom_types_MojomStruct__}, - }, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_MojomMethod_ResponseParams, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Nullable: true, Identifier: &ID_mojom_types_MojomStruct__, - TypeKey: &ID_mojom_types_MojomStruct__}, - }, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_MojomMethod_Ordinal, - }, - Type: &TypeSimpleType{SimpleType_UinT32}, - }}, - } + return MojomStruct{ + DeclData: &DeclarationData{ + ShortName: &structName_MojomMethod, + },Fields: []StructField{StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_MojomMethod_DeclData, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Nullable: true,Identifier: &ID_mojom_types_DeclarationData__, + TypeKey: &ID_mojom_types_DeclarationData__,}, +}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_MojomMethod_Parameters, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_MojomStruct__, + TypeKey: &ID_mojom_types_MojomStruct__,}, +}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_MojomMethod_ResponseParams, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Nullable: true,Identifier: &ID_mojom_types_MojomStruct__, + TypeKey: &ID_mojom_types_MojomStruct__,}, +}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_MojomMethod_Ordinal, + }, + Type: &TypeSimpleType{SimpleType_UinT32}, + },}, + } } type MojomInterface struct { - DeclData *DeclarationData + DeclData *DeclarationData InterfaceName string - Methods map[uint32]MojomMethod + Methods map[uint32]MojomMethod } func (s *MojomInterface) Encode(encoder *bindings.Encoder) error { @@ -2436,48 +2504,48 @@ // String names and labels used by the MojomStruct types. var ( - structName_MojomInterface = "MojomInterface" - structFieldName_MojomInterface_DeclData = "DeclData" - structFieldName_MojomInterface_InterfaceName = "InterfaceName" - structFieldName_MojomInterface_Methods = "Methods" + structName_MojomInterface = "MojomInterface" + structFieldName_MojomInterface_DeclData = "DeclData" + structFieldName_MojomInterface_InterfaceName = "InterfaceName" + structFieldName_MojomInterface_Methods = "Methods" ) func mojom_types_MojomInterface__() MojomStruct { - return MojomStruct{ - DeclData: &DeclarationData{ - ShortName: &structName_MojomInterface, - }, Fields: []StructField{StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_MojomInterface_DeclData, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Nullable: true, Identifier: &ID_mojom_types_DeclarationData__, - TypeKey: &ID_mojom_types_DeclarationData__}, - }, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_MojomInterface_InterfaceName, - }, - Type: &TypeStringType{StringType{false}}, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_MojomInterface_Methods, - }, - Type: &TypeMapType{ - Value: MapType{KeyType: &TypeSimpleType{SimpleType_UinT32}, - ValueType: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_MojomMethod__, - TypeKey: &ID_mojom_types_MojomMethod__}, - }, - }, - }, - }}, - } + return MojomStruct{ + DeclData: &DeclarationData{ + ShortName: &structName_MojomInterface, + },Fields: []StructField{StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_MojomInterface_DeclData, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Nullable: true,Identifier: &ID_mojom_types_DeclarationData__, + TypeKey: &ID_mojom_types_DeclarationData__,}, +}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_MojomInterface_InterfaceName, + }, + Type: &TypeStringType{StringType{false}}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_MojomInterface_Methods, + }, + Type: &TypeMapType{ + Value: MapType{KeyType: &TypeSimpleType{SimpleType_UinT32}, + ValueType: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_MojomMethod__, + TypeKey: &ID_mojom_types_MojomMethod__,}, +}, + }, + }, + },}, + } } type UserValueReference struct { - Identifier string - ValueKey *string + Identifier string + ValueKey *string ResolvedConcreteValue Value } @@ -2581,42 +2649,42 @@ // String names and labels used by the MojomStruct types. var ( - structName_UserValueReference = "UserValueReference" - structFieldName_UserValueReference_Identifier = "Identifier" - structFieldName_UserValueReference_ValueKey = "ValueKey" - structFieldName_UserValueReference_ResolvedConcreteValue = "ResolvedConcreteValue" + structName_UserValueReference = "UserValueReference" + structFieldName_UserValueReference_Identifier = "Identifier" + structFieldName_UserValueReference_ValueKey = "ValueKey" + structFieldName_UserValueReference_ResolvedConcreteValue = "ResolvedConcreteValue" ) func mojom_types_UserValueReference__() MojomStruct { - return MojomStruct{ - DeclData: &DeclarationData{ - ShortName: &structName_UserValueReference, - }, Fields: []StructField{StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_UserValueReference_Identifier, - }, - Type: &TypeStringType{StringType{false}}, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_UserValueReference_ValueKey, - }, - Type: &TypeStringType{StringType{true}}, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_UserValueReference_ResolvedConcreteValue, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Nullable: true, Identifier: &ID_mojom_types_Value__, - TypeKey: &ID_mojom_types_Value__}, - }, - }}, - } + return MojomStruct{ + DeclData: &DeclarationData{ + ShortName: &structName_UserValueReference, + },Fields: []StructField{StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_UserValueReference_Identifier, + }, + Type: &TypeStringType{StringType{false}}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_UserValueReference_ValueKey, + }, + Type: &TypeStringType{StringType{true}}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_UserValueReference_ResolvedConcreteValue, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Nullable: true,Identifier: &ID_mojom_types_Value__, + TypeKey: &ID_mojom_types_Value__,}, +}, + },}, + } } type DeclaredConstant struct { DeclData DeclarationData - Type Type - Value Value + Type Type + Value Value } func (s *DeclaredConstant) Encode(encoder *bindings.Encoder) error { @@ -2709,57 +2777,58 @@ // String names and labels used by the MojomStruct types. var ( - structName_DeclaredConstant = "DeclaredConstant" - structFieldName_DeclaredConstant_DeclData = "DeclData" - structFieldName_DeclaredConstant_Type = "Type" - structFieldName_DeclaredConstant_Value = "Value" + structName_DeclaredConstant = "DeclaredConstant" + structFieldName_DeclaredConstant_DeclData = "DeclData" + structFieldName_DeclaredConstant_Type = "Type" + structFieldName_DeclaredConstant_Value = "Value" ) func mojom_types_DeclaredConstant__() MojomStruct { - return MojomStruct{ - DeclData: &DeclarationData{ - ShortName: &structName_DeclaredConstant, - }, Fields: []StructField{StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_DeclaredConstant_DeclData, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_DeclarationData__, - TypeKey: &ID_mojom_types_DeclarationData__}, - }, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_DeclaredConstant_Type, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_Type__, - TypeKey: &ID_mojom_types_Type__}, - }, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_DeclaredConstant_Value, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_Value__, - TypeKey: &ID_mojom_types_Value__}, - }, - }}, - } + return MojomStruct{ + DeclData: &DeclarationData{ + ShortName: &structName_DeclaredConstant, + },Fields: []StructField{StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_DeclaredConstant_DeclData, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_DeclarationData__, + TypeKey: &ID_mojom_types_DeclarationData__,}, +}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_DeclaredConstant_Type, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_Type__, + TypeKey: &ID_mojom_types_Type__,}, +}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_DeclaredConstant_Value, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_Value__, + TypeKey: &ID_mojom_types_Value__,}, +}, + },}, + } } type DeclarationData struct { - Attributes *[]Attribute - MinVersion int32 - ShortName *string - FullIdentifier *string - DeclaredOrdinal int32 - DeclarationOrder int32 - SourceFileInfo *SourceFileInfo + Attributes *[]Attribute + MinVersion int32 + ShortName *string + FullIdentifier *string + DeclaredOrdinal int32 + DeclarationOrder int32 + SourceFileInfo *SourceFileInfo ContainedDeclarations *ContainedDeclarations + ContainerTypeKey *string } func (s *DeclarationData) Encode(encoder *bindings.Encoder) error { - encoder.StartStruct(56, 0) + encoder.StartStruct(64, 0) if s.Attributes == nil { encoder.WriteNullPointer() } else { @@ -2767,7 +2836,7 @@ return err } encoder.StartArray(uint32(len((*s.Attributes))), 64) - for _, elem0 := range *s.Attributes { + for _, elem0 := range (*s.Attributes) { if err := encoder.WritePointer(); err != nil { return err } @@ -2828,6 +2897,16 @@ return err } } + if s.ContainerTypeKey == nil { + encoder.WriteNullPointer() + } else { + if err := encoder.WritePointer(); err != nil { + return err + } + if err := encoder.WriteString((*s.ContainerTypeKey)); err != nil { + return err + } + } if err := encoder.Finish(); err != nil { return err } @@ -2835,7 +2914,7 @@ } var declarationData_Versions []bindings.DataHeader = []bindings.DataHeader{ - bindings.DataHeader{64, 0}, + bindings.DataHeader{72, 0}, } func (s *DeclarationData) Decode(decoder *bindings.Decoder) error { @@ -2970,6 +3049,22 @@ } } } + if header.ElementsOrVersion >= 0 { + pointer0, err := decoder.ReadPointer() + if err != nil { + return err + } + if pointer0 == 0 { + s.ContainerTypeKey = nil + } else { + s.ContainerTypeKey = new(string) + value0, err := decoder.ReadString() + if err != nil { + return err + } + (*s.ContainerTypeKey) = value0 + } + } if err := decoder.Finish(); err != nil { return err } @@ -2978,80 +3073,86 @@ // String names and labels used by the MojomStruct types. var ( - structName_DeclarationData = "DeclarationData" - structFieldName_DeclarationData_Attributes = "Attributes" - structFieldName_DeclarationData_MinVersion = "MinVersion" - structFieldName_DeclarationData_ShortName = "ShortName" - structFieldName_DeclarationData_FullIdentifier = "FullIdentifier" - structFieldName_DeclarationData_DeclaredOrdinal = "DeclaredOrdinal" - structFieldName_DeclarationData_DeclarationOrder = "DeclarationOrder" - structFieldName_DeclarationData_SourceFileInfo = "SourceFileInfo" - structFieldName_DeclarationData_ContainedDeclarations = "ContainedDeclarations" + structName_DeclarationData = "DeclarationData" + structFieldName_DeclarationData_Attributes = "Attributes" + structFieldName_DeclarationData_MinVersion = "MinVersion" + structFieldName_DeclarationData_ShortName = "ShortName" + structFieldName_DeclarationData_FullIdentifier = "FullIdentifier" + structFieldName_DeclarationData_DeclaredOrdinal = "DeclaredOrdinal" + structFieldName_DeclarationData_DeclarationOrder = "DeclarationOrder" + structFieldName_DeclarationData_SourceFileInfo = "SourceFileInfo" + structFieldName_DeclarationData_ContainedDeclarations = "ContainedDeclarations" + structFieldName_DeclarationData_ContainerTypeKey = "ContainerTypeKey" ) func mojom_types_DeclarationData__() MojomStruct { - return MojomStruct{ - DeclData: &DeclarationData{ - ShortName: &structName_DeclarationData, - }, Fields: []StructField{StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_DeclarationData_Attributes, - }, - Type: &TypeArrayType{ - Value: ArrayType{Nullable: true, ElementType: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_Attribute__, - TypeKey: &ID_mojom_types_Attribute__}, - }, - }, - }, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_DeclarationData_MinVersion, - }, - Type: &TypeSimpleType{SimpleType_InT32}, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_DeclarationData_ShortName, - }, - Type: &TypeStringType{StringType{true}}, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_DeclarationData_FullIdentifier, - }, - Type: &TypeStringType{StringType{true}}, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_DeclarationData_DeclaredOrdinal, - }, - Type: &TypeSimpleType{SimpleType_InT32}, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_DeclarationData_DeclarationOrder, - }, - Type: &TypeSimpleType{SimpleType_InT32}, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_DeclarationData_SourceFileInfo, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Nullable: true, Identifier: &ID_mojom_types_SourceFileInfo__, - TypeKey: &ID_mojom_types_SourceFileInfo__}, - }, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_DeclarationData_ContainedDeclarations, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Nullable: true, Identifier: &ID_mojom_types_ContainedDeclarations__, - TypeKey: &ID_mojom_types_ContainedDeclarations__}, - }, - }}, - } + return MojomStruct{ + DeclData: &DeclarationData{ + ShortName: &structName_DeclarationData, + },Fields: []StructField{StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_DeclarationData_Attributes, + }, + Type: &TypeArrayType{ + Value: ArrayType{Nullable: true,ElementType: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_Attribute__, + TypeKey: &ID_mojom_types_Attribute__,}, +}, + }, + }, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_DeclarationData_MinVersion, + }, + Type: &TypeSimpleType{SimpleType_InT32}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_DeclarationData_ShortName, + }, + Type: &TypeStringType{StringType{true}}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_DeclarationData_FullIdentifier, + }, + Type: &TypeStringType{StringType{true}}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_DeclarationData_DeclaredOrdinal, + }, + Type: &TypeSimpleType{SimpleType_InT32}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_DeclarationData_DeclarationOrder, + }, + Type: &TypeSimpleType{SimpleType_InT32}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_DeclarationData_SourceFileInfo, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Nullable: true,Identifier: &ID_mojom_types_SourceFileInfo__, + TypeKey: &ID_mojom_types_SourceFileInfo__,}, +}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_DeclarationData_ContainedDeclarations, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Nullable: true,Identifier: &ID_mojom_types_ContainedDeclarations__, + TypeKey: &ID_mojom_types_ContainedDeclarations__,}, +}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_DeclarationData_ContainerTypeKey, + }, + Type: &TypeStringType{StringType{true}}, + },}, + } } type SourceFileInfo struct { - FileName string - LineNumber uint32 + FileName string + LineNumber uint32 ColumnNumber uint32 } @@ -3135,37 +3236,37 @@ // String names and labels used by the MojomStruct types. var ( - structName_SourceFileInfo = "SourceFileInfo" - structFieldName_SourceFileInfo_FileName = "FileName" - structFieldName_SourceFileInfo_LineNumber = "LineNumber" - structFieldName_SourceFileInfo_ColumnNumber = "ColumnNumber" + structName_SourceFileInfo = "SourceFileInfo" + structFieldName_SourceFileInfo_FileName = "FileName" + structFieldName_SourceFileInfo_LineNumber = "LineNumber" + structFieldName_SourceFileInfo_ColumnNumber = "ColumnNumber" ) func mojom_types_SourceFileInfo__() MojomStruct { - return MojomStruct{ - DeclData: &DeclarationData{ - ShortName: &structName_SourceFileInfo, - }, Fields: []StructField{StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_SourceFileInfo_FileName, - }, - Type: &TypeStringType{StringType{false}}, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_SourceFileInfo_LineNumber, - }, - Type: &TypeSimpleType{SimpleType_UinT32}, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_SourceFileInfo_ColumnNumber, - }, - Type: &TypeSimpleType{SimpleType_UinT32}, - }}, - } + return MojomStruct{ + DeclData: &DeclarationData{ + ShortName: &structName_SourceFileInfo, + },Fields: []StructField{StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_SourceFileInfo_FileName, + }, + Type: &TypeStringType{StringType{false}}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_SourceFileInfo_LineNumber, + }, + Type: &TypeSimpleType{SimpleType_UinT32}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_SourceFileInfo_ColumnNumber, + }, + Type: &TypeSimpleType{SimpleType_UinT32}, + },}, + } } type ContainedDeclarations struct { - Enums *[]string + Enums *[]string Constants *[]string } @@ -3178,7 +3279,7 @@ return err } encoder.StartArray(uint32(len((*s.Enums))), 64) - for _, elem0 := range *s.Enums { + for _, elem0 := range (*s.Enums) { if err := encoder.WritePointer(); err != nil { return err } @@ -3197,7 +3298,7 @@ return err } encoder.StartArray(uint32(len((*s.Constants))), 64) - for _, elem0 := range *s.Constants { + for _, elem0 := range (*s.Constants) { if err := encoder.WritePointer(); err != nil { return err } @@ -3314,35 +3415,37 @@ // String names and labels used by the MojomStruct types. var ( - structName_ContainedDeclarations = "ContainedDeclarations" - structFieldName_ContainedDeclarations_Enums = "Enums" - structFieldName_ContainedDeclarations_Constants = "Constants" + structName_ContainedDeclarations = "ContainedDeclarations" + structFieldName_ContainedDeclarations_Enums = "Enums" + structFieldName_ContainedDeclarations_Constants = "Constants" ) func mojom_types_ContainedDeclarations__() MojomStruct { - return MojomStruct{ - DeclData: &DeclarationData{ - ShortName: &structName_ContainedDeclarations, - }, Fields: []StructField{StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_ContainedDeclarations_Enums, - }, - Type: &TypeArrayType{ - Value: ArrayType{Nullable: true, ElementType: &TypeStringType{StringType{false}}}, - }, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_ContainedDeclarations_Constants, - }, - Type: &TypeArrayType{ - Value: ArrayType{Nullable: true, ElementType: &TypeStringType{StringType{false}}}, - }, - }}, - } + return MojomStruct{ + DeclData: &DeclarationData{ + ShortName: &structName_ContainedDeclarations, + },Fields: []StructField{StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_ContainedDeclarations_Enums, + }, + Type: &TypeArrayType{ + Value: ArrayType{Nullable: true,ElementType: &TypeStringType{StringType{false}}, + }, + }, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_ContainedDeclarations_Constants, + }, + Type: &TypeArrayType{ + Value: ArrayType{Nullable: true,ElementType: &TypeStringType{StringType{false}}, + }, + }, + },}, + } } type Attribute struct { - Key string + Key string Value string } @@ -3427,27 +3530,27 @@ // String names and labels used by the MojomStruct types. var ( - structName_Attribute = "Attribute" - structFieldName_Attribute_Key = "Key" - structFieldName_Attribute_Value = "Value" + structName_Attribute = "Attribute" + structFieldName_Attribute_Key = "Key" + structFieldName_Attribute_Value = "Value" ) func mojom_types_Attribute__() MojomStruct { - return MojomStruct{ - DeclData: &DeclarationData{ - ShortName: &structName_Attribute, - }, Fields: []StructField{StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_Attribute_Key, - }, - Type: &TypeStringType{StringType{false}}, - }, StructField{ - DeclData: &DeclarationData{ - ShortName: &structFieldName_Attribute_Value, - }, - Type: &TypeStringType{StringType{false}}, - }}, - } + return MojomStruct{ + DeclData: &DeclarationData{ + ShortName: &structName_Attribute, + },Fields: []StructField{StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_Attribute_Key, + }, + Type: &TypeStringType{StringType{false}}, + },StructField{ + DeclData: &DeclarationData{ + ShortName: &structFieldName_Attribute_Value, + }, + Type: &TypeStringType{StringType{false}}, + },}, + } } type Type interface { @@ -3458,11 +3561,11 @@ } type __TypeReflect struct { - SimpleType SimpleType - StringType StringType - ArrayType ArrayType - MapType MapType - HandleType HandleType + SimpleType SimpleType + StringType StringType + ArrayType ArrayType + MapType MapType + HandleType HandleType TypeReference TypeReference } @@ -3526,20 +3629,18 @@ return &TypeUnknown{tag: tag}, nil } -type TypeUnknown struct{ tag uint32 } - -func (u *TypeUnknown) Tag() uint32 { return u.tag } -func (u *TypeUnknown) Interface() interface{} { return nil } +type TypeUnknown struct { tag uint32 } +func (u *TypeUnknown) Tag() uint32 { return u.tag } +func (u *TypeUnknown) Interface() interface{} { return nil } func (u *TypeUnknown) __Reflect(__TypeReflect) {} func (u *TypeUnknown) Encode(encoder *bindings.Encoder) error { - return fmt.Errorf("Trying to serialize an unknown Type. There is no sane way to do that!") + return fmt.Errorf("Trying to serialize an unknown Type. There is no sane way to do that!"); } -type TypeSimpleType struct{ Value SimpleType } - -func (u *TypeSimpleType) Tag() uint32 { return 0 } -func (u *TypeSimpleType) Interface() interface{} { return u.Value } +type TypeSimpleType struct { Value SimpleType } +func (u *TypeSimpleType) Tag() uint32 { return 0 } +func (u *TypeSimpleType) Interface() interface{} { return u.Value } func (u *TypeSimpleType) __Reflect(__TypeReflect) {} func (u *TypeSimpleType) Encode(encoder *bindings.Encoder) error { @@ -3547,7 +3648,7 @@ if err := encoder.WriteInt32(int32(u.Value)); err != nil { return err } - + encoder.FinishWritingUnionValue() return nil } @@ -3558,14 +3659,13 @@ return err } u.Value = SimpleType(value0) - + return nil } -type TypeStringType struct{ Value StringType } - -func (u *TypeStringType) Tag() uint32 { return 1 } -func (u *TypeStringType) Interface() interface{} { return u.Value } +type TypeStringType struct { Value StringType } +func (u *TypeStringType) Tag() uint32 { return 1 } +func (u *TypeStringType) Interface() interface{} { return u.Value } func (u *TypeStringType) __Reflect(__TypeReflect) {} func (u *TypeStringType) Encode(encoder *bindings.Encoder) error { @@ -3576,7 +3676,7 @@ if err := u.Value.Encode(encoder); err != nil { return err } - + encoder.FinishWritingUnionValue() return nil } @@ -3593,14 +3693,13 @@ return err } } - + return nil } -type TypeArrayType struct{ Value ArrayType } - -func (u *TypeArrayType) Tag() uint32 { return 2 } -func (u *TypeArrayType) Interface() interface{} { return u.Value } +type TypeArrayType struct { Value ArrayType } +func (u *TypeArrayType) Tag() uint32 { return 2 } +func (u *TypeArrayType) Interface() interface{} { return u.Value } func (u *TypeArrayType) __Reflect(__TypeReflect) {} func (u *TypeArrayType) Encode(encoder *bindings.Encoder) error { @@ -3611,7 +3710,7 @@ if err := u.Value.Encode(encoder); err != nil { return err } - + encoder.FinishWritingUnionValue() return nil } @@ -3628,14 +3727,13 @@ return err } } - + return nil } -type TypeMapType struct{ Value MapType } - -func (u *TypeMapType) Tag() uint32 { return 3 } -func (u *TypeMapType) Interface() interface{} { return u.Value } +type TypeMapType struct { Value MapType } +func (u *TypeMapType) Tag() uint32 { return 3 } +func (u *TypeMapType) Interface() interface{} { return u.Value } func (u *TypeMapType) __Reflect(__TypeReflect) {} func (u *TypeMapType) Encode(encoder *bindings.Encoder) error { @@ -3646,7 +3744,7 @@ if err := u.Value.Encode(encoder); err != nil { return err } - + encoder.FinishWritingUnionValue() return nil } @@ -3663,14 +3761,13 @@ return err } } - + return nil } -type TypeHandleType struct{ Value HandleType } - -func (u *TypeHandleType) Tag() uint32 { return 4 } -func (u *TypeHandleType) Interface() interface{} { return u.Value } +type TypeHandleType struct { Value HandleType } +func (u *TypeHandleType) Tag() uint32 { return 4 } +func (u *TypeHandleType) Interface() interface{} { return u.Value } func (u *TypeHandleType) __Reflect(__TypeReflect) {} func (u *TypeHandleType) Encode(encoder *bindings.Encoder) error { @@ -3681,7 +3778,7 @@ if err := u.Value.Encode(encoder); err != nil { return err } - + encoder.FinishWritingUnionValue() return nil } @@ -3698,14 +3795,13 @@ return err } } - + return nil } -type TypeTypeReference struct{ Value TypeReference } - -func (u *TypeTypeReference) Tag() uint32 { return 5 } -func (u *TypeTypeReference) Interface() interface{} { return u.Value } +type TypeTypeReference struct { Value TypeReference } +func (u *TypeTypeReference) Tag() uint32 { return 5 } +func (u *TypeTypeReference) Interface() interface{} { return u.Value } func (u *TypeTypeReference) __Reflect(__TypeReflect) {} func (u *TypeTypeReference) Encode(encoder *bindings.Encoder) error { @@ -3716,7 +3812,7 @@ if err := u.Value.Encode(encoder); err != nil { return err } - + encoder.FinishWritingUnionValue() return nil } @@ -3733,81 +3829,82 @@ return err } } - + return nil } + // String names and labels used by the MojomUnion types. var ( - unionName_Type = "Type" - unionFieldName_Type_SimpleType = "SimpleType" - unionFieldName_Type_StringType = "StringType" - unionFieldName_Type_ArrayType = "ArrayType" - unionFieldName_Type_MapType = "MapType" - unionFieldName_Type_HandleType = "HandleType" - unionFieldName_Type_TypeReference = "TypeReference" + unionName_Type = "Type" + unionFieldName_Type_SimpleType = "SimpleType" + unionFieldName_Type_StringType = "StringType" + unionFieldName_Type_ArrayType = "ArrayType" + unionFieldName_Type_MapType = "MapType" + unionFieldName_Type_HandleType = "HandleType" + unionFieldName_Type_TypeReference = "TypeReference" ) func mojom_types_Type__() MojomUnion { - return MojomUnion{ - DeclData: &DeclarationData{ - ShortName: &unionName_Type, - }, Fields: []UnionField{UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_Type_SimpleType, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_SimpleType__, - TypeKey: &ID_mojom_types_SimpleType__}, - }, - Tag: 0, - }, UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_Type_StringType, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_StringType__, - TypeKey: &ID_mojom_types_StringType__}, - }, - Tag: 1, - }, UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_Type_ArrayType, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_ArrayType__, - TypeKey: &ID_mojom_types_ArrayType__}, - }, - Tag: 2, - }, UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_Type_MapType, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_MapType__, - TypeKey: &ID_mojom_types_MapType__}, - }, - Tag: 3, - }, UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_Type_HandleType, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_HandleType__, - TypeKey: &ID_mojom_types_HandleType__}, - }, - Tag: 4, - }, UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_Type_TypeReference, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_TypeReference__, - TypeKey: &ID_mojom_types_TypeReference__}, - }, - Tag: 5, - }}, - } + return MojomUnion{ + DeclData: &DeclarationData{ + ShortName: &unionName_Type, + },Fields: []UnionField{UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_Type_SimpleType, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_SimpleType__, + TypeKey: &ID_mojom_types_SimpleType__,}, +}, + Tag: 0, + },UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_Type_StringType, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_StringType__, + TypeKey: &ID_mojom_types_StringType__,}, +}, + Tag: 1, + },UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_Type_ArrayType, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_ArrayType__, + TypeKey: &ID_mojom_types_ArrayType__,}, +}, + Tag: 2, + },UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_Type_MapType, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_MapType__, + TypeKey: &ID_mojom_types_MapType__,}, +}, + Tag: 3, + },UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_Type_HandleType, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_HandleType__, + TypeKey: &ID_mojom_types_HandleType__,}, +}, + Tag: 4, + },UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_Type_TypeReference, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_TypeReference__, + TypeKey: &ID_mojom_types_TypeReference__,}, +}, + Tag: 5, + },}, + } } type UserDefinedType interface { @@ -3818,9 +3915,9 @@ } type __UserDefinedTypeReflect struct { - EnumType MojomEnum - StructType MojomStruct - UnionType MojomUnion + EnumType MojomEnum + StructType MojomStruct + UnionType MojomUnion InterfaceType MojomInterface } @@ -3870,20 +3967,18 @@ return &UserDefinedTypeUnknown{tag: tag}, nil } -type UserDefinedTypeUnknown struct{ tag uint32 } - -func (u *UserDefinedTypeUnknown) Tag() uint32 { return u.tag } -func (u *UserDefinedTypeUnknown) Interface() interface{} { return nil } +type UserDefinedTypeUnknown struct { tag uint32 } +func (u *UserDefinedTypeUnknown) Tag() uint32 { return u.tag } +func (u *UserDefinedTypeUnknown) Interface() interface{} { return nil } func (u *UserDefinedTypeUnknown) __Reflect(__UserDefinedTypeReflect) {} func (u *UserDefinedTypeUnknown) Encode(encoder *bindings.Encoder) error { - return fmt.Errorf("Trying to serialize an unknown UserDefinedType. There is no sane way to do that!") + return fmt.Errorf("Trying to serialize an unknown UserDefinedType. There is no sane way to do that!"); } -type UserDefinedTypeEnumType struct{ Value MojomEnum } - -func (u *UserDefinedTypeEnumType) Tag() uint32 { return 0 } -func (u *UserDefinedTypeEnumType) Interface() interface{} { return u.Value } +type UserDefinedTypeEnumType struct { Value MojomEnum } +func (u *UserDefinedTypeEnumType) Tag() uint32 { return 0 } +func (u *UserDefinedTypeEnumType) Interface() interface{} { return u.Value } func (u *UserDefinedTypeEnumType) __Reflect(__UserDefinedTypeReflect) {} func (u *UserDefinedTypeEnumType) Encode(encoder *bindings.Encoder) error { @@ -3894,7 +3989,7 @@ if err := u.Value.Encode(encoder); err != nil { return err } - + encoder.FinishWritingUnionValue() return nil } @@ -3911,14 +4006,13 @@ return err } } - + return nil } -type UserDefinedTypeStructType struct{ Value MojomStruct } - -func (u *UserDefinedTypeStructType) Tag() uint32 { return 1 } -func (u *UserDefinedTypeStructType) Interface() interface{} { return u.Value } +type UserDefinedTypeStructType struct { Value MojomStruct } +func (u *UserDefinedTypeStructType) Tag() uint32 { return 1 } +func (u *UserDefinedTypeStructType) Interface() interface{} { return u.Value } func (u *UserDefinedTypeStructType) __Reflect(__UserDefinedTypeReflect) {} func (u *UserDefinedTypeStructType) Encode(encoder *bindings.Encoder) error { @@ -3929,7 +4023,7 @@ if err := u.Value.Encode(encoder); err != nil { return err } - + encoder.FinishWritingUnionValue() return nil } @@ -3946,14 +4040,13 @@ return err } } - + return nil } -type UserDefinedTypeUnionType struct{ Value MojomUnion } - -func (u *UserDefinedTypeUnionType) Tag() uint32 { return 2 } -func (u *UserDefinedTypeUnionType) Interface() interface{} { return u.Value } +type UserDefinedTypeUnionType struct { Value MojomUnion } +func (u *UserDefinedTypeUnionType) Tag() uint32 { return 2 } +func (u *UserDefinedTypeUnionType) Interface() interface{} { return u.Value } func (u *UserDefinedTypeUnionType) __Reflect(__UserDefinedTypeReflect) {} func (u *UserDefinedTypeUnionType) Encode(encoder *bindings.Encoder) error { @@ -3964,7 +4057,7 @@ if err := u.Value.Encode(encoder); err != nil { return err } - + encoder.FinishWritingUnionValue() return nil } @@ -3981,14 +4074,13 @@ return err } } - + return nil } -type UserDefinedTypeInterfaceType struct{ Value MojomInterface } - -func (u *UserDefinedTypeInterfaceType) Tag() uint32 { return 3 } -func (u *UserDefinedTypeInterfaceType) Interface() interface{} { return u.Value } +type UserDefinedTypeInterfaceType struct { Value MojomInterface } +func (u *UserDefinedTypeInterfaceType) Tag() uint32 { return 3 } +func (u *UserDefinedTypeInterfaceType) Interface() interface{} { return u.Value } func (u *UserDefinedTypeInterfaceType) __Reflect(__UserDefinedTypeReflect) {} func (u *UserDefinedTypeInterfaceType) Encode(encoder *bindings.Encoder) error { @@ -3999,7 +4091,7 @@ if err := u.Value.Encode(encoder); err != nil { return err } - + encoder.FinishWritingUnionValue() return nil } @@ -4016,61 +4108,62 @@ return err } } - + return nil } + // String names and labels used by the MojomUnion types. var ( - unionName_UserDefinedType = "UserDefinedType" - unionFieldName_UserDefinedType_EnumType = "EnumType" - unionFieldName_UserDefinedType_StructType = "StructType" - unionFieldName_UserDefinedType_UnionType = "UnionType" - unionFieldName_UserDefinedType_InterfaceType = "InterfaceType" + unionName_UserDefinedType = "UserDefinedType" + unionFieldName_UserDefinedType_EnumType = "EnumType" + unionFieldName_UserDefinedType_StructType = "StructType" + unionFieldName_UserDefinedType_UnionType = "UnionType" + unionFieldName_UserDefinedType_InterfaceType = "InterfaceType" ) func mojom_types_UserDefinedType__() MojomUnion { - return MojomUnion{ - DeclData: &DeclarationData{ - ShortName: &unionName_UserDefinedType, - }, Fields: []UnionField{UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_UserDefinedType_EnumType, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_MojomEnum__, - TypeKey: &ID_mojom_types_MojomEnum__}, - }, - Tag: 0, - }, UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_UserDefinedType_StructType, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_MojomStruct__, - TypeKey: &ID_mojom_types_MojomStruct__}, - }, - Tag: 1, - }, UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_UserDefinedType_UnionType, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_MojomUnion__, - TypeKey: &ID_mojom_types_MojomUnion__}, - }, - Tag: 2, - }, UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_UserDefinedType_InterfaceType, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_MojomInterface__, - TypeKey: &ID_mojom_types_MojomInterface__}, - }, - Tag: 3, - }}, - } + return MojomUnion{ + DeclData: &DeclarationData{ + ShortName: &unionName_UserDefinedType, + },Fields: []UnionField{UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_UserDefinedType_EnumType, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_MojomEnum__, + TypeKey: &ID_mojom_types_MojomEnum__,}, +}, + Tag: 0, + },UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_UserDefinedType_StructType, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_MojomStruct__, + TypeKey: &ID_mojom_types_MojomStruct__,}, +}, + Tag: 1, + },UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_UserDefinedType_UnionType, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_MojomUnion__, + TypeKey: &ID_mojom_types_MojomUnion__,}, +}, + Tag: 2, + },UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_UserDefinedType_InterfaceType, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_MojomInterface__, + TypeKey: &ID_mojom_types_MojomInterface__,}, +}, + Tag: 3, + },}, + } } type DefaultFieldValue interface { @@ -4081,7 +4174,7 @@ } type __DefaultFieldValueReflect struct { - Value Value + Value Value DefaultKeyword DefaultKeyword } @@ -4117,20 +4210,18 @@ return &DefaultFieldValueUnknown{tag: tag}, nil } -type DefaultFieldValueUnknown struct{ tag uint32 } - -func (u *DefaultFieldValueUnknown) Tag() uint32 { return u.tag } -func (u *DefaultFieldValueUnknown) Interface() interface{} { return nil } +type DefaultFieldValueUnknown struct { tag uint32 } +func (u *DefaultFieldValueUnknown) Tag() uint32 { return u.tag } +func (u *DefaultFieldValueUnknown) Interface() interface{} { return nil } func (u *DefaultFieldValueUnknown) __Reflect(__DefaultFieldValueReflect) {} func (u *DefaultFieldValueUnknown) Encode(encoder *bindings.Encoder) error { - return fmt.Errorf("Trying to serialize an unknown DefaultFieldValue. There is no sane way to do that!") + return fmt.Errorf("Trying to serialize an unknown DefaultFieldValue. There is no sane way to do that!"); } -type DefaultFieldValueValue struct{ Value Value } - -func (u *DefaultFieldValueValue) Tag() uint32 { return 0 } -func (u *DefaultFieldValueValue) Interface() interface{} { return u.Value } +type DefaultFieldValueValue struct { Value Value } +func (u *DefaultFieldValueValue) Tag() uint32 { return 0 } +func (u *DefaultFieldValueValue) Interface() interface{} { return u.Value } func (u *DefaultFieldValueValue) __Reflect(__DefaultFieldValueReflect) {} func (u *DefaultFieldValueValue) Encode(encoder *bindings.Encoder) error { @@ -4138,7 +4229,7 @@ if err := encoder.WritePointer(); err != nil { return err } - + encoder.StartNestedUnion() if u.Value == nil { return &bindings.ValidationError{bindings.UnexpectedNullUnion, "unexpected null union"} @@ -4146,7 +4237,7 @@ if err := u.Value.Encode(encoder); err != nil { return err } - + encoder.Finish() encoder.FinishWritingUnionValue() return nil @@ -4159,11 +4250,11 @@ } return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null union pointer"} } - + if err := decoder.StartNestedUnion(); err != nil { return err } - + var err error u.Value, err = DecodeValue(decoder) if err != nil { @@ -4172,15 +4263,15 @@ if u.Value == nil { return &bindings.ValidationError{bindings.UnexpectedNullUnion, "unexpected null union"} } - + + decoder.Finish() return nil } -type DefaultFieldValueDefaultKeyword struct{ Value DefaultKeyword } - -func (u *DefaultFieldValueDefaultKeyword) Tag() uint32 { return 1 } -func (u *DefaultFieldValueDefaultKeyword) Interface() interface{} { return u.Value } +type DefaultFieldValueDefaultKeyword struct { Value DefaultKeyword } +func (u *DefaultFieldValueDefaultKeyword) Tag() uint32 { return 1 } +func (u *DefaultFieldValueDefaultKeyword) Interface() interface{} { return u.Value } func (u *DefaultFieldValueDefaultKeyword) __Reflect(__DefaultFieldValueReflect) {} func (u *DefaultFieldValueDefaultKeyword) Encode(encoder *bindings.Encoder) error { @@ -4191,7 +4282,7 @@ if err := u.Value.Encode(encoder); err != nil { return err } - + encoder.FinishWritingUnionValue() return nil } @@ -4208,41 +4299,42 @@ return err } } - + return nil } + // String names and labels used by the MojomUnion types. var ( - unionName_DefaultFieldValue = "DefaultFieldValue" - unionFieldName_DefaultFieldValue_Value = "Value" - unionFieldName_DefaultFieldValue_DefaultKeyword = "DefaultKeyword" + unionName_DefaultFieldValue = "DefaultFieldValue" + unionFieldName_DefaultFieldValue_Value = "Value" + unionFieldName_DefaultFieldValue_DefaultKeyword = "DefaultKeyword" ) func mojom_types_DefaultFieldValue__() MojomUnion { - return MojomUnion{ - DeclData: &DeclarationData{ - ShortName: &unionName_DefaultFieldValue, - }, Fields: []UnionField{UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_DefaultFieldValue_Value, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_Value__, - TypeKey: &ID_mojom_types_Value__}, - }, - Tag: 0, - }, UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_DefaultFieldValue_DefaultKeyword, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_DefaultKeyword__, - TypeKey: &ID_mojom_types_DefaultKeyword__}, - }, - Tag: 1, - }}, - } + return MojomUnion{ + DeclData: &DeclarationData{ + ShortName: &unionName_DefaultFieldValue, + },Fields: []UnionField{UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_DefaultFieldValue_Value, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_Value__, + TypeKey: &ID_mojom_types_Value__,}, +}, + Tag: 0, + },UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_DefaultFieldValue_DefaultKeyword, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_DefaultKeyword__, + TypeKey: &ID_mojom_types_DefaultKeyword__,}, +}, + Tag: 1, + },}, + } } type Value interface { @@ -4253,9 +4345,9 @@ } type __ValueReflect struct { - LiteralValue LiteralValue + LiteralValue LiteralValue UserValueReference UserValueReference - BuiltinValue BuiltinConstantValue + BuiltinValue BuiltinConstantValue } func DecodeValue(decoder *bindings.Decoder) (Value, error) { @@ -4297,20 +4389,18 @@ return &ValueUnknown{tag: tag}, nil } -type ValueUnknown struct{ tag uint32 } - -func (u *ValueUnknown) Tag() uint32 { return u.tag } -func (u *ValueUnknown) Interface() interface{} { return nil } +type ValueUnknown struct { tag uint32 } +func (u *ValueUnknown) Tag() uint32 { return u.tag } +func (u *ValueUnknown) Interface() interface{} { return nil } func (u *ValueUnknown) __Reflect(__ValueReflect) {} func (u *ValueUnknown) Encode(encoder *bindings.Encoder) error { - return fmt.Errorf("Trying to serialize an unknown Value. There is no sane way to do that!") + return fmt.Errorf("Trying to serialize an unknown Value. There is no sane way to do that!"); } -type ValueLiteralValue struct{ Value LiteralValue } - -func (u *ValueLiteralValue) Tag() uint32 { return 0 } -func (u *ValueLiteralValue) Interface() interface{} { return u.Value } +type ValueLiteralValue struct { Value LiteralValue } +func (u *ValueLiteralValue) Tag() uint32 { return 0 } +func (u *ValueLiteralValue) Interface() interface{} { return u.Value } func (u *ValueLiteralValue) __Reflect(__ValueReflect) {} func (u *ValueLiteralValue) Encode(encoder *bindings.Encoder) error { @@ -4318,7 +4408,7 @@ if err := encoder.WritePointer(); err != nil { return err } - + encoder.StartNestedUnion() if u.Value == nil { return &bindings.ValidationError{bindings.UnexpectedNullUnion, "unexpected null union"} @@ -4326,7 +4416,7 @@ if err := u.Value.Encode(encoder); err != nil { return err } - + encoder.Finish() encoder.FinishWritingUnionValue() return nil @@ -4339,11 +4429,11 @@ } return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null union pointer"} } - + if err := decoder.StartNestedUnion(); err != nil { return err } - + var err error u.Value, err = DecodeLiteralValue(decoder) if err != nil { @@ -4352,15 +4442,15 @@ if u.Value == nil { return &bindings.ValidationError{bindings.UnexpectedNullUnion, "unexpected null union"} } - + + decoder.Finish() return nil } -type ValueUserValueReference struct{ Value UserValueReference } - -func (u *ValueUserValueReference) Tag() uint32 { return 1 } -func (u *ValueUserValueReference) Interface() interface{} { return u.Value } +type ValueUserValueReference struct { Value UserValueReference } +func (u *ValueUserValueReference) Tag() uint32 { return 1 } +func (u *ValueUserValueReference) Interface() interface{} { return u.Value } func (u *ValueUserValueReference) __Reflect(__ValueReflect) {} func (u *ValueUserValueReference) Encode(encoder *bindings.Encoder) error { @@ -4371,7 +4461,7 @@ if err := u.Value.Encode(encoder); err != nil { return err } - + encoder.FinishWritingUnionValue() return nil } @@ -4388,14 +4478,13 @@ return err } } - + return nil } -type ValueBuiltinValue struct{ Value BuiltinConstantValue } - -func (u *ValueBuiltinValue) Tag() uint32 { return 2 } -func (u *ValueBuiltinValue) Interface() interface{} { return u.Value } +type ValueBuiltinValue struct { Value BuiltinConstantValue } +func (u *ValueBuiltinValue) Tag() uint32 { return 2 } +func (u *ValueBuiltinValue) Interface() interface{} { return u.Value } func (u *ValueBuiltinValue) __Reflect(__ValueReflect) {} func (u *ValueBuiltinValue) Encode(encoder *bindings.Encoder) error { @@ -4403,7 +4492,7 @@ if err := encoder.WriteInt32(int32(u.Value)); err != nil { return err } - + encoder.FinishWritingUnionValue() return nil } @@ -4414,51 +4503,52 @@ return err } u.Value = BuiltinConstantValue(value0) - + return nil } + // String names and labels used by the MojomUnion types. var ( - unionName_Value = "Value" - unionFieldName_Value_LiteralValue = "LiteralValue" - unionFieldName_Value_UserValueReference = "UserValueReference" - unionFieldName_Value_BuiltinValue = "BuiltinValue" + unionName_Value = "Value" + unionFieldName_Value_LiteralValue = "LiteralValue" + unionFieldName_Value_UserValueReference = "UserValueReference" + unionFieldName_Value_BuiltinValue = "BuiltinValue" ) func mojom_types_Value__() MojomUnion { - return MojomUnion{ - DeclData: &DeclarationData{ - ShortName: &unionName_Value, - }, Fields: []UnionField{UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_Value_LiteralValue, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_LiteralValue__, - TypeKey: &ID_mojom_types_LiteralValue__}, - }, - Tag: 0, - }, UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_Value_UserValueReference, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_UserValueReference__, - TypeKey: &ID_mojom_types_UserValueReference__}, - }, - Tag: 1, - }, UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_Value_BuiltinValue, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_BuiltinConstantValue__, - TypeKey: &ID_mojom_types_BuiltinConstantValue__}, - }, - Tag: 2, - }}, - } + return MojomUnion{ + DeclData: &DeclarationData{ + ShortName: &unionName_Value, + },Fields: []UnionField{UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_Value_LiteralValue, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_LiteralValue__, + TypeKey: &ID_mojom_types_LiteralValue__,}, +}, + Tag: 0, + },UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_Value_UserValueReference, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_UserValueReference__, + TypeKey: &ID_mojom_types_UserValueReference__,}, +}, + Tag: 1, + },UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_Value_BuiltinValue, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_BuiltinConstantValue__, + TypeKey: &ID_mojom_types_BuiltinConstantValue__,}, +}, + Tag: 2, + },}, + } } type LiteralValue interface { @@ -4469,15 +4559,15 @@ } type __LiteralValueReflect struct { - BoolValue bool + BoolValue bool DoubleValue float64 - FloatValue float32 - Int8Value int8 - Int16Value int16 - Int32Value int32 - Int64Value int64 + FloatValue float32 + Int8Value int8 + Int16Value int16 + Int32Value int32 + Int64Value int64 StringValue string - Uint8Value uint8 + Uint8Value uint8 Uint16Value uint16 Uint32Value uint32 Uint64Value uint64 @@ -4585,20 +4675,18 @@ return &LiteralValueUnknown{tag: tag}, nil } -type LiteralValueUnknown struct{ tag uint32 } - -func (u *LiteralValueUnknown) Tag() uint32 { return u.tag } -func (u *LiteralValueUnknown) Interface() interface{} { return nil } +type LiteralValueUnknown struct { tag uint32 } +func (u *LiteralValueUnknown) Tag() uint32 { return u.tag } +func (u *LiteralValueUnknown) Interface() interface{} { return nil } func (u *LiteralValueUnknown) __Reflect(__LiteralValueReflect) {} func (u *LiteralValueUnknown) Encode(encoder *bindings.Encoder) error { - return fmt.Errorf("Trying to serialize an unknown LiteralValue. There is no sane way to do that!") + return fmt.Errorf("Trying to serialize an unknown LiteralValue. There is no sane way to do that!"); } -type LiteralValueBoolValue struct{ Value bool } - -func (u *LiteralValueBoolValue) Tag() uint32 { return 0 } -func (u *LiteralValueBoolValue) Interface() interface{} { return u.Value } +type LiteralValueBoolValue struct { Value bool } +func (u *LiteralValueBoolValue) Tag() uint32 { return 0 } +func (u *LiteralValueBoolValue) Interface() interface{} { return u.Value } func (u *LiteralValueBoolValue) __Reflect(__LiteralValueReflect) {} func (u *LiteralValueBoolValue) Encode(encoder *bindings.Encoder) error { @@ -4606,7 +4694,7 @@ if err := encoder.WriteBool(u.Value); err != nil { return err } - + encoder.FinishWritingUnionValue() return nil } @@ -4617,14 +4705,13 @@ return err } u.Value = value0 - + return nil } -type LiteralValueDoubleValue struct{ Value float64 } - -func (u *LiteralValueDoubleValue) Tag() uint32 { return 1 } -func (u *LiteralValueDoubleValue) Interface() interface{} { return u.Value } +type LiteralValueDoubleValue struct { Value float64 } +func (u *LiteralValueDoubleValue) Tag() uint32 { return 1 } +func (u *LiteralValueDoubleValue) Interface() interface{} { return u.Value } func (u *LiteralValueDoubleValue) __Reflect(__LiteralValueReflect) {} func (u *LiteralValueDoubleValue) Encode(encoder *bindings.Encoder) error { @@ -4632,7 +4719,7 @@ if err := encoder.WriteFloat64(u.Value); err != nil { return err } - + encoder.FinishWritingUnionValue() return nil } @@ -4643,14 +4730,13 @@ return err } u.Value = value0 - + return nil } -type LiteralValueFloatValue struct{ Value float32 } - -func (u *LiteralValueFloatValue) Tag() uint32 { return 2 } -func (u *LiteralValueFloatValue) Interface() interface{} { return u.Value } +type LiteralValueFloatValue struct { Value float32 } +func (u *LiteralValueFloatValue) Tag() uint32 { return 2 } +func (u *LiteralValueFloatValue) Interface() interface{} { return u.Value } func (u *LiteralValueFloatValue) __Reflect(__LiteralValueReflect) {} func (u *LiteralValueFloatValue) Encode(encoder *bindings.Encoder) error { @@ -4658,7 +4744,7 @@ if err := encoder.WriteFloat32(u.Value); err != nil { return err } - + encoder.FinishWritingUnionValue() return nil } @@ -4669,14 +4755,13 @@ return err } u.Value = value0 - + return nil } -type LiteralValueInt8Value struct{ Value int8 } - -func (u *LiteralValueInt8Value) Tag() uint32 { return 3 } -func (u *LiteralValueInt8Value) Interface() interface{} { return u.Value } +type LiteralValueInt8Value struct { Value int8 } +func (u *LiteralValueInt8Value) Tag() uint32 { return 3 } +func (u *LiteralValueInt8Value) Interface() interface{} { return u.Value } func (u *LiteralValueInt8Value) __Reflect(__LiteralValueReflect) {} func (u *LiteralValueInt8Value) Encode(encoder *bindings.Encoder) error { @@ -4684,7 +4769,7 @@ if err := encoder.WriteInt8(u.Value); err != nil { return err } - + encoder.FinishWritingUnionValue() return nil } @@ -4695,14 +4780,13 @@ return err } u.Value = value0 - + return nil } -type LiteralValueInt16Value struct{ Value int16 } - -func (u *LiteralValueInt16Value) Tag() uint32 { return 4 } -func (u *LiteralValueInt16Value) Interface() interface{} { return u.Value } +type LiteralValueInt16Value struct { Value int16 } +func (u *LiteralValueInt16Value) Tag() uint32 { return 4 } +func (u *LiteralValueInt16Value) Interface() interface{} { return u.Value } func (u *LiteralValueInt16Value) __Reflect(__LiteralValueReflect) {} func (u *LiteralValueInt16Value) Encode(encoder *bindings.Encoder) error { @@ -4710,7 +4794,7 @@ if err := encoder.WriteInt16(u.Value); err != nil { return err } - + encoder.FinishWritingUnionValue() return nil } @@ -4721,14 +4805,13 @@ return err } u.Value = value0 - + return nil } -type LiteralValueInt32Value struct{ Value int32 } - -func (u *LiteralValueInt32Value) Tag() uint32 { return 5 } -func (u *LiteralValueInt32Value) Interface() interface{} { return u.Value } +type LiteralValueInt32Value struct { Value int32 } +func (u *LiteralValueInt32Value) Tag() uint32 { return 5 } +func (u *LiteralValueInt32Value) Interface() interface{} { return u.Value } func (u *LiteralValueInt32Value) __Reflect(__LiteralValueReflect) {} func (u *LiteralValueInt32Value) Encode(encoder *bindings.Encoder) error { @@ -4736,7 +4819,7 @@ if err := encoder.WriteInt32(u.Value); err != nil { return err } - + encoder.FinishWritingUnionValue() return nil } @@ -4747,14 +4830,13 @@ return err } u.Value = value0 - + return nil } -type LiteralValueInt64Value struct{ Value int64 } - -func (u *LiteralValueInt64Value) Tag() uint32 { return 6 } -func (u *LiteralValueInt64Value) Interface() interface{} { return u.Value } +type LiteralValueInt64Value struct { Value int64 } +func (u *LiteralValueInt64Value) Tag() uint32 { return 6 } +func (u *LiteralValueInt64Value) Interface() interface{} { return u.Value } func (u *LiteralValueInt64Value) __Reflect(__LiteralValueReflect) {} func (u *LiteralValueInt64Value) Encode(encoder *bindings.Encoder) error { @@ -4762,7 +4844,7 @@ if err := encoder.WriteInt64(u.Value); err != nil { return err } - + encoder.FinishWritingUnionValue() return nil } @@ -4773,14 +4855,13 @@ return err } u.Value = value0 - + return nil } -type LiteralValueStringValue struct{ Value string } - -func (u *LiteralValueStringValue) Tag() uint32 { return 7 } -func (u *LiteralValueStringValue) Interface() interface{} { return u.Value } +type LiteralValueStringValue struct { Value string } +func (u *LiteralValueStringValue) Tag() uint32 { return 7 } +func (u *LiteralValueStringValue) Interface() interface{} { return u.Value } func (u *LiteralValueStringValue) __Reflect(__LiteralValueReflect) {} func (u *LiteralValueStringValue) Encode(encoder *bindings.Encoder) error { @@ -4791,7 +4872,7 @@ if err := encoder.WriteString(u.Value); err != nil { return err } - + encoder.FinishWritingUnionValue() return nil } @@ -4810,14 +4891,13 @@ } u.Value = value0 } - + return nil } -type LiteralValueUint8Value struct{ Value uint8 } - -func (u *LiteralValueUint8Value) Tag() uint32 { return 8 } -func (u *LiteralValueUint8Value) Interface() interface{} { return u.Value } +type LiteralValueUint8Value struct { Value uint8 } +func (u *LiteralValueUint8Value) Tag() uint32 { return 8 } +func (u *LiteralValueUint8Value) Interface() interface{} { return u.Value } func (u *LiteralValueUint8Value) __Reflect(__LiteralValueReflect) {} func (u *LiteralValueUint8Value) Encode(encoder *bindings.Encoder) error { @@ -4825,7 +4905,7 @@ if err := encoder.WriteUint8(u.Value); err != nil { return err } - + encoder.FinishWritingUnionValue() return nil } @@ -4836,14 +4916,13 @@ return err } u.Value = value0 - + return nil } -type LiteralValueUint16Value struct{ Value uint16 } - -func (u *LiteralValueUint16Value) Tag() uint32 { return 9 } -func (u *LiteralValueUint16Value) Interface() interface{} { return u.Value } +type LiteralValueUint16Value struct { Value uint16 } +func (u *LiteralValueUint16Value) Tag() uint32 { return 9 } +func (u *LiteralValueUint16Value) Interface() interface{} { return u.Value } func (u *LiteralValueUint16Value) __Reflect(__LiteralValueReflect) {} func (u *LiteralValueUint16Value) Encode(encoder *bindings.Encoder) error { @@ -4851,7 +4930,7 @@ if err := encoder.WriteUint16(u.Value); err != nil { return err } - + encoder.FinishWritingUnionValue() return nil } @@ -4862,14 +4941,13 @@ return err } u.Value = value0 - + return nil } -type LiteralValueUint32Value struct{ Value uint32 } - -func (u *LiteralValueUint32Value) Tag() uint32 { return 10 } -func (u *LiteralValueUint32Value) Interface() interface{} { return u.Value } +type LiteralValueUint32Value struct { Value uint32 } +func (u *LiteralValueUint32Value) Tag() uint32 { return 10 } +func (u *LiteralValueUint32Value) Interface() interface{} { return u.Value } func (u *LiteralValueUint32Value) __Reflect(__LiteralValueReflect) {} func (u *LiteralValueUint32Value) Encode(encoder *bindings.Encoder) error { @@ -4877,7 +4955,7 @@ if err := encoder.WriteUint32(u.Value); err != nil { return err } - + encoder.FinishWritingUnionValue() return nil } @@ -4888,14 +4966,13 @@ return err } u.Value = value0 - + return nil } -type LiteralValueUint64Value struct{ Value uint64 } - -func (u *LiteralValueUint64Value) Tag() uint32 { return 11 } -func (u *LiteralValueUint64Value) Interface() interface{} { return u.Value } +type LiteralValueUint64Value struct { Value uint64 } +func (u *LiteralValueUint64Value) Tag() uint32 { return 11 } +func (u *LiteralValueUint64Value) Interface() interface{} { return u.Value } func (u *LiteralValueUint64Value) __Reflect(__LiteralValueReflect) {} func (u *LiteralValueUint64Value) Encode(encoder *bindings.Encoder) error { @@ -4903,7 +4980,7 @@ if err := encoder.WriteUint64(u.Value); err != nil { return err } - + encoder.FinishWritingUnionValue() return nil } @@ -4914,105 +4991,106 @@ return err } u.Value = value0 - + return nil } + // String names and labels used by the MojomUnion types. var ( - unionName_LiteralValue = "LiteralValue" - unionFieldName_LiteralValue_BoolValue = "BoolValue" - unionFieldName_LiteralValue_DoubleValue = "DoubleValue" - unionFieldName_LiteralValue_FloatValue = "FloatValue" - unionFieldName_LiteralValue_Int8Value = "Int8Value" - unionFieldName_LiteralValue_Int16Value = "Int16Value" - unionFieldName_LiteralValue_Int32Value = "Int32Value" - unionFieldName_LiteralValue_Int64Value = "Int64Value" - unionFieldName_LiteralValue_StringValue = "StringValue" - unionFieldName_LiteralValue_Uint8Value = "Uint8Value" - unionFieldName_LiteralValue_Uint16Value = "Uint16Value" - unionFieldName_LiteralValue_Uint32Value = "Uint32Value" - unionFieldName_LiteralValue_Uint64Value = "Uint64Value" + unionName_LiteralValue = "LiteralValue" + unionFieldName_LiteralValue_BoolValue = "BoolValue" + unionFieldName_LiteralValue_DoubleValue = "DoubleValue" + unionFieldName_LiteralValue_FloatValue = "FloatValue" + unionFieldName_LiteralValue_Int8Value = "Int8Value" + unionFieldName_LiteralValue_Int16Value = "Int16Value" + unionFieldName_LiteralValue_Int32Value = "Int32Value" + unionFieldName_LiteralValue_Int64Value = "Int64Value" + unionFieldName_LiteralValue_StringValue = "StringValue" + unionFieldName_LiteralValue_Uint8Value = "Uint8Value" + unionFieldName_LiteralValue_Uint16Value = "Uint16Value" + unionFieldName_LiteralValue_Uint32Value = "Uint32Value" + unionFieldName_LiteralValue_Uint64Value = "Uint64Value" ) func mojom_types_LiteralValue__() MojomUnion { - return MojomUnion{ - DeclData: &DeclarationData{ - ShortName: &unionName_LiteralValue, - }, Fields: []UnionField{UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_LiteralValue_BoolValue, - }, - Type: &TypeSimpleType{SimpleType_Bool}, - Tag: 0, - }, UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_LiteralValue_DoubleValue, - }, - Type: &TypeSimpleType{SimpleType_Double}, - Tag: 1, - }, UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_LiteralValue_FloatValue, - }, - Type: &TypeSimpleType{SimpleType_Float}, - Tag: 2, - }, UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_LiteralValue_Int8Value, - }, - Type: &TypeSimpleType{SimpleType_InT8}, - Tag: 3, - }, UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_LiteralValue_Int16Value, - }, - Type: &TypeSimpleType{SimpleType_InT16}, - Tag: 4, - }, UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_LiteralValue_Int32Value, - }, - Type: &TypeSimpleType{SimpleType_InT32}, - Tag: 5, - }, UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_LiteralValue_Int64Value, - }, - Type: &TypeSimpleType{SimpleType_InT64}, - Tag: 6, - }, UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_LiteralValue_StringValue, - }, - Type: &TypeStringType{StringType{false}}, - Tag: 7, - }, UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_LiteralValue_Uint8Value, - }, - Type: &TypeSimpleType{SimpleType_UinT8}, - Tag: 8, - }, UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_LiteralValue_Uint16Value, - }, - Type: &TypeSimpleType{SimpleType_UinT16}, - Tag: 9, - }, UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_LiteralValue_Uint32Value, - }, - Type: &TypeSimpleType{SimpleType_UinT32}, - Tag: 10, - }, UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_LiteralValue_Uint64Value, - }, - Type: &TypeSimpleType{SimpleType_UinT64}, - Tag: 11, - }}, - } + return MojomUnion{ + DeclData: &DeclarationData{ + ShortName: &unionName_LiteralValue, + },Fields: []UnionField{UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_LiteralValue_BoolValue, + }, + Type: &TypeSimpleType{SimpleType_Bool}, + Tag: 0, + },UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_LiteralValue_DoubleValue, + }, + Type: &TypeSimpleType{SimpleType_Double}, + Tag: 1, + },UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_LiteralValue_FloatValue, + }, + Type: &TypeSimpleType{SimpleType_Float}, + Tag: 2, + },UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_LiteralValue_Int8Value, + }, + Type: &TypeSimpleType{SimpleType_InT8}, + Tag: 3, + },UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_LiteralValue_Int16Value, + }, + Type: &TypeSimpleType{SimpleType_InT16}, + Tag: 4, + },UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_LiteralValue_Int32Value, + }, + Type: &TypeSimpleType{SimpleType_InT32}, + Tag: 5, + },UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_LiteralValue_Int64Value, + }, + Type: &TypeSimpleType{SimpleType_InT64}, + Tag: 6, + },UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_LiteralValue_StringValue, + }, + Type: &TypeStringType{StringType{false}}, + Tag: 7, + },UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_LiteralValue_Uint8Value, + }, + Type: &TypeSimpleType{SimpleType_UinT8}, + Tag: 8, + },UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_LiteralValue_Uint16Value, + }, + Type: &TypeSimpleType{SimpleType_UinT16}, + Tag: 9, + },UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_LiteralValue_Uint32Value, + }, + Type: &TypeSimpleType{SimpleType_UinT32}, + Tag: 10, + },UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_LiteralValue_Uint64Value, + }, + Type: &TypeSimpleType{SimpleType_UinT64}, + Tag: 11, + },}, + } } type UserDefinedValue interface { @@ -5023,7 +5101,7 @@ } type __UserDefinedValueReflect struct { - EnumValue EnumValue + EnumValue EnumValue DeclaredConstant DeclaredConstant } @@ -5059,20 +5137,18 @@ return &UserDefinedValueUnknown{tag: tag}, nil } -type UserDefinedValueUnknown struct{ tag uint32 } - -func (u *UserDefinedValueUnknown) Tag() uint32 { return u.tag } -func (u *UserDefinedValueUnknown) Interface() interface{} { return nil } +type UserDefinedValueUnknown struct { tag uint32 } +func (u *UserDefinedValueUnknown) Tag() uint32 { return u.tag } +func (u *UserDefinedValueUnknown) Interface() interface{} { return nil } func (u *UserDefinedValueUnknown) __Reflect(__UserDefinedValueReflect) {} func (u *UserDefinedValueUnknown) Encode(encoder *bindings.Encoder) error { - return fmt.Errorf("Trying to serialize an unknown UserDefinedValue. There is no sane way to do that!") + return fmt.Errorf("Trying to serialize an unknown UserDefinedValue. There is no sane way to do that!"); } -type UserDefinedValueEnumValue struct{ Value EnumValue } - -func (u *UserDefinedValueEnumValue) Tag() uint32 { return 0 } -func (u *UserDefinedValueEnumValue) Interface() interface{} { return u.Value } +type UserDefinedValueEnumValue struct { Value EnumValue } +func (u *UserDefinedValueEnumValue) Tag() uint32 { return 0 } +func (u *UserDefinedValueEnumValue) Interface() interface{} { return u.Value } func (u *UserDefinedValueEnumValue) __Reflect(__UserDefinedValueReflect) {} func (u *UserDefinedValueEnumValue) Encode(encoder *bindings.Encoder) error { @@ -5083,7 +5159,7 @@ if err := u.Value.Encode(encoder); err != nil { return err } - + encoder.FinishWritingUnionValue() return nil } @@ -5100,14 +5176,13 @@ return err } } - + return nil } -type UserDefinedValueDeclaredConstant struct{ Value DeclaredConstant } - -func (u *UserDefinedValueDeclaredConstant) Tag() uint32 { return 1 } -func (u *UserDefinedValueDeclaredConstant) Interface() interface{} { return u.Value } +type UserDefinedValueDeclaredConstant struct { Value DeclaredConstant } +func (u *UserDefinedValueDeclaredConstant) Tag() uint32 { return 1 } +func (u *UserDefinedValueDeclaredConstant) Interface() interface{} { return u.Value } func (u *UserDefinedValueDeclaredConstant) __Reflect(__UserDefinedValueReflect) {} func (u *UserDefinedValueDeclaredConstant) Encode(encoder *bindings.Encoder) error { @@ -5118,7 +5193,7 @@ if err := u.Value.Encode(encoder); err != nil { return err } - + encoder.FinishWritingUnionValue() return nil } @@ -5135,39 +5210,41 @@ return err } } - + return nil } + // String names and labels used by the MojomUnion types. var ( - unionName_UserDefinedValue = "UserDefinedValue" - unionFieldName_UserDefinedValue_EnumValue = "EnumValue" - unionFieldName_UserDefinedValue_DeclaredConstant = "DeclaredConstant" + unionName_UserDefinedValue = "UserDefinedValue" + unionFieldName_UserDefinedValue_EnumValue = "EnumValue" + unionFieldName_UserDefinedValue_DeclaredConstant = "DeclaredConstant" ) func mojom_types_UserDefinedValue__() MojomUnion { - return MojomUnion{ - DeclData: &DeclarationData{ - ShortName: &unionName_UserDefinedValue, - }, Fields: []UnionField{UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_UserDefinedValue_EnumValue, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_EnumValue__, - TypeKey: &ID_mojom_types_EnumValue__}, - }, - Tag: 0, - }, UnionField{ - DeclData: &DeclarationData{ - ShortName: &unionFieldName_UserDefinedValue_DeclaredConstant, - }, - Type: &TypeTypeReference{ - Value: TypeReference{Identifier: &ID_mojom_types_DeclaredConstant__, - TypeKey: &ID_mojom_types_DeclaredConstant__}, - }, - Tag: 1, - }}, - } + return MojomUnion{ + DeclData: &DeclarationData{ + ShortName: &unionName_UserDefinedValue, + },Fields: []UnionField{UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_UserDefinedValue_EnumValue, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_EnumValue__, + TypeKey: &ID_mojom_types_EnumValue__,}, +}, + Tag: 0, + },UnionField{ + DeclData: &DeclarationData{ + ShortName: &unionFieldName_UserDefinedValue_DeclaredConstant, + }, + Type: &TypeTypeReference{ + Value: TypeReference {Identifier: &ID_mojom_types_DeclaredConstant__, + TypeKey: &ID_mojom_types_DeclaredConstant__,}, +}, + Tag: 1, + },}, + } } +
diff --git a/mojom/mojom_parser/mojom/mojom_descriptor.go b/mojom/mojom_parser/mojom/mojom_descriptor.go index 3109654..3a27aea 100644 --- a/mojom/mojom_parser/mojom/mojom_descriptor.go +++ b/mojom/mojom_parser/mojom/mojom_descriptor.go
@@ -105,7 +105,7 @@ // methods below may invoked. |moduleNamespace| may be the empty string. func (f *MojomFile) InitializeFileScope(moduleNamespace string) *Scope { f.ModuleNamespace = moduleNamespace - f.FileScope = NewLexicalScope(ScopeFileModule, nil, moduleNamespace, f) + f.FileScope = NewLexicalScope(ScopeFileModule, nil, moduleNamespace, f, nil) return f.FileScope }
diff --git a/mojom/mojom_parser/mojom/scopes.go b/mojom/mojom_parser/mojom/scopes.go index 3eec38b..df5b4ac 100644 --- a/mojom/mojom_parser/mojom/scopes.go +++ b/mojom/mojom_parser/mojom/scopes.go
@@ -82,8 +82,11 @@ typesByName map[string]UserDefinedType valuesByName map[string]UserDefinedValue // file is nil for abstract module scopes - file *MojomFile - descriptor *MojomDescriptor + file *MojomFile + // If this is an Interface or Struct scope then |containingType| + // is the corresponding Interface or Struct. + containingType UserDefinedType + descriptor *MojomDescriptor } func buildDottedName(prefix, suffix string) string { @@ -95,24 +98,29 @@ // init is invoked by NewLexicalScope and NewAbstractModuleScope func (scope *Scope) init(kind ScopeKind, shortName string, - fullyQualifiedName string, parentScope *Scope, descriptor *MojomDescriptor) { + fullyQualifiedName string, parentScope *Scope, containingType UserDefinedType, descriptor *MojomDescriptor) { scope.kind = kind scope.shortName = shortName scope.fullyQualifiedName = fullyQualifiedName scope.parentScope = parentScope scope.typesByName = make(map[string]UserDefinedType) scope.valuesByName = make(map[string]UserDefinedValue) + scope.containingType = containingType scope.descriptor = descriptor } // NewLexicalScope creates a new LexicalScope. The scopeKind must be -// one of the lexical kinds, not ABSTRACT_MODULE. The file must not be nil +// one of the lexical kinds, not ScopeAbstractMoudle. The file must not be nil // and it must not have a nil descriptor because the new scope will be // embedded into the tree of scopes for that descriptor. // The parent scope must be appropriate for the type of scope being created. // When creating a ScopeFileModule parentScope should be nil: The // parent scope will be set to an abstract module scope automatically. -func NewLexicalScope(kind ScopeKind, parentScope *Scope, shortName string, file *MojomFile) *Scope { +// +// |containingType| must be non-nil just in case an Interface or Struct scope +// is being created and in that case it should be the Interface or Struct. +func NewLexicalScope(kind ScopeKind, parentScope *Scope, shortName string, + file *MojomFile, containingType UserDefinedType) *Scope { scope := new(Scope) if file == nil { panic("The file must not be nil for a lexical scope.") @@ -125,18 +133,26 @@ if parentScope != nil { panic("A file module lexical scope cannot have a parent lexical scope.") } + if containingType != nil { + panic("A file scope does not have a containing type.") + } fullyQualifiedName = file.ModuleNamespace parentScope = file.Descriptor.getAbstractModuleScope(fullyQualifiedName) case ScopeInterface, ScopeStruct: if parentScope == nil || parentScope.kind != ScopeFileModule { panic("An interface or struct lexical scope must have a parent lexical scope of type FILE_MODULE.") } + if containingType == nil { + panic("An interface or struct scope must have a containing type.") + } fullyQualifiedName = buildDottedName(parentScope.fullyQualifiedName, shortName) case ScopeEnum: if parentScope == nil || parentScope.kind == ScopeAbstractModule { - // Note(rudominer) We panic here because this is a programming error. This cannot occur due to bad user input. panic("An enum lexical scope must have a parent lexical scope not an ABSTRACT_MODULE scope.") } + if containingType == nil { + panic("An enum scope must have a containing type.") + } fullyQualifiedName = buildDottedName(parentScope.fullyQualifiedName, shortName) case ScopeAbstractModule: panic("The type of a lexical scope cannot be ABSTRACT_MODULE.") @@ -144,7 +160,7 @@ panic(fmt.Sprintf("Unrecognized ScopeKind %d", kind)) } - scope.init(kind, shortName, fullyQualifiedName, parentScope, file.Descriptor) + scope.init(kind, shortName, fullyQualifiedName, parentScope, containingType, file.Descriptor) return scope } @@ -168,7 +184,7 @@ parentScope = descriptor.getGlobalScobe() } } - scope.init(ScopeAbstractModule, shortName, fullyQualifiedName, parentScope, descriptor) + scope.init(ScopeAbstractModule, shortName, fullyQualifiedName, parentScope, nil, descriptor) return scope } @@ -254,7 +270,7 @@ registrationName := namePrefix + userDefinedType.SimpleName() if existingType := scope.typesByName[registrationName]; existingType != nil { return &DuplicateTypeNameError{ - DuplicateNameErrorBase{nameToken: userDefinedType.NameToken(), owningFile: userDefinedType.Scope().file}, + DuplicateNameErrorBase{nameToken: userDefinedType.NameToken(), owningFile: scope.file}, existingType} } scope.typesByName[registrationName] = userDefinedType @@ -285,7 +301,7 @@ registrationName := namePrefix + value.SimpleName() if existingVal := scope.valuesByName[registrationName]; existingVal != nil { return &DuplicateValueNameError{ - DuplicateNameErrorBase{nameToken: value.NameToken(), owningFile: value.Scope().file}, + DuplicateNameErrorBase{nameToken: value.NameToken(), owningFile: scope.file}, existingVal} } scope.valuesByName[registrationName] = value
diff --git a/mojom/mojom_parser/mojom/scopes_test.go b/mojom/mojom_parser/mojom/scopes_test.go index ea1237e..2672bbd 100644 --- a/mojom/mojom_parser/mojom/scopes_test.go +++ b/mojom/mojom_parser/mojom/scopes_test.go
@@ -22,8 +22,7 @@ fileScope := NewTestFileScope("foo.bar") // Create a new interface scope - interfaceScope := NewLexicalScope(ScopeInterface, fileScope, "MyInterface", - fileScope.descriptor.mojomFiles[0]) + interfaceScope := NewInterfaceScope(fileScope) // Obtain the auto-generated abstract module scopes. fooBarScope := fileScope.descriptor.abstractScopesByName["foo.bar"] @@ -107,8 +106,7 @@ fileScope := NewTestFileScope("foo.bar") // Create a new interface scope - interfaceScope := NewLexicalScope(ScopeInterface, fileScope, "MyInterface", - fileScope.descriptor.mojomFiles[0]) + interfaceScope := NewInterfaceScope(fileScope) // Obtain the auto-generated abstract module scopes. fooBarScope := fileScope.descriptor.abstractScopesByName["foo.bar"]
diff --git a/mojom/mojom_parser/mojom/test_utils.go b/mojom/mojom_parser/mojom/test_utils.go index d367318..5ea6688 100644 --- a/mojom/mojom_parser/mojom/test_utils.go +++ b/mojom/mojom_parser/mojom/test_utils.go
@@ -12,6 +12,11 @@ return NewMojomDescriptor().AddMojomFile("test.mojom").InitializeFileScope(scopeName) } +func NewInterfaceScope(fileScope *Scope) *Scope { + return NewLexicalScope(ScopeInterface, fileScope, "MyInterface", + fileScope.descriptor.mojomFiles[0], &MojomInterface{}) +} + func NewResolvedUserRef(name string, resolvedType UserDefinedType, usedAsMapKey, usedForConstant bool, lv *LiteralValue) *UserTypeRef { userRef := NewUserTypeRef(name, false, false, nil, lexer.Token{}) userRef.resolvedType = resolvedType
diff --git a/mojom/mojom_parser/mojom/types.go b/mojom/mojom_parser/mojom/types.go index 0baa519..60ae778 100644 --- a/mojom/mojom_parser/mojom/types.go +++ b/mojom/mojom_parser/mojom/types.go
@@ -393,12 +393,12 @@ nullable bool // If fixed_length < 0 then the array does not have a fixed length; - fixedLength int + fixedLength int32 elementType TypeRef } -func NewArrayTypeRef(elementType TypeRef, fixedSize int, nullable bool) *ArrayTypeRef { +func NewArrayTypeRef(elementType TypeRef, fixedSize int32, nullable bool) *ArrayTypeRef { return &ArrayTypeRef{nullable, fixedSize, elementType} } @@ -406,7 +406,7 @@ return a.nullable } -func (a ArrayTypeRef) FixedLength() int { +func (a ArrayTypeRef) FixedLength() int32 { return a.fixedLength } @@ -787,10 +787,34 @@ return LiteralValue{SimpleTypeBool, value, false} } +func MakeInt8LiteralValue(value int8) LiteralValue { + return LiteralValue{SimpleTypeInt8, value, false} +} +func MakeInt16LiteralValue(value int16) LiteralValue { + return LiteralValue{SimpleTypeInt16, value, false} +} +func MakeInt32LiteralValue(value int32) LiteralValue { + return LiteralValue{SimpleTypeInt32, value, false} +} + func MakeInt64LiteralValue(value int64) LiteralValue { return LiteralValue{SimpleTypeInt64, value, false} } +func MakeUint8LiteralValue(value uint8) LiteralValue { + return LiteralValue{SimpleTypeUInt8, value, false} +} +func MakeUint16LiteralValue(value uint16) LiteralValue { + return LiteralValue{SimpleTypeUInt16, value, false} +} +func MakeUint32LiteralValue(value uint32) LiteralValue { + return LiteralValue{SimpleTypeUInt32, value, false} +} + +func MakeUint64LiteralValue(value uint64) LiteralValue { + return LiteralValue{SimpleTypeUInt64, value, false} +} + func MakeDoubleLiteralValue(value float64) LiteralValue { return LiteralValue{SimpleTypeDouble, value, false} } @@ -807,7 +831,7 @@ case TypeKindString: return fmt.Sprintf("\"%v\"", lv.value) default: - return fmt.Sprintf("%v", lv.value) + return fmt.Sprintf("%v(%v)", lv.valueType, lv.value) } }
diff --git a/mojom/mojom_parser/mojom/user_defined_types.go b/mojom/mojom_parser/mojom/user_defined_types.go index bd477a7..1e164f3 100644 --- a/mojom/mojom_parser/mojom/user_defined_types.go +++ b/mojom/mojom_parser/mojom/user_defined_types.go
@@ -66,7 +66,6 @@ DeclarationData thisType UserDefinedType typeKey string - scope *Scope } // This method is invoked from the constructors for the containing types: @@ -80,7 +79,7 @@ return TypeKindUserDefined } -// Generates the fully-qualified name and the type key and registers the +// Generates the fully-qualified name and the type Key and registers the // type in the given |scope| and also with the associated MojomDescriptor. // // This method is invoked when a UserDefinedType is added to its container, @@ -126,7 +125,8 @@ Constants []*UserDefinedConstant } -// Adds an enum to this type, which must be an interface or struct. +// Adds an enum to the type associated with this DeclarationContainer, +// which must be an interface or struct. func (c *DeclarationContainer) AddEnum(mojomEnum *MojomEnum) DuplicateNameError { c.Enums = append(c.Enums, mojomEnum) return mojomEnum.RegisterInScope(c.containedScope) @@ -156,7 +156,7 @@ } func (s *MojomStruct) InitAsScope(parentScope *Scope) *Scope { - s.containedScope = NewLexicalScope(ScopeStruct, parentScope, s.simpleName, parentScope.file) + s.containedScope = NewLexicalScope(ScopeStruct, parentScope, s.simpleName, parentScope.file, s) return s.containedScope } @@ -297,7 +297,7 @@ func (i *MojomInterface) InitAsScope(parentScope *Scope) *Scope { i.containedScope = NewLexicalScope(ScopeInterface, parentScope, - i.simpleName, parentScope.file) + i.simpleName, parentScope.file, i) return i.containedScope } @@ -524,7 +524,7 @@ func (e *MojomEnum) InitAsScope(parentScope *Scope) *Scope { e.scopeForValues = NewLexicalScope(ScopeEnum, parentScope, - e.simpleName, parentScope.file) + e.simpleName, parentScope.file, e) return e.scopeForValues } @@ -634,7 +634,6 @@ // declaration. For an enum value it will be an integer literal. For // a constant declartion it may be a literal or it may be a reference. valueRef ValueRef - scope *Scope } // This method is invoked from the constructors for the containing types: @@ -866,8 +865,14 @@ attributes *Attributes simpleName string fullyQualifiedName string - owningFile *MojomFile - nameToken lexer.Token + + owningFile *MojomFile + nameToken lexer.Token + + // If not nil, this field points to the LexicalScope of the declaration + // corresponding to this data. This will be nil for some embedees + // of DeclarationData which do not keep track of their scopes. + scope *Scope // We use int64 here because valid ordinals are uint32 and we want to // be able to represent an unset value as -1. @@ -916,6 +921,13 @@ return d.owningFile } +func (d *DeclarationData) ContainingType() UserDefinedType { + if d.scope == nil { + return nil + } + return d.scope.containingType +} + type Attributes struct { List []MojomAttribute }
diff --git a/mojom/mojom_parser/parser/parse_driver.go b/mojom/mojom_parser/parser/parse_driver.go index cb54791..53f4fe5 100644 --- a/mojom/mojom_parser/parser/parse_driver.go +++ b/mojom/mojom_parser/parser/parse_driver.go
@@ -24,13 +24,13 @@ // // We attempt to find the file named by a given path, both top-level and // imported, using the following algorithm: -// (1) If the specified path is an absolute path use that path -// (2) Otherwise if the file was imported from another file first attempt +// (1) If the specified path is an absolute path we use that path +// (2) Otherwise if the file was imported from another file we first attempt // to find a file with the specified path relative to the directory of the // importing file -// (3) Otherwise if the file was imported attempt to find a file with the +// (3) Otherwise if the file was imported we attempt to find a file with the // specified path relative to one of the specified import directories. -// (4) Otherwise attempt to find a file with the specified path relative to +// (4) Otherwise we attempt to find a file with the specified path relative to // the current working directory. // // After all files have been parsed the populated |MojomDescriptor| will be @@ -224,6 +224,9 @@ return } +// findFile populates the |absolutePath| and |directoryPath| fields of +// *fileRef. It attempts to find a file on the file system named by the |specifiedPath| +// field using the search algorithm described at the top of this file. func (p *OSFileProvider) findFile(fileRef *FileReference) (err error) { // If this FileReference has already been processed there is nothing to do. if len(fileRef.absolutePath) > 0 { @@ -243,7 +246,7 @@ // importing file. attemptedName := filepath.Join(fileRef.importedFrom.directoryPath, fileRef.specifiedPath) if isFile(attemptedName) { - fileRef.absolutePath = attemptedName + fileRef.absolutePath, err = filepath.Abs(attemptedName) fileRef.directoryPath = filepath.Dir(fileRef.absolutePath) return } @@ -253,7 +256,7 @@ for _, dir := range p.importDirs { attemptedName := filepath.Join(dir, fileRef.specifiedPath) if isFile(attemptedName) { - fileRef.absolutePath = attemptedName + fileRef.absolutePath, err = filepath.Abs(attemptedName) fileRef.directoryPath = filepath.Dir(fileRef.absolutePath) return }
diff --git a/mojom/mojom_parser/parser/parse_driver_test.go b/mojom/mojom_parser/parser/parse_driver_test.go index b4880ed..f8ec120 100644 --- a/mojom/mojom_parser/parser/parse_driver_test.go +++ b/mojom/mojom_parser/parser/parse_driver_test.go
@@ -6,7 +6,10 @@ import ( "mojom/mojom_parser/mojom" + "os" + "path/filepath" "reflect" + "strings" "testing" ) @@ -89,3 +92,83 @@ t.Errorf("%v != %v", expectedFileRefs, fakeFileProvider.requestedFileNames) } } + +// TestOSFileProvider tests the function OSFileProvider.findFiles() and OSFileProvider.provideContents() +func TestOSFileProvider(t *testing.T) { + // Top level files (not imported from anything) are found relative to the current directory. + fileReferenceA := doOSFileProviderTest(t, "../test_data/a/testfile1", nil, nil, "mojom_parser/test_data/a") + fileReferenceB := doOSFileProviderTest(t, "../test_data/b/testfile1", nil, nil, "mojom_parser/test_data/b") + + // A file imported from a file in directory 'a' should be found in directory 'a' + doOSFileProviderTest(t, "testfile1", &fileReferenceA, nil, "mojom_parser/test_data/a") + + // A file imported from a file in directory 'b' should be found in directory 'a' + doOSFileProviderTest(t, "testfile1", &fileReferenceB, nil, "mojom_parser/test_data/b") + + // A file imported from a file in directory 'a' should be found in directory 'b' if there is no file with the + // specified name in directory 'a' and directory 'b' is in the search path. + doOSFileProviderTest(t, "testfile2", &fileReferenceA, []string{"../test_data/b"}, "mojom_parser/test_data/b") + + // The file is imported from directory 'a' and directory 'b' is on the search path but there is no file with the + // specified name in either directory and there is a file with the specified name in the current directory. + // The file should be found in the current directory. Note that the last argument is a random string of digits that + // we expect to find in the contents of the file parser_driver_test.go. + doOSFileProviderTest(t, "parse_driver_test.go", &fileReferenceA, []string{"../test_data/b"}, "840274941330987490326243") +} + +// doOSFileProviderTest is the workhorse for TestOSFileProvider. +func doOSFileProviderTest(t *testing.T, specifiedPath string, importedFrom *FileReference, + globalImports []string, expectedContents string) FileReference { + fileProvider := new(OSFileProvider) + fileProvider.importDirs = globalImports + fileReference := FileReference{specifiedPath: specifiedPath} + fileReference.importedFrom = importedFrom + + // Invoke findFile() + if err := fileProvider.findFile(&fileReference); err != nil { + t.Fatalf(err.Error()) + } + + // Check that the absolutePath has been populated to the absolute path of a file. + if fileReference.absolutePath == "" { + t.Fatalf("absolutePath is not set for %s", fileReference.specifiedPath) + } + if !filepath.IsAbs(fileReference.absolutePath) { + t.Fatalf("absolutePath is not absolute for %s: %s", fileReference.specifiedPath, fileReference.absolutePath) + } + info, err := os.Stat(fileReference.absolutePath) + if err != nil { + t.Fatalf("cannot stat absolutePath %s: %s", fileReference.absolutePath, err.Error()) + } + if info.IsDir() { + t.Fatalf("absolutePath refers to a directory: %s", fileReference.absolutePath) + } + + // Check that the dirPath has been populated to the absolute path of a directory. + if fileReference.directoryPath == "" { + t.Fatalf("directoryPath is not set for %s", fileReference.specifiedPath) + } + if !filepath.IsAbs(fileReference.directoryPath) { + t.Fatalf("directoryPath is not absolute for %s: %s", fileReference.specifiedPath, fileReference.directoryPath) + } + info, err = os.Stat(fileReference.directoryPath) + if err != nil { + t.Fatalf("cannot stat directoryPath %s: %s", fileReference.directoryPath, err.Error()) + } + if !info.IsDir() { + t.Fatalf("directoryPath does not refer to a directory: %s", fileReference.directoryPath) + } + if filepath.Dir(fileReference.absolutePath) != fileReference.directoryPath { + t.Fatalf("wrong directoryPath expected parent of %s got %s", fileReference.absolutePath, fileReference.directoryPath) + } + + contents, err := fileProvider.provideContents(&fileReference) + if err != nil { + t.Errorf("Error from provideContents for %v: %s", fileReference, err.Error()) + } + if !strings.Contains(contents, expectedContents) { + t.Errorf("Wrong file contents for %v. Expecting %s got %s.", fileReference, expectedContents, contents) + } + + return fileReference +}
diff --git a/mojom/mojom_parser/parser/parser_test.go b/mojom/mojom_parser/parser/parser_test.go index 78b4649..eef685c 100644 --- a/mojom/mojom_parser/parser/parser_test.go +++ b/mojom/mojom_parser/parser/parser_test.go
@@ -111,6 +111,41 @@ endTestCase() //////////////////////////////////////////////////////////// + // Test Case (Integer constants) + //////////////////////////////////////////////////////////// + startTestCase("") + cases[testCaseNum].mojomContents = ` + const uint8 xu8 = 255; + const int8 x8 = -127; + const uint16 xu16 = 0xFFFF; + const int16 x16 = -0x7FFF; + const uint32 xu32 = 4294967295; + const int32 x32 = -2147483647; + const uint64 xu64 = 0xFFFFFFFFFFFFFFFF; + const int64 x64 = -0x7FFFFFFFFFFFFFFF; + const uint64 manyNines = 9999999999999999999; + ` + expectedFile.AddConstant(mojom.NewUserDefinedConstant(mojom.DeclTestData("xu8"), + mojom.SimpleTypeUInt8, mojom.MakeUint8LiteralValue(0xFF))) + expectedFile.AddConstant(mojom.NewUserDefinedConstant(mojom.DeclTestData("x8"), + mojom.SimpleTypeInt8, mojom.MakeInt8LiteralValue(-0x7F))) + expectedFile.AddConstant(mojom.NewUserDefinedConstant(mojom.DeclTestData("xu16"), + mojom.SimpleTypeUInt16, mojom.MakeUint16LiteralValue(65535))) + expectedFile.AddConstant(mojom.NewUserDefinedConstant(mojom.DeclTestData("x16"), + mojom.SimpleTypeInt16, mojom.MakeInt16LiteralValue(-32767))) + expectedFile.AddConstant(mojom.NewUserDefinedConstant(mojom.DeclTestData("xu32"), + mojom.SimpleTypeUInt32, mojom.MakeUint32LiteralValue(0xFFFFFFFF))) + expectedFile.AddConstant(mojom.NewUserDefinedConstant(mojom.DeclTestData("x32"), + mojom.SimpleTypeInt32, mojom.MakeInt32LiteralValue(-0x7FFFFFFF))) + expectedFile.AddConstant(mojom.NewUserDefinedConstant(mojom.DeclTestData("xu64"), + mojom.SimpleTypeUInt64, mojom.MakeUint64LiteralValue(18446744073709551615))) + expectedFile.AddConstant(mojom.NewUserDefinedConstant(mojom.DeclTestData("x64"), + mojom.SimpleTypeInt64, mojom.MakeInt64LiteralValue(-9223372036854775807))) + expectedFile.AddConstant(mojom.NewUserDefinedConstant(mojom.DeclTestData("manyNines"), + mojom.SimpleTypeUInt64, mojom.MakeUint64LiteralValue(9999999999999999999))) + endTestCase() + + //////////////////////////////////////////////////////////// // Test Case //////////////////////////////////////////////////////////// startTestCase("mojom.test") @@ -172,9 +207,9 @@ expectedFile.AddImport("and.another.file") structFoo := mojom.NewMojomStruct(mojom.DeclTestData("Foo")) - structFoo.AddField(mojom.NewStructField(mojom.DeclTestDataWithOrdinal("x", 4), mojom.SimpleTypeInt32, mojom.MakeInt64LiteralValue(42))) + structFoo.AddField(mojom.NewStructField(mojom.DeclTestDataWithOrdinal("x", 4), mojom.SimpleTypeInt32, mojom.MakeInt8LiteralValue(42))) attributes := mojom.NewAttributes() - attributes.List = append(attributes.List, mojom.MojomAttribute{"age", mojom.MakeInt64LiteralValue(7)}) + attributes.List = append(attributes.List, mojom.MojomAttribute{"age", mojom.MakeInt8LiteralValue(7)}) attributes.List = append(attributes.List, mojom.MojomAttribute{"level", mojom.MakeStringLiteralValue("high")}) structFoo.AddField(mojom.NewStructField(mojom.DeclTestDataA("y", attributes), mojom.BuiltInType("string"), mojom.MakeStringLiteralValue("Howdy!"))) structFoo.AddField(mojom.NewStructField(mojom.DeclTestData("z"), mojom.BuiltInType("string?"), nil)) @@ -272,7 +307,7 @@ expectedFile.AddImport("and.another.file") expectedFile.AddConstant(mojom.NewUserDefinedConstant(mojom.DeclTestData("TOO_SMALL_VALUE"), - mojom.SimpleTypeInt8, mojom.MakeInt64LiteralValue(6))) + mojom.SimpleTypeInt8, mojom.MakeInt8LiteralValue(6))) errorCodeEnum := mojom.NewMojomEnum(mojom.DeclTestData("ErrorCodes")) errorCodeEnum.InitAsScope(expectedFile.FileScope) @@ -282,7 +317,7 @@ tooSmallValueRef := mojom.NewUserValueRef(assigneeType, "TOO_SMALL_VALUE", expectedFile.FileScope, lexer.Token{}) - errorCodeEnum.AddEnumValue(mojom.DeclTestData("TOO_BIG"), mojom.MakeInt64LiteralValue(5)) + errorCodeEnum.AddEnumValue(mojom.DeclTestData("TOO_BIG"), mojom.MakeInt8LiteralValue(5)) errorCodeEnum.AddEnumValue(mojom.DeclTestData("TOO_SMALL"), tooSmallValueRef) errorCodeEnum.AddEnumValue(mojom.DeclTestData("JUST_RIGHT"), nil) expectedFile.AddEnum(errorCodeEnum) @@ -487,6 +522,17 @@ endTestCase() //////////////////////////////////////////////////////////// + // Test Case (Constant integer too big for uint64) + //////////////////////////////////////////////////////////// + startTestCase("") + cases[testCaseNum].mojomContents = ` + const uint64 manyNines = 99999999999999999999; + ` + expectError("Integer literal value out of range") + expectError("99999999999999999999") + endTestCase() + + //////////////////////////////////////////////////////////// // Execute all of the test cases. //////////////////////////////////////////////////////////// for i, c := range cases {
diff --git a/mojom/mojom_parser/parser/parsing.go b/mojom/mojom_parser/parser/parsing.go index fde8e70..79ecdc2 100644 --- a/mojom/mojom_parser/parser/parsing.go +++ b/mojom/mojom_parser/parser/parsing.go
@@ -1117,8 +1117,45 @@ nextToken := p.peekNextToken("I was parsing a numberliteral.") switch nextToken.Kind { case lexer.IntConstDec, lexer.IntConstHex: - value, _ := p.parsePositiveIntegerLiteral(initialMinus, true, 64) - return mojom.MakeInt64LiteralValue(value) + absoluteValue, numBits, signed, ok := p.parsePositiveIntegerLiteral(initialMinus, true, !initialMinus, 64) + if !ok { + return mojom.LiteralValue{} + } + var value int64 + if signed { + value = int64(absoluteValue) + if initialMinus { + value = -1 * value + } + } + switch numBits { + case 8: + if signed { + return mojom.MakeInt8LiteralValue(int8(value)) + } else { + return mojom.MakeUint8LiteralValue(uint8(absoluteValue)) + } + case 16: + if signed { + return mojom.MakeInt16LiteralValue(int16(value)) + } else { + return mojom.MakeUint16LiteralValue(uint16(absoluteValue)) + } + case 32: + if signed { + return mojom.MakeInt32LiteralValue(int32(value)) + } else { + return mojom.MakeUint32LiteralValue(uint32(absoluteValue)) + } + case 64: + if signed { + return mojom.MakeInt64LiteralValue(value) + } else { + return mojom.MakeUint64LiteralValue(absoluteValue) + } + default: + panic(fmt.Sprintf("Unexpected value for numBits: %d", numBits)) + } case lexer.FloatConst: value, _ := p.parsePositiveFloatLiteral(initialMinus) return mojom.MakeDoubleLiteralValue(value) @@ -1265,10 +1302,10 @@ } isFixedSize := p.tryMatch(lexer.Comma) - fixedSize := -1 + fixedSize := int32(-1) if isFixedSize { - if size, ok := p.parsePositiveIntegerLiteral(false, false, 0); ok { - fixedSize = int(size) + if size, _, _, ok := p.parsePositiveIntegerLiteral(false, false, false, 32); ok { + fixedSize = int32(size) } else { return nil } @@ -1368,18 +1405,53 @@ } // POS_INT_LITERAL -> int_const_dec | int_const_hex -func (p *Parser) parsePositiveIntegerLiteral(initialMinus, acceptHex bool, - maxBits int) (int64, bool) { +// +// parsePositiveIntegerLiteral() parses the next token as an integer using the smallest +// size integer possible given the input constraints. +// +// |initialMinus| should the string to be parsed be prepended with an initial minus sign? +// If this is true then |allowUnsigned| must also be false. +// +// |acceptHex| should the string to be parsed be allowed to be expressed in "0x" notation? +// +// |allowUnsigned| If the string cannot be parsed into a signed integer with a certain number of +// bits then before trying a larger number of bits we will try an unsigned integer if this is true. +// If |allowUnsigned| is not true then the returned |signed| will never be false if |ok| is true. +// +// |maxNumBits| This value should be 8, 16, 32 or 64 and represents the maximum size of an integer +// variable into which the parsed value may fit. If |ok| is true then |numBits| <= |maxNumBits|. +// +// |absoluteValue| The absolute value of the parsed integer, stored in a uint64. If |ok| +// is true then the value, times -1 if |initialMinus| is true, is guaranteed to be +// convertible without loss to the signed or unsigned integer type given by |signed| and +// |numBits|. For example if |numBits| = 16 and |signed| is true and |initialMinus| is true +// then -1 * |absoluteValue| may be cast to an int16. If |numBits| = 64 and |signed| is false then +// |absoluteValue| may be cast to a uint64. +// +// |numBits| is the smalles number of bits, 8, 16, 32, or 64, that the parsed value +// may fit into. If |ok| is true then |numBits| <= |maxNumBits|. +// +// |signed| modifies |numBits| to indicate what type of integer variable the result may be cast to. +// +// |ok| If this is false then there was a parsing error stored in p.err. +func (p *Parser) parsePositiveIntegerLiteral(initialMinus, acceptHex, allowUnsigned bool, maxNumBits int) (absoluteValue uint64, numBits int, signed, ok bool) { p.pushChildNode("positive integer literal") defer p.popNode() + if maxNumBits != 8 && maxNumBits != 16 && maxNumBits != 32 && maxNumBits != 64 { + panic(fmt.Sprintf("maxNumBits must be 8, 16, 32 or 64: %d", maxNumBits)) + } + + if initialMinus && allowUnsigned { + panic("If initialMinus is true then allowUnsigned must be false.") + } + nextToken := p.peekNextToken("I was parsing an integer literal.") p.consumeNextToken() - base := 10 intText := p.lastConsumed.Text - if initialMinus { - intText = "-" + intText - } + + // Set the base to 10 or 16. + base := 10 switch nextToken.Kind { case lexer.IntConstDec: break @@ -1389,37 +1461,65 @@ "integer literal is allowed here. Hexadecimal is not valid.", nextToken.LongLocationString(), nextToken) p.err = &ParseError{ParserErrorCodeUnexpectedToken, message} - return 0, false + return } if len(intText) < 3 { message := fmt.Sprintf("Invalid hex integer literal"+ " '%s' at %s.", intText, nextToken.LongLocationString()) p.err = &ParseError{ParserErrorCodeIntegerParseError, message} - return 0, false + return } intText = intText[2:] base = 16 default: p.unexpectedTokenError(nextToken, "a positive integer literal") - return 0, false + return } - intVal, err := strconv.ParseInt(intText, base, maxBits) - if err == nil { - return intVal, true + // Add the initial minus sign if present. + if initialMinus { + intText = "-" + intText } + + var parseError error + for _, numBits := range []int{8, 16, 32, 64} { + if numBits > maxNumBits { + break + } + // First try to parse as signed. + signed = true + intVal, err := strconv.ParseInt(intText, base, numBits) + if err == nil { + if intVal < 0 { + intVal = -intVal + } + return uint64(intVal), numBits, signed, true + } + + parseError = err + // Then try unsigned. + if allowUnsigned { + signed = false + intVal, err := strconv.ParseUint(intText, base, numBits) + if err == nil { + return intVal, numBits, signed, true + } + parseError = err + } + } + message := "parseIntegerLiteral error." - switch err.(*strconv.NumError).Err { + switch parseError.(*strconv.NumError).Err { case strconv.ErrRange: message = fmt.Sprintf("Integer literal value out of range: "+ "%s at %s.", intText, nextToken.LongLocationString()) case strconv.ErrSyntax: panic(fmt.Sprintf("Lexer allowed unparsable integer literal: %s. "+ - "Kind = %s. error=%s.", nextToken.Text, nextToken.Kind, err)) + "Kind = %s. error=%s.", nextToken.Text, nextToken.Kind, parseError)) } p.err = &ParseError{ParserErrorCodeIntegerOutOfRange, message} - return 0, false + return 0, 0, false, false } // POS_FLOAT_LITERAL -> float_const
diff --git a/mojom/mojom_parser/serialization/serialization.go b/mojom/mojom_parser/serialization/serialization.go index d46479b..bf107ee 100644 --- a/mojom/mojom_parser/serialization/serialization.go +++ b/mojom/mojom_parser/serialization/serialization.go
@@ -501,6 +501,20 @@ // TODO(rudominer) DeclarationOrder is currently not populated. declData.DeclarationOrder = -1 + // container_type_key + containingType := d.ContainingType() + if containingType != nil { + switch containingType.(type) { + case *mojom.MojomEnum: + // We do not write the |container_type_key| field for an EnumValue + // because the EnumValue already has the type_key of the Enum + // in a different field. + break + default: + declData.ContainerTypeKey = stringPointer(containingType.TypeKey()) + } + } + // source_file_info declData.SourceFileInfo = new(mojom_types.SourceFileInfo) declData.SourceFileInfo.FileName = d.OwningFile().CanonicalFileName
diff --git a/mojom/mojom_parser/serialization/serialization_test.go b/mojom/mojom_parser/serialization/serialization_test.go index 184ab89..58db0da 100644 --- a/mojom/mojom_parser/serialization/serialization_test.go +++ b/mojom/mojom_parser/serialization/serialization_test.go
@@ -72,14 +72,21 @@ // newDeclData constructs a new DeclarationData with the given data. func (test *singleFileTest) newDeclData(shortName, fullIdentifier string) *mojom_types.DeclarationData { + return test.newContainedDeclData(shortName, fullIdentifier, nil) +} + +// newContainedDeclData constructs a new DeclarationData with the given data. +func (test *singleFileTest) newContainedDeclData(shortName, fullIdentifier string, containerTypeKey *string) *mojom_types.DeclarationData { return &mojom_types.DeclarationData{ ShortName: &shortName, FullIdentifier: &fullIdentifier, DeclaredOrdinal: -1, DeclarationOrder: -1, + ContainerTypeKey: containerTypeKey, SourceFileInfo: &mojom_types.SourceFileInfo{ FileName: test.fileName(), }} + } // TestSingleFileSerialization uses a series of test cases in which the text of a .mojom @@ -225,7 +232,7 @@ test.expectedGraph().ResolvedValues["TYPE_KEY:Foo.X1"] = &mojom_types.UserDefinedValueEnumValue{mojom_types.EnumValue{ DeclData: test.newDeclData("X1", "Foo.X1"), EnumTypeKey: "TYPE_KEY:Foo", - InitializerValue: &mojom_types.ValueLiteralValue{&mojom_types.LiteralValueInt64Value{42}}, + InitializerValue: &mojom_types.ValueLiteralValue{&mojom_types.LiteralValueInt8Value{42}}, IntValue: -1, }} @@ -259,6 +266,90 @@ } //////////////////////////////////////////////////////////// + // Test Case: Integer constants + //////////////////////////////////////////////////////////// + { + + contents := ` + const uint8 xu8 = 255; + const int8 x8 = -127; + const uint16 xu16 = 0xFFFF; + const int16 x16 = -0x7FFF; + const uint32 xu32 = 4294967295; + const int32 x32 = -2147483647; + const uint64 xu64 = 0xFFFFFFFFFFFFFFFF; + const int64 x64 = -0x7FFFFFFFFFFFFFFF; + ` + test.addTestCase("", contents) + + // DeclaredMojomObjects + + test.expectedFile().DeclaredMojomObjects.TopLevelConstants = &[]string{ + "TYPE_KEY:xu8", "TYPE_KEY:x8", "TYPE_KEY:xu16", "TYPE_KEY:x16", + "TYPE_KEY:xu32", "TYPE_KEY:x32", "TYPE_KEY:xu64", "TYPE_KEY:x64"} + + // Resolved Values + + // xu8 + test.expectedGraph().ResolvedValues["TYPE_KEY:xu8"] = &mojom_types.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ + DeclData: *test.newDeclData("xu8", "xu8"), + Type: &mojom_types.TypeSimpleType{mojom_types.SimpleType_UinT8}, + Value: &mojom_types.ValueLiteralValue{&mojom_types.LiteralValueUint8Value{255}}, + }} + + // x8 + test.expectedGraph().ResolvedValues["TYPE_KEY:x8"] = &mojom_types.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ + DeclData: *test.newDeclData("x8", "x8"), + Type: &mojom_types.TypeSimpleType{mojom_types.SimpleType_InT8}, + Value: &mojom_types.ValueLiteralValue{&mojom_types.LiteralValueInt8Value{-127}}, + }} + + // xu16 + test.expectedGraph().ResolvedValues["TYPE_KEY:xu16"] = &mojom_types.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ + DeclData: *test.newDeclData("xu16", "xu16"), + Type: &mojom_types.TypeSimpleType{mojom_types.SimpleType_UinT16}, + Value: &mojom_types.ValueLiteralValue{&mojom_types.LiteralValueUint16Value{0xFFFF}}, + }} + + // x16 + test.expectedGraph().ResolvedValues["TYPE_KEY:x16"] = &mojom_types.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ + DeclData: *test.newDeclData("x16", "x16"), + Type: &mojom_types.TypeSimpleType{mojom_types.SimpleType_InT16}, + Value: &mojom_types.ValueLiteralValue{&mojom_types.LiteralValueInt16Value{-0x7FFF}}, + }} + + // xu32 + test.expectedGraph().ResolvedValues["TYPE_KEY:xu32"] = &mojom_types.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ + DeclData: *test.newDeclData("xu32", "xu32"), + Type: &mojom_types.TypeSimpleType{mojom_types.SimpleType_UinT32}, + Value: &mojom_types.ValueLiteralValue{&mojom_types.LiteralValueUint32Value{4294967295}}, + }} + + // x32 + test.expectedGraph().ResolvedValues["TYPE_KEY:x32"] = &mojom_types.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ + DeclData: *test.newDeclData("x32", "x32"), + Type: &mojom_types.TypeSimpleType{mojom_types.SimpleType_InT32}, + Value: &mojom_types.ValueLiteralValue{&mojom_types.LiteralValueInt32Value{-2147483647}}, + }} + + // xu64 + test.expectedGraph().ResolvedValues["TYPE_KEY:xu64"] = &mojom_types.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ + DeclData: *test.newDeclData("xu64", "xu64"), + Type: &mojom_types.TypeSimpleType{mojom_types.SimpleType_UinT64}, + Value: &mojom_types.ValueLiteralValue{&mojom_types.LiteralValueUint64Value{0xFFFFFFFFFFFFFFFF}}, + }} + + // x64 + test.expectedGraph().ResolvedValues["TYPE_KEY:x64"] = &mojom_types.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ + DeclData: *test.newDeclData("x64", "x64"), + Type: &mojom_types.TypeSimpleType{mojom_types.SimpleType_InT64}, + Value: &mojom_types.ValueLiteralValue{&mojom_types.LiteralValueInt64Value{-0x7FFFFFFFFFFFFFFF}}, + }} + + test.endTestCase() + } + + //////////////////////////////////////////////////////////// // Test Case //////////////////////////////////////////////////////////// { @@ -307,7 +398,7 @@ test.expectedGraph().ResolvedValues["TYPE_KEY:mojom.test.NUM_MAGI"] = &mojom_types.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ DeclData: *test.newDeclData("NUM_MAGI", "mojom.test.NUM_MAGI"), Type: &mojom_types.TypeSimpleType{mojom_types.SimpleType_UinT16}, - Value: &mojom_types.ValueLiteralValue{&mojom_types.LiteralValueInt64Value{3}}, + Value: &mojom_types.ValueLiteralValue{&mojom_types.LiteralValueInt8Value{3}}, }} // Hats.TOP @@ -365,7 +456,7 @@ // enum Hats test.expectedGraph().ResolvedTypes["TYPE_KEY:mojom.test.Foo.Hats"] = &mojom_types.UserDefinedTypeEnumType{mojom_types.MojomEnum{ - DeclData: test.newDeclData("Hats", "mojom.test.Foo.Hats"), + DeclData: test.newContainedDeclData("Hats", "mojom.test.Foo.Hats", stringPointer("TYPE_KEY:mojom.test.Foo")), Values: []mojom_types.EnumValue{ // Note(rudominer) It is a bug that we need to copy the enum values here. // See https://github.com/domokit/mojo/issues/513. @@ -446,6 +537,13 @@ // precisely capture the structure of expected and actual. expectedString := myfmt.Sprintf("%+v", expected) actualString := myfmt.Sprintf("%+v", actual) + if expectedString == actualString { + // The "#v" format is Go-syntax representation of the value and + // uses the type names. We may need this extra detail to discern + // the difference between expected and actual. + expectedString = myfmt.Sprintf("%#v", expected) + actualString = myfmt.Sprintf("%#v", actual) + } if expectedString != actualString { diffPos := -1 for i := 0; i < len(expectedString) && i < len(actualString); i++ {
diff --git a/mojom/mojom_parser/test_data/a/testfile1 b/mojom/mojom_parser/test_data/a/testfile1 new file mode 100644 index 0000000..c8d8961 --- /dev/null +++ b/mojom/mojom_parser/test_data/a/testfile1
@@ -0,0 +1,2 @@ +This file is read by the test TestOSFileProvider() in parser_driver_test.go +location:mojom_parser/test_data/a \ No newline at end of file
diff --git a/mojom/mojom_parser/test_data/b/testfile1 b/mojom/mojom_parser/test_data/b/testfile1 new file mode 100644 index 0000000..06c11b6 --- /dev/null +++ b/mojom/mojom_parser/test_data/b/testfile1
@@ -0,0 +1,2 @@ +This file is read by the test TestOSFileProvider() in parser_driver_test.go +location:mojom_parser/test_data/b \ No newline at end of file
diff --git a/mojom/mojom_parser/test_data/b/testfile2 b/mojom/mojom_parser/test_data/b/testfile2 new file mode 100644 index 0000000..06c11b6 --- /dev/null +++ b/mojom/mojom_parser/test_data/b/testfile2
@@ -0,0 +1,2 @@ +This file is read by the test TestOSFileProvider() in parser_driver_test.go +location:mojom_parser/test_data/b \ No newline at end of file
diff --git a/services/BUILD.gn b/services/BUILD.gn index e7b815d..69e2350 100644 --- a/services/BUILD.gn +++ b/services/BUILD.gn
@@ -29,6 +29,7 @@ deps += [ "//services/android:java_handler", "//services/camera", + "//services/camera:camera_roll", "//services/contacts", "//services/location", "//services/notifications",
diff --git a/services/camera/BUILD.gn b/services/camera/BUILD.gn index 239524f..6bcc677 100644 --- a/services/camera/BUILD.gn +++ b/services/camera/BUILD.gn
@@ -23,10 +23,10 @@ mojo_android_java_application("camera_roll") { sources = [ - "src/org/chromium/services/camera/CameraRollApp.java", + "src/org/chromium/services/camera_roll/CameraRollApp.java", ] - mojo_main = "org.chromium.services.camera.CameraRollApp" + mojo_main = "org.chromium.services.camera_roll.CameraRollApp" deps = [ "//mojo/public/interfaces/application:application_java",
diff --git a/services/camera/src/org/chromium/services/camera/CameraApp.java b/services/camera/src/org/chromium/services/camera/CameraApp.java index 76fabd5..b0dd4e5 100644 --- a/services/camera/src/org/chromium/services/camera/CameraApp.java +++ b/services/camera/src/org/chromium/services/camera/CameraApp.java
@@ -23,6 +23,7 @@ mCameraServiceImpl = new CameraServiceImpl(context, core); } + @Override public void initialize(Shell shell, String[] args, String url) { }
diff --git a/services/camera/src/org/chromium/services/camera/CameraRollApp.java b/services/camera/src/org/chromium/services/camera_roll/CameraRollApp.java similarity index 94% rename from services/camera/src/org/chromium/services/camera/CameraRollApp.java rename to services/camera/src/org/chromium/services/camera_roll/CameraRollApp.java index 07ea074..40d4fef 100644 --- a/services/camera/src/org/chromium/services/camera/CameraRollApp.java +++ b/services/camera/src/org/chromium/services/camera_roll/CameraRollApp.java
@@ -51,6 +51,7 @@ private ArrayList<File> mPhotos; class CopyToPipeJob implements Runnable { + @SuppressWarnings("hiding") private static final String TAG = "CopyToPipeJob"; private final File mPhotoFile; @@ -109,7 +110,7 @@ /** * Returns the number of photos available in the camera roll. * - * @see org.chromium.mojom.mojo.CameraRollService#getCount(CountResponse) + * @see org.chromium.mojom.mojo.CameraRollService#getCount(GetCountResponse) */ @Override public void getCount(CameraRollService.GetCountResponse callback) { @@ -117,10 +118,9 @@ } /** - * Returns the photo from the current snapshot of the camera roll at the - * requested index. + * Returns the photo from the current snapshot of the camera roll at the requested index. * - * @see org.chromium.mojom.mojo.CameraRollService#getPhoto(int, GetNextPhotoResponse) + * @see org.chromium.mojom.mojo.CameraRollService#getPhoto(int, GetPhotoResponse) */ @Override public void getPhoto(int index, CameraRollService.GetPhotoResponse callback) { @@ -159,6 +159,7 @@ File dcimDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM); findAllImageFiles(dcimDir, mPhotos); Collections.sort(mPhotos, Collections.reverseOrder(new Comparator<File>() { + @Override public int compare(File f1, File f2) { return Long.compare(f1.lastModified(), f2.lastModified()); } @@ -191,13 +192,15 @@ * @see org.chromium.mojo.bindings.Interface#close() */ @Override - public void close() {} + public void close() { + } /** * @see org.chromium.mojo.bindings.Interface#onConnectionError(MojoException) */ @Override - public void onConnectionError(MojoException e) {} + public void onConnectionError(MojoException e) { + } } /** @@ -217,7 +220,9 @@ */ @Override - public void initialize(Shell shell, String[] args, String url) {} + public void initialize(Shell shell, String[] args, String url) { + } + /** * @see ApplicationDelegate#configureIncomingConnection(ApplicationConnection) */ @@ -247,7 +252,8 @@ } public static void mojoMain( - Context context, Core core, MessagePipeHandle applicationRequestHandle) { + @SuppressWarnings("unused") Context context, Core core, + MessagePipeHandle applicationRequestHandle) { ApplicationRunner.run(new CameraRollApp(core), core, applicationRequestHandle); } }
diff --git a/services/dart/dart_apptests/BUILD.gn b/services/dart/dart_apptests/BUILD.gn index 269f807..89acc06 100644 --- a/services/dart/dart_apptests/BUILD.gn +++ b/services/dart/dart_apptests/BUILD.gn
@@ -19,9 +19,7 @@ "pubspec.yaml", ] deps = [ - "//mojo/dart/mojo_services", - "//mojo/dart/packages/mojo", - "//mojo/dart/packages/mojo_apptest", + "//mojo/dart/packages/", "//mojo/public/dart", "//mojo/public/interfaces/bindings/tests:versioning_test_client_interfaces", "//mojo/public/interfaces/bindings/tests:versioning_test_service_interfaces",
diff --git a/services/files/directory_impl_unittest.cc b/services/files/directory_impl_unittest.cc index 1e57f0f..246ccb0 100644 --- a/services/files/directory_impl_unittest.cc +++ b/services/files/directory_impl_unittest.cc
@@ -163,6 +163,7 @@ EXPECT_EQ(Error::OK, error); // Rename my_file to my_new_file. + error = Error::INTERNAL; directory->Rename("my_file", "my_new_file", Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); EXPECT_EQ(Error::OK, error); @@ -180,7 +181,8 @@ EXPECT_EQ(Error::OK, error); // Delete my_new_file (no flags). - directory->Delete("my_new_file", 0, Capture(&error)); + error = Error::INTERNAL; + directory->Delete("my_new_file", 0u, Capture(&error)); ASSERT_TRUE(directory.WaitForIncomingResponse()); EXPECT_EQ(Error::OK, error); @@ -195,6 +197,34 @@ // operations on it being affected. // TODO(vtl): Test delete flags. +// TODO(vtl): Strictly speaking, this is a test of |FilesImpl|, but we need +// |Directory| to do anything, so it lives here. +TEST_F(DirectoryImplTest, AppPersistentCache) { + { + DirectoryPtr directory; + GetAppPersistentCacheRoot(&directory); + + // Create my_file. + Error error = Error::INTERNAL; + directory->OpenFile("my_file", nullptr, kOpenFlagCreate | kOpenFlagWrite, + Capture(&error)); + ASSERT_TRUE(directory.WaitForIncomingResponse()); + EXPECT_EQ(Error::OK, error); + } + + { + DirectoryPtr directory; + GetAppPersistentCacheRoot(&directory); + + // We should be in the same directory and my_file should still exist, so we + // should be able to delete it. + Error error = Error::INTERNAL; + directory->Delete("my_file", kDeleteFlagFileOnly, Capture(&error)); + ASSERT_TRUE(directory.WaitForIncomingResponse()); + EXPECT_EQ(Error::OK, error); + } +} + } // namespace } // namespace files } // namespace mojo
diff --git a/services/files/file_impl_unittest.cc b/services/files/file_impl_unittest.cc index ef521f4..a1d90c1 100644 --- a/services/files/file_impl_unittest.cc +++ b/services/files/file_impl_unittest.cc
@@ -57,7 +57,7 @@ EXPECT_EQ(Error::OK, error); { - // Open my_file again. + // Open your_file. FilePtr file; error = Error::INTERNAL; directory->OpenFile("your_file", GetProxy(&file), kOpenFlagRead,
diff --git a/services/files/files_impl.cc b/services/files/files_impl.cc index 6826427..94eb6cd 100644 --- a/services/files/files_impl.cc +++ b/services/files/files_impl.cc
@@ -4,6 +4,7 @@ #include "services/files/files_impl.h" +#include <errno.h> #include <fcntl.h> #include <stdlib.h> #include <sys/stat.h> @@ -16,6 +17,9 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/posix/eintr_wrapper.h" +#include "base/sha1.h" +#include "base/strings/string_number_conversions.h" +#include "mojo/public/cpp/application/application_connection.h" #include "services/files/directory_impl.h" namespace mojo { @@ -35,15 +39,59 @@ return temp_dir_fd; } -#ifndef NDEBUG -base::ScopedFD OpenMojoDebugDirectory() { +// Gets the path to a directory relative to the home directory. Returns an empty +// path on failure. +base::FilePath GetHomeRelativePath(const char* dir_name) { const char* home_dir_name = getenv("HOME"); if (!home_dir_name || !home_dir_name[0]) { LOG(ERROR) << "HOME not set"; + return base::FilePath(); + } + return base::FilePath(home_dir_name).Append(dir_name); +} + +// Ensures that the parent directory for the (per-application) persistent cache +// directory exists and returns a path to it. Returns an empty path on failure. +base::FilePath EnsureAppPersistentCacheParentDirectory() { + base::FilePath parent_dir_name = + GetHomeRelativePath("MojoAppPersistentCaches"); + + // Just |mkdir()| it (|mkdir()| isn't interruptible). If it already exists, + // assume everything is OK (this isn't entirely right -- e.g., it may not be a + // directory or it may have the wrong permissions -- but it's enough for us to + // proceed to the next step). + if (mkdir(parent_dir_name.value().c_str(), S_IRWXU) != 0 && errno != EEXIST) { + PLOG(ERROR) << "mkdir failed: " << parent_dir_name.value(); + return base::FilePath(); + } + return parent_dir_name; +} + +// Opens the application-specific persistent cache directory for the given |url| +// (creating it if necessary). +base::ScopedFD OpenAppPersistentCacheDirectory(std::string url) { + base::FilePath parent_dir_name = EnsureAppPersistentCacheParentDirectory(); + if (parent_dir_name.empty()) + return base::ScopedFD(); + + // TODO(vtl): We should probably use SHA-256 instead of SHA-1. + std::string raw_hash = base::SHA1HashString(url); + std::string hex_hash = base::HexEncode(raw_hash.data(), raw_hash.size()); + base::FilePath dir_name = parent_dir_name.Append(hex_hash); + if (mkdir(dir_name.value().c_str(), S_IRWXU) != 0 && errno != EEXIST) { + PLOG(ERROR) << "mkdir failed: " << dir_name.value(); return base::ScopedFD(); } - base::FilePath mojo_debug_dir_name = - base::FilePath(home_dir_name).Append("MojoDebug"); + + return base::ScopedFD( + HANDLE_EINTR(open(dir_name.value().c_str(), O_RDONLY | O_DIRECTORY, 0))); +} + +#ifndef NDEBUG +base::ScopedFD OpenMojoDebugDirectory() { + base::FilePath mojo_debug_dir_name = GetHomeRelativePath("MojoDebug"); + if (mojo_debug_dir_name.empty()) + return base::ScopedFD(); return base::ScopedFD(HANDLE_EINTR( open(mojo_debug_dir_name.value().c_str(), O_RDONLY | O_DIRECTORY, 0))); } @@ -53,12 +101,10 @@ FilesImpl::FilesImpl(ApplicationConnection* connection, InterfaceRequest<Files> request) - : binding_(this, request.Pass()) { - // TODO(vtl): record other app's URL -} + : client_url_(connection->GetRemoteApplicationURL()), + binding_(this, request.Pass()) {} -FilesImpl::~FilesImpl() { -} +FilesImpl::~FilesImpl() {} void FilesImpl::OpenFileSystem(const mojo::String& file_system, InterfaceRequest<Directory> directory, @@ -70,6 +116,15 @@ // TODO(vtl): ScopedGeneric (hence ScopedFD) doesn't have an operator=! dir_fd.reset(CreateAndOpenTemporaryDirectory(&temp_dir).release()); DCHECK(temp_dir); + } else if (file_system.get() == std::string("app_persistent_cache")) { + // TODO(vtl): ScopedGeneric (hence ScopedFD) doesn't have an operator=! + dir_fd.reset(OpenAppPersistentCacheDirectory(client_url_).release()); + if (!dir_fd.is_valid()) { + LOG(ERROR) << "Failed to open app persistent cache directory for " + << client_url_; + callback.Run(Error::UNKNOWN); + return; + } } else if (file_system.get() == std::string("debug")) { #ifdef NDEBUG LOG(WARNING) << "~/MojoDebug only available in Debug builds";
diff --git a/services/files/files_impl.h b/services/files/files_impl.h index e4eab61..eafb1fe 100644 --- a/services/files/files_impl.h +++ b/services/files/files_impl.h
@@ -5,6 +5,8 @@ #ifndef SERVICES_FILES_FILES_IMPL_H_ #define SERVICES_FILES_FILES_IMPL_H_ +#include <string> + #include "base/macros.h" #include "mojo/public/cpp/bindings/interface_request.h" #include "mojo/public/cpp/bindings/strong_binding.h" @@ -30,6 +32,8 @@ const OpenFileSystemCallback& callback) override; private: + const std::string client_url_; + StrongBinding<Files> binding_; DISALLOW_COPY_AND_ASSIGN(FilesImpl);
diff --git a/services/files/files_test_base.cc b/services/files/files_test_base.cc index 10baa0f..89fbd58 100644 --- a/services/files/files_test_base.cc +++ b/services/files/files_test_base.cc
@@ -29,5 +29,13 @@ ASSERT_EQ(Error::OK, error); } +void FilesTestBase::GetAppPersistentCacheRoot(DirectoryPtr* directory) { + Error error = Error::INTERNAL; + files()->OpenFileSystem("app_persistent_cache", GetProxy(directory), + Capture(&error)); + ASSERT_TRUE(files().WaitForIncomingResponse()); + ASSERT_EQ(Error::OK, error); +} + } // namespace files } // namespace mojo
diff --git a/services/files/files_test_base.h b/services/files/files_test_base.h index dbb9205..09446cc 100644 --- a/services/files/files_test_base.h +++ b/services/files/files_test_base.h
@@ -65,9 +65,10 @@ void SetUp() override; protected: - // Note: This has an out parameter rather than returning the |DirectoryPtr|, - // since |ASSERT_...()| doesn't work with return values. + // Note: This have out parameters rather than returning |DirectoryPtr|, since + // |ASSERT_...()| doesn't work with return values. void GetTemporaryRoot(DirectoryPtr* directory); + void GetAppPersistentCacheRoot(DirectoryPtr* directory); FilesPtr& files() { return files_; }
diff --git a/services/nacl/README.md b/services/nacl/README.md index d2a1e2c..99b3ee3 100644 --- a/services/nacl/README.md +++ b/services/nacl/README.md
@@ -65,9 +65,6 @@ TODO ==== -* Turn the NexeContentHandler, PexeContentHandler, PexeCompiler, and -PexeLinker services into "anti-singletons". When each service is requested, a -unique process must be created. * Use subzero (a NaCl project to improve translation speed) for pexe translation. * Enable caching of translated pexes.
diff --git a/services/native_viewport/android/src/org/chromium/mojo/PlatformViewportAndroid.java b/services/native_viewport/android/src/org/chromium/mojo/PlatformViewportAndroid.java index 649e92b..fc39880 100644 --- a/services/native_viewport/android/src/org/chromium/mojo/PlatformViewportAndroid.java +++ b/services/native_viewport/android/src/org/chromium/mojo/PlatformViewportAndroid.java
@@ -5,6 +5,7 @@ package org.chromium.mojo; import android.app.Activity; +import android.os.Build; import android.view.MotionEvent; import android.view.Surface; import android.view.SurfaceHolder; @@ -111,6 +112,10 @@ @Override public boolean onTouchEvent(MotionEvent event) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + requestUnbufferedDispatch(event); + } + final int actionMasked = event.getActionMasked(); if (actionMasked == MotionEvent.ACTION_POINTER_DOWN || actionMasked == MotionEvent.ACTION_POINTER_UP) {
diff --git a/services/native_viewport/native_viewport_impl.cc b/services/native_viewport/native_viewport_impl.cc index 42c3980..eb5e8f1 100644 --- a/services/native_viewport/native_viewport_impl.cc +++ b/services/native_viewport/native_viewport_impl.cc
@@ -45,7 +45,7 @@ mojo::SizePtr size, mojo::SurfaceConfigurationPtr requested_configuration, const CreateCallback& callback) { - if (requested_configuration == nullptr) + if (!requested_configuration) requested_configuration = mojo::SurfaceConfiguration::New(); create_callback_ = callback;
diff --git a/services/python/mojo_url_redirector/mojo_url_redirector_apptest.cc b/services/python/mojo_url_redirector/mojo_url_redirector_apptest.cc index 43e0fa4..38e6ba6 100644 --- a/services/python/mojo_url_redirector/mojo_url_redirector_apptest.cc +++ b/services/python/mojo_url_redirector/mojo_url_redirector_apptest.cc
@@ -38,7 +38,7 @@ // starting the request that is now complete. base::MessageLoop::current()->Quit(); - EXPECT_EQ(nullptr, response->error); + EXPECT_FALSE(response->error); EXPECT_EQ(expected_http_status, response->status_code); std::string response_body; mojo::common::BlockingCopyToString(response->body.Pass(), &response_body);
diff --git a/services/ui/view_manager/view_registry.cc b/services/ui/view_manager/view_registry.cc index 182ae3d..9c691d9 100644 --- a/services/ui/view_manager/view_registry.cc +++ b/services/ui/view_manager/view_registry.cc
@@ -14,7 +14,7 @@ namespace view_manager { -static bool AreViewLayoutParamsValid(mojo::ui::ViewLayoutParams* params) { +static bool AreViewLayoutParamsValid(const mojo::ui::ViewLayoutParams* params) { return params && params->constraints && params->constraints->min_width >= 0 && params->constraints->max_width >= params->constraints->min_width && params->constraints->min_height >= 0 && @@ -22,31 +22,33 @@ params->device_pixel_ratio > 0; } -static std::ostream& operator<<(std::ostream& os, mojo::Size* size) { +static std::ostream& operator<<(std::ostream& os, const mojo::Size* size) { return size ? os << "{width=" << size->width << ", height=" << size->height << "}" : os << "{null}"; } -static std::ostream& operator<<(std::ostream& os, mojo::SurfaceId* surface_id) { +static std::ostream& operator<<(std::ostream& os, + const mojo::SurfaceId* surface_id) { return surface_id ? os << "{id_namespace=" << surface_id->id_namespace << ", local=" << surface_id->local << "}" : os << "{null}"; } -static std::ostream& operator<<(std::ostream& os, mojo::ui::ViewToken* token) { +static std::ostream& operator<<(std::ostream& os, + const mojo::ui::ViewToken* token) { return token ? os << "{token=" << token->value << "}" : os << "{null}"; } -static std::ostream& operator<<(std::ostream& os, ViewState* view_state) { +static std::ostream& operator<<(std::ostream& os, const ViewState* view_state) { return view_state ? os << "{token=" << view_state->view_token_value() << "}" : os << "{null}"; } static std::ostream& operator<<(std::ostream& os, - mojo::ui::BoxConstraints* constraints) { + const mojo::ui::BoxConstraints* constraints) { return constraints ? os << "{min_width=" << constraints->min_width << ", max_width=" << constraints->max_width @@ -56,7 +58,7 @@ }; static std::ostream& operator<<(std::ostream& os, - mojo::ui::ViewLayoutParams* params) { + const mojo::ui::ViewLayoutParams* params) { return params ? os << "{constraints=" << params->constraints.get() << ", device_pixel_ratio=" << params->device_pixel_ratio @@ -65,7 +67,7 @@ } static std::ostream& operator<<(std::ostream& os, - mojo::ui::ViewLayoutInfo* info) { + const mojo::ui::ViewLayoutInfo* info) { return info ? os << "{size=" << info->size.get() << ", surface_id=" << info->surface_id.get() << "}" @@ -244,7 +246,7 @@ if (!AreViewLayoutParamsValid(child_layout_params.get())) { LOG(ERROR) << "View provided invalid child layout parameters: " << "parent=" << parent_state << ", child_key=" << child_key - << ", child_layout_params=" << child_layout_params; + << ", child_layout_params=" << child_layout_params.get(); UnregisterView(parent_state); callback.Run(nullptr); return; @@ -255,7 +257,7 @@ if (child_it == parent_state->children().end()) { LOG(ERROR) << "View attempted to layout a child with an invalid key: " << "parent=" << parent_state << ", child_key=" << child_key - << ", child_layout_params=" << child_layout_params; + << ", child_layout_params=" << child_layout_params.get(); UnregisterView(parent_state); callback.Run(nullptr); return; @@ -314,7 +316,7 @@ if (!AreViewLayoutParamsValid(root_layout_params.get())) { LOG(ERROR) << "View tree provided invalid root layout parameters: " << "tree=" << tree_state - << ", root_layout_params=" << root_layout_params; + << ", root_layout_params=" << root_layout_params.get(); UnregisterViewTree(tree_state); callback.Run(nullptr); return; @@ -325,7 +327,8 @@ if (!tree_state->explicit_root()) { LOG(ERROR) << "View tree attempted to layout the rout without having " "set one first: tree=" - << tree_state << ", root_layout_params=" << root_layout_params; + << tree_state + << ", root_layout_params=" << root_layout_params.get(); UnregisterViewTree(tree_state); callback.Run(nullptr); return;
diff --git a/services/vsync/BUILD.gn b/services/vsync/BUILD.gn new file mode 100644 index 0000000..fa46639 --- /dev/null +++ b/services/vsync/BUILD.gn
@@ -0,0 +1,16 @@ +# Copyright 2015 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//build/config/android/config.gni") +import("//build/config/android/rules.gni") + +android_library("vsync") { + java_files = [ "src/org/chromium/mojo/vsync/VSyncProviderImpl.java" ] + + deps = [ + "//mojo/public/java:bindings", + "//mojo/public/java:system", + "//mojo/services/vsync/interfaces:interfaces_java", + ] +}
diff --git a/services/vsync/src/org/chromium/mojo/vsync/VSyncProviderImpl.java b/services/vsync/src/org/chromium/mojo/vsync/VSyncProviderImpl.java new file mode 100644 index 0000000..adca2bc --- /dev/null +++ b/services/vsync/src/org/chromium/mojo/vsync/VSyncProviderImpl.java
@@ -0,0 +1,81 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package org.chromium.mojo.vsync; + +import android.os.Handler; +import android.os.Looper; +import android.view.Choreographer; + +import org.chromium.mojo.system.Core; +import org.chromium.mojo.system.MojoException; +import org.chromium.mojo.system.RunLoop; +import org.chromium.mojom.vsync.VSyncProvider; + +/** + * Android implementation of VSyncProvider. + */ +public class VSyncProviderImpl implements VSyncProvider, Choreographer.FrameCallback { + private final RunLoop mRunLoop; + private Choreographer mChoreographer; + private AwaitVSyncResponse mCallback; + private Binding mBinding = null; + + public VSyncProviderImpl(Core core, Looper looper) { + mRunLoop = core.getCurrentRunLoop(); + // The choreographer must be initialized on a thread with a looper. + new Handler(looper).post(new Runnable() { + @Override + public void run() { + final Choreographer choreographer = Choreographer.getInstance(); + mRunLoop.postDelayedTask(new Runnable() { + @Override + public void run() { + mChoreographer = choreographer; + if (mCallback != null) { + mChoreographer.postFrameCallback(VSyncProviderImpl.this); + } + } + }, 0); + } + }); + } + + public void setBinding(Binding binding) { + if (mBinding != null) { + mBinding.unbind().close(); + } + mBinding = binding; + } + + @Override + public void close() {} + + @Override + public void onConnectionError(MojoException e) {} + + @Override + public void awaitVSync(final AwaitVSyncResponse callback) { + if (mCallback != null) { + setBinding(null); + return; + } + mCallback = callback; + if (mChoreographer != null) { + // Posting from another thread is allowed on a choreographer. + mChoreographer.postFrameCallback(this); + } + } + + @Override + public void doFrame(final long frameTimeNanos) { + mRunLoop.postDelayedTask(new Runnable() { + @Override + public void run() { + mCallback.call(frameTimeNanos / 1000); + mCallback = null; + } + }, 0); + } +}
diff --git a/shell/BUILD.gn b/shell/BUILD.gn index f2a777d..981df80 100644 --- a/shell/BUILD.gn +++ b/shell/BUILD.gn
@@ -80,6 +80,7 @@ ":jni_headers", "//gpu/config", "//mojo/android:libsystem_java", + "//mojo/common", "//mojo/services/window_manager/interfaces:interfaces", "//services/native_viewport:lib", "//shell/application_manager", @@ -350,6 +351,7 @@ "android/apk/src/org/chromium/mojo/shell/SharingApplicationDelegate.java", "android/apk/src/org/chromium/mojo/shell/ShellService.java", "android/apk/src/org/chromium/mojo/shell/ViewportActivity.java", + "android/apk/src/org/chromium/mojo/shell/VsyncFactory.java", ] deps = [ @@ -363,6 +365,7 @@ "//mojo/services/input/interfaces:interfaces_java", "//mojo/services/keyboard/interfaces:interfaces_java", "//mojo/services/nfc/interfaces:interfaces_java", + "//mojo/services/vsync/interfaces:interfaces_java", "//services/authentication", "//services/input", "//services/intent_receiver:bindings_java", @@ -372,6 +375,7 @@ "//services/native_viewport:native_viewport_java", "//services/nfc_message_sink:bindings_java", "//services/sharing_sink:bindings_java", + "//services/vsync", "//third_party/android_tools:android_support_v13_java", ] } @@ -649,6 +653,7 @@ "//mojo/public/cpp/bindings:callback", "//mojo/public/cpp/environment", "//mojo/public/cpp/system:system", + "//mojo/public/interfaces/application", "//mojo/services/http_server/cpp", "//mojo/services/http_server/interfaces", "//mojo/services/network/interfaces",
diff --git a/shell/android/apk/src/org/chromium/mojo/shell/JavaApplicationRegistry.java b/shell/android/apk/src/org/chromium/mojo/shell/JavaApplicationRegistry.java index b0e81db..67241c1 100644 --- a/shell/android/apk/src/org/chromium/mojo/shell/JavaApplicationRegistry.java +++ b/shell/android/apk/src/org/chromium/mojo/shell/JavaApplicationRegistry.java
@@ -4,6 +4,8 @@ package org.chromium.mojo.shell; +import android.os.HandlerThread; + import org.chromium.base.ApplicationStatus; import org.chromium.base.CalledByNative; import org.chromium.base.JNINamespace; @@ -30,6 +32,8 @@ @JNINamespace("shell") public class JavaApplicationRegistry { private final Map<String, ApplicationDelegate> mApplicationDelegateMap = new HashMap<>(); + // Thread with a Looper required to get callbacks from the android framework.. + private final HandlerThread mHandlerThread = new HandlerThread("FrameworkThread"); private static final class ApplicationRunnable implements Runnable { private final ApplicationDelegate mApplicationDelegate; @@ -51,7 +55,9 @@ } } - private JavaApplicationRegistry() {} + private JavaApplicationRegistry() { + mHandlerThread.start(); + } private void registerApplicationDelegate(String url, ApplicationDelegate applicationDelegate) { mApplicationDelegateMap.put(url, applicationDelegate); @@ -97,6 +103,9 @@ registry.registerApplicationDelegate("mojo:sharing", new SharingApplicationDelegate()); registry.registerApplicationDelegate( "mojo:native_viewport_support", new NativeViewportSupportApplicationDelegate()); + registry.registerApplicationDelegate( + "mojo:vsync", new ServiceProviderFactoryApplicationDelegate( + new VsyncFactory(registry.mHandlerThread.getLooper()))); return registry; }
diff --git a/shell/android/apk/src/org/chromium/mojo/shell/ShellService.java b/shell/android/apk/src/org/chromium/mojo/shell/ShellService.java index c6f758c..669d2ab 100644 --- a/shell/android/apk/src/org/chromium/mojo/shell/ShellService.java +++ b/shell/android/apk/src/org/chromium/mojo/shell/ShellService.java
@@ -19,12 +19,11 @@ import org.chromium.base.ApplicationStatus; import org.chromium.base.CalledByNative; import org.chromium.base.JNINamespace; +import org.chromium.mojo.bindings.ConnectionErrorHandler; import org.chromium.mojo.bindings.InterfaceRequest; -import org.chromium.mojo.system.MessagePipeHandle; import org.chromium.mojo.system.MojoException; import org.chromium.mojo.system.Pair; import org.chromium.mojo.system.impl.CoreImpl; -import org.chromium.mojom.mojo.ServiceProvider; import org.chromium.mojom.mojo.Shell; import java.io.BufferedReader; @@ -69,46 +68,7 @@ // A static reference to the service. private static ShellService sShellService; - private static class ShellImpl implements Shell { - private static final ShellImpl INSTANCE = new ShellImpl(); - - /** - * @see Shell#close() - */ - @Override - public void close() {} - - /** - * @see Shell#onConnectionError(org.chromium.mojo.system.MojoException) - */ - @Override - public void onConnectionError(MojoException e) {} - - /** - * @see Shell#connectToApplication(String, InterfaceRequest, ServiceProvider) - */ - @Override - public void connectToApplication(String applicationUrl, - InterfaceRequest<ServiceProvider> services, ServiceProvider exposedServices) { - int exposedServicesHandle = CoreImpl.INVALID_HANDLE; - if (exposedServices != null) { - if (exposedServices instanceof ServiceProvider.Proxy) { - ServiceProvider.Proxy proxy = (ServiceProvider.Proxy) exposedServices; - exposedServicesHandle = - proxy.getProxyHandler().passHandle().releaseNativeHandle(); - } else { - Pair<MessagePipeHandle, MessagePipeHandle> pipes = - CoreImpl.getInstance().createMessagePipe(null); - ServiceProvider.MANAGER.bind(exposedServices, pipes.first); - exposedServicesHandle = pipes.second.releaseNativeHandle(); - } - } - nativeConnectToApplication(applicationUrl, - services == null ? CoreImpl.INVALID_HANDLE - : services.passHandle().releaseNativeHandle(), - exposedServicesHandle); - } - } + private final ThreadLocal<Shell> mShell = new ThreadLocal<Shell>(); /** * Binder for the Shell service. This object is passed to the calling activities. @@ -284,9 +244,24 @@ /** * Returns an instance of the shell interface that allows to interact with mojo applications. + * Can be called on any thread, the returned proxy is thread-local. */ Shell getShell() { - return ShellImpl.INSTANCE; + Shell shell = mShell.get(); + if (shell != null) { + return shell; + } + Pair<Shell.Proxy, InterfaceRequest<Shell>> request = + Shell.MANAGER.getInterfaceRequest(CoreImpl.getInstance()); + mShell.set(request.first); + request.first.getProxyHandler().setErrorHandler(new ConnectionErrorHandler() { + @Override + public void onConnectionError(MojoException e) { + mShell.remove(); + } + }); + nativeBindShell(request.second.passHandle().releaseNativeHandle()); + return mShell.get(); } private static File getLocalAppsDir(Context context) { @@ -329,6 +304,5 @@ private static native void nativeStartApplicationURL(String url); - private static native void nativeConnectToApplication( - String applicationURL, int servicesHandle, int exposedServicesHandle); + private static native void nativeBindShell(int shellHandle); }
diff --git a/shell/android/apk/src/org/chromium/mojo/shell/VsyncFactory.java b/shell/android/apk/src/org/chromium/mojo/shell/VsyncFactory.java new file mode 100644 index 0000000..b159ce2 --- /dev/null +++ b/shell/android/apk/src/org/chromium/mojo/shell/VsyncFactory.java
@@ -0,0 +1,35 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package org.chromium.mojo.shell; + +import android.os.Looper; + +import org.chromium.mojo.application.ServiceFactoryBinder; +import org.chromium.mojo.bindings.InterfaceRequest; +import org.chromium.mojo.system.impl.CoreImpl; +import org.chromium.mojo.vsync.VSyncProviderImpl; +import org.chromium.mojom.vsync.VSyncProvider; + +/** + * A ServiceFactoryBinder for the vsync service. + */ +final class VsyncFactory implements ServiceFactoryBinder<VSyncProvider> { + private final Looper mLooper; + + public VsyncFactory(Looper looper) { + mLooper = looper; + } + + @Override + public void bind(InterfaceRequest<VSyncProvider> request) { + VSyncProviderImpl implementation = new VSyncProviderImpl(CoreImpl.getInstance(), mLooper); + implementation.setBinding(VSyncProvider.MANAGER.bind(implementation, request)); + } + + @Override + public String getInterfaceName() { + return VSyncProvider.MANAGER.getName(); + } +}
diff --git a/shell/android/main.cc b/shell/android/main.cc index a922d22..ec52a15 100644 --- a/shell/android/main.cc +++ b/shell/android/main.cc
@@ -25,6 +25,7 @@ #include "base/threading/simple_thread.h" #include "gpu/config/gpu_util.h" #include "jni/ShellService_jni.h" +#include "mojo/common/binding_set.h" #include "mojo/message_pump/message_pump_mojo.h" #include "mojo/services/network/interfaces/network_service.mojom.h" #include "mojo/services/window_manager/interfaces/window_manager.mojom.h" @@ -34,6 +35,7 @@ #include "shell/android/ui_application_loader_android.h" #include "shell/android/url_response_disk_cache_delegate_impl.h" #include "shell/application_manager/application_loader.h" +#include "shell/application_manager/shell_impl.h" #include "shell/background_application_loader.h" #include "shell/command_line_util.h" #include "shell/context.h" @@ -97,6 +99,12 @@ // Delegate for URLResponseDiskCache. Allows to access bundled application on // cold start. scoped_ptr<URLResponseDiskCacheDelegateImpl> url_response_disk_cache_delegate; + + // Shell implementation to expose to java. + scoped_ptr<ShellImpl> shell_impl; + + // Binding set to the shell implementation. + mojo::BindingSet<mojo::Shell> shell_bindings; }; LazyInstance<InternalShellData> g_internal_data = LAZY_INSTANCE_INITIALIZER; @@ -184,18 +192,22 @@ LOG(ERROR) << "Failed to set stdout to be line buffered."; } -void ConnectToApplicationImpl( - const GURL& url, - mojo::ScopedMessagePipeHandle services_handle, - mojo::ScopedMessagePipeHandle exposed_services_handle) { +void BindShellImpl(mojo::ScopedMessagePipeHandle shell_handle) { Context* context = g_internal_data.Get().context.get(); - mojo::InterfaceRequest<mojo::ServiceProvider> services; - services.Bind(services_handle.Pass()); - mojo::ServiceProviderPtr exposed_services; - exposed_services.Bind(mojo::InterfacePtrInfo<mojo::ServiceProvider>( - exposed_services_handle.Pass(), 0u)); - context->application_manager()->ConnectToApplication( - url, GURL(), services.Pass(), exposed_services.Pass(), base::Closure()); + if (!g_internal_data.Get().shell_impl.get()) { + // The application proxy is null, as the shell is not connectable from other + // applications. + mojo::ApplicationPtr application; + // The identity of the shell is the empty URL. + GURL identity; + g_internal_data.Get().shell_impl.reset( + new ShellImpl(application.Pass(), context->application_manager(), + Identity(identity), base::Closure())); + } + mojo::InterfaceRequest<mojo::Shell> shell; + shell.Bind(shell_handle.Pass()); + g_internal_data.Get().shell_bindings.AddBinding( + g_internal_data.Get().shell_impl.get(), shell.Pass()); } void EmbedApplicationByURL(std::string url) { @@ -326,19 +338,11 @@ FROM_HERE, base::Bind(&EmbedApplicationByURL, url)); } -static void ConnectToApplication(JNIEnv* env, - jclass clazz, - jstring jurl, - jint services_handle, - jint exposed_services_handle) { - GURL url = GURL(base::android::ConvertJavaStringToUTF8(env, jurl)); +static void BindShell(JNIEnv* env, jclass clazz, jint shell_handle) { g_internal_data.Get().shell_task_runner->PostTask( FROM_HERE, - base::Bind(&ConnectToApplicationImpl, url, - base::Passed(mojo::ScopedMessagePipeHandle( - mojo::MessagePipeHandle(services_handle))), - base::Passed(mojo::ScopedMessagePipeHandle( - mojo::MessagePipeHandle(exposed_services_handle))))); + base::Bind(&BindShellImpl, base::Passed(mojo::ScopedMessagePipeHandle( + mojo::MessagePipeHandle(shell_handle))))); } bool RegisterShellService(JNIEnv* env) {
diff --git a/shell/application_manager/BUILD.gn b/shell/application_manager/BUILD.gn index 9a9cf0c..dac121c 100644 --- a/shell/application_manager/BUILD.gn +++ b/shell/application_manager/BUILD.gn
@@ -44,6 +44,7 @@ "//base/third_party/dynamic_annotations", "//crypto:crypto", "//url", + "//mojo/common", "//mojo/edk/system", "//mojo/environment:chromium", "//mojo/services/content_handler/interfaces",
diff --git a/shell/application_manager/application_manager.cc b/shell/application_manager/application_manager.cc index 6e7b965..2dfdc3e 100644 --- a/shell/application_manager/application_manager.cc +++ b/shell/application_manager/application_manager.cc
@@ -8,6 +8,7 @@ #include "base/command_line.h" #include "base/logging.h" #include "base/macros.h" +#include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/trace_event/trace_event.h" #include "mojo/public/cpp/bindings/binding.h" @@ -48,11 +49,10 @@ class ApplicationManager::ContentHandlerConnection { public: - ContentHandlerConnection(ApplicationManager* manager, - const GURL& content_handler_url) - : manager_(manager), content_handler_url_(content_handler_url) { + ContentHandlerConnection(ApplicationManager* manager, Identity identity) + : manager_(manager), identity_(identity) { ServiceProviderPtr services; - manager->ConnectToApplication(content_handler_url, GURL(), + manager->ConnectToApplication(identity_.url, GURL(), mojo::GetProxy(&services), nullptr, base::Closure()); mojo::MessagePipe pipe; @@ -67,11 +67,13 @@ mojo::ContentHandler* content_handler() { return content_handler_.get(); } - GURL content_handler_url() { return content_handler_url_; } + const GURL& content_handler_url() const { return identity_.url; } + + const Identity& identity() const { return identity_; } private: ApplicationManager* manager_; - GURL content_handler_url_; + const Identity identity_; mojo::ContentHandlerPtr content_handler_; DISALLOW_COPY_AND_ASSIGN(ContentHandlerConnection); @@ -230,6 +232,9 @@ if (!shell_impl) return false; + DCHECK(!GetNativeApplicationOptionsForURL(application_url) + ->new_process_per_connection); + ConnectToClient(shell_impl, resolved_url, requestor_url, services->Pass(), exposed_services->Pass()); return true; @@ -253,6 +258,17 @@ return true; } +Identity ApplicationManager::MakeApplicationIdentity(const GURL& resolved_url) { + static uint64_t unique_id_number = 1; + bool new_process_per_connection = + GetNativeApplicationOptionsForURL( + GetBaseURLAndQuery(resolved_url, nullptr)) + ->new_process_per_connection; + return new_process_per_connection + ? Identity(resolved_url, base::Uint64ToString(unique_id_number++)) + : Identity(resolved_url); +} + InterfaceRequest<Application> ApplicationManager::RegisterShell( const GURL& resolved_url, const GURL& requestor_url, @@ -260,7 +276,7 @@ ServiceProviderPtr exposed_services, const base::Closure& on_application_end, const std::vector<std::string>& parameters) { - Identity app_identity(resolved_url); + Identity app_identity = MakeApplicationIdentity(resolved_url); mojo::ApplicationPtr application; InterfaceRequest<Application> application_request = @@ -274,6 +290,9 @@ return application_request; } +// Note: If a service was created with a unique ID, intending to be unique +// (such that multiple requests for a service result in unique processes), then +// 'GetShellImpl' should return nullptr. ShellImpl* ApplicationManager::GetShellImpl(const GURL& url) { const auto& shell_it = identity_to_shell_impl_.find(Identity(url)); if (shell_it != identity_to_shell_impl_.end()) @@ -410,12 +429,14 @@ InterfaceRequest<Application> application_request, mojo::URLResponsePtr url_response) { ContentHandlerConnection* connection = nullptr; - auto it = url_to_content_handler_.find(content_handler_url); - if (it != url_to_content_handler_.end()) { + Identity content_handler_id = MakeApplicationIdentity(content_handler_url); + auto it = identity_to_content_handler_.find(content_handler_id); + if (it != identity_to_content_handler_.end()) { connection = it->second.get(); } else { - connection = new ContentHandlerConnection(this, content_handler_url); - url_to_content_handler_[content_handler_url] = make_scoped_ptr(connection); + connection = new ContentHandlerConnection(this, content_handler_id); + identity_to_content_handler_[content_handler_id] = + make_scoped_ptr(connection); } connection->content_handler()->StartApplication(application_request.Pass(), @@ -485,10 +506,9 @@ void ApplicationManager::OnContentHandlerError( ContentHandlerConnection* content_handler) { // Remove the mapping to the content handler. - auto it = - url_to_content_handler_.find(content_handler->content_handler_url()); - DCHECK(it != url_to_content_handler_.end()); - url_to_content_handler_.erase(it); + auto it = identity_to_content_handler_.find(content_handler->identity()); + DCHECK(it != identity_to_content_handler_.end()); + identity_to_content_handler_.erase(it); } mojo::ScopedMessagePipeHandle ApplicationManager::ConnectToServiceByName(
diff --git a/shell/application_manager/application_manager.h b/shell/application_manager/application_manager.h index 0a5e8b0..3be4992 100644 --- a/shell/application_manager/application_manager.h +++ b/shell/application_manager/application_manager.h
@@ -146,8 +146,8 @@ using SchemeToLoaderMap = std::map<std::string, scoped_ptr<ApplicationLoader>>; using IdentityToShellImplMap = std::map<Identity, scoped_ptr<ShellImpl>>; - using URLToContentHandlerMap = - std::map<GURL, scoped_ptr<ContentHandlerConnection>>; + using IdentityToContentHandlerMap = + std::map<Identity, scoped_ptr<ContentHandlerConnection>>; using URLToArgsMap = std::map<GURL, std::vector<std::string>>; using MimeTypeToURLMap = std::map<std::string, GURL>; using URLToNativeOptionsMap = std::map<GURL, NativeApplicationOptions>; @@ -175,6 +175,12 @@ const std::vector<std::string>& parameters, ApplicationLoader* loader); + // Creates an Identity for the service identified by |resolved_url|. + // If |new_process_per_connection| is true for the URL's options, then the + // identity is unique. Otherwise, repeated invocations with the same + // |resolved_url| will result in an equivalent Identity. + Identity MakeApplicationIdentity(const GURL& resolved_url); + mojo::InterfaceRequest<mojo::Application> RegisterShell( // The URL after resolution and redirects, including the querystring. const GURL& resolved_url, @@ -234,7 +240,7 @@ scoped_ptr<NativeRunnerFactory> native_runner_factory_; IdentityToShellImplMap identity_to_shell_impl_; - URLToContentHandlerMap url_to_content_handler_; + IdentityToContentHandlerMap identity_to_content_handler_; URLToArgsMap url_to_args_; // Note: The keys are URLs after mapping and resolving. URLToNativeOptionsMap url_to_native_options_;
diff --git a/shell/application_manager/native_application_options.h b/shell/application_manager/native_application_options.h index f4c71c4..103ab14 100644 --- a/shell/application_manager/native_application_options.h +++ b/shell/application_manager/native_application_options.h
@@ -12,6 +12,7 @@ // TODO(vtl): Maybe these some of these should be tristate (unknown/true/false) // instead of of booleans. struct NativeApplicationOptions { + bool new_process_per_connection = false; bool force_in_process = false; bool require_32_bit = false; bool allow_new_privs = false;
diff --git a/shell/application_manager/shell_impl.cc b/shell/application_manager/shell_impl.cc index f75c028..a54adb5 100644 --- a/shell/application_manager/shell_impl.cc +++ b/shell/application_manager/shell_impl.cc
@@ -4,24 +4,56 @@ #include "shell/application_manager/shell_impl.h" +#include <utility> + #include "mojo/converters/url/url_type_converters.h" #include "mojo/services/content_handler/interfaces/content_handler.mojom.h" #include "shell/application_manager/application_manager.h" +using mojo::ApplicationConnector; +using mojo::ApplicationPtr; +using mojo::Array; +using mojo::InterfaceRequest; using mojo::ServiceProvider; using mojo::ServiceProviderPtr; +using mojo::Shell; +using mojo::ShellPtr; +using mojo::String; namespace shell { -ShellImpl::ShellImpl(mojo::ApplicationPtr application, +// ShellImpl::ApplicationConnectorImpl ----------------------------------------- + +ShellImpl::ApplicationConnectorImpl::ApplicationConnectorImpl(Shell* shell) + : shell_(shell) {} + +ShellImpl::ApplicationConnectorImpl::~ApplicationConnectorImpl() {} + +void ShellImpl::ApplicationConnectorImpl::ConnectToApplication( + const String& app_url, + InterfaceRequest<ServiceProvider> services, + ServiceProviderPtr exposed_services) { + shell_->ConnectToApplication(app_url, std::move(services), + std::move(exposed_services)); +} + +void ShellImpl::ApplicationConnectorImpl::Duplicate( + InterfaceRequest<ApplicationConnector> application_connector_request) { + bindings_.AddBinding(this, std::move(application_connector_request)); +} + +// ShellImpl ------------------------------------------------------------------- + +ShellImpl::ShellImpl(ApplicationPtr application, ApplicationManager* manager, const Identity& identity, const base::Closure& on_application_end) : manager_(manager), identity_(identity), on_application_end_(on_application_end), - application_(application.Pass()), - binding_(this) { + application_(std::move(application)), + binding_(this), + application_connector_impl_(this) { binding_.set_connection_error_handler( [this]() { manager_->OnShellImplError(this); }); } @@ -29,34 +61,38 @@ ShellImpl::~ShellImpl() { } -void ShellImpl::InitializeApplication(mojo::Array<mojo::String> args) { - mojo::ShellPtr shell; - binding_.Bind(mojo::GetProxy(&shell)); - application_->Initialize(shell.Pass(), args.Pass(), identity_.url.spec()); +void ShellImpl::InitializeApplication(Array<String> args) { + ShellPtr shell; + binding_.Bind(GetProxy(&shell)); + application_->Initialize(std::move(shell), std::move(args), + identity_.url.spec()); } -void ShellImpl::ConnectToClient( - const GURL& requested_url, - const GURL& requestor_url, - mojo::InterfaceRequest<ServiceProvider> services, - ServiceProviderPtr exposed_services) { - application_->AcceptConnection(mojo::String::From(requestor_url), - services.Pass(), exposed_services.Pass(), - requested_url.spec()); +void ShellImpl::ConnectToClient(const GURL& requested_url, + const GURL& requestor_url, + InterfaceRequest<ServiceProvider> services, + ServiceProviderPtr exposed_services) { + application_->AcceptConnection( + String::From(requestor_url), std::move(services), + std::move(exposed_services), requested_url.spec()); } -// Shell implementation: -void ShellImpl::ConnectToApplication( - const mojo::String& app_url, - mojo::InterfaceRequest<ServiceProvider> services, - ServiceProviderPtr exposed_services) { +void ShellImpl::ConnectToApplication(const String& app_url, + InterfaceRequest<ServiceProvider> services, + ServiceProviderPtr exposed_services) { GURL app_gurl(app_url); if (!app_gurl.is_valid()) { LOG(ERROR) << "Error: invalid URL: " << app_url; return; } - manager_->ConnectToApplication(app_gurl, identity_.url, services.Pass(), - exposed_services.Pass(), base::Closure()); + manager_->ConnectToApplication(app_gurl, identity_.url, std::move(services), + std::move(exposed_services), base::Closure()); +} + +void ShellImpl::CreateApplicationConnector( + InterfaceRequest<ApplicationConnector> application_connector_request) { + application_connector_impl_.Duplicate( + std::move(application_connector_request)); } } // namespace shell
diff --git a/shell/application_manager/shell_impl.h b/shell/application_manager/shell_impl.h index 0155720..0fa93ca 100644 --- a/shell/application_manager/shell_impl.h +++ b/shell/application_manager/shell_impl.h
@@ -6,8 +6,11 @@ #define SHELL_APPLICATION_MANAGER_SHELL_IMPL_H_ #include "base/callback.h" +#include "base/macros.h" +#include "mojo/common/binding_set.h" #include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/interfaces/application/application.mojom.h" +#include "mojo/public/interfaces/application/application_connector.mojom.h" #include "mojo/public/interfaces/application/shell.mojom.h" #include "shell/application_manager/identity.h" #include "url/gurl.h" @@ -16,6 +19,11 @@ class ApplicationManager; +// TODO(vtl): This both implements the |Shell| interface and holds the +// |ApplicationPtr| (from back when they were paired interfaces on the same +// message pipe). The way it manages lifetime is dubious/wrong. We should have +// an object holding stuff associated to an application, namely its "real" +// |ShellImpl|, its |ApplicationPtr|, and tracking its |ApplicationConnector|s. class ShellImpl : public mojo::Shell { public: ShellImpl(mojo::ApplicationPtr application, @@ -37,11 +45,34 @@ base::Closure on_application_end() const { return on_application_end_; } private: + // This is a per-|ShellImpl| singleton. + class ApplicationConnectorImpl : public mojo::ApplicationConnector { + public: + explicit ApplicationConnectorImpl(mojo::Shell* shell); + ~ApplicationConnectorImpl() override; + + void ConnectToApplication( + const mojo::String& app_url, + mojo::InterfaceRequest<mojo::ServiceProvider> services, + mojo::ServiceProviderPtr exposed_services) override; + void Duplicate(mojo::InterfaceRequest<mojo::ApplicationConnector> + application_connector_request) override; + + private: + mojo::Shell* const shell_; + mojo::BindingSet<mojo::ApplicationConnector> bindings_; + + DISALLOW_COPY_AND_ASSIGN(ApplicationConnectorImpl); + }; + // mojo::Shell implementation: void ConnectToApplication( const mojo::String& app_url, mojo::InterfaceRequest<mojo::ServiceProvider> services, mojo::ServiceProviderPtr exposed_services) override; + void CreateApplicationConnector( + mojo::InterfaceRequest<mojo::ApplicationConnector> + application_connector_request) override; ApplicationManager* const manager_; const Identity identity_; @@ -49,6 +80,8 @@ mojo::ApplicationPtr application_; mojo::Binding<mojo::Shell> binding_; + ApplicationConnectorImpl application_connector_impl_; + DISALLOW_COPY_AND_ASSIGN(ShellImpl); };
diff --git a/shell/context.cc b/shell/context.cc index abd30a1..b881338 100644 --- a/shell/context.cc +++ b/shell/context.cc
@@ -157,7 +157,7 @@ if (parts.size() % 2 != 0) { LOG(ERROR) << "Invalid value for switch " << switches::kContentHandlers << ": must be a comma-separated list of mimetype/url pairs." - << handlers_spec; + << " Value was: " << handlers_spec; return; } @@ -194,6 +194,17 @@ // configuring options for native apps. manager->GetNativeApplicationOptionsForURL(GURL("mojo:native_support")) ->allow_new_privs = true; + // All NaCl operations require a unique process + manager->GetNativeApplicationOptionsForURL(GURL("mojo:pnacl_compile")) + ->new_process_per_connection = true; + manager->GetNativeApplicationOptionsForURL(GURL("mojo:pnacl_link")) + ->new_process_per_connection = true; + manager->GetNativeApplicationOptionsForURL( + GURL("mojo:content_handler_nonsfi_pexe")) + ->new_process_per_connection = true; + manager->GetNativeApplicationOptionsForURL( + GURL("mojo:content_handler_nonsfi_nexe")) + ->new_process_per_connection = true; } class TracingServiceProvider : public ServiceProvider {
diff --git a/shell/shell_apptest.cc b/shell/shell_apptest.cc index 1011e24..2829155 100644 --- a/shell/shell_apptest.cc +++ b/shell/shell_apptest.cc
@@ -13,7 +13,9 @@ #include "mojo/data_pipe_utils/data_pipe_utils.h" #include "mojo/public/cpp/application/application_impl.h" #include "mojo/public/cpp/application/application_test_base.h" +#include "mojo/public/cpp/application/connect.h" #include "mojo/public/cpp/system/macros.h" +#include "mojo/public/interfaces/application/application_connector.mojom.h" #include "mojo/services/http_server/cpp/http_server_util.h" #include "mojo/services/http_server/interfaces/http_server.mojom.h" #include "mojo/services/http_server/interfaces/http_server_factory.mojom.h" @@ -88,14 +90,14 @@ local_address->ipv4->addr[2] = 0; local_address->ipv4->addr[3] = 1; local_address->ipv4->port = 0; - http_server_factory_->CreateHttpServer(mojo::GetProxy(&http_server_), + http_server_factory_->CreateHttpServer(GetProxy(&http_server_), local_address.Pass()); http_server_->GetPort([this](uint16_t p) { port_ = p; }); EXPECT_TRUE(http_server_.WaitForIncomingResponse()); http_server::HttpHandlerPtr http_handler; - handler_.reset(new GetHandler(mojo::GetProxy(&http_handler).Pass(), port_)); + handler_.reset(new GetHandler(GetProxy(&http_handler).Pass(), port_)); http_server_->SetHandler(".*", http_handler.Pass(), [](bool result) { EXPECT_TRUE(result); }); EXPECT_TRUE(http_server_.WaitForIncomingResponse()); @@ -184,8 +186,8 @@ TEST_F(ShellAppTest, MojoURLQueryHandling) { PingablePtr pingable; application_impl()->ConnectToService("mojo:pingable_app?foo", &pingable); - auto callback = [this](const String& app_url, const String& connection_url, - const String& message) { + auto callback = [](const String& app_url, const String& connection_url, + const String& message) { EXPECT_TRUE(EndsWith(app_url, "/pingable_app.mojo", true)); EXPECT_EQ(app_url.To<std::string>() + "?foo", connection_url); EXPECT_EQ("hello", message); @@ -195,4 +197,46 @@ base::RunLoop().Run(); } +void TestApplicationConnector(mojo::ApplicationConnector* app_connector) { + PingablePtr pingable; + ConnectToService(app_connector, "mojo:pingable_app", &pingable); + auto callback = [](const String& app_url, const String& connection_url, + const String& message) { + EXPECT_TRUE(EndsWith(app_url, "/pingable_app.mojo", true)); + EXPECT_EQ(app_url, connection_url); + EXPECT_EQ("hello", message); + base::MessageLoop::current()->Quit(); + }; + pingable->Ping("hello", callback); + base::RunLoop().Run(); +} + +TEST_F(ShellAppTest, ApplicationConnector) { + mojo::ApplicationConnectorPtr app_connector; + app_connector.Bind(application_impl()->CreateApplicationConnector()); + TestApplicationConnector(app_connector.get()); +} + +TEST_F(ShellAppTest, ApplicationConnectorDuplicate) { + mojo::ApplicationConnectorPtr app_connector1; + app_connector1.Bind(application_impl()->CreateApplicationConnector()); + { + SCOPED_TRACE("app_connector1"); + TestApplicationConnector(app_connector1.get()); + } + + mojo::ApplicationConnectorPtr app_connector2; + app_connector1->Duplicate(GetProxy(&app_connector2)); + { + SCOPED_TRACE("app_connector2"); + TestApplicationConnector(app_connector2.get()); + } + + // The first one should still work. + { + SCOPED_TRACE("app_connector1 again"); + TestApplicationConnector(app_connector1.get()); + } +} + } // namespace