| OLD | NEW |
| 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/platform_file.h" | 7 #include "base/platform_file.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| 11 #include "net/base/escape.h" | 11 #include "net/base/escape.h" |
| 12 #include "ppapi/c/pp_errors.h" | 12 #include "ppapi/c/pp_errors.h" |
| 13 #include "ppapi/shared_impl/file_type_conversion.h" | 13 #include "ppapi/shared_impl/file_type_conversion.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 "ppapi/thunk/enter.h" | 16 #include "ppapi/thunk/enter.h" |
| 17 #include "ppapi/thunk/ppb_file_system_api.h" | 17 #include "ppapi/thunk/ppb_file_system_api.h" |
| 18 #include "webkit/plugins/ppapi/common.h" | 18 #include "webkit/plugins/ppapi/common.h" |
| 19 #include "webkit/plugins/ppapi/file_callbacks.h" | 19 #include "webkit/plugins/ppapi/file_callbacks.h" |
| 20 #include "webkit/plugins/ppapi/plugin_delegate.h" | 20 #include "webkit/plugins/ppapi/plugin_delegate.h" |
| 21 #include "webkit/plugins/ppapi/plugin_module.h" | 21 #include "webkit/plugins/ppapi/plugin_module.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_system_impl.h" | |
| 24 #include "webkit/plugins/ppapi/resource_helper.h" | 23 #include "webkit/plugins/ppapi/resource_helper.h" |
| 25 | 24 |
| 26 using ppapi::HostResource; | 25 using ppapi::HostResource; |
| 27 using ppapi::PPB_FileRef_CreateInfo; | 26 using ppapi::PPB_FileRef_CreateInfo; |
| 28 using ppapi::PPTimeToTime; | 27 using ppapi::PPTimeToTime; |
| 29 using ppapi::StringVar; | 28 using ppapi::StringVar; |
| 30 using ppapi::TrackedCallback; | 29 using ppapi::TrackedCallback; |
| 31 using ppapi::thunk::EnterResourceNoLock; | 30 using ppapi::thunk::EnterResourceNoLock; |
| 32 using ppapi::thunk::PPB_FileRef_API; | 31 using ppapi::thunk::PPB_FileRef_API; |
| 33 using ppapi::thunk::PPB_FileSystem_API; | 32 using ppapi::thunk::PPB_FileSystem_API; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 callback))) { | 141 callback))) { |
| 143 base::FileUtilProxy::Close( | 142 base::FileUtilProxy::Close( |
| 144 task_runner, file, base::Bind(&IgnoreCloseCallback)); | 143 task_runner, file, base::Bind(&IgnoreCloseCallback)); |
| 145 callback->Run(PP_ERROR_FAILED); | 144 callback->Run(PP_ERROR_FAILED); |
| 146 } | 145 } |
| 147 } | 146 } |
| 148 | 147 |
| 149 } // namespace | 148 } // namespace |
| 150 | 149 |
| 151 PPB_FileRef_Impl::PPB_FileRef_Impl(const PPB_FileRef_CreateInfo& info, | 150 PPB_FileRef_Impl::PPB_FileRef_Impl(const PPB_FileRef_CreateInfo& info, |
| 152 PPB_FileSystem_Impl* file_system) | 151 PP_Resource file_system) |
| 153 : PPB_FileRef_Shared(::ppapi::OBJECT_IS_IMPL, info), | 152 : PPB_FileRef_Shared(::ppapi::OBJECT_IS_IMPL, info), |
| 154 file_system_(file_system), | 153 file_system_(file_system), |
| 155 external_file_system_path_() { | 154 external_file_system_path_() { |
| 156 } | 155 } |
| 157 | 156 |
| 158 PPB_FileRef_Impl::PPB_FileRef_Impl(const PPB_FileRef_CreateInfo& info, | 157 PPB_FileRef_Impl::PPB_FileRef_Impl(const PPB_FileRef_CreateInfo& info, |
| 159 const base::FilePath& external_file_path) | 158 const base::FilePath& external_file_path) |
| 160 : PPB_FileRef_Shared(::ppapi::OBJECT_IS_IMPL, info), | 159 : PPB_FileRef_Shared(::ppapi::OBJECT_IS_IMPL, info), |
| 161 file_system_(), | 160 file_system_(), |
| 162 external_file_system_path_(external_file_path) { | 161 external_file_system_path_(external_file_path) { |
| 163 } | 162 } |
| 164 | 163 |
| 165 PPB_FileRef_Impl::~PPB_FileRef_Impl() { | 164 PPB_FileRef_Impl::~PPB_FileRef_Impl() { |
| 166 } | 165 } |
| 167 | 166 |
| 168 // static | 167 // static |
| 169 PPB_FileRef_Impl* PPB_FileRef_Impl::CreateInternal(PP_Resource pp_file_system, | 168 PPB_FileRef_Impl* PPB_FileRef_Impl::CreateInternal(PP_Instance instance, |
| 169 PP_Resource pp_file_system, |
| 170 const std::string& path) { | 170 const std::string& path) { |
| 171 EnterResourceNoLock<PPB_FileSystem_API> enter(pp_file_system, true); | 171 PluginInstance* plugin_instance = |
| 172 if (enter.failed()) | 172 ResourceHelper::PPInstanceToPluginInstance(instance); |
| 173 if (!plugin_instance || !plugin_instance->delegate()) |
| 173 return 0; | 174 return 0; |
| 174 | 175 |
| 175 PPB_FileSystem_Impl* file_system = | 176 PP_FileSystemType type = |
| 176 static_cast<PPB_FileSystem_Impl*>(enter.object()); | 177 plugin_instance->delegate()->GetFileSystemType(instance, pp_file_system); |
| 177 if (!file_system->pp_instance()) | 178 if (type != PP_FILESYSTEMTYPE_LOCALPERSISTENT && |
| 178 return 0; | 179 type != PP_FILESYSTEMTYPE_LOCALTEMPORARY && |
| 179 | 180 type != PP_FILESYSTEMTYPE_EXTERNAL) |
| 180 if (file_system->type() != PP_FILESYSTEMTYPE_LOCALPERSISTENT && | |
| 181 file_system->type() != PP_FILESYSTEMTYPE_LOCALTEMPORARY && | |
| 182 file_system->type() != PP_FILESYSTEMTYPE_EXTERNAL) | |
| 183 return 0; | 181 return 0; |
| 184 | 182 |
| 185 PPB_FileRef_CreateInfo info; | 183 PPB_FileRef_CreateInfo info; |
| 186 info.resource = HostResource::MakeInstanceOnly(file_system->pp_instance()); | 184 info.resource = HostResource::MakeInstanceOnly(instance); |
| 187 info.file_system_type = file_system->type(); | 185 info.file_system_plugin_resource = pp_file_system; |
| 186 info.file_system_type = type; |
| 188 | 187 |
| 189 // Validate the path. | 188 // Validate the path. |
| 190 info.path = path; | 189 info.path = path; |
| 191 if (!IsValidLocalPath(info.path)) | 190 if (!IsValidLocalPath(info.path)) |
| 192 return 0; | 191 return 0; |
| 193 TrimTrailingSlash(&info.path); | 192 TrimTrailingSlash(&info.path); |
| 194 | 193 |
| 195 info.name = GetNameForVirtualFilePath(info.path); | 194 info.name = GetNameForVirtualFilePath(info.path); |
| 196 | 195 |
| 197 return new PPB_FileRef_Impl(info, file_system); | 196 PPB_FileRef_Impl* file_ref = new PPB_FileRef_Impl(info, pp_file_system); |
| 197 if (plugin_instance->delegate()->IsRunningInProcess(instance)) |
| 198 file_ref->AddFileSystemRefCount(); |
| 199 return file_ref; |
| 198 } | 200 } |
| 199 | 201 |
| 200 // static | 202 // static |
| 201 PPB_FileRef_Impl* PPB_FileRef_Impl::CreateExternal( | 203 PPB_FileRef_Impl* PPB_FileRef_Impl::CreateExternal( |
| 202 PP_Instance instance, | 204 PP_Instance instance, |
| 203 const base::FilePath& external_file_path, | 205 const base::FilePath& external_file_path, |
| 204 const std::string& display_name) { | 206 const std::string& display_name) { |
| 205 PPB_FileRef_CreateInfo info; | 207 PPB_FileRef_CreateInfo info; |
| 206 info.resource = HostResource::MakeInstanceOnly(instance); | 208 info.resource = HostResource::MakeInstanceOnly(instance); |
| 209 info.file_system_plugin_resource = 0; |
| 207 info.file_system_type = PP_FILESYSTEMTYPE_EXTERNAL; | 210 info.file_system_type = PP_FILESYSTEMTYPE_EXTERNAL; |
| 208 if (display_name.empty()) | 211 if (display_name.empty()) |
| 209 info.name = GetNameForExternalFilePath(external_file_path); | 212 info.name = GetNameForExternalFilePath(external_file_path); |
| 210 else | 213 else |
| 211 info.name = display_name; | 214 info.name = display_name; |
| 212 | 215 |
| 213 return new PPB_FileRef_Impl(info, external_file_path); | 216 return new PPB_FileRef_Impl(info, external_file_path); |
| 214 } | 217 } |
| 215 | 218 |
| 216 PP_Resource PPB_FileRef_Impl::GetParent() { | 219 PP_Resource PPB_FileRef_Impl::GetParent() { |
| 217 if (GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL) | 220 if (GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL) |
| 218 return 0; | 221 return 0; |
| 219 | 222 |
| 220 const std::string& virtual_path = GetCreateInfo().path; | 223 const std::string& virtual_path = GetCreateInfo().path; |
| 221 | 224 |
| 222 // There should always be a leading slash at least! | 225 // There should always be a leading slash at least! |
| 223 size_t pos = virtual_path.rfind('/'); | 226 size_t pos = virtual_path.rfind('/'); |
| 224 CHECK(pos != std::string::npos); | 227 CHECK(pos != std::string::npos); |
| 225 | 228 |
| 226 // If the path is "/foo", then we want to include the slash. | 229 // If the path is "/foo", then we want to include the slash. |
| 227 if (pos == 0) | 230 if (pos == 0) |
| 228 pos++; | 231 pos++; |
| 229 std::string parent_path = virtual_path.substr(0, pos); | 232 std::string parent_path = virtual_path.substr(0, pos); |
| 230 | 233 |
| 231 scoped_refptr<PPB_FileRef_Impl> parent_ref( | 234 scoped_refptr<PPB_FileRef_Impl> parent_ref( |
| 232 CreateInternal(file_system_->pp_resource(), parent_path)); | 235 CreateInternal(pp_instance(), file_system_, parent_path)); |
| 233 if (!parent_ref.get()) | 236 if (!parent_ref.get()) |
| 234 return 0; | 237 return 0; |
| 235 return parent_ref->GetReference(); | 238 return parent_ref->GetReference(); |
| 236 } | 239 } |
| 237 | 240 |
| 238 int32_t PPB_FileRef_Impl::MakeDirectory( | 241 int32_t PPB_FileRef_Impl::MakeDirectory( |
| 239 PP_Bool make_ancestors, | 242 PP_Bool make_ancestors, |
| 240 scoped_refptr<TrackedCallback> callback) { | 243 scoped_refptr<TrackedCallback> callback) { |
| 241 if (!IsValidNonExternalFileSystem()) | 244 if (!IsValidNonExternalFileSystem()) |
| 242 return PP_ERROR_NOACCESS; | 245 return PP_ERROR_NOACCESS; |
| 243 | 246 |
| 244 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); | 247 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); |
| 245 if (!plugin_instance) | 248 if (!plugin_instance) |
| 246 return PP_ERROR_FAILED; | 249 return PP_ERROR_FAILED; |
| 247 if (!plugin_instance->delegate()->MakeDirectory( | 250 if (!plugin_instance->delegate()->MakeDirectory( |
| 248 GetFileSystemURL(), PP_ToBool(make_ancestors), | 251 GetFileSystemURL(), PP_ToBool(make_ancestors), |
| 249 new FileCallbacks(this, callback, NULL, NULL))) | 252 new FileCallbacks(this, callback, NULL))) |
| 250 return PP_ERROR_FAILED; | 253 return PP_ERROR_FAILED; |
| 251 return PP_OK_COMPLETIONPENDING; | 254 return PP_OK_COMPLETIONPENDING; |
| 252 } | 255 } |
| 253 | 256 |
| 254 int32_t PPB_FileRef_Impl::Touch(PP_Time last_access_time, | 257 int32_t PPB_FileRef_Impl::Touch(PP_Time last_access_time, |
| 255 PP_Time last_modified_time, | 258 PP_Time last_modified_time, |
| 256 scoped_refptr<TrackedCallback> callback) { | 259 scoped_refptr<TrackedCallback> callback) { |
| 257 if (!IsValidNonExternalFileSystem()) | 260 if (!IsValidNonExternalFileSystem()) |
| 258 return PP_ERROR_NOACCESS; | 261 return PP_ERROR_NOACCESS; |
| 259 | 262 |
| 260 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); | 263 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); |
| 261 if (!plugin_instance) | 264 if (!plugin_instance) |
| 262 return PP_ERROR_FAILED; | 265 return PP_ERROR_FAILED; |
| 263 if (!plugin_instance->delegate()->Touch( | 266 if (!plugin_instance->delegate()->Touch( |
| 264 GetFileSystemURL(), | 267 GetFileSystemURL(), |
| 265 PPTimeToTime(last_access_time), | 268 PPTimeToTime(last_access_time), |
| 266 PPTimeToTime(last_modified_time), | 269 PPTimeToTime(last_modified_time), |
| 267 new FileCallbacks(this, callback, NULL, NULL))) | 270 new FileCallbacks(this, callback, NULL))) |
| 268 return PP_ERROR_FAILED; | 271 return PP_ERROR_FAILED; |
| 269 return PP_OK_COMPLETIONPENDING; | 272 return PP_OK_COMPLETIONPENDING; |
| 270 } | 273 } |
| 271 | 274 |
| 272 int32_t PPB_FileRef_Impl::Delete(scoped_refptr<TrackedCallback> callback) { | 275 int32_t PPB_FileRef_Impl::Delete(scoped_refptr<TrackedCallback> callback) { |
| 273 if (!IsValidNonExternalFileSystem()) | 276 if (!IsValidNonExternalFileSystem()) |
| 274 return PP_ERROR_NOACCESS; | 277 return PP_ERROR_NOACCESS; |
| 275 | 278 |
| 276 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); | 279 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); |
| 277 if (!plugin_instance) | 280 if (!plugin_instance) |
| 278 return PP_ERROR_FAILED; | 281 return PP_ERROR_FAILED; |
| 279 if (!plugin_instance->delegate()->Delete( | 282 if (!plugin_instance->delegate()->Delete( |
| 280 GetFileSystemURL(), | 283 GetFileSystemURL(), |
| 281 new FileCallbacks(this, callback, NULL, NULL))) | 284 new FileCallbacks(this, callback, NULL))) |
| 282 return PP_ERROR_FAILED; | 285 return PP_ERROR_FAILED; |
| 283 return PP_OK_COMPLETIONPENDING; | 286 return PP_OK_COMPLETIONPENDING; |
| 284 } | 287 } |
| 285 | 288 |
| 286 int32_t PPB_FileRef_Impl::Rename(PP_Resource new_pp_file_ref, | 289 int32_t PPB_FileRef_Impl::Rename(PP_Resource new_pp_file_ref, |
| 287 scoped_refptr<TrackedCallback> callback) { | 290 scoped_refptr<TrackedCallback> callback) { |
| 288 EnterResourceNoLock<PPB_FileRef_API> enter(new_pp_file_ref, true); | 291 EnterResourceNoLock<PPB_FileRef_API> enter(new_pp_file_ref, true); |
| 289 if (enter.failed()) | 292 if (enter.failed()) |
| 290 return PP_ERROR_BADRESOURCE; | 293 return PP_ERROR_BADRESOURCE; |
| 291 PPB_FileRef_Impl* new_file_ref = | 294 PPB_FileRef_Impl* new_file_ref = |
| 292 static_cast<PPB_FileRef_Impl*>(enter.object()); | 295 static_cast<PPB_FileRef_Impl*>(enter.object()); |
| 293 | 296 |
| 294 if (!IsValidNonExternalFileSystem() || | 297 if (!IsValidNonExternalFileSystem() || |
| 295 file_system_.get() != new_file_ref->file_system_.get()) | 298 file_system_ != new_file_ref->file_system_) |
| 296 return PP_ERROR_NOACCESS; | 299 return PP_ERROR_NOACCESS; |
| 297 | 300 |
| 298 // TODO(viettrungluu): Also cancel when the new file ref is destroyed? | 301 // TODO(viettrungluu): Also cancel when the new file ref is destroyed? |
| 299 // http://crbug.com/67624 | 302 // http://crbug.com/67624 |
| 300 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); | 303 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); |
| 301 if (!plugin_instance) | 304 if (!plugin_instance) |
| 302 return PP_ERROR_FAILED; | 305 return PP_ERROR_FAILED; |
| 303 if (!plugin_instance->delegate()->Rename( | 306 if (!plugin_instance->delegate()->Rename( |
| 304 GetFileSystemURL(), new_file_ref->GetFileSystemURL(), | 307 GetFileSystemURL(), new_file_ref->GetFileSystemURL(), |
| 305 new FileCallbacks(this, callback, NULL, NULL))) | 308 new FileCallbacks(this, callback, NULL))) |
| 306 return PP_ERROR_FAILED; | 309 return PP_ERROR_FAILED; |
| 307 return PP_OK_COMPLETIONPENDING; | 310 return PP_OK_COMPLETIONPENDING; |
| 308 } | 311 } |
| 309 | 312 |
| 310 PP_Var PPB_FileRef_Impl::GetAbsolutePath() { | 313 PP_Var PPB_FileRef_Impl::GetAbsolutePath() { |
| 311 if (GetFileSystemType() != PP_FILESYSTEMTYPE_EXTERNAL) | 314 if (GetFileSystemType() != PP_FILESYSTEMTYPE_EXTERNAL) |
| 312 return GetPath(); | 315 return GetPath(); |
| 313 if (!external_path_var_.get()) { | 316 if (!external_path_var_.get()) { |
| 314 external_path_var_ = new StringVar( | 317 external_path_var_ = new StringVar( |
| 315 external_file_system_path_.AsUTF8Unsafe()); | 318 external_file_system_path_.AsUTF8Unsafe()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 333 return GURL(); | 336 return GURL(); |
| 334 } | 337 } |
| 335 | 338 |
| 336 const std::string& virtual_path = GetCreateInfo().path; | 339 const std::string& virtual_path = GetCreateInfo().path; |
| 337 CHECK(!virtual_path.empty()); // Should always be at least "/". | 340 CHECK(!virtual_path.empty()); // Should always be at least "/". |
| 338 | 341 |
| 339 // Since |virtual_path_| starts with a '/', it looks like an absolute path. | 342 // Since |virtual_path_| starts with a '/', it looks like an absolute path. |
| 340 // We need to trim off the '/' before calling Resolve, as FileSystem URLs | 343 // We need to trim off the '/' before calling Resolve, as FileSystem URLs |
| 341 // start with a storage type identifier that looks like a path segment. | 344 // start with a storage type identifier that looks like a path segment. |
| 342 | 345 |
| 343 return file_system_->root_url().Resolve( | 346 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); |
| 344 net::EscapePath(virtual_path.substr(1))); | 347 PluginDelegate* delegate = |
| 348 plugin_instance ? plugin_instance->delegate() : NULL; |
| 349 if (!delegate) |
| 350 return GURL(); |
| 351 return GURL(delegate->GetFileSystemRootUrl(pp_instance(), file_system_)) |
| 352 .Resolve(net::EscapePath(virtual_path.substr(1))); |
| 353 } |
| 354 |
| 355 bool PPB_FileRef_Impl::IsValidNonExternalFileSystem() const { |
| 356 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); |
| 357 PluginDelegate* delegate = |
| 358 plugin_instance ? plugin_instance->delegate() : NULL; |
| 359 return delegate && |
| 360 delegate->IsFileSystemOpened(pp_instance(), file_system_) && |
| 361 delegate->GetFileSystemType(pp_instance(), file_system_) != |
| 362 PP_FILESYSTEMTYPE_EXTERNAL; |
| 345 } | 363 } |
| 346 | 364 |
| 347 bool PPB_FileRef_Impl::HasValidFileSystem() const { | 365 bool PPB_FileRef_Impl::HasValidFileSystem() const { |
| 348 return file_system_ && file_system_->opened(); | 366 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); |
| 349 } | 367 PluginDelegate* delegate = |
| 350 | 368 plugin_instance ? plugin_instance->delegate() : NULL; |
| 351 bool PPB_FileRef_Impl::IsValidNonExternalFileSystem() const { | 369 return delegate && delegate->IsFileSystemOpened(pp_instance(), file_system_); |
| 352 return file_system_ && file_system_->opened() && | |
| 353 file_system_->type() != PP_FILESYSTEMTYPE_EXTERNAL; | |
| 354 } | 370 } |
| 355 | 371 |
| 356 int32_t PPB_FileRef_Impl::Query(PP_FileInfo* info, | 372 int32_t PPB_FileRef_Impl::Query(PP_FileInfo* info, |
| 357 scoped_refptr<TrackedCallback> callback) { | 373 scoped_refptr<TrackedCallback> callback) { |
| 358 scoped_refptr<PluginInstance> plugin_instance = | 374 scoped_refptr<PluginInstance> plugin_instance = |
| 359 ResourceHelper::GetPluginInstance(this); | 375 ResourceHelper::GetPluginInstance(this); |
| 360 if (!plugin_instance.get()) | 376 if (!plugin_instance.get()) |
| 361 return PP_ERROR_FAILED; | 377 return PP_ERROR_FAILED; |
| 362 | 378 |
| 363 if (!file_system_) { | 379 if (!file_system_) { |
| 364 // External file system | 380 // External file system |
| 365 // We have to do something totally different for external file systems. | 381 // We have to do something totally different for external file systems. |
| 366 | 382 |
| 367 // TODO(teravest): Use the SequencedWorkerPool instead. | 383 // TODO(teravest): Use the SequencedWorkerPool instead. |
| 368 scoped_refptr<base::TaskRunner> task_runner = | 384 scoped_refptr<base::TaskRunner> task_runner = |
| 369 plugin_instance->delegate()->GetFileThreadMessageLoopProxy(); | 385 plugin_instance->delegate()->GetFileThreadMessageLoopProxy(); |
| 370 if (!plugin_instance->delegate()->AsyncOpenFile( | 386 if (!plugin_instance->delegate()->AsyncOpenFile( |
| 371 GetSystemPath(), | 387 GetSystemPath(), |
| 372 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, | 388 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, |
| 373 base::Bind(&QueryCallback, task_runner, info, callback))) | 389 base::Bind(&QueryCallback, task_runner, info, callback))) |
| 374 return PP_ERROR_FAILED; | 390 return PP_ERROR_FAILED; |
| 375 } else { | 391 } else { |
| 376 // Non-external file system | 392 // Non-external file system |
| 377 if (!HasValidFileSystem()) | 393 if (!HasValidFileSystem()) |
| 378 return PP_ERROR_NOACCESS; | 394 return PP_ERROR_NOACCESS; |
| 379 | 395 |
| 396 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); |
| 397 PluginDelegate* delegate = |
| 398 plugin_instance ? plugin_instance->delegate() : NULL; |
| 399 if (!delegate) |
| 400 return PP_ERROR_FAILED; |
| 401 |
| 380 if (!plugin_instance->delegate()->Query( | 402 if (!plugin_instance->delegate()->Query( |
| 381 GetFileSystemURL(), | 403 GetFileSystemURL(), |
| 382 new FileCallbacks(this, callback, info, file_system_))) | 404 new FileCallbacks(this, callback, info, |
| 405 delegate->GetFileSystemType(pp_instance(), |
| 406 file_system_)))) |
| 383 return PP_ERROR_FAILED; | 407 return PP_ERROR_FAILED; |
| 384 | 408 |
| 385 } | 409 } |
| 386 return PP_OK_COMPLETIONPENDING; | 410 return PP_OK_COMPLETIONPENDING; |
| 387 } | 411 } |
| 388 | 412 |
| 389 } // namespace ppapi | 413 } // namespace ppapi |
| 390 } // namespace webkit | 414 } // namespace webkit |
| OLD | NEW |