| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" |
| 8 #include "base/callback.h" | 9 #include "base/callback.h" |
| 9 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 10 #include "base/file_util_proxy.h" | 11 #include "base/file_util_proxy.h" |
| 11 #include "base/message_loop_proxy.h" | 12 #include "base/message_loop_proxy.h" |
| 12 #include "base/platform_file.h" | 13 #include "base/platform_file.h" |
| 13 #include "base/logging.h" | 14 #include "base/logging.h" |
| 14 #include "base/time.h" | 15 #include "base/time.h" |
| 15 #include "ppapi/c/ppb_file_io.h" | 16 #include "ppapi/c/ppb_file_io.h" |
| 16 #include "ppapi/c/trusted/ppb_file_io_trusted.h" | 17 #include "ppapi/c/trusted/ppb_file_io_trusted.h" |
| 17 #include "ppapi/c/pp_completion_callback.h" | 18 #include "ppapi/c/pp_completion_callback.h" |
| 18 #include "ppapi/c/pp_errors.h" | 19 #include "ppapi/c/pp_errors.h" |
| 19 #include "ppapi/shared_impl/time_conversion.h" | 20 #include "ppapi/shared_impl/time_conversion.h" |
| 20 #include "ppapi/thunk/enter.h" | 21 #include "ppapi/thunk/enter.h" |
| 21 #include "ppapi/thunk/ppb_file_ref_api.h" | 22 #include "ppapi/thunk/ppb_file_ref_api.h" |
| 22 #include "webkit/plugins/ppapi/common.h" | 23 #include "webkit/plugins/ppapi/common.h" |
| 23 #include "webkit/plugins/ppapi/file_type_conversions.h" | 24 #include "webkit/plugins/ppapi/file_type_conversions.h" |
| 24 #include "webkit/plugins/ppapi/plugin_module.h" | 25 #include "webkit/plugins/ppapi/plugin_module.h" |
| 25 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 26 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 26 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" | 27 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" |
| 27 #include "webkit/plugins/ppapi/quota_file_io.h" | 28 #include "webkit/plugins/ppapi/quota_file_io.h" |
| 28 #include "webkit/plugins/ppapi/resource_helper.h" | 29 #include "webkit/plugins/ppapi/resource_helper.h" |
| 29 #include "webkit/plugins/ppapi/resource_tracker.h" | 30 #include "webkit/plugins/ppapi/resource_tracker.h" |
| 30 | 31 |
| 32 using base::FileUtilProxy; |
| 33 using base::PlatformFileError; |
| 34 |
| 31 using ppapi::PPTimeToTime; | 35 using ppapi::PPTimeToTime; |
| 32 using ppapi::TimeToPPTime; | 36 using ppapi::TimeToPPTime; |
| 33 using ppapi::thunk::EnterResourceNoLock; | 37 using ppapi::thunk::EnterResourceNoLock; |
| 34 using ppapi::thunk::PPB_FileIO_API; | 38 using ppapi::thunk::PPB_FileIO_API; |
| 35 using ppapi::thunk::PPB_FileRef_API; | 39 using ppapi::thunk::PPB_FileRef_API; |
| 36 | 40 |
| 37 namespace webkit { | 41 namespace webkit { |
| 38 namespace ppapi { | 42 namespace ppapi { |
| 39 | 43 |
| 40 PPB_FileIO_Impl::CallbackEntry::CallbackEntry() | 44 PPB_FileIO_Impl::CallbackEntry::CallbackEntry() |
| 41 : read_buffer(NULL) { | 45 : read_buffer(NULL) { |
| 42 } | 46 } |
| 43 | 47 |
| 44 PPB_FileIO_Impl::CallbackEntry::CallbackEntry(const CallbackEntry& entry) | 48 PPB_FileIO_Impl::CallbackEntry::CallbackEntry(const CallbackEntry& entry) |
| 45 : callback(entry.callback), | 49 : callback(entry.callback), |
| 46 read_buffer(entry.read_buffer) { | 50 read_buffer(entry.read_buffer) { |
| 47 } | 51 } |
| 48 | 52 |
| 49 PPB_FileIO_Impl::CallbackEntry::~CallbackEntry() { | 53 PPB_FileIO_Impl::CallbackEntry::~CallbackEntry() { |
| 50 } | 54 } |
| 51 | 55 |
| 52 PPB_FileIO_Impl::PPB_FileIO_Impl(PP_Instance instance) | 56 PPB_FileIO_Impl::PPB_FileIO_Impl(PP_Instance instance) |
| 53 : Resource(instance), | 57 : Resource(instance), |
| 54 ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)), | |
| 55 file_(base::kInvalidPlatformFileValue), | 58 file_(base::kInvalidPlatformFileValue), |
| 56 file_system_type_(PP_FILESYSTEMTYPE_INVALID), | 59 file_system_type_(PP_FILESYSTEMTYPE_INVALID), |
| 57 pending_op_(OPERATION_NONE), | 60 pending_op_(OPERATION_NONE), |
| 58 info_(NULL), | 61 info_(NULL), |
| 59 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { | 62 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { |
| 60 } | 63 } |
| 61 | 64 |
| 62 PPB_FileIO_Impl::~PPB_FileIO_Impl() { | 65 PPB_FileIO_Impl::~PPB_FileIO_Impl() { |
| 63 Close(); | 66 Close(); |
| 64 } | 67 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 if (!info) | 126 if (!info) |
| 124 return PP_ERROR_BADARGUMENT; | 127 return PP_ERROR_BADARGUMENT; |
| 125 | 128 |
| 126 DCHECK(!info_); // If |info_|, a callback should be pending (caught above). | 129 DCHECK(!info_); // If |info_|, a callback should be pending (caught above). |
| 127 info_ = info; | 130 info_ = info; |
| 128 | 131 |
| 129 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); | 132 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); |
| 130 if (!plugin_delegate) | 133 if (!plugin_delegate) |
| 131 return PP_ERROR_FAILED; | 134 return PP_ERROR_FAILED; |
| 132 | 135 |
| 133 if (!base::FileUtilProxy::GetFileInfoFromPlatformFile( | 136 if (!FileUtilProxy::GetFileInfoFromPlatformFile( |
| 134 plugin_delegate->GetFileThreadMessageLoopProxy(), file_, | 137 plugin_delegate->GetFileThreadMessageLoopProxy(), file_, |
| 135 callback_factory_.NewCallback(&PPB_FileIO_Impl::QueryInfoCallback))) | 138 base::Bind(&PPB_FileIO_Impl::QueryInfoCallback, |
| 139 weak_ptr_factory_.GetWeakPtr()))) |
| 136 return PP_ERROR_FAILED; | 140 return PP_ERROR_FAILED; |
| 137 | 141 |
| 138 RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL); | 142 RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL); |
| 139 return PP_OK_COMPLETIONPENDING; | 143 return PP_OK_COMPLETIONPENDING; |
| 140 } | 144 } |
| 141 | 145 |
| 142 int32_t PPB_FileIO_Impl::Touch(PP_Time last_access_time, | 146 int32_t PPB_FileIO_Impl::Touch(PP_Time last_access_time, |
| 143 PP_Time last_modified_time, | 147 PP_Time last_modified_time, |
| 144 PP_CompletionCallback callback) { | 148 PP_CompletionCallback callback) { |
| 145 int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE, callback); | 149 int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE, callback); |
| 146 if (rv != PP_OK) | 150 if (rv != PP_OK) |
| 147 return rv; | 151 return rv; |
| 148 | 152 |
| 149 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); | 153 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); |
| 150 if (!plugin_delegate) | 154 if (!plugin_delegate) |
| 151 return PP_ERROR_FAILED; | 155 return PP_ERROR_FAILED; |
| 152 | 156 |
| 153 if (!base::FileUtilProxy::Touch( | 157 if (!FileUtilProxy::PostFileTaskAndReplyStatus<bool, PlatformFileError>( |
| 154 plugin_delegate->GetFileThreadMessageLoopProxy(), | 158 plugin_delegate->GetFileThreadMessageLoopProxy(), |
| 155 file_, PPTimeToTime(last_access_time), | 159 FROM_HERE, |
| 156 PPTimeToTime(last_modified_time), | 160 Bind(&base::TouchPlatformFile, file_, |
| 157 callback_factory_.NewCallback(&PPB_FileIO_Impl::StatusCallback))) | 161 PPTimeToTime(last_access_time), |
| 162 PPTimeToTime(last_modified_time)), |
| 163 Bind(&PPB_FileIO_Impl::StatusCallback, |
| 164 weak_ptr_factory_.GetWeakPtr()))) |
| 158 return PP_ERROR_FAILED; | 165 return PP_ERROR_FAILED; |
| 159 | 166 |
| 160 RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL); | 167 RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL); |
| 161 return PP_OK_COMPLETIONPENDING; | 168 return PP_OK_COMPLETIONPENDING; |
| 162 } | 169 } |
| 163 | 170 |
| 164 int32_t PPB_FileIO_Impl::Read(int64_t offset, | 171 int32_t PPB_FileIO_Impl::Read(int64_t offset, |
| 165 char* buffer, | 172 char* buffer, |
| 166 int32_t bytes_to_read, | 173 int32_t bytes_to_read, |
| 167 PP_CompletionCallback callback) { | 174 PP_CompletionCallback callback) { |
| 168 int32_t rv = CommonCallValidation(true, OPERATION_READ, callback); | 175 int32_t rv = CommonCallValidation(true, OPERATION_READ, callback); |
| 169 if (rv != PP_OK) | 176 if (rv != PP_OK) |
| 170 return rv; | 177 return rv; |
| 171 | 178 |
| 172 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); | 179 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); |
| 173 if (!plugin_delegate) | 180 if (!plugin_delegate) |
| 174 return PP_ERROR_FAILED; | 181 return PP_ERROR_FAILED; |
| 175 | 182 |
| 176 if (!base::FileUtilProxy::Read( | 183 if (!FileUtilProxy::Read( |
| 177 plugin_delegate->GetFileThreadMessageLoopProxy(), | 184 plugin_delegate->GetFileThreadMessageLoopProxy(), |
| 178 file_, offset, bytes_to_read, | 185 file_, offset, bytes_to_read, |
| 179 callback_factory_.NewCallback(&PPB_FileIO_Impl::ReadCallback))) | 186 base::Bind(&PPB_FileIO_Impl::ReadCallback, |
| 187 weak_ptr_factory_.GetWeakPtr()))) |
| 180 return PP_ERROR_FAILED; | 188 return PP_ERROR_FAILED; |
| 181 | 189 |
| 182 RegisterCallback(OPERATION_READ, callback, buffer); | 190 RegisterCallback(OPERATION_READ, callback, buffer); |
| 183 return PP_OK_COMPLETIONPENDING; | 191 return PP_OK_COMPLETIONPENDING; |
| 184 } | 192 } |
| 185 | 193 |
| 186 int32_t PPB_FileIO_Impl::Write(int64_t offset, | 194 int32_t PPB_FileIO_Impl::Write(int64_t offset, |
| 187 const char* buffer, | 195 const char* buffer, |
| 188 int32_t bytes_to_write, | 196 int32_t bytes_to_write, |
| 189 PP_CompletionCallback callback) { | 197 PP_CompletionCallback callback) { |
| 190 int32_t rv = CommonCallValidation(true, OPERATION_WRITE, callback); | 198 int32_t rv = CommonCallValidation(true, OPERATION_WRITE, callback); |
| 191 if (rv != PP_OK) | 199 if (rv != PP_OK) |
| 192 return rv; | 200 return rv; |
| 193 | 201 |
| 194 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); | 202 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); |
| 195 if (!plugin_delegate) | 203 if (!plugin_delegate) |
| 196 return PP_ERROR_FAILED; | 204 return PP_ERROR_FAILED; |
| 197 | 205 |
| 198 if (quota_file_io_.get()) { | 206 if (quota_file_io_.get()) { |
| 199 if (!quota_file_io_->Write( | 207 if (!quota_file_io_->Write( |
| 200 offset, buffer, bytes_to_write, | 208 offset, buffer, bytes_to_write, |
| 201 callback_factory_.NewCallback(&PPB_FileIO_Impl::WriteCallback))) | 209 base::Bind(&PPB_FileIO_Impl::WriteCallback, |
| 210 weak_ptr_factory_.GetWeakPtr()))) |
| 202 return PP_ERROR_FAILED; | 211 return PP_ERROR_FAILED; |
| 203 } else { | 212 } else { |
| 204 if (!base::FileUtilProxy::Write( | 213 if (!FileUtilProxy::Write( |
| 205 plugin_delegate->GetFileThreadMessageLoopProxy(), | 214 plugin_delegate->GetFileThreadMessageLoopProxy(), |
| 206 file_, offset, buffer, bytes_to_write, | 215 file_, offset, buffer, bytes_to_write, |
| 207 callback_factory_.NewCallback(&PPB_FileIO_Impl::WriteCallback))) | 216 base::Bind(&PPB_FileIO_Impl::WriteCallback, |
| 217 weak_ptr_factory_.GetWeakPtr()))) |
| 208 return PP_ERROR_FAILED; | 218 return PP_ERROR_FAILED; |
| 209 } | 219 } |
| 210 | 220 |
| 211 RegisterCallback(OPERATION_WRITE, callback, NULL); | 221 RegisterCallback(OPERATION_WRITE, callback, NULL); |
| 212 return PP_OK_COMPLETIONPENDING; | 222 return PP_OK_COMPLETIONPENDING; |
| 213 } | 223 } |
| 214 | 224 |
| 215 int32_t PPB_FileIO_Impl::SetLength(int64_t length, | 225 int32_t PPB_FileIO_Impl::SetLength(int64_t length, |
| 216 PP_CompletionCallback callback) { | 226 PP_CompletionCallback callback) { |
| 217 int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE, callback); | 227 int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE, callback); |
| 218 if (rv != PP_OK) | 228 if (rv != PP_OK) |
| 219 return rv; | 229 return rv; |
| 220 | 230 |
| 221 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); | 231 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); |
| 222 if (!plugin_delegate) | 232 if (!plugin_delegate) |
| 223 return PP_ERROR_FAILED; | 233 return PP_ERROR_FAILED; |
| 224 | 234 |
| 225 if (quota_file_io_.get()) { | 235 if (quota_file_io_.get()) { |
| 226 if (!quota_file_io_->SetLength( | 236 if (!quota_file_io_->SetLength( |
| 227 length, | 237 length, |
| 228 callback_factory_.NewCallback(&PPB_FileIO_Impl::StatusCallback))) | 238 base::Bind(&PPB_FileIO_Impl::StatusCallback, |
| 239 weak_ptr_factory_.GetWeakPtr()))) |
| 229 return PP_ERROR_FAILED; | 240 return PP_ERROR_FAILED; |
| 230 } else { | 241 } else { |
| 231 if (!base::FileUtilProxy::Truncate( | 242 if (!FileUtilProxy::PostFileTaskAndReplyStatus<bool, PlatformFileError>( |
| 232 plugin_delegate->GetFileThreadMessageLoopProxy(), | 243 plugin_delegate->GetFileThreadMessageLoopProxy(), |
| 233 file_, length, | 244 FROM_HERE, |
| 234 callback_factory_.NewCallback(&PPB_FileIO_Impl::StatusCallback))) | 245 base::Bind(&base::TruncatePlatformFile, file_, length), |
| 246 base::Bind(&PPB_FileIO_Impl::StatusCallback, |
| 247 weak_ptr_factory_.GetWeakPtr()))) |
| 235 return PP_ERROR_FAILED; | 248 return PP_ERROR_FAILED; |
| 236 } | 249 } |
| 237 | 250 |
| 238 RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL); | 251 RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL); |
| 239 return PP_OK_COMPLETIONPENDING; | 252 return PP_OK_COMPLETIONPENDING; |
| 240 } | 253 } |
| 241 | 254 |
| 242 int32_t PPB_FileIO_Impl::Flush(PP_CompletionCallback callback) { | 255 int32_t PPB_FileIO_Impl::Flush(PP_CompletionCallback callback) { |
| 243 int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE, callback); | 256 int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE, callback); |
| 244 if (rv != PP_OK) | 257 if (rv != PP_OK) |
| 245 return rv; | 258 return rv; |
| 246 | 259 |
| 247 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); | 260 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); |
| 248 if (!plugin_delegate) | 261 if (!plugin_delegate) |
| 249 return PP_ERROR_FAILED; | 262 return PP_ERROR_FAILED; |
| 250 | 263 |
| 251 if (!base::FileUtilProxy::Flush( | 264 if (!FileUtilProxy::PostFileTaskAndReplyStatus<bool, PlatformFileError>( |
| 252 plugin_delegate->GetFileThreadMessageLoopProxy(), file_, | 265 plugin_delegate->GetFileThreadMessageLoopProxy(), |
| 253 callback_factory_.NewCallback(&PPB_FileIO_Impl::StatusCallback))) | 266 FROM_HERE, |
| 267 base::Bind(&base::FlushPlatformFile, file_), |
| 268 base::Bind(&PPB_FileIO_Impl::StatusCallback, |
| 269 weak_ptr_factory_.GetWeakPtr()))) |
| 254 return PP_ERROR_FAILED; | 270 return PP_ERROR_FAILED; |
| 255 | 271 |
| 256 RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL); | 272 RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL); |
| 257 return PP_OK_COMPLETIONPENDING; | 273 return PP_OK_COMPLETIONPENDING; |
| 258 } | 274 } |
| 259 | 275 |
| 260 void PPB_FileIO_Impl::Close() { | 276 void PPB_FileIO_Impl::Close() { |
| 261 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); | 277 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); |
| 262 if (file_ != base::kInvalidPlatformFileValue && plugin_delegate) { | 278 if (file_ != base::kInvalidPlatformFileValue && plugin_delegate) { |
| 263 base::FileUtilProxy::Close( | 279 |
| 264 plugin_delegate->GetFileThreadMessageLoopProxy(), file_, NULL); | 280 plugin_delegate->GetFileThreadMessageLoopProxy()->PostTask( |
| 281 FROM_HERE, |
| 282 base::IgnoreReturn(base::Callback<bool(void)>( |
| 283 base::Bind(&base::ClosePlatformFile, file_)))); |
| 265 file_ = base::kInvalidPlatformFileValue; | 284 file_ = base::kInvalidPlatformFileValue; |
| 266 quota_file_io_.reset(); | 285 quota_file_io_.reset(); |
| 267 } | 286 } |
| 268 } | 287 } |
| 269 | 288 |
| 270 int32_t PPB_FileIO_Impl::GetOSFileDescriptor() { | 289 int32_t PPB_FileIO_Impl::GetOSFileDescriptor() { |
| 271 #if defined(OS_POSIX) | 290 #if defined(OS_POSIX) |
| 272 return file_; | 291 return file_; |
| 273 #elif defined(OS_WIN) | 292 #elif defined(OS_WIN) |
| 274 return reinterpret_cast<uintptr_t>(file_); | 293 return reinterpret_cast<uintptr_t>(file_); |
| 275 #else | 294 #else |
| 276 #error "Platform not supported." | 295 #error "Platform not supported." |
| 277 #endif | 296 #endif |
| 278 } | 297 } |
| 279 | 298 |
| 280 int32_t PPB_FileIO_Impl::WillWrite(int64_t offset, | 299 int32_t PPB_FileIO_Impl::WillWrite(int64_t offset, |
| 281 int32_t bytes_to_write, | 300 int32_t bytes_to_write, |
| 282 PP_CompletionCallback callback) { | 301 PP_CompletionCallback callback) { |
| 283 int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE, callback); | 302 int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE, callback); |
| 284 if (rv != PP_OK) | 303 if (rv != PP_OK) |
| 285 return rv; | 304 return rv; |
| 286 | 305 |
| 287 if (!quota_file_io_.get()) | 306 if (!quota_file_io_.get()) |
| 288 return PP_OK; | 307 return PP_OK; |
| 289 | 308 |
| 290 if (!quota_file_io_->WillWrite( | 309 if (!quota_file_io_->WillWrite( |
| 291 offset, bytes_to_write, | 310 offset, bytes_to_write, |
| 292 callback_factory_.NewCallback(&PPB_FileIO_Impl::WillWriteCallback))) | 311 base::Bind(&PPB_FileIO_Impl::WillWriteCallback, |
| 312 weak_ptr_factory_.GetWeakPtr()))) |
| 293 return PP_ERROR_FAILED; | 313 return PP_ERROR_FAILED; |
| 294 | 314 |
| 295 RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL); | 315 RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL); |
| 296 return PP_OK_COMPLETIONPENDING; | 316 return PP_OK_COMPLETIONPENDING; |
| 297 } | 317 } |
| 298 | 318 |
| 299 int32_t PPB_FileIO_Impl::WillSetLength(int64_t length, | 319 int32_t PPB_FileIO_Impl::WillSetLength(int64_t length, |
| 300 PP_CompletionCallback callback) { | 320 PP_CompletionCallback callback) { |
| 301 int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE, callback); | 321 int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE, callback); |
| 302 if (rv != PP_OK) | 322 if (rv != PP_OK) |
| 303 return rv; | 323 return rv; |
| 304 | 324 |
| 305 if (!quota_file_io_.get()) | 325 if (!quota_file_io_.get()) |
| 306 return PP_OK; | 326 return PP_OK; |
| 307 | 327 |
| 308 if (!quota_file_io_->WillSetLength( | 328 if (!quota_file_io_->WillSetLength( |
| 309 length, | 329 length, |
| 310 callback_factory_.NewCallback(&PPB_FileIO_Impl::StatusCallback))) | 330 base::Bind(&PPB_FileIO_Impl::StatusCallback, |
| 331 weak_ptr_factory_.GetWeakPtr()))) |
| 311 return PP_ERROR_FAILED; | 332 return PP_ERROR_FAILED; |
| 312 | 333 |
| 313 RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL); | 334 RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL); |
| 314 return PP_OK_COMPLETIONPENDING; | 335 return PP_OK_COMPLETIONPENDING; |
| 315 } | 336 } |
| 316 | 337 |
| 317 int32_t PPB_FileIO_Impl::CommonCallValidation(bool should_be_open, | 338 int32_t PPB_FileIO_Impl::CommonCallValidation(bool should_be_open, |
| 318 OperationType new_op, | 339 OperationType new_op, |
| 319 PP_CompletionCallback callback) { | 340 PP_CompletionCallback callback) { |
| 320 // Only asynchronous operation is supported. | 341 // Only asynchronous operation is supported. |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 if (error_code != base::PLATFORM_FILE_OK) { | 492 if (error_code != base::PLATFORM_FILE_OK) { |
| 472 RunAndRemoveFirstPendingCallback( | 493 RunAndRemoveFirstPendingCallback( |
| 473 PlatformFileErrorToPepperError(error_code)); | 494 PlatformFileErrorToPepperError(error_code)); |
| 474 } else { | 495 } else { |
| 475 RunAndRemoveFirstPendingCallback(bytes_written); | 496 RunAndRemoveFirstPendingCallback(bytes_written); |
| 476 } | 497 } |
| 477 } | 498 } |
| 478 | 499 |
| 479 } // namespace ppapi | 500 } // namespace ppapi |
| 480 } // namespace webkit | 501 } // namespace webkit |
| OLD | NEW |