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

Side by Side Diff: content/renderer/pepper/pepper_file_io_host.cc

Issue 16140025: Pepper: Refactor FileInfo conversions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix yzshen's comments. Created 7 years, 6 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
« no previous file with comments | « no previous file | ppapi/shared_impl/file_type_conversion.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_io_host.h" 5 #include "content/renderer/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/command_line.h" 10 #include "base/command_line.h"
11 #include "base/files/file_util_proxy.h" 11 #include "base/files/file_util_proxy.h"
12 #include "content/public/common/content_client.h" 12 #include "content/public/common/content_client.h"
13 #include "content/public/renderer/content_renderer_client.h" 13 #include "content/public/renderer/content_renderer_client.h"
14 #include "ppapi/c/pp_errors.h" 14 #include "ppapi/c/pp_errors.h"
15 #include "ppapi/host/dispatch_host_message.h" 15 #include "ppapi/host/dispatch_host_message.h"
16 #include "ppapi/host/ppapi_host.h" 16 #include "ppapi/host/ppapi_host.h"
17 #include "ppapi/proxy/ppapi_messages.h" 17 #include "ppapi/proxy/ppapi_messages.h"
18 #include "ppapi/shared_impl/file_type_conversion.h" 18 #include "ppapi/shared_impl/file_type_conversion.h"
19 #include "ppapi/shared_impl/time_conversion.h" 19 #include "ppapi/shared_impl/time_conversion.h"
20 #include "ppapi/thunk/enter.h" 20 #include "ppapi/thunk/enter.h"
21 #include "webkit/plugins/ppapi/host_globals.h" 21 #include "webkit/plugins/ppapi/host_globals.h"
22 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 22 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
23 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" 23 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h"
24 #include "webkit/plugins/ppapi/quota_file_io.h" 24 #include "webkit/plugins/ppapi/quota_file_io.h"
25 25
26 namespace content { 26 namespace content {
27 27
28 using ppapi::FileIOStateManager; 28 using ppapi::FileIOStateManager;
29 using ppapi::PPTimeToTime; 29 using ppapi::PPTimeToTime;
30 using ppapi::TimeToPPTime;
31 using ppapi::host::ReplyMessageContext; 30 using ppapi::host::ReplyMessageContext;
32 using ppapi::thunk::EnterResourceNoLock; 31 using ppapi::thunk::EnterResourceNoLock;
33 using ppapi::thunk::PPB_FileRef_API; 32 using ppapi::thunk::PPB_FileRef_API;
34 using webkit::ppapi::PPB_FileRef_Impl; 33 using webkit::ppapi::PPB_FileRef_Impl;
35 using webkit::ppapi::PluginDelegate; 34 using webkit::ppapi::PluginDelegate;
36 35
37 namespace { 36 namespace {
38 37
39 // The maximum size we'll support reading in one chunk. The renderer process 38 // The maximum size we'll support reading in one chunk. The renderer process
40 // must allocate a buffer sized according to the request of the plugin. To 39 // must allocate a buffer sized according to the request of the plugin. To
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 notify_close_file_callback_ = callback; 485 notify_close_file_callback_ = callback;
487 quota_policy_ = quota_policy; 486 quota_policy_ = quota_policy;
488 ExecutePlatformOpenFileCallback(reply_context, error_code, file); 487 ExecutePlatformOpenFileCallback(reply_context, error_code, file);
489 } 488 }
490 489
491 void PepperFileIOHost::ExecutePlatformQueryCallback( 490 void PepperFileIOHost::ExecutePlatformQueryCallback(
492 ppapi::host::ReplyMessageContext reply_context, 491 ppapi::host::ReplyMessageContext reply_context,
493 base::PlatformFileError error_code, 492 base::PlatformFileError error_code,
494 const base::PlatformFileInfo& file_info) { 493 const base::PlatformFileInfo& file_info) {
495 PP_FileInfo pp_info; 494 PP_FileInfo pp_info;
496 pp_info.size = file_info.size; 495 ppapi::PlatformFileInfoToPepperFileInfo(file_info, file_system_type_,
497 pp_info.creation_time = TimeToPPTime(file_info.creation_time); 496 &pp_info);
498 pp_info.last_access_time = TimeToPPTime(file_info.last_accessed);
499 pp_info.last_modified_time = TimeToPPTime(file_info.last_modified);
500 pp_info.system_type = file_system_type_;
501 if (file_info.is_directory)
502 pp_info.type = PP_FILETYPE_DIRECTORY;
503 else
504 pp_info.type = PP_FILETYPE_REGULAR;
505 497
506 int32_t pp_error = ::ppapi::PlatformFileErrorToPepperError(error_code); 498 int32_t pp_error = ::ppapi::PlatformFileErrorToPepperError(error_code);
507 reply_context.params.set_result(pp_error); 499 reply_context.params.set_result(pp_error);
508 host()->SendReply(reply_context, 500 host()->SendReply(reply_context,
509 PpapiPluginMsg_FileIO_QueryReply(pp_info)); 501 PpapiPluginMsg_FileIO_QueryReply(pp_info));
510 state_manager_.SetOperationFinished(); 502 state_manager_.SetOperationFinished();
511 } 503 }
512 504
513 void PepperFileIOHost::ExecutePlatformReadCallback( 505 void PepperFileIOHost::ExecutePlatformReadCallback(
514 ppapi::host::ReplyMessageContext reply_context, 506 ppapi::host::ReplyMessageContext reply_context,
(...skipping 17 matching lines...) Expand all
532 // On the plugin side, the callback expects a parameter with different meaning 524 // On the plugin side, the callback expects a parameter with different meaning
533 // depends on whether is negative or not. It is the result here. We translate 525 // depends on whether is negative or not. It is the result here. We translate
534 // for the callback. 526 // for the callback.
535 int32_t pp_error = ::ppapi::PlatformFileErrorToPepperError(error_code); 527 int32_t pp_error = ::ppapi::PlatformFileErrorToPepperError(error_code);
536 reply_context.params.set_result(ErrorOrByteNumber(pp_error, bytes_written)); 528 reply_context.params.set_result(ErrorOrByteNumber(pp_error, bytes_written));
537 host()->SendReply(reply_context, PpapiPluginMsg_FileIO_GeneralReply()); 529 host()->SendReply(reply_context, PpapiPluginMsg_FileIO_GeneralReply());
538 state_manager_.SetOperationFinished(); 530 state_manager_.SetOperationFinished();
539 } 531 }
540 532
541 } // namespace content 533 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | ppapi/shared_impl/file_type_conversion.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698