Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: content/browser/renderer_host/pepper/pepper_file_io_host.cc

Issue 145303002: Convert Media Galleries to use base::File (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 return PP_OK; 351 return PP_OK;
352 } 352 }
353 353
354 void PepperFileIOHost::DidOpenQuotaFile( 354 void PepperFileIOHost::DidOpenQuotaFile(
355 ppapi::host::ReplyMessageContext reply_context, 355 ppapi::host::ReplyMessageContext reply_context,
356 base::PlatformFile file, 356 base::PlatformFile file,
357 int64_t max_written_offset) { 357 int64_t max_written_offset) {
358 max_written_offset_ = max_written_offset; 358 max_written_offset_ = max_written_offset;
359 359
360 ExecutePlatformOpenFileCallback( 360 ExecutePlatformOpenFileCallback(
361 reply_context, base::PLATFORM_FILE_OK, base::PassPlatformFile(&file), 361 reply_context, base::File::FILE_OK, base::PassPlatformFile(&file),
362 true); 362 true);
363 } 363 }
364 364
365 void PepperFileIOHost::DidCloseFile(base::PlatformFileError error) { 365 void PepperFileIOHost::DidCloseFile(base::File::Error error) {
366 // Silently ignore if we fail to close the file. 366 // Silently ignore if we fail to close the file.
367 if (!on_close_callback_.is_null()) { 367 if (!on_close_callback_.is_null()) {
368 on_close_callback_.Run(); 368 on_close_callback_.Run();
369 on_close_callback_.Reset(); 369 on_close_callback_.Reset();
370 } 370 }
371 } 371 }
372 372
373 int32_t PepperFileIOHost::OnHostMsgRequestOSFileHandle( 373 int32_t PepperFileIOHost::OnHostMsgRequestOSFileHandle(
374 ppapi::host::HostMessageContext* context) { 374 ppapi::host::HostMessageContext* context) {
375 if (open_flags_ != PP_FILEOPENFLAG_READ && file_system_host_->ChecksQuota()) 375 if (open_flags_ != PP_FILEOPENFLAG_READ && file_system_host_->ChecksQuota())
(...skipping 24 matching lines...) Expand all
400 reply_context.params.set_result(PP_ERROR_FAILED); 400 reply_context.params.set_result(PP_ERROR_FAILED);
401 } else { 401 } else {
402 reply_context.params.set_result(PP_ERROR_NOACCESS); 402 reply_context.params.set_result(PP_ERROR_NOACCESS);
403 } 403 }
404 host()->SendReply(reply_context, 404 host()->SendReply(reply_context,
405 PpapiPluginMsg_FileIO_RequestOSFileHandleReply()); 405 PpapiPluginMsg_FileIO_RequestOSFileHandleReply());
406 } 406 }
407 407
408 void PepperFileIOHost::ExecutePlatformGeneralCallback( 408 void PepperFileIOHost::ExecutePlatformGeneralCallback(
409 ppapi::host::ReplyMessageContext reply_context, 409 ppapi::host::ReplyMessageContext reply_context,
410 base::PlatformFileError error_code) { 410 base::File::Error error_code) {
411 reply_context.params.set_result( 411 reply_context.params.set_result(
412 ppapi::PlatformFileErrorToPepperError(error_code)); 412 ppapi::FileErrorToPepperError(error_code));
413 host()->SendReply(reply_context, PpapiPluginMsg_FileIO_GeneralReply()); 413 host()->SendReply(reply_context, PpapiPluginMsg_FileIO_GeneralReply());
414 state_manager_.SetOperationFinished(); 414 state_manager_.SetOperationFinished();
415 } 415 }
416 416
417 void PepperFileIOHost::ExecutePlatformOpenFileCallback( 417 void PepperFileIOHost::ExecutePlatformOpenFileCallback(
418 ppapi::host::ReplyMessageContext reply_context, 418 ppapi::host::ReplyMessageContext reply_context,
419 base::PlatformFileError error_code, 419 base::File::Error error_code,
420 base::PassPlatformFile file, 420 base::PassPlatformFile file,
421 bool unused_created) { 421 bool unused_created) {
422 int32_t pp_error = ppapi::PlatformFileErrorToPepperError(error_code); 422 int32_t pp_error = ppapi::FileErrorToPepperError(error_code);
423 DCHECK(file_ == base::kInvalidPlatformFileValue); 423 DCHECK(file_ == base::kInvalidPlatformFileValue);
424 file_ = file.ReleaseValue(); 424 file_ = file.ReleaseValue();
425 425
426 if (file_ != base::kInvalidPlatformFileValue && 426 if (file_ != base::kInvalidPlatformFileValue &&
427 !AddFileToReplyContext(open_flags_, &reply_context)) 427 !AddFileToReplyContext(open_flags_, &reply_context))
428 pp_error = PP_ERROR_FAILED; 428 pp_error = PP_ERROR_FAILED;
429 429
430 PP_Resource quota_file_system = 0; 430 PP_Resource quota_file_system = 0;
431 if (pp_error == PP_OK) { 431 if (pp_error == PP_OK) {
432 state_manager_.SetOpenSucceed(); 432 state_manager_.SetOpenSucceed();
(...skipping 29 matching lines...) Expand all
462 462
463 ppapi::proxy::SerializedHandle file_handle; 463 ppapi::proxy::SerializedHandle file_handle;
464 // A non-zero resource id signals NaClIPCAdapter to create a NaClQuotaDesc. 464 // A non-zero resource id signals NaClIPCAdapter to create a NaClQuotaDesc.
465 PP_Resource quota_file_io = check_quota_ ? pp_resource() : 0; 465 PP_Resource quota_file_io = check_quota_ ? pp_resource() : 0;
466 file_handle.set_file_handle(transit_file, open_flags, quota_file_io); 466 file_handle.set_file_handle(transit_file, open_flags, quota_file_io);
467 reply_context->params.AppendHandle(file_handle); 467 reply_context->params.AppendHandle(file_handle);
468 return true; 468 return true;
469 } 469 }
470 470
471 } // namespace content 471 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698