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

Side by Side Diff: webkit/plugins/ppapi/ppb_file_ref_impl.cc

Issue 11958033: Implement Pepper proxy for PPB_DirectoryReader (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test fix Created 7 years, 10 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 (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 "webkit/plugins/ppapi/ppb_file_ref_impl.h" 5 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "googleurl/src/gurl.h" 9 #include "googleurl/src/gurl.h"
10 #include "net/base/escape.h" 10 #include "net/base/escape.h"
11 #include "ppapi/c/pp_errors.h" 11 #include "ppapi/c/pp_errors.h"
12 #include "ppapi/thunk/enter.h" 12 #include "ppapi/thunk/enter.h"
13 #include "ppapi/thunk/ppb_file_system_api.h" 13 #include "ppapi/thunk/ppb_file_system_api.h"
14 #include "ppapi/shared_impl/time_conversion.h" 14 #include "ppapi/shared_impl/time_conversion.h"
15 #include "ppapi/shared_impl/var.h" 15 #include "ppapi/shared_impl/var.h"
16 #include "webkit/plugins/ppapi/common.h" 16 #include "webkit/plugins/ppapi/common.h"
17 #include "webkit/plugins/ppapi/file_callbacks.h" 17 #include "webkit/plugins/ppapi/file_callbacks.h"
18 #include "webkit/plugins/ppapi/plugin_delegate.h" 18 #include "webkit/plugins/ppapi/plugin_delegate.h"
19 #include "webkit/plugins/ppapi/plugin_module.h" 19 #include "webkit/plugins/ppapi/plugin_module.h"
20 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 20 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
21 #include "webkit/plugins/ppapi/ppb_directory_reader_impl.h"
22 #include "webkit/plugins/ppapi/ppb_file_system_impl.h" 21 #include "webkit/plugins/ppapi/ppb_file_system_impl.h"
23 #include "webkit/plugins/ppapi/resource_helper.h" 22 #include "webkit/plugins/ppapi/resource_helper.h"
24 23
25 using ppapi::HostResource; 24 using ppapi::HostResource;
26 using ppapi::PPB_FileRef_CreateInfo; 25 using ppapi::PPB_FileRef_CreateInfo;
27 using ppapi::PPTimeToTime; 26 using ppapi::PPTimeToTime;
28 using ppapi::StringVar; 27 using ppapi::StringVar;
29 using ppapi::TrackedCallback; 28 using ppapi::TrackedCallback;
30 using ppapi::thunk::EnterResourceNoLock; 29 using ppapi::thunk::EnterResourceNoLock;
31 using ppapi::thunk::PPB_FileRef_API; 30 using ppapi::thunk::PPB_FileRef_API;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 PP_Bool make_ancestors, 170 PP_Bool make_ancestors,
172 scoped_refptr<TrackedCallback> callback) { 171 scoped_refptr<TrackedCallback> callback) {
173 if (!IsValidNonExternalFileSystem()) 172 if (!IsValidNonExternalFileSystem())
174 return PP_ERROR_NOACCESS; 173 return PP_ERROR_NOACCESS;
175 174
176 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); 175 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
177 if (!plugin_instance) 176 if (!plugin_instance)
178 return PP_ERROR_FAILED; 177 return PP_ERROR_FAILED;
179 if (!plugin_instance->delegate()->MakeDirectory( 178 if (!plugin_instance->delegate()->MakeDirectory(
180 GetFileSystemURL(), PP_ToBool(make_ancestors), 179 GetFileSystemURL(), PP_ToBool(make_ancestors),
181 new FileCallbacks(this, callback, NULL, NULL, NULL))) 180 new FileCallbacks(this, callback, NULL, NULL)))
182 return PP_ERROR_FAILED; 181 return PP_ERROR_FAILED;
183 return PP_OK_COMPLETIONPENDING; 182 return PP_OK_COMPLETIONPENDING;
184 } 183 }
185 184
186 int32_t PPB_FileRef_Impl::Touch(PP_Time last_access_time, 185 int32_t PPB_FileRef_Impl::Touch(PP_Time last_access_time,
187 PP_Time last_modified_time, 186 PP_Time last_modified_time,
188 scoped_refptr<TrackedCallback> callback) { 187 scoped_refptr<TrackedCallback> callback) {
189 if (!IsValidNonExternalFileSystem()) 188 if (!IsValidNonExternalFileSystem())
190 return PP_ERROR_NOACCESS; 189 return PP_ERROR_NOACCESS;
191 190
192 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); 191 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
193 if (!plugin_instance) 192 if (!plugin_instance)
194 return PP_ERROR_FAILED; 193 return PP_ERROR_FAILED;
195 if (!plugin_instance->delegate()->Touch( 194 if (!plugin_instance->delegate()->Touch(
196 GetFileSystemURL(), 195 GetFileSystemURL(),
197 PPTimeToTime(last_access_time), 196 PPTimeToTime(last_access_time),
198 PPTimeToTime(last_modified_time), 197 PPTimeToTime(last_modified_time),
199 new FileCallbacks(this, callback, NULL, NULL, NULL))) 198 new FileCallbacks(this, callback, NULL, NULL)))
200 return PP_ERROR_FAILED; 199 return PP_ERROR_FAILED;
201 return PP_OK_COMPLETIONPENDING; 200 return PP_OK_COMPLETIONPENDING;
202 } 201 }
203 202
204 int32_t PPB_FileRef_Impl::Delete(scoped_refptr<TrackedCallback> callback) { 203 int32_t PPB_FileRef_Impl::Delete(scoped_refptr<TrackedCallback> callback) {
205 if (!IsValidNonExternalFileSystem()) 204 if (!IsValidNonExternalFileSystem())
206 return PP_ERROR_NOACCESS; 205 return PP_ERROR_NOACCESS;
207 206
208 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); 207 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
209 if (!plugin_instance) 208 if (!plugin_instance)
210 return PP_ERROR_FAILED; 209 return PP_ERROR_FAILED;
211 if (!plugin_instance->delegate()->Delete( 210 if (!plugin_instance->delegate()->Delete(
212 GetFileSystemURL(), 211 GetFileSystemURL(),
213 new FileCallbacks(this, callback, NULL, NULL, NULL))) 212 new FileCallbacks(this, callback, NULL, NULL)))
214 return PP_ERROR_FAILED; 213 return PP_ERROR_FAILED;
215 return PP_OK_COMPLETIONPENDING; 214 return PP_OK_COMPLETIONPENDING;
216 } 215 }
217 216
218 int32_t PPB_FileRef_Impl::Rename(PP_Resource new_pp_file_ref, 217 int32_t PPB_FileRef_Impl::Rename(PP_Resource new_pp_file_ref,
219 scoped_refptr<TrackedCallback> callback) { 218 scoped_refptr<TrackedCallback> callback) {
220 EnterResourceNoLock<PPB_FileRef_API> enter(new_pp_file_ref, true); 219 EnterResourceNoLock<PPB_FileRef_API> enter(new_pp_file_ref, true);
221 if (enter.failed()) 220 if (enter.failed())
222 return PP_ERROR_BADRESOURCE; 221 return PP_ERROR_BADRESOURCE;
223 PPB_FileRef_Impl* new_file_ref = 222 PPB_FileRef_Impl* new_file_ref =
224 static_cast<PPB_FileRef_Impl*>(enter.object()); 223 static_cast<PPB_FileRef_Impl*>(enter.object());
225 224
226 if (!IsValidNonExternalFileSystem() || 225 if (!IsValidNonExternalFileSystem() ||
227 file_system_.get() != new_file_ref->file_system_.get()) 226 file_system_.get() != new_file_ref->file_system_.get())
228 return PP_ERROR_NOACCESS; 227 return PP_ERROR_NOACCESS;
229 228
230 // TODO(viettrungluu): Also cancel when the new file ref is destroyed? 229 // TODO(viettrungluu): Also cancel when the new file ref is destroyed?
231 // http://crbug.com/67624 230 // http://crbug.com/67624
232 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); 231 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
233 if (!plugin_instance) 232 if (!plugin_instance)
234 return PP_ERROR_FAILED; 233 return PP_ERROR_FAILED;
235 if (!plugin_instance->delegate()->Rename( 234 if (!plugin_instance->delegate()->Rename(
236 GetFileSystemURL(), new_file_ref->GetFileSystemURL(), 235 GetFileSystemURL(), new_file_ref->GetFileSystemURL(),
237 new FileCallbacks(this, callback, NULL, NULL, NULL))) 236 new FileCallbacks(this, callback, NULL, NULL)))
238 return PP_ERROR_FAILED; 237 return PP_ERROR_FAILED;
239 return PP_OK_COMPLETIONPENDING; 238 return PP_OK_COMPLETIONPENDING;
240 } 239 }
241 240
242 PP_Var PPB_FileRef_Impl::GetAbsolutePath() { 241 PP_Var PPB_FileRef_Impl::GetAbsolutePath() {
243 if (GetFileSystemType() != PP_FILESYSTEMTYPE_EXTERNAL) 242 if (GetFileSystemType() != PP_FILESYSTEMTYPE_EXTERNAL)
244 return GetPath(); 243 return GetPath();
245 if (!external_path_var_.get()) { 244 if (!external_path_var_.get()) {
246 external_path_var_ = new StringVar( 245 external_path_var_ = new StringVar(
247 external_file_system_path_.AsUTF8Unsafe()); 246 external_file_system_path_.AsUTF8Unsafe());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 return file_system_ && file_system_->opened(); 279 return file_system_ && file_system_->opened();
281 } 280 }
282 281
283 bool PPB_FileRef_Impl::IsValidNonExternalFileSystem() const { 282 bool PPB_FileRef_Impl::IsValidNonExternalFileSystem() const {
284 return file_system_ && file_system_->opened() && 283 return file_system_ && file_system_->opened() &&
285 file_system_->type() != PP_FILESYSTEMTYPE_EXTERNAL; 284 file_system_->type() != PP_FILESYSTEMTYPE_EXTERNAL;
286 } 285 }
287 286
288 } // namespace ppapi 287 } // namespace ppapi
289 } // namespace webkit 288 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_directory_reader_impl.cc ('k') | webkit/plugins/ppapi/ppb_file_system_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698