OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/browser/renderer_host/pepper/pepper_file_io_host.h" | 5 #include "content/browser/renderer_host/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/files/file_util_proxy.h" | 10 #include "base/files/file_util_proxy.h" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 file_system_host_->GetFileSystemOperationRunner()->OpenFile( | 218 file_system_host_->GetFileSystemOperationRunner()->OpenFile( |
219 file_system_url_, | 219 file_system_url_, |
220 platform_file_flags, | 220 platform_file_flags, |
221 base::Bind(&PepperFileIOHost::DidOpenInternalFile, | 221 base::Bind(&PepperFileIOHost::DidOpenInternalFile, |
222 weak_factory_.GetWeakPtr(), | 222 weak_factory_.GetWeakPtr(), |
223 reply_context)); | 223 reply_context)); |
224 } | 224 } |
225 | 225 |
226 void PepperFileIOHost::DidOpenInternalFile( | 226 void PepperFileIOHost::DidOpenInternalFile( |
227 ppapi::host::ReplyMessageContext reply_context, | 227 ppapi::host::ReplyMessageContext reply_context, |
228 base::PlatformFileError result, | 228 base::File::Error result, |
229 base::PlatformFile file, | 229 base::PlatformFile file, |
230 const base::Closure& on_close_callback) { | 230 const base::Closure& on_close_callback) { |
231 if (result == base::PLATFORM_FILE_OK) { | 231 if (result == base::File::FILE_OK) { |
232 on_close_callback_ = on_close_callback; | 232 on_close_callback_ = on_close_callback; |
233 | 233 |
234 if (FileOpenForWrite(open_flags_) && file_system_host_->ChecksQuota()) { | 234 if (FileOpenForWrite(open_flags_) && file_system_host_->ChecksQuota()) { |
235 check_quota_ = true; | 235 check_quota_ = true; |
236 file_system_host_->OpenQuotaFile( | 236 file_system_host_->OpenQuotaFile( |
237 this, | 237 this, |
238 file_system_url_, | 238 file_system_url_, |
239 base::Bind(&PepperFileIOHost::DidOpenQuotaFile, | 239 base::Bind(&PepperFileIOHost::DidOpenQuotaFile, |
240 weak_factory_.GetWeakPtr(), | 240 weak_factory_.GetWeakPtr(), |
241 reply_context, | 241 reply_context, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 return PP_OK; | 353 return PP_OK; |
354 } | 354 } |
355 | 355 |
356 void PepperFileIOHost::DidOpenQuotaFile( | 356 void PepperFileIOHost::DidOpenQuotaFile( |
357 ppapi::host::ReplyMessageContext reply_context, | 357 ppapi::host::ReplyMessageContext reply_context, |
358 base::PlatformFile file, | 358 base::PlatformFile file, |
359 int64_t max_written_offset) { | 359 int64_t max_written_offset) { |
360 max_written_offset_ = max_written_offset; | 360 max_written_offset_ = max_written_offset; |
361 | 361 |
362 ExecutePlatformOpenFileCallback( | 362 ExecutePlatformOpenFileCallback( |
363 reply_context, base::PLATFORM_FILE_OK, base::PassPlatformFile(&file), | 363 reply_context, base::File::FILE_OK, base::PassPlatformFile(&file), |
364 true); | 364 true); |
365 } | 365 } |
366 | 366 |
367 void PepperFileIOHost::DidCloseFile(base::PlatformFileError error) { | 367 void PepperFileIOHost::DidCloseFile(base::File::Error error) { |
368 // Silently ignore if we fail to close the file. | 368 // Silently ignore if we fail to close the file. |
369 if (!on_close_callback_.is_null()) { | 369 if (!on_close_callback_.is_null()) { |
370 on_close_callback_.Run(); | 370 on_close_callback_.Run(); |
371 on_close_callback_.Reset(); | 371 on_close_callback_.Reset(); |
372 } | 372 } |
373 } | 373 } |
374 | 374 |
375 int32_t PepperFileIOHost::OnHostMsgRequestOSFileHandle( | 375 int32_t PepperFileIOHost::OnHostMsgRequestOSFileHandle( |
376 ppapi::host::HostMessageContext* context) { | 376 ppapi::host::HostMessageContext* context) { |
377 if (open_flags_ != PP_FILEOPENFLAG_READ && file_system_host_->ChecksQuota()) | 377 if (open_flags_ != PP_FILEOPENFLAG_READ && file_system_host_->ChecksQuota()) |
(...skipping 24 matching lines...) Expand all Loading... |
402 reply_context.params.set_result(PP_ERROR_FAILED); | 402 reply_context.params.set_result(PP_ERROR_FAILED); |
403 } else { | 403 } else { |
404 reply_context.params.set_result(PP_ERROR_NOACCESS); | 404 reply_context.params.set_result(PP_ERROR_NOACCESS); |
405 } | 405 } |
406 host()->SendReply(reply_context, | 406 host()->SendReply(reply_context, |
407 PpapiPluginMsg_FileIO_RequestOSFileHandleReply()); | 407 PpapiPluginMsg_FileIO_RequestOSFileHandleReply()); |
408 } | 408 } |
409 | 409 |
410 void PepperFileIOHost::ExecutePlatformGeneralCallback( | 410 void PepperFileIOHost::ExecutePlatformGeneralCallback( |
411 ppapi::host::ReplyMessageContext reply_context, | 411 ppapi::host::ReplyMessageContext reply_context, |
412 base::PlatformFileError error_code) { | 412 base::File::Error error_code) { |
413 reply_context.params.set_result( | 413 reply_context.params.set_result( |
414 ppapi::PlatformFileErrorToPepperError(error_code)); | 414 ppapi::FileErrorToPepperError(error_code)); |
415 host()->SendReply(reply_context, PpapiPluginMsg_FileIO_GeneralReply()); | 415 host()->SendReply(reply_context, PpapiPluginMsg_FileIO_GeneralReply()); |
416 state_manager_.SetOperationFinished(); | 416 state_manager_.SetOperationFinished(); |
417 } | 417 } |
418 | 418 |
419 void PepperFileIOHost::ExecutePlatformOpenFileCallback( | 419 void PepperFileIOHost::ExecutePlatformOpenFileCallback( |
420 ppapi::host::ReplyMessageContext reply_context, | 420 ppapi::host::ReplyMessageContext reply_context, |
421 base::PlatformFileError error_code, | 421 base::File::Error error_code, |
422 base::PassPlatformFile file, | 422 base::PassPlatformFile file, |
423 bool unused_created) { | 423 bool unused_created) { |
424 int32_t pp_error = ppapi::PlatformFileErrorToPepperError(error_code); | 424 int32_t pp_error = ppapi::FileErrorToPepperError(error_code); |
425 DCHECK(file_ == base::kInvalidPlatformFileValue); | 425 DCHECK(file_ == base::kInvalidPlatformFileValue); |
426 file_ = file.ReleaseValue(); | 426 file_ = file.ReleaseValue(); |
427 | 427 |
428 if (file_ != base::kInvalidPlatformFileValue && | 428 if (file_ != base::kInvalidPlatformFileValue && |
429 !AddFileToReplyContext(open_flags_, &reply_context)) | 429 !AddFileToReplyContext(open_flags_, &reply_context)) |
430 pp_error = PP_ERROR_FAILED; | 430 pp_error = PP_ERROR_FAILED; |
431 | 431 |
432 PP_Resource quota_file_system = 0; | 432 PP_Resource quota_file_system = 0; |
433 if (pp_error == PP_OK) { | 433 if (pp_error == PP_OK) { |
434 state_manager_.SetOpenSucceed(); | 434 state_manager_.SetOpenSucceed(); |
(...skipping 29 matching lines...) Expand all Loading... |
464 | 464 |
465 ppapi::proxy::SerializedHandle file_handle; | 465 ppapi::proxy::SerializedHandle file_handle; |
466 // A non-zero resource id signals NaClIPCAdapter to create a NaClQuotaDesc. | 466 // A non-zero resource id signals NaClIPCAdapter to create a NaClQuotaDesc. |
467 PP_Resource quota_file_io = check_quota_ ? pp_resource() : 0; | 467 PP_Resource quota_file_io = check_quota_ ? pp_resource() : 0; |
468 file_handle.set_file_handle(transit_file, open_flags, quota_file_io); | 468 file_handle.set_file_handle(transit_file, open_flags, quota_file_io); |
469 reply_context->params.AppendHandle(file_handle); | 469 reply_context->params.AppendHandle(file_handle); |
470 return true; | 470 return true; |
471 } | 471 } |
472 | 472 |
473 } // namespace content | 473 } // namespace content |
OLD | NEW |