OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ppapi/proxy/file_io_resource.h" | 5 #include "ppapi/proxy/file_io_resource.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/task_runner_util.h" | 8 #include "base/task_runner_util.h" |
9 #include "ipc/ipc_message.h" | 9 #include "ipc/ipc_message.h" |
10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 offset_(offset), | 86 offset_(offset), |
87 buffer_(buffer.Pass()), | 87 buffer_(buffer.Pass()), |
88 bytes_to_write_(bytes_to_write), | 88 bytes_to_write_(bytes_to_write), |
89 append_(append) { | 89 append_(append) { |
90 } | 90 } |
91 | 91 |
92 FileIOResource::WriteOp::~WriteOp() { | 92 FileIOResource::WriteOp::~WriteOp() { |
93 } | 93 } |
94 | 94 |
95 int32_t FileIOResource::WriteOp::DoWork() { | 95 int32_t FileIOResource::WriteOp::DoWork() { |
96 // In append mode, we can't call WritePlatformFile, since NaCl doesn't | 96 // In append mode, we can't call Write, since NaCl doesn't implement fcntl, |
97 // implement fcntl, causing the function to call pwrite, which is incorrect. | 97 // causing the function to call pwrite, which is incorrect. |
98 if (append_) { | 98 if (append_) { |
99 return file_holder_->file()->WriteAtCurrentPos(buffer_.get(), | 99 return file_holder_->file()->WriteAtCurrentPos(buffer_.get(), |
100 bytes_to_write_); | 100 bytes_to_write_); |
101 } else { | 101 } else { |
102 return file_holder_->file()->Write(offset_, buffer_.get(), bytes_to_write_); | 102 return file_holder_->file()->Write(offset_, buffer_.get(), bytes_to_write_); |
103 } | 103 } |
104 } | 104 } |
105 | 105 |
106 FileIOResource::FileIOResource(Connection connection, PP_Instance instance) | 106 FileIOResource::FileIOResource(Connection connection, PP_Instance instance) |
107 : PluginResource(connection, instance), | 107 : PluginResource(connection, instance), |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 *output_handle = IPC::PlatformFileForTransitToPlatformFile(transit_file); | 709 *output_handle = IPC::PlatformFileForTransitToPlatformFile(transit_file); |
710 | 710 |
711 // End this operation now, so the user's callback can execute another FileIO | 711 // End this operation now, so the user's callback can execute another FileIO |
712 // operation, assuming there are no other pending operations. | 712 // operation, assuming there are no other pending operations. |
713 state_manager_.SetOperationFinished(); | 713 state_manager_.SetOperationFinished(); |
714 callback->Run(result); | 714 callback->Run(result); |
715 } | 715 } |
716 | 716 |
717 } // namespace proxy | 717 } // namespace proxy |
718 } // namespace ppapi | 718 } // namespace ppapi |
OLD | NEW |