diff options
author | ericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-13 19:53:30 +0000 |
---|---|---|
committer | ericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-13 19:53:30 +0000 |
commit | 41e889432dacf1044c38d23a49b7edbc44d273b6 (patch) | |
tree | a797a6dae1c5035f2a291bbae9276fb5dafeb6fe /webkit/plugins | |
parent | 2d90cbded0eff1772c1baec0ad4a7034542c15c1 (diff) | |
download | chromium_src-41e889432dacf1044c38d23a49b7edbc44d273b6.zip chromium_src-41e889432dacf1044c38d23a49b7edbc44d273b6.tar.gz chromium_src-41e889432dacf1044c38d23a49b7edbc44d273b6.tar.bz2 |
More filesystem cleanup: convert URL-encoded-as-FilePath to actual URL, where
possible without WebKit API changes. The WebKit changes will happen in another
CL.
This is a resubmit of http://codereview.chromium.org/6767010/, which bounced
recently. There are a few changes here that weren't there [most notably in
file_system_operation_write_unittest.cc and file_system_operation.cc], but
they're pretty trivial build/test fixes.
Review URL: http://codereview.chromium.org/6833007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81463 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins')
-rw-r--r-- | webkit/plugins/ppapi/file_callbacks.cc | 7 | ||||
-rw-r--r-- | webkit/plugins/ppapi/file_callbacks.h | 2 | ||||
-rw-r--r-- | webkit/plugins/ppapi/mock_plugin_delegate.cc | 14 | ||||
-rw-r--r-- | webkit/plugins/ppapi/mock_plugin_delegate.h | 14 | ||||
-rw-r--r-- | webkit/plugins/ppapi/plugin_delegate.h | 14 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_directory_reader_impl.cc | 2 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_file_ref_impl.cc | 43 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_file_ref_impl.h | 6 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_file_system_impl.h | 10 |
9 files changed, 60 insertions, 52 deletions
diff --git a/webkit/plugins/ppapi/file_callbacks.cc b/webkit/plugins/ppapi/file_callbacks.cc index 92d443b..6706d47 100644 --- a/webkit/plugins/ppapi/file_callbacks.cc +++ b/webkit/plugins/ppapi/file_callbacks.cc @@ -1,10 +1,9 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "webkit/plugins/ppapi/file_callbacks.h" -#include "base/file_path.h" #include "base/logging.h" #include "ppapi/c/dev/ppb_file_system_dev.h" #include "ppapi/c/dev/pp_file_info_dev.h" @@ -76,12 +75,12 @@ void FileCallbacks::DidReadDirectory( } void FileCallbacks::DidOpenFileSystem(const std::string&, - const FilePath& root_path) { + const GURL& root_url) { if (callback_->completed()) return; DCHECK(file_system_); - file_system_->set_root_path(root_path); + file_system_->set_root_url(root_url); file_system_->set_opened(true); callback_->Run(PP_OK); diff --git a/webkit/plugins/ppapi/file_callbacks.h b/webkit/plugins/ppapi/file_callbacks.h index e0a129f..4bdaa1d 100644 --- a/webkit/plugins/ppapi/file_callbacks.h +++ b/webkit/plugins/ppapi/file_callbacks.h @@ -45,7 +45,7 @@ class FileCallbacks : public fileapi::FileSystemCallbackDispatcher { virtual void DidReadDirectory( const std::vector<base::FileUtilProxy::Entry>& entries, bool has_more); virtual void DidOpenFileSystem(const std::string&, - const FilePath& root_path); + const GURL& root_url); virtual void DidFail(base::PlatformFileError error_code); virtual void DidWrite(int64 bytes, bool complete); diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.cc b/webkit/plugins/ppapi/mock_plugin_delegate.cc index f81e9c2..a9da765 100644 --- a/webkit/plugins/ppapi/mock_plugin_delegate.cc +++ b/webkit/plugins/ppapi/mock_plugin_delegate.cc @@ -87,20 +87,20 @@ bool MockPluginDelegate::OpenFileSystem( } bool MockPluginDelegate::MakeDirectory( - const FilePath& path, + const GURL& path, bool recursive, fileapi::FileSystemCallbackDispatcher* dispatcher) { return false; } bool MockPluginDelegate::Query( - const FilePath& path, + const GURL& path, fileapi::FileSystemCallbackDispatcher* dispatcher) { return false; } bool MockPluginDelegate::Touch( - const FilePath& path, + const GURL& path, const base::Time& last_access_time, const base::Time& last_modified_time, fileapi::FileSystemCallbackDispatcher* dispatcher) { @@ -108,20 +108,20 @@ bool MockPluginDelegate::Touch( } bool MockPluginDelegate::Delete( - const FilePath& path, + const GURL& path, fileapi::FileSystemCallbackDispatcher* dispatcher) { return false; } bool MockPluginDelegate::Rename( - const FilePath& file_path, - const FilePath& new_file_path, + const GURL& file_path, + const GURL& new_file_path, fileapi::FileSystemCallbackDispatcher* dispatcher) { return false; } bool MockPluginDelegate::ReadDirectory( - const FilePath& directory_path, + const GURL& directory_path, fileapi::FileSystemCallbackDispatcher* dispatcher) { return false; } diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.h b/webkit/plugins/ppapi/mock_plugin_delegate.h index dd5e8f1..78d59a2 100644 --- a/webkit/plugins/ppapi/mock_plugin_delegate.h +++ b/webkit/plugins/ppapi/mock_plugin_delegate.h @@ -44,22 +44,22 @@ class MockPluginDelegate : public PluginDelegate { long long size, fileapi::FileSystemCallbackDispatcher* dispatcher); virtual bool MakeDirectory( - const FilePath& path, + const GURL& path, bool recursive, fileapi::FileSystemCallbackDispatcher* dispatcher); - virtual bool Query(const FilePath& path, + virtual bool Query(const GURL& path, fileapi::FileSystemCallbackDispatcher* dispatcher); - virtual bool Touch(const FilePath& path, + virtual bool Touch(const GURL& path, const base::Time& last_access_time, const base::Time& last_modified_time, fileapi::FileSystemCallbackDispatcher* dispatcher); - virtual bool Delete(const FilePath& path, + virtual bool Delete(const GURL& path, fileapi::FileSystemCallbackDispatcher* dispatcher); - virtual bool Rename(const FilePath& file_path, - const FilePath& new_file_path, + virtual bool Rename(const GURL& file_path, + const GURL& new_file_path, fileapi::FileSystemCallbackDispatcher* dispatcher); virtual bool ReadDirectory( - const FilePath& directory_path, + const GURL& directory_path, fileapi::FileSystemCallbackDispatcher* dispatcher); virtual base::PlatformFileError OpenFile(const PepperFilePath& path, int flags, diff --git a/webkit/plugins/ppapi/plugin_delegate.h b/webkit/plugins/ppapi/plugin_delegate.h index 33fb820..786e924 100644 --- a/webkit/plugins/ppapi/plugin_delegate.h +++ b/webkit/plugins/ppapi/plugin_delegate.h @@ -288,22 +288,22 @@ class PluginDelegate { long long size, fileapi::FileSystemCallbackDispatcher* dispatcher) = 0; virtual bool MakeDirectory( - const FilePath& path, + const GURL& path, bool recursive, fileapi::FileSystemCallbackDispatcher* dispatcher) = 0; - virtual bool Query(const FilePath& path, + virtual bool Query(const GURL& path, fileapi::FileSystemCallbackDispatcher* dispatcher) = 0; - virtual bool Touch(const FilePath& path, + virtual bool Touch(const GURL& path, const base::Time& last_access_time, const base::Time& last_modified_time, fileapi::FileSystemCallbackDispatcher* dispatcher) = 0; - virtual bool Delete(const FilePath& path, + virtual bool Delete(const GURL& path, fileapi::FileSystemCallbackDispatcher* dispatcher) = 0; - virtual bool Rename(const FilePath& file_path, - const FilePath& new_file_path, + virtual bool Rename(const GURL& file_path, + const GURL& new_file_path, fileapi::FileSystemCallbackDispatcher* dispatcher) = 0; virtual bool ReadDirectory( - const FilePath& directory_path, + const GURL& directory_path, fileapi::FileSystemCallbackDispatcher* dispatcher) = 0; virtual base::PlatformFileError OpenFile(const PepperFilePath& path, diff --git a/webkit/plugins/ppapi/ppb_directory_reader_impl.cc b/webkit/plugins/ppapi/ppb_directory_reader_impl.cc index e704b3f..77935cf 100644 --- a/webkit/plugins/ppapi/ppb_directory_reader_impl.cc +++ b/webkit/plugins/ppapi/ppb_directory_reader_impl.cc @@ -113,7 +113,7 @@ int32_t PPB_DirectoryReader_Impl::GetNextEntry( PP_Resource resource_id = GetReferenceNoAddRef(); DCHECK(resource_id != 0); if (!instance->delegate()->ReadDirectory( - directory_ref_->GetSystemPath(), + directory_ref_->GetFileSystemURL(), new FileCallbacks(instance->module()->AsWeakPtr(), resource_id, callback, NULL, NULL, this))) diff --git a/webkit/plugins/ppapi/ppb_file_ref_impl.cc b/webkit/plugins/ppapi/ppb_file_ref_impl.cc index c2ec5b2..b048caf 100644 --- a/webkit/plugins/ppapi/ppb_file_ref_impl.cc +++ b/webkit/plugins/ppapi/ppb_file_ref_impl.cc @@ -6,6 +6,7 @@ #include "base/string_util.h" #include "base/utf_string_conversions.h" +#include "googleurl/src/gurl.h" #include "ppapi/c/pp_errors.h" #include "webkit/plugins/ppapi/common.h" #include "webkit/plugins/ppapi/file_callbacks.h" @@ -126,7 +127,7 @@ int32_t MakeDirectory(PP_Resource directory_ref_id, PluginInstance* instance = file_system->instance(); if (!instance->delegate()->MakeDirectory( - directory_ref->GetSystemPath(), PPBoolToBool(make_ancestors), + directory_ref->GetFileSystemURL(), PPBoolToBool(make_ancestors), new FileCallbacks(instance->module()->AsWeakPtr(), directory_ref_id, callback, NULL, NULL, NULL))) return PP_ERROR_FAILED; @@ -150,7 +151,8 @@ int32_t Touch(PP_Resource file_ref_id, PluginInstance* instance = file_system->instance(); if (!instance->delegate()->Touch( - file_ref->GetSystemPath(), base::Time::FromDoubleT(last_access_time), + file_ref->GetFileSystemURL(), + base::Time::FromDoubleT(last_access_time), base::Time::FromDoubleT(last_modified_time), new FileCallbacks(instance->module()->AsWeakPtr(), file_ref_id, callback, NULL, NULL, NULL))) @@ -173,7 +175,7 @@ int32_t Delete(PP_Resource file_ref_id, PluginInstance* instance = file_system->instance(); if (!instance->delegate()->Delete( - file_ref->GetSystemPath(), + file_ref->GetFileSystemURL(), new FileCallbacks(instance->module()->AsWeakPtr(), file_ref_id, callback, NULL, NULL, NULL))) return PP_ERROR_FAILED; @@ -204,7 +206,7 @@ int32_t Rename(PP_Resource file_ref_id, // http://crbug.com/67624 PluginInstance* instance = file_system->instance(); if (!instance->delegate()->Rename( - file_ref->GetSystemPath(), new_file_ref->GetSystemPath(), + file_ref->GetFileSystemURL(), new_file_ref->GetFileSystemURL(), new FileCallbacks(instance->module()->AsWeakPtr(), file_ref_id, callback, NULL, NULL, NULL))) return PP_ERROR_FAILED; @@ -320,22 +322,25 @@ std::string PPB_FileRef_Impl::GetPath() const { } FilePath PPB_FileRef_Impl::GetSystemPath() const { - if (GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL) - return system_path_; + if (GetFileSystemType() != PP_FILESYSTEMTYPE_EXTERNAL) { + NOTREACHED(); + return FilePath(); + } + return system_path_; +} - // Since |virtual_path_| starts with a '/', it is considered an absolute path - // on POSIX systems. We need to remove the '/' before calling Append() or we - // will run into a DCHECK. - FilePath virtual_file_path( -#if defined(OS_WIN) - UTF8ToWide(virtual_path_.substr(1)) -#elif defined(OS_POSIX) - virtual_path_.substr(1) -#else -#error "Unsupported platform." -#endif - ); - return file_system_->root_path().Append(virtual_file_path); +GURL PPB_FileRef_Impl::GetFileSystemURL() const { + if (GetFileSystemType() != PP_FILESYSTEMTYPE_LOCALPERSISTENT && + GetFileSystemType() != PP_FILESYSTEMTYPE_LOCALTEMPORARY) { + NOTREACHED(); + return GURL(); + } + if (!virtual_path_.size()) + return file_system_->root_url(); + // Since |virtual_path_| starts with a '/', it looks like an absolute path. + // We need to trim off the '/' before calling Resolve, as FileSystem URLs + // start with a storage type identifier that looks like a path segment. + return file_system_->root_url().Resolve(virtual_path_.substr(1)); } } // namespace ppapi diff --git a/webkit/plugins/ppapi/ppb_file_ref_impl.h b/webkit/plugins/ppapi/ppb_file_ref_impl.h index f006991..234e150 100644 --- a/webkit/plugins/ppapi/ppb_file_ref_impl.h +++ b/webkit/plugins/ppapi/ppb_file_ref_impl.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -8,6 +8,7 @@ #include <string> #include "base/file_path.h" +#include "googleurl/src/gurl.h" #include "ppapi/c/dev/ppb_file_ref_dev.h" #include "webkit/plugins/ppapi/resource.h" @@ -52,6 +53,9 @@ class PPB_FileRef_Impl : public Resource { // Returns the system path corresponding to this file. FilePath GetSystemPath() const; + // Returns the FileSystem API URL corresponding to this file. + GURL GetFileSystemURL() const; + private: scoped_refptr<PPB_FileSystem_Impl> file_system_; std::string virtual_path_; // UTF-8 encoded diff --git a/webkit/plugins/ppapi/ppb_file_system_impl.h b/webkit/plugins/ppapi/ppb_file_system_impl.h index 3ee3756..b381f56 100644 --- a/webkit/plugins/ppapi/ppb_file_system_impl.h +++ b/webkit/plugins/ppapi/ppb_file_system_impl.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,7 +6,7 @@ #define WEBKIT_PLUGINS_PPAPI_PPB_FILE_SYSTEM_IMPL_H_ #include "base/basictypes.h" -#include "base/file_path.h" +#include "googleurl/src/gurl.h" #include "ppapi/c/dev/pp_file_info_dev.h" #include "webkit/plugins/ppapi/resource.h" @@ -28,8 +28,8 @@ class PPB_FileSystem_Impl : public Resource { PluginInstance* instance() { return instance_; } PP_FileSystemType_Dev type() { return type_; } - const FilePath& root_path() const { return root_path_; } - void set_root_path(const FilePath& root_path) { root_path_ = root_path; } + const GURL& root_url() const { return root_url_; } + void set_root_url(const GURL& root_url) { root_url_ = root_url; } bool opened() const { return opened_; } void set_opened(bool opened) { opened_ = opened; } bool called_open() const { return called_open_; } @@ -38,7 +38,7 @@ class PPB_FileSystem_Impl : public Resource { private: PluginInstance* instance_; PP_FileSystemType_Dev type_; - FilePath root_path_; + GURL root_url_; bool opened_; bool called_open_; |