OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 library http_request_mojom; | 5 library http_request_mojom; |
6 import 'package:mojo/bindings.dart' as bindings; | 6 import 'package:mojo/bindings.dart' as bindings; |
7 import 'package:mojo/core.dart' as core; | 7 import 'package:mojo/core.dart' as core; |
8 | 8 |
9 | 9 |
10 | 10 |
11 | 11 |
12 class HttpRequest extends bindings.Struct { | 12 class HttpRequest extends bindings.Struct { |
13 static const List<bindings.StructDataHeader> kVersions = const [ | 13 static const List<bindings.StructDataHeader> kVersions = const [ |
14 const bindings.StructDataHeader(40, 0) | 14 const bindings.StructDataHeader(40, 0) |
15 ]; | 15 ]; |
16 String relativeUrl = null; | 16 String relativeUrl = null; |
17 String method = "GET"; | 17 String method = "GET"; |
18 Map<String, String> headers = null; | 18 Map<String, String> headers = null; |
19 core.MojoDataPipeConsumer body = null; | 19 core.MojoDataPipeConsumer body = null; |
20 | 20 |
21 HttpRequest() : super(kVersions.last.size); | 21 HttpRequest() : super(kVersions.last.size); |
22 | 22 |
| 23 HttpRequest.init( |
| 24 String this.relativeUrl, |
| 25 String this.method, |
| 26 Map<String, String> this.headers, |
| 27 core.MojoDataPipeConsumer this.body |
| 28 ) : super(kVersions.last.size); |
| 29 |
23 static HttpRequest deserialize(bindings.Message message) { | 30 static HttpRequest deserialize(bindings.Message message) { |
24 var decoder = new bindings.Decoder(message); | 31 var decoder = new bindings.Decoder(message); |
25 var result = decode(decoder); | 32 var result = decode(decoder); |
26 if (decoder.excessHandles != null) { | 33 if (decoder.excessHandles != null) { |
27 decoder.excessHandles.forEach((h) => h.close()); | 34 decoder.excessHandles.forEach((h) => h.close()); |
28 } | 35 } |
29 return result; | 36 return result; |
30 } | 37 } |
31 | 38 |
32 static HttpRequest decode(bindings.Decoder decoder0) { | 39 static HttpRequest decode(bindings.Decoder decoder0) { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 } | 173 } |
167 | 174 |
168 Map toJson() { | 175 Map toJson() { |
169 throw new bindings.MojoCodecError( | 176 throw new bindings.MojoCodecError( |
170 'Object containing handles cannot be encoded to JSON.'); | 177 'Object containing handles cannot be encoded to JSON.'); |
171 } | 178 } |
172 } | 179 } |
173 | 180 |
174 | 181 |
175 | 182 |
OLD | NEW |