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

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

Issue 113363004: PPAPI: Add new PPB_FileRef.MakeDirectory to support exclusive operation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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_internal_file_ref_backend. h" 5 #include "content/browser/renderer_host/pepper/pepper_internal_file_ref_backend. h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/files/file_util_proxy.h" 11 #include "base/files/file_util_proxy.h"
12 #include "content/browser/child_process_security_policy_impl.h" 12 #include "content/browser/child_process_security_policy_impl.h"
13 #include "content/browser/fileapi/browser_file_system_helper.h" 13 #include "content/browser/fileapi/browser_file_system_helper.h"
14 #include "content/browser/renderer_host/pepper/pepper_file_system_browser_host.h " 14 #include "content/browser/renderer_host/pepper/pepper_file_system_browser_host.h "
15 #include "content/public/browser/browser_context.h" 15 #include "content/public/browser/browser_context.h"
16 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/render_process_host.h" 17 #include "content/public/browser/render_process_host.h"
18 #include "content/public/browser/storage_partition.h" 18 #include "content/public/browser/storage_partition.h"
19 #include "net/base/escape.h" 19 #include "net/base/escape.h"
20 #include "ppapi/c/pp_errors.h" 20 #include "ppapi/c/pp_errors.h"
21 #include "ppapi/c/pp_file_info.h" 21 #include "ppapi/c/pp_file_info.h"
22 #include "ppapi/c/pp_instance.h" 22 #include "ppapi/c/pp_instance.h"
23 #include "ppapi/c/pp_resource.h" 23 #include "ppapi/c/pp_resource.h"
24 #include "ppapi/c/ppb_file_ref.h"
24 #include "ppapi/host/dispatch_host_message.h" 25 #include "ppapi/host/dispatch_host_message.h"
25 #include "ppapi/host/ppapi_host.h" 26 #include "ppapi/host/ppapi_host.h"
26 #include "ppapi/proxy/ppapi_messages.h" 27 #include "ppapi/proxy/ppapi_messages.h"
27 #include "ppapi/shared_impl/file_ref_create_info.h" 28 #include "ppapi/shared_impl/file_ref_create_info.h"
28 #include "ppapi/shared_impl/file_ref_util.h" 29 #include "ppapi/shared_impl/file_ref_util.h"
29 #include "ppapi/shared_impl/file_type_conversion.h" 30 #include "ppapi/shared_impl/file_type_conversion.h"
30 #include "ppapi/shared_impl/scoped_pp_var.h" 31 #include "ppapi/shared_impl/scoped_pp_var.h"
31 #include "ppapi/shared_impl/time_conversion.h" 32 #include "ppapi/shared_impl/time_conversion.h"
32 #include "ppapi/shared_impl/var.h" 33 #include "ppapi/shared_impl/var.h"
33 #include "ppapi/thunk/enter.h" 34 #include "ppapi/thunk/enter.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 void PepperInternalFileRefBackend::DidFinish( 86 void PepperInternalFileRefBackend::DidFinish(
86 ppapi::host::ReplyMessageContext context, 87 ppapi::host::ReplyMessageContext context,
87 const IPC::Message& msg, 88 const IPC::Message& msg,
88 base::PlatformFileError error) { 89 base::PlatformFileError error) {
89 context.params.set_result(ppapi::PlatformFileErrorToPepperError(error)); 90 context.params.set_result(ppapi::PlatformFileErrorToPepperError(error));
90 host_->SendReply(context, msg); 91 host_->SendReply(context, msg);
91 } 92 }
92 93
93 int32_t PepperInternalFileRefBackend::MakeDirectory( 94 int32_t PepperInternalFileRefBackend::MakeDirectory(
94 ppapi::host::ReplyMessageContext reply_context, 95 ppapi::host::ReplyMessageContext reply_context,
95 bool make_ancestors) { 96 int32_t make_directory_flags) {
96 if (!GetFileSystemURL().is_valid()) 97 if (!GetFileSystemURL().is_valid())
97 return PP_ERROR_FAILED; 98 return PP_ERROR_FAILED;
98 99
99 GetFileSystemContext()->operation_runner()->CreateDirectory( 100 GetFileSystemContext()->operation_runner()->CreateDirectory(
100 GetFileSystemURL(), 101 GetFileSystemURL(),
101 false, 102 !!(make_directory_flags & PP_MAKEDIRECTORYFLAG_EXCLUSIVE),
102 make_ancestors, 103 !!(make_directory_flags & PP_MAKEDIRECTORYFLAG_WITH_ANCESTORS),
103 base::Bind(&PepperInternalFileRefBackend::DidFinish, 104 base::Bind(&PepperInternalFileRefBackend::DidFinish,
104 weak_factory_.GetWeakPtr(), 105 weak_factory_.GetWeakPtr(),
105 reply_context, 106 reply_context,
106 PpapiPluginMsg_FileRef_MakeDirectoryReply())); 107 PpapiPluginMsg_FileRef_MakeDirectoryReply()));
107 return PP_OK_COMPLETIONPENDING; 108 return PP_OK_COMPLETIONPENDING;
108 } 109 }
109 110
110 int32_t PepperInternalFileRefBackend::Touch( 111 int32_t PepperInternalFileRefBackend::Touch(
111 ppapi::host::ReplyMessageContext reply_context, 112 ppapi::host::ReplyMessageContext reply_context,
112 PP_Time last_access_time, 113 PP_Time last_access_time,
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 ChildProcessSecurityPolicyImpl* policy = 292 ChildProcessSecurityPolicyImpl* policy =
292 ChildProcessSecurityPolicyImpl::GetInstance(); 293 ChildProcessSecurityPolicyImpl::GetInstance();
293 if (!policy->CanReadFileSystemFile(render_process_id_, url) || 294 if (!policy->CanReadFileSystemFile(render_process_id_, url) ||
294 !policy->CanWriteFileSystemFile(render_process_id_, url)) { 295 !policy->CanWriteFileSystemFile(render_process_id_, url)) {
295 return PP_ERROR_NOACCESS; 296 return PP_ERROR_NOACCESS;
296 } 297 }
297 return PP_OK; 298 return PP_OK;
298 } 299 }
299 300
300 } // namespace content 301 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.h ('k') | content/renderer/pepper/plugin_module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698