| 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.h" | 7 #include "mojo/public/cpp/application/application.h" |
| 8 #include "mojo/services/public/interfaces/network/network_service.mojom.h" | 8 #include "mojo/services/public/interfaces/network/network_service.mojom.h" |
| 9 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" | 9 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" |
| 10 | 10 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 for (;;) { | 82 for (;;) { |
| 83 char buf[512]; | 83 char buf[512]; |
| 84 uint32_t num_bytes = sizeof(buf); | 84 uint32_t num_bytes = sizeof(buf); |
| 85 MojoResult result = ReadDataRaw( | 85 MojoResult result = ReadDataRaw( |
| 86 response_body_stream_.get(), | 86 response_body_stream_.get(), |
| 87 buf, | 87 buf, |
| 88 &num_bytes, | 88 &num_bytes, |
| 89 MOJO_READ_DATA_FLAG_NONE); | 89 MOJO_READ_DATA_FLAG_NONE); |
| 90 if (result == MOJO_RESULT_SHOULD_WAIT) { | 90 if (result == MOJO_RESULT_SHOULD_WAIT) { |
| 91 Wait(response_body_stream_.get(), | 91 Wait(response_body_stream_.get(), |
| 92 MOJO_WAIT_FLAG_READABLE, | 92 MOJO_HANDLE_SIGNAL_READABLE, |
| 93 MOJO_DEADLINE_INDEFINITE); | 93 MOJO_DEADLINE_INDEFINITE); |
| 94 } else if (result == MOJO_RESULT_OK) { | 94 } else if (result == MOJO_RESULT_OK) { |
| 95 fwrite(buf, num_bytes, 1, stdout); | 95 fwrite(buf, num_bytes, 1, stdout); |
| 96 } else { | 96 } else { |
| 97 break; | 97 break; |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 | 100 |
| 101 printf("\n>>> EOF <<<\n"); | 101 printf("\n>>> EOF <<<\n"); |
| 102 } | 102 } |
| 103 | 103 |
| 104 NetworkServicePtr network_service_; | 104 NetworkServicePtr network_service_; |
| 105 URLLoaderPtr url_loader_; | 105 URLLoaderPtr url_loader_; |
| 106 ScopedDataPipeConsumerHandle response_body_stream_; | 106 ScopedDataPipeConsumerHandle response_body_stream_; |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 } // namespace examples | 109 } // namespace examples |
| 110 | 110 |
| 111 // static | 111 // static |
| 112 Application* Application::Create() { | 112 Application* Application::Create() { |
| 113 return new examples::WGetApp(); | 113 return new examples::WGetApp(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 } // namespace mojo | 116 } // namespace mojo |
| OLD | NEW |