| 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 "content/renderer/pepper/pepper_file_io_host.h" | 5 #include "content/renderer/pepper/pepper_file_io_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/files/file_util_proxy.h" | 11 #include "base/files/file_util_proxy.h" |
| 12 #include "content/child/child_thread.h" | 12 #include "content/child/child_thread.h" |
| 13 #include "content/child/fileapi/file_system_dispatcher.h" | 13 #include "content/child/fileapi/file_system_dispatcher.h" |
| 14 #include "content/child/quota_dispatcher.h" | 14 #include "content/child/quota_dispatcher.h" |
| 15 #include "content/common/fileapi/file_system_messages.h" | 15 #include "content/common/fileapi/file_system_messages.h" |
| 16 #include "content/common/view_messages.h" | 16 #include "content/common/view_messages.h" |
| 17 #include "content/public/common/content_client.h" | 17 #include "content/public/common/content_client.h" |
| 18 #include "content/public/renderer/content_renderer_client.h" | 18 #include "content/public/renderer/content_renderer_client.h" |
| 19 #include "content/renderer/pepper/pepper_file_ref_renderer_host.h" | 19 #include "content/renderer/pepper/pepper_file_ref_renderer_host.h" |
| 20 #include "content/renderer/pepper/quota_file_io.h" | 20 #include "content/renderer/pepper/quota_file_io.h" |
| 21 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" | 21 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
| 22 #include "content/renderer/render_thread_impl.h" | 22 #include "content/renderer/render_thread_impl.h" |
| 23 #include "ppapi/c/pp_errors.h" | 23 #include "ppapi/c/pp_errors.h" |
| 24 #include "ppapi/c/ppb_file_io.h" | 24 #include "ppapi/c/ppb_file_io.h" |
| 25 #include "ppapi/host/dispatch_host_message.h" | 25 #include "ppapi/host/dispatch_host_message.h" |
| 26 #include "ppapi/host/ppapi_host.h" | 26 #include "ppapi/host/ppapi_host.h" |
| 27 #include "ppapi/proxy/ppapi_messages.h" | 27 #include "ppapi/proxy/ppapi_messages.h" |
| 28 #include "ppapi/shared_impl/file_system_util.h" |
| 28 #include "ppapi/shared_impl/file_type_conversion.h" | 29 #include "ppapi/shared_impl/file_type_conversion.h" |
| 29 #include "ppapi/shared_impl/time_conversion.h" | 30 #include "ppapi/shared_impl/time_conversion.h" |
| 30 #include "ppapi/thunk/enter.h" | 31 #include "ppapi/thunk/enter.h" |
| 31 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 32 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
| 32 | 33 |
| 33 namespace content { | 34 namespace content { |
| 34 | 35 |
| 35 using ppapi::FileIOStateManager; | 36 using ppapi::FileIOStateManager; |
| 36 using ppapi::PPTimeToTime; | 37 using ppapi::PPTimeToTime; |
| 37 using ppapi::host::ReplyMessageContext; | 38 using ppapi::host::ReplyMessageContext; |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 base::PassPlatformFile file) { | 430 base::PassPlatformFile file) { |
| 430 int32_t pp_error = ppapi::PlatformFileErrorToPepperError(error_code); | 431 int32_t pp_error = ppapi::PlatformFileErrorToPepperError(error_code); |
| 431 if (pp_error == PP_OK) | 432 if (pp_error == PP_OK) |
| 432 state_manager_.SetOpenSucceed(); | 433 state_manager_.SetOpenSucceed(); |
| 433 | 434 |
| 434 DCHECK(file_ == base::kInvalidPlatformFileValue); | 435 DCHECK(file_ == base::kInvalidPlatformFileValue); |
| 435 file_ = file.ReleaseValue(); | 436 file_ = file.ReleaseValue(); |
| 436 | 437 |
| 437 DCHECK(!quota_file_io_.get()); | 438 DCHECK(!quota_file_io_.get()); |
| 438 if (file_ != base::kInvalidPlatformFileValue) { | 439 if (file_ != base::kInvalidPlatformFileValue) { |
| 439 if (file_system_type_ == PP_FILESYSTEMTYPE_LOCALTEMPORARY || | 440 if (ppapi::FileSystemTypeHasQuota(file_system_type_)) { |
| 440 file_system_type_ == PP_FILESYSTEMTYPE_LOCALPERSISTENT) { | |
| 441 quota_file_io_.reset(new QuotaFileIO( | 441 quota_file_io_.reset(new QuotaFileIO( |
| 442 new QuotaFileIODelegate, file_, file_system_url_, file_system_type_)); | 442 new QuotaFileIODelegate, file_, file_system_url_, file_system_type_)); |
| 443 } | 443 } |
| 444 | 444 |
| 445 IPC::PlatformFileForTransit file_for_transit = | 445 IPC::PlatformFileForTransit file_for_transit = |
| 446 renderer_ppapi_host_->ShareHandleWithRemote(file_, false); | 446 renderer_ppapi_host_->ShareHandleWithRemote(file_, false); |
| 447 if (!(file_for_transit == IPC::InvalidPlatformFileForTransit())) { | 447 if (!(file_for_transit == IPC::InvalidPlatformFileForTransit())) { |
| 448 // Send the file descriptor to the plugin process. This is used in the | 448 // Send the file descriptor to the plugin process. This is used in the |
| 449 // plugin for any file operations that can be done there. | 449 // plugin for any file operations that can be done there. |
| 450 int32_t flags_to_send = open_flags_; | 450 int32_t flags_to_send = open_flags_; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 // On the plugin side, the callback expects a parameter with different meaning | 484 // On the plugin side, the callback expects a parameter with different meaning |
| 485 // depends on whether is negative or not. It is the result here. We translate | 485 // depends on whether is negative or not. It is the result here. We translate |
| 486 // for the callback. | 486 // for the callback. |
| 487 int32_t pp_error = ppapi::PlatformFileErrorToPepperError(error_code); | 487 int32_t pp_error = ppapi::PlatformFileErrorToPepperError(error_code); |
| 488 reply_context.params.set_result(ErrorOrByteNumber(pp_error, bytes_written)); | 488 reply_context.params.set_result(ErrorOrByteNumber(pp_error, bytes_written)); |
| 489 host()->SendReply(reply_context, PpapiPluginMsg_FileIO_GeneralReply()); | 489 host()->SendReply(reply_context, PpapiPluginMsg_FileIO_GeneralReply()); |
| 490 state_manager_.SetOperationFinished(); | 490 state_manager_.SetOperationFinished(); |
| 491 } | 491 } |
| 492 | 492 |
| 493 } // namespace content | 493 } // namespace content |
| OLD | NEW |