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

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

Issue 291513003: Remove PlatformFile from fileapi::FileSystemOperation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 file_system_host_->GetFileSystemOperationRunner()->OpenFile( 230 file_system_host_->GetFileSystemOperationRunner()->OpenFile(
231 file_system_url_, 231 file_system_url_,
232 platform_file_flags, 232 platform_file_flags,
233 base::Bind(&PepperFileIOHost::DidOpenInternalFile, 233 base::Bind(&PepperFileIOHost::DidOpenInternalFile,
234 weak_factory_.GetWeakPtr(), 234 weak_factory_.GetWeakPtr(),
235 reply_context)); 235 reply_context));
236 } 236 }
237 237
238 void PepperFileIOHost::DidOpenInternalFile( 238 void PepperFileIOHost::DidOpenInternalFile(
239 ppapi::host::ReplyMessageContext reply_context, 239 ppapi::host::ReplyMessageContext reply_context,
240 base::File::Error result, 240 base::File file,
241 base::PlatformFile file,
242 const base::Closure& on_close_callback) { 241 const base::Closure& on_close_callback) {
243 if (result == base::File::FILE_OK) { 242 if (file.IsValid()) {
244 on_close_callback_ = on_close_callback; 243 on_close_callback_ = on_close_callback;
245 244
246 if (FileOpenForWrite(open_flags_) && file_system_host_->ChecksQuota()) { 245 if (FileOpenForWrite(open_flags_) && file_system_host_->ChecksQuota()) {
247 check_quota_ = true; 246 check_quota_ = true;
248 file_system_host_->OpenQuotaFile( 247 file_system_host_->OpenQuotaFile(
249 this, 248 this,
250 file_system_url_, 249 file_system_url_,
251 base::Bind(&PepperFileIOHost::DidOpenQuotaFile, 250 base::Bind(&PepperFileIOHost::DidOpenQuotaFile,
252 weak_factory_.GetWeakPtr(), 251 weak_factory_.GetWeakPtr(),
253 reply_context, 252 reply_context,
254 file)); 253 Passed(&file)));
bbudge 2014/05/22 17:12:20 nit: could you fully qualify this (base::Passed) s
rvargas (doing something else) 2014/05/22 20:52:53 Done.
255 return; 254 return;
256 } 255 }
257 } 256 }
258 257
259 ExecutePlatformOpenFileCallback( 258 DCHECK(!file_.IsValid());
260 reply_context, result, base::PassPlatformFile(&file), true); 259 base::File::Error error =
260 file.IsValid() ? base::File::FILE_OK : file.error_details();
261 file_.SetFile(file.Pass());
262 OnOpenProxyCallback(reply_context, error);
261 } 263 }
262 264
263 void PepperFileIOHost::GotResolvedRenderProcessId( 265 void PepperFileIOHost::GotResolvedRenderProcessId(
264 ppapi::host::ReplyMessageContext reply_context, 266 ppapi::host::ReplyMessageContext reply_context,
265 base::FilePath path, 267 base::FilePath path,
266 int file_flags, 268 int file_flags,
267 base::ProcessId resolved_render_process_id) { 269 base::ProcessId resolved_render_process_id) {
268 DCHECK_CURRENTLY_ON(BrowserThread::IO); 270 DCHECK_CURRENTLY_ON(BrowserThread::IO);
269 resolved_render_process_id_ = resolved_render_process_id; 271 resolved_render_process_id_ = resolved_render_process_id;
270 file_.CreateOrOpen( 272 file_.CreateOrOpen(
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 352
351 if (file_.IsValid()) { 353 if (file_.IsValid()) {
352 file_.Close(base::Bind(&PepperFileIOHost::DidCloseFile, 354 file_.Close(base::Bind(&PepperFileIOHost::DidCloseFile,
353 weak_factory_.GetWeakPtr())); 355 weak_factory_.GetWeakPtr()));
354 } 356 }
355 return PP_OK; 357 return PP_OK;
356 } 358 }
357 359
358 void PepperFileIOHost::DidOpenQuotaFile( 360 void PepperFileIOHost::DidOpenQuotaFile(
359 ppapi::host::ReplyMessageContext reply_context, 361 ppapi::host::ReplyMessageContext reply_context,
360 base::PlatformFile file, 362 base::File file,
361 int64_t max_written_offset) { 363 int64_t max_written_offset) {
364 DCHECK(!file_.IsValid());
365 DCHECK(file.IsValid());
362 max_written_offset_ = max_written_offset; 366 max_written_offset_ = max_written_offset;
367 file_.SetFile(file.Pass());
363 368
364 ExecutePlatformOpenFileCallback( 369 OnOpenProxyCallback(reply_context, base::File::FILE_OK);
365 reply_context, base::File::FILE_OK, base::PassPlatformFile(&file), true);
366 } 370 }
367 371
368 void PepperFileIOHost::DidCloseFile(base::File::Error /*error*/) { 372 void PepperFileIOHost::DidCloseFile(base::File::Error /*error*/) {
369 // Silently ignore if we fail to close the file. 373 // Silently ignore if we fail to close the file.
370 if (!on_close_callback_.is_null()) { 374 if (!on_close_callback_.is_null()) {
371 on_close_callback_.Run(); 375 on_close_callback_.Run();
372 on_close_callback_.Reset(); 376 on_close_callback_.Reset();
373 } 377 }
374 } 378 }
375 379
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 } 413 }
410 414
411 void PepperFileIOHost::ExecutePlatformGeneralCallback( 415 void PepperFileIOHost::ExecutePlatformGeneralCallback(
412 ppapi::host::ReplyMessageContext reply_context, 416 ppapi::host::ReplyMessageContext reply_context,
413 base::File::Error error_code) { 417 base::File::Error error_code) {
414 reply_context.params.set_result(ppapi::FileErrorToPepperError(error_code)); 418 reply_context.params.set_result(ppapi::FileErrorToPepperError(error_code));
415 host()->SendReply(reply_context, PpapiPluginMsg_FileIO_GeneralReply()); 419 host()->SendReply(reply_context, PpapiPluginMsg_FileIO_GeneralReply());
416 state_manager_.SetOperationFinished(); 420 state_manager_.SetOperationFinished();
417 } 421 }
418 422
419 // TODO(rvargas): this method should go away when FileApi moves to use File.
420 void PepperFileIOHost::ExecutePlatformOpenFileCallback(
421 ppapi::host::ReplyMessageContext reply_context,
422 base::File::Error error_code,
423 base::PassPlatformFile file,
424 bool unused_created) {
425 DCHECK(!file_.IsValid());
426 file_.SetFile(base::File(file.ReleaseValue()));
427
428 OnOpenProxyCallback(reply_context, error_code);
429 }
430
431 void PepperFileIOHost::OnOpenProxyCallback( 423 void PepperFileIOHost::OnOpenProxyCallback(
432 ppapi::host::ReplyMessageContext reply_context, 424 ppapi::host::ReplyMessageContext reply_context,
433 base::File::Error error_code) { 425 base::File::Error error_code) {
434 int32_t pp_error = ppapi::FileErrorToPepperError(error_code); 426 int32_t pp_error = ppapi::FileErrorToPepperError(error_code);
435 if (file_.IsValid() && !AddFileToReplyContext(open_flags_, &reply_context)) 427 if (file_.IsValid() && !AddFileToReplyContext(open_flags_, &reply_context))
436 pp_error = PP_ERROR_FAILED; 428 pp_error = PP_ERROR_FAILED;
437 429
438 PP_Resource quota_file_system = 0; 430 PP_Resource quota_file_system = 0;
439 if (pp_error == PP_OK) { 431 if (pp_error == PP_OK) {
440 state_manager_.SetOpenSucceed(); 432 state_manager_.SetOpenSucceed();
(...skipping 30 matching lines...) Expand all
471 463
472 ppapi::proxy::SerializedHandle file_handle; 464 ppapi::proxy::SerializedHandle file_handle;
473 // A non-zero resource id signals NaClIPCAdapter to create a NaClQuotaDesc. 465 // A non-zero resource id signals NaClIPCAdapter to create a NaClQuotaDesc.
474 PP_Resource quota_file_io = check_quota_ ? pp_resource() : 0; 466 PP_Resource quota_file_io = check_quota_ ? pp_resource() : 0;
475 file_handle.set_file_handle(transit_file, open_flags, quota_file_io); 467 file_handle.set_file_handle(transit_file, open_flags, quota_file_io);
476 reply_context->params.AppendHandle(file_handle); 468 reply_context->params.AppendHandle(file_handle);
477 return true; 469 return true;
478 } 470 }
479 471
480 } // namespace content 472 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/pepper/pepper_file_io_host.h ('k') | webkit/browser/fileapi/file_system_operation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698