| 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/public/cpp/utility/run_loop.h" | 9 #include "mojo/public/cpp/utility/run_loop.h" |
| 10 #include "mojo/services/public/interfaces/network/network_service.mojom.h" | 10 #include "mojo/services/public/interfaces/network/network_service.mojom.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 for (;;) { | 44 for (;;) { |
| 45 char buf[512]; | 45 char buf[512]; |
| 46 uint32_t num_bytes = sizeof(buf); | 46 uint32_t num_bytes = sizeof(buf); |
| 47 MojoResult result = ReadDataRaw(body.get(), buf, &num_bytes, | 47 MojoResult result = ReadDataRaw(body.get(), buf, &num_bytes, |
| 48 MOJO_READ_DATA_FLAG_NONE); | 48 MOJO_READ_DATA_FLAG_NONE); |
| 49 if (result == MOJO_RESULT_SHOULD_WAIT) { | 49 if (result == MOJO_RESULT_SHOULD_WAIT) { |
| 50 Wait(body.get(), | 50 Wait(body.get(), |
| 51 MOJO_HANDLE_SIGNAL_READABLE, | 51 MOJO_HANDLE_SIGNAL_READABLE, |
| 52 MOJO_DEADLINE_INDEFINITE); | 52 MOJO_DEADLINE_INDEFINITE); |
| 53 } else if (result == MOJO_RESULT_OK) { | 53 } else if (result == MOJO_RESULT_OK) { |
| 54 if (fwrite(buf, num_bytes, 1, stdout) != num_bytes) { | 54 if (fwrite(buf, num_bytes, 1, stdout) != 1) { |
| 55 printf("\nUnexpected error writing to file\n"); | 55 printf("\nUnexpected error writing to file\n"); |
| 56 break; | 56 break; |
| 57 } | 57 } |
| 58 } else { | 58 } else { |
| 59 break; | 59 break; |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 | 62 |
| 63 printf("\n>>> EOF <<<\n"); | 63 printf("\n>>> EOF <<<\n"); |
| 64 } | 64 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 } // namespace examples | 103 } // namespace examples |
| 104 | 104 |
| 105 // static | 105 // static |
| 106 ApplicationDelegate* ApplicationDelegate::Create() { | 106 ApplicationDelegate* ApplicationDelegate::Create() { |
| 107 return new examples::WGetApp(); | 107 return new examples::WGetApp(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 } // namespace mojo | 110 } // namespace mojo |
| OLD | NEW |