| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_system_host.h" | 5 #include "content/renderer/pepper/pepper_file_system_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 "content/common/child_thread.h" | 9 #include "content/common/child_thread.h" |
| 10 #include "content/common/fileapi/file_system_dispatcher.h" | 10 #include "content/common/fileapi/file_system_dispatcher.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 PepperFileSystemHost::PepperFileSystemHost(RendererPpapiHost* host, | 55 PepperFileSystemHost::PepperFileSystemHost(RendererPpapiHost* host, |
| 56 PP_Instance instance, | 56 PP_Instance instance, |
| 57 PP_Resource resource, | 57 PP_Resource resource, |
| 58 PP_FileSystemType type) | 58 PP_FileSystemType type) |
| 59 : ResourceHost(host->GetPpapiHost(), instance, resource), | 59 : ResourceHost(host->GetPpapiHost(), instance, resource), |
| 60 renderer_ppapi_host_(host), | 60 renderer_ppapi_host_(host), |
| 61 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 61 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 62 type_(type), | 62 type_(type), |
| 63 opened_(false), | 63 opened_(false), |
| 64 called_open_(false) { | 64 called_open_(false) { |
| 65 ppapi::host::FileSystemRegistry::GetInstance()->Register(pp_instance(), |
| 66 pp_resource(), |
| 67 this); |
| 65 } | 68 } |
| 66 | 69 |
| 67 PepperFileSystemHost::~PepperFileSystemHost() { | 70 PepperFileSystemHost::~PepperFileSystemHost() { |
| 71 ppapi::host::FileSystemRegistry::GetInstance()->Unregister(pp_instance(), |
| 72 pp_resource()); |
| 68 } | 73 } |
| 69 | 74 |
| 70 int32_t PepperFileSystemHost::OnResourceMessageReceived( | 75 int32_t PepperFileSystemHost::OnResourceMessageReceived( |
| 71 const IPC::Message& msg, | 76 const IPC::Message& msg, |
| 72 ppapi::host::HostMessageContext* context) { | 77 ppapi::host::HostMessageContext* context) { |
| 73 IPC_BEGIN_MESSAGE_MAP(PepperFileSystemHost, msg) | 78 IPC_BEGIN_MESSAGE_MAP(PepperFileSystemHost, msg) |
| 74 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileSystem_Open, | 79 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileSystem_Open, |
| 75 OnHostMsgOpen) | 80 OnHostMsgOpen) |
| 76 IPC_END_MESSAGE_MAP() | 81 IPC_END_MESSAGE_MAP() |
| 77 return PP_ERROR_FAILED; | 82 return PP_ERROR_FAILED; |
| 78 } | 83 } |
| 79 | 84 |
| 85 PP_FileSystemType PepperFileSystemHost::GetType() const { |
| 86 return type_; |
| 87 } |
| 88 |
| 89 bool PepperFileSystemHost::IsOpened() const { |
| 90 return opened_; |
| 91 } |
| 92 |
| 93 const GURL& PepperFileSystemHost::GetRootUrl() const { |
| 94 return root_url_; |
| 95 } |
| 96 |
| 80 void PepperFileSystemHost::OpenFileSystemReply(int32_t pp_error, | 97 void PepperFileSystemHost::OpenFileSystemReply(int32_t pp_error, |
| 81 const GURL& root) { | 98 const GURL& root) { |
| 82 opened_ = (pp_error == PP_OK); | 99 opened_ = (pp_error == PP_OK); |
| 83 root_url_ = root; | 100 root_url_ = root; |
| 84 reply_context_.params.set_result(pp_error); | 101 reply_context_.params.set_result(pp_error); |
| 85 host()->SendReply(reply_context_, | 102 host()->SendReply(reply_context_, |
| 86 PpapiPluginMsg_FileSystem_OpenReply()); | 103 PpapiPluginMsg_FileSystem_OpenReply()); |
| 87 reply_context_ = ppapi::host::ReplyMessageContext(); | 104 reply_context_ = ppapi::host::ReplyMessageContext(); |
| 88 } | 105 } |
| 89 | 106 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 GetOrigin(), | 140 GetOrigin(), |
| 124 file_system_type, expected_size, true /* create */, | 141 file_system_type, expected_size, true /* create */, |
| 125 new PlatformCallbackAdaptor(weak_factory_.GetWeakPtr()))) { | 142 new PlatformCallbackAdaptor(weak_factory_.GetWeakPtr()))) { |
| 126 return PP_ERROR_FAILED; | 143 return PP_ERROR_FAILED; |
| 127 } | 144 } |
| 128 | 145 |
| 129 return PP_OK_COMPLETIONPENDING; | 146 return PP_OK_COMPLETIONPENDING; |
| 130 } | 147 } |
| 131 | 148 |
| 132 } // namespace content | 149 } // namespace content |
| OLD | NEW |