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 "mojo/common/data_pipe_utils.h" | 5 #include "mojo/common/data_pipe_utils.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 MojoResult result = BeginReadDataRaw( | 24 MojoResult result = BeginReadDataRaw( |
25 source.get(), &buffer, &num_bytes, MOJO_READ_DATA_FLAG_NONE); | 25 source.get(), &buffer, &num_bytes, MOJO_READ_DATA_FLAG_NONE); |
26 if (result == MOJO_RESULT_OK) { | 26 if (result == MOJO_RESULT_OK) { |
27 size_t bytes_written = write_bytes.Run(buffer, num_bytes); | 27 size_t bytes_written = write_bytes.Run(buffer, num_bytes); |
28 result = EndReadDataRaw(source.get(), num_bytes); | 28 result = EndReadDataRaw(source.get(), num_bytes); |
29 if (bytes_written < num_bytes || result != MOJO_RESULT_OK) | 29 if (bytes_written < num_bytes || result != MOJO_RESULT_OK) |
30 return false; | 30 return false; |
31 } else if (result == MOJO_RESULT_SHOULD_WAIT) { | 31 } else if (result == MOJO_RESULT_SHOULD_WAIT) { |
32 result = Wait(source.get(), | 32 result = Wait(source.get(), |
33 MOJO_HANDLE_SIGNAL_READABLE, | 33 MOJO_HANDLE_SIGNAL_READABLE, |
34 MOJO_DEADLINE_INDEFINITE); | 34 MOJO_DEADLINE_INDEFINITE, |
| 35 nullptr); |
35 if (result != MOJO_RESULT_OK) { | 36 if (result != MOJO_RESULT_OK) { |
36 // If the producer handle was closed, then treat as EOF. | 37 // If the producer handle was closed, then treat as EOF. |
37 return result == MOJO_RESULT_FAILED_PRECONDITION; | 38 return result == MOJO_RESULT_FAILED_PRECONDITION; |
38 } | 39 } |
39 } else if (result == MOJO_RESULT_FAILED_PRECONDITION) { | 40 } else if (result == MOJO_RESULT_FAILED_PRECONDITION) { |
40 // If the producer handle was closed, then treat as EOF. | 41 // If the producer handle was closed, then treat as EOF. |
41 return true; | 42 return true; |
42 } else { | 43 } else { |
43 // Some other error occurred. | 44 // Some other error occurred. |
44 break; | 45 break; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 const base::Callback<void(bool)>& callback) { | 86 const base::Callback<void(bool)>& callback) { |
86 base::PostTaskAndReplyWithResult( | 87 base::PostTaskAndReplyWithResult( |
87 task_runner, | 88 task_runner, |
88 FROM_HERE, | 89 FROM_HERE, |
89 base::Bind(&BlockingCopyToFile, base::Passed(&source), destination), | 90 base::Bind(&BlockingCopyToFile, base::Passed(&source), destination), |
90 callback); | 91 callback); |
91 } | 92 } |
92 | 93 |
93 } // namespace common | 94 } // namespace common |
94 } // namespace mojo | 95 } // namespace mojo |
OLD | NEW |