| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/plugins/ppapi/ppb_file_io_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_file_io_impl.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/file_util_proxy.h" | 9 #include "base/file_util_proxy.h" |
| 10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| 11 #include "base/platform_file.h" | 11 #include "base/platform_file.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/time.h" | 13 #include "base/time.h" |
| 14 #include "ppapi/c/dev/ppb_file_io_dev.h" | 14 #include "ppapi/c/ppb_file_io.h" |
| 15 #include "ppapi/c/dev/ppb_file_io_trusted_dev.h" | 15 #include "ppapi/c/trusted/ppb_file_io_trusted.h" |
| 16 #include "ppapi/c/pp_completion_callback.h" | 16 #include "ppapi/c/pp_completion_callback.h" |
| 17 #include "ppapi/c/pp_errors.h" | 17 #include "ppapi/c/pp_errors.h" |
| 18 #include "ppapi/thunk/enter.h" | 18 #include "ppapi/thunk/enter.h" |
| 19 #include "ppapi/thunk/ppb_file_ref_api.h" | 19 #include "ppapi/thunk/ppb_file_ref_api.h" |
| 20 #include "webkit/plugins/ppapi/common.h" | 20 #include "webkit/plugins/ppapi/common.h" |
| 21 #include "webkit/plugins/ppapi/file_type_conversions.h" | 21 #include "webkit/plugins/ppapi/file_type_conversions.h" |
| 22 #include "webkit/plugins/ppapi/plugin_module.h" | 22 #include "webkit/plugins/ppapi/plugin_module.h" |
| 23 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 23 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 24 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" | 24 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" |
| 25 #include "webkit/plugins/ppapi/resource_tracker.h" | 25 #include "webkit/plugins/ppapi/resource_tracker.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 return PP_ERROR_FAILED; | 82 return PP_ERROR_FAILED; |
| 83 break; | 83 break; |
| 84 default: | 84 default: |
| 85 return PP_ERROR_FAILED; | 85 return PP_ERROR_FAILED; |
| 86 } | 86 } |
| 87 | 87 |
| 88 RegisterCallback(callback); | 88 RegisterCallback(callback); |
| 89 return PP_OK_COMPLETIONPENDING; | 89 return PP_OK_COMPLETIONPENDING; |
| 90 } | 90 } |
| 91 | 91 |
| 92 int32_t PPB_FileIO_Impl::Query(PP_FileInfo_Dev* info, | 92 int32_t PPB_FileIO_Impl::Query(PP_FileInfo* info, |
| 93 PP_CompletionCallback callback) { | 93 PP_CompletionCallback callback) { |
| 94 int32_t rv = CommonCallValidation(true, callback); | 94 int32_t rv = CommonCallValidation(true, callback); |
| 95 if (rv != PP_OK) | 95 if (rv != PP_OK) |
| 96 return rv; | 96 return rv; |
| 97 | 97 |
| 98 if (!info) | 98 if (!info) |
| 99 return PP_ERROR_BADARGUMENT; | 99 return PP_ERROR_BADARGUMENT; |
| 100 | 100 |
| 101 DCHECK(!info_); // If |info_|, a callback should be pending (caught above). | 101 DCHECK(!info_); // If |info_|, a callback should be pending (caught above). |
| 102 info_ = info; | 102 info_ = info; |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 void PPB_FileIO_Impl::ReadCallback(base::PlatformFileError error_code, | 301 void PPB_FileIO_Impl::ReadCallback(base::PlatformFileError error_code, |
| 302 const char* data, int bytes_read) { | 302 const char* data, int bytes_read) { |
| 303 DCHECK(data); | 303 DCHECK(data); |
| 304 DCHECK(read_buffer_); | 304 DCHECK(read_buffer_); |
| 305 | 305 |
| 306 int rv; | 306 int rv; |
| 307 if (error_code == base::PLATFORM_FILE_OK) { | 307 if (error_code == base::PLATFORM_FILE_OK) { |
| 308 rv = bytes_read; | 308 rv = bytes_read; |
| 309 if (file_ != base::kInvalidPlatformFileValue) | 309 if (file_ != base::kInvalidPlatformFileValue) |
| 310 memcpy(read_buffer_, data, bytes_read); | 310 memcpy(read_buffer_, data, bytes_read); |
| 311 } else | 311 } else { |
| 312 rv = PlatformFileErrorToPepperError(error_code); | 312 rv = PlatformFileErrorToPepperError(error_code); |
| 313 } |
| 313 | 314 |
| 314 read_buffer_ = NULL; | 315 read_buffer_ = NULL; |
| 315 RunPendingCallback(rv); | 316 RunPendingCallback(rv); |
| 316 } | 317 } |
| 317 | 318 |
| 318 void PPB_FileIO_Impl::WriteCallback(base::PlatformFileError error_code, | 319 void PPB_FileIO_Impl::WriteCallback(base::PlatformFileError error_code, |
| 319 int bytes_written) { | 320 int bytes_written) { |
| 320 if (error_code != base::PLATFORM_FILE_OK) | 321 if (error_code != base::PLATFORM_FILE_OK) |
| 321 RunPendingCallback(PlatformFileErrorToPepperError(error_code)); | 322 RunPendingCallback(PlatformFileErrorToPepperError(error_code)); |
| 322 else | 323 else |
| 323 RunPendingCallback(bytes_written); | 324 RunPendingCallback(bytes_written); |
| 324 } | 325 } |
| 325 | 326 |
| 326 } // namespace ppapi | 327 } // namespace ppapi |
| 327 } // namespace webkit | 328 } // namespace webkit |
| OLD | NEW |