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 if (fwrite(buf, num_bytes, 1, stdout) != num_bytes) { |
darin (slow to review)
2014/07/09 21:02:21
LGTM
| |
97 printf("\nUnexpected error writing to file\n"); | |
98 break; | |
99 } | |
97 } else { | 100 } else { |
98 break; | 101 break; |
99 } | 102 } |
100 } | 103 } |
101 | 104 |
102 printf("\n>>> EOF <<<\n"); | 105 printf("\n>>> EOF <<<\n"); |
103 } | 106 } |
104 | 107 |
105 NetworkServicePtr network_service_; | 108 NetworkServicePtr network_service_; |
106 URLLoaderPtr url_loader_; | 109 URLLoaderPtr url_loader_; |
107 ScopedDataPipeConsumerHandle response_body_stream_; | 110 ScopedDataPipeConsumerHandle response_body_stream_; |
108 }; | 111 }; |
109 | 112 |
110 } // namespace examples | 113 } // namespace examples |
111 | 114 |
112 // static | 115 // static |
113 ApplicationDelegate* ApplicationDelegate::Create() { | 116 ApplicationDelegate* ApplicationDelegate::Create() { |
114 return new examples::WGetApp(); | 117 return new examples::WGetApp(); |
115 } | 118 } |
116 | 119 |
117 } // namespace mojo | 120 } // namespace mojo |
OLD | NEW |