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 #include <stdio.h> | 5 #include <stdio.h> |
6 | 6 |
7 #include "mojo/public/cpp/application/application_delegate.h" | 7 #include "mojo/public/cpp/application/application_delegate.h" |
8 #include "mojo/public/cpp/application/application_impl.h" | 8 #include "mojo/public/cpp/application/application_impl.h" |
9 #include "mojo/services/public/interfaces/network/network_service.mojom.h" | 9 #include "mojo/services/public/interfaces/network/network_service.mojom.h" |
10 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" | 10 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 MojoResult result = ReadDataRaw( | 86 MojoResult result = ReadDataRaw( |
87 response_body_stream_.get(), | 87 response_body_stream_.get(), |
88 buf, | 88 buf, |
89 &num_bytes, | 89 &num_bytes, |
90 MOJO_READ_DATA_FLAG_NONE); | 90 MOJO_READ_DATA_FLAG_NONE); |
91 if (result == MOJO_RESULT_SHOULD_WAIT) { | 91 if (result == MOJO_RESULT_SHOULD_WAIT) { |
92 Wait(response_body_stream_.get(), | 92 Wait(response_body_stream_.get(), |
93 MOJO_HANDLE_SIGNAL_READABLE, | 93 MOJO_HANDLE_SIGNAL_READABLE, |
94 MOJO_DEADLINE_INDEFINITE); | 94 MOJO_DEADLINE_INDEFINITE); |
95 } else if (result == MOJO_RESULT_OK) { | 95 } else if (result == MOJO_RESULT_OK) { |
96 fwrite(buf, num_bytes, 1, stdout); | 96 assert(num_bytes == fwrite(buf, num_bytes, 1, stdout)); |
darin (slow to review)
2014/06/28 05:29:00
doesn't assert(x) compile to nothing in release bu
| |
97 } else { | 97 } else { |
98 break; | 98 break; |
99 } | 99 } |
100 } | 100 } |
101 | 101 |
102 printf("\n>>> EOF <<<\n"); | 102 printf("\n>>> EOF <<<\n"); |
103 } | 103 } |
104 | 104 |
105 NetworkServicePtr network_service_; | 105 NetworkServicePtr network_service_; |
106 URLLoaderPtr url_loader_; | 106 URLLoaderPtr url_loader_; |
107 ScopedDataPipeConsumerHandle response_body_stream_; | 107 ScopedDataPipeConsumerHandle response_body_stream_; |
108 }; | 108 }; |
109 | 109 |
110 } // namespace examples | 110 } // namespace examples |
111 | 111 |
112 // static | 112 // static |
113 ApplicationDelegate* ApplicationDelegate::Create() { | 113 ApplicationDelegate* ApplicationDelegate::Create() { |
114 return new examples::WGetApp(); | 114 return new examples::WGetApp(); |
115 } | 115 } |
116 | 116 |
117 } // namespace mojo | 117 } // namespace mojo |
OLD | NEW |