| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:typed_data'; | 6 import 'dart:typed_data'; |
| 7 import 'mojo:bindings' as bindings; | 7 import 'mojo:bindings' as bindings; |
| 8 import 'mojo:core' as core; | 8 import 'mojo:core' as core; |
| 9 | 9 |
| 10 import 'package:mojo/dart/embedder/test/dart_to_cpp.mojom.dart'; | 10 import 'package:mojo/dart/embedder/test/dart_to_cpp.mojom.dart'; |
| 11 | 11 |
| 12 class DartSideImpl implements DartSide { | 12 class DartSideImpl implements DartSide { |
| 13 static const int BAD_VALUE = 13; | 13 static const int BAD_VALUE = 13; |
| 14 static const int ELEMENT_BYTES = 1; | 14 static const int ELEMENT_BYTES = 1; |
| 15 static const int CAPACITY_BYTES = 64; | 15 static const int CAPACITY_BYTES = 64; |
| 16 | 16 |
| 17 DartSideStub _stub; | 17 DartSideStub _stub; |
| 18 CppSideProxy cppSide; | 18 CppSideProxy cppSide; |
| 19 | 19 |
| 20 Uint8List _sampleData; | 20 Uint8List _sampleData; |
| 21 Uint8List _sampleMessage; | 21 Uint8List _sampleMessage; |
| 22 Completer _completer; | 22 Completer _completer; |
| 23 | 23 |
| 24 DartSideImpl(core.MojoMessagePipeEndpoint endpoint) { | 24 DartSideImpl(core.MojoMessagePipeEndpoint endpoint) { |
| 25 _stub = new DartSideStub.fromEndpoint(endpoint) | 25 _stub = new DartSideStub.fromEndpoint(endpoint, impl: this); |
| 26 ..delegate = this | |
| 27 ..listen(); | |
| 28 _sampleData = new Uint8List(CAPACITY_BYTES); | 26 _sampleData = new Uint8List(CAPACITY_BYTES); |
| 29 for (int i = 0; i < _sampleData.length; ++i) { | 27 for (int i = 0; i < _sampleData.length; ++i) { |
| 30 _sampleData[i] = i; | 28 _sampleData[i] = i; |
| 31 } | 29 } |
| 32 _sampleMessage = new Uint8List(CAPACITY_BYTES); | 30 _sampleMessage = new Uint8List(CAPACITY_BYTES); |
| 33 for (int i = 0; i < _sampleMessage.length; ++i) { | 31 for (int i = 0; i < _sampleMessage.length; ++i) { |
| 34 _sampleMessage[i] = 255 - i; | 32 _sampleMessage[i] = 255 - i; |
| 35 } | 33 } |
| 36 _completer = new Completer(); | 34 _completer = new Completer(); |
| 37 } | 35 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 main(List args) { | 111 main(List args) { |
| 114 assert(args.length == 2); | 112 assert(args.length == 2); |
| 115 int mojoHandle = args[0]; | 113 int mojoHandle = args[0]; |
| 116 var rawHandle = new core.MojoHandle(mojoHandle); | 114 var rawHandle = new core.MojoHandle(mojoHandle); |
| 117 var endpoint = new core.MojoMessagePipeEndpoint(rawHandle); | 115 var endpoint = new core.MojoMessagePipeEndpoint(rawHandle); |
| 118 var dartSide = new DartSideImpl(endpoint); | 116 var dartSide = new DartSideImpl(endpoint); |
| 119 dartSide.future.then((_) { | 117 dartSide.future.then((_) { |
| 120 print('Success'); | 118 print('Success'); |
| 121 }); | 119 }); |
| 122 } | 120 } |
| OLD | NEW |