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/public/common/content_client.h" | 12 #include "content/public/common/content_client.h" |
13 #include "content/public/renderer/content_renderer_client.h" | 13 #include "content/public/renderer/content_renderer_client.h" |
14 #include "ppapi/c/pp_errors.h" | 14 #include "ppapi/c/pp_errors.h" |
15 #include "ppapi/host/dispatch_host_message.h" | 15 #include "ppapi/host/dispatch_host_message.h" |
16 #include "ppapi/host/ppapi_host.h" | 16 #include "ppapi/host/ppapi_host.h" |
17 #include "ppapi/proxy/ppapi_messages.h" | 17 #include "ppapi/proxy/ppapi_messages.h" |
18 #include "ppapi/shared_impl/file_type_conversion.h" | 18 #include "ppapi/shared_impl/file_type_conversion.h" |
19 #include "ppapi/shared_impl/time_conversion.h" | 19 #include "ppapi/shared_impl/time_conversion.h" |
20 #include "ppapi/thunk/enter.h" | 20 #include "ppapi/thunk/enter.h" |
21 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 21 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
22 #include "webkit/plugins/ppapi/host_globals.h" | 22 #include "webkit/plugins/ppapi/host_globals.h" |
23 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 23 #include "webkit/plugins/ppapi/ppapi_plugin_instance_impl.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/quota_file_io.h" | 25 #include "webkit/plugins/ppapi/quota_file_io.h" |
26 | 26 |
27 namespace content { | 27 namespace content { |
28 | 28 |
29 using ppapi::FileIOStateManager; | 29 using ppapi::FileIOStateManager; |
30 using ppapi::PPTimeToTime; | 30 using ppapi::PPTimeToTime; |
31 using ppapi::host::ReplyMessageContext; | 31 using ppapi::host::ReplyMessageContext; |
32 using ppapi::thunk::EnterResourceNoLock; | 32 using ppapi::thunk::EnterResourceNoLock; |
33 using ppapi::thunk::PPB_FileRef_API; | 33 using ppapi::thunk::PPB_FileRef_API; |
(...skipping 17 matching lines...) Expand all Loading... |
51 // callbacks here. | 51 // callbacks here. |
52 return pp_error == PP_OK ? byte_number : pp_error; | 52 return pp_error == PP_OK ? byte_number : pp_error; |
53 } | 53 } |
54 | 54 |
55 } // namespace | 55 } // namespace |
56 | 56 |
57 PepperFileIOHost::PepperFileIOHost(RendererPpapiHost* host, | 57 PepperFileIOHost::PepperFileIOHost(RendererPpapiHost* host, |
58 PP_Instance instance, | 58 PP_Instance instance, |
59 PP_Resource resource) | 59 PP_Resource resource) |
60 : ResourceHost(host->GetPpapiHost(), instance, resource), | 60 : ResourceHost(host->GetPpapiHost(), instance, resource), |
| 61 plugin_delegate_(NULL), |
61 file_(base::kInvalidPlatformFileValue), | 62 file_(base::kInvalidPlatformFileValue), |
62 file_system_type_(PP_FILESYSTEMTYPE_INVALID), | 63 file_system_type_(PP_FILESYSTEMTYPE_INVALID), |
63 quota_policy_(quota::kQuotaLimitTypeUnknown), | 64 quota_policy_(quota::kQuotaLimitTypeUnknown), |
64 is_running_in_process_(host->IsRunningInProcess()), | 65 is_running_in_process_(host->IsRunningInProcess()), |
65 open_flags_(0), | 66 open_flags_(0), |
66 weak_factory_(this) { | 67 weak_factory_(this) { |
67 // TODO(victorhsieh): eliminate plugin_delegate_ as it's no longer needed. | 68 // TODO(victorhsieh): eliminate plugin_delegate_ as it's no longer needed. |
68 webkit::ppapi::PluginInstance* plugin_instance = | 69 webkit::ppapi::PluginInstanceImpl* plugin_instance = |
69 webkit::ppapi::HostGlobals::Get()->GetInstance(instance); | 70 webkit::ppapi::HostGlobals::Get()->GetInstance(instance); |
70 plugin_delegate_ = plugin_instance ? plugin_instance->delegate() : NULL; | 71 plugin_delegate_ = plugin_instance ? plugin_instance->delegate() : NULL; |
71 } | 72 } |
72 | 73 |
73 PepperFileIOHost::~PepperFileIOHost() { | 74 PepperFileIOHost::~PepperFileIOHost() { |
74 OnHostMsgClose(NULL); | 75 OnHostMsgClose(NULL); |
75 } | 76 } |
76 | 77 |
77 int32_t PepperFileIOHost::OnResourceMessageReceived( | 78 int32_t PepperFileIOHost::OnResourceMessageReceived( |
78 const IPC::Message& msg, | 79 const IPC::Message& msg, |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 // On the plugin side, the callback expects a parameter with different meaning | 538 // On the plugin side, the callback expects a parameter with different meaning |
538 // depends on whether is negative or not. It is the result here. We translate | 539 // depends on whether is negative or not. It is the result here. We translate |
539 // for the callback. | 540 // for the callback. |
540 int32_t pp_error = ::ppapi::PlatformFileErrorToPepperError(error_code); | 541 int32_t pp_error = ::ppapi::PlatformFileErrorToPepperError(error_code); |
541 reply_context.params.set_result(ErrorOrByteNumber(pp_error, bytes_written)); | 542 reply_context.params.set_result(ErrorOrByteNumber(pp_error, bytes_written)); |
542 host()->SendReply(reply_context, PpapiPluginMsg_FileIO_GeneralReply()); | 543 host()->SendReply(reply_context, PpapiPluginMsg_FileIO_GeneralReply()); |
543 state_manager_.SetOperationFinished(); | 544 state_manager_.SetOperationFinished(); |
544 } | 545 } |
545 | 546 |
546 } // namespace content | 547 } // namespace content |
OLD | NEW |