summaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorjamescook <jamescook@chromium.org>2015-01-09 08:43:04 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-09 16:44:36 +0000
commit92d7e42458467aabf64b147e8b95d0f4d205fa3f (patch)
treedb9af14d64f3993f876befe0357cff2212b5dfc2 /storage
parent95c44bb9cd2e1bdad1eaf99b6a0896708466bb67 (diff)
downloadchromium_src-92d7e42458467aabf64b147e8b95d0f4d205fa3f.zip
chromium_src-92d7e42458467aabf64b147e8b95d0f4d205fa3f.tar.gz
chromium_src-92d7e42458467aabf64b147e8b95d0f4d205fa3f.tar.bz2
app_shell: Fix crash on chrome.runtime.getPackageDirectoryEntry for cros
Because app_shell does not support code in //chrome it cannot register the special chromeos::FileSystemBackend that handles kFileSystemTypeNativeLocal. However, code in //storage in IsolatedFileSystemBackend implicitly assumes that on Chrome OS kFileSystemTypeNativeLocal will be handled elsewhere. This patch changes IsolatedFileSystemBackend to provide support for kFileSystemTypeNativeLocal whenever the //storage embedder does not provide a backend for it. This preserves existing behavior for non-app_shell platforms and makes app_shell behave like Linux, which works fine. A better solution would be to refactor chromeos::FileSystemBackend out of //chrome/browser/chromeos, but that is blocked on componentization of //chrome/browser/drive, see http://crbug.com/257943 BUG=447027 TEST=existing FileSystem unit and browser tests, manual test of app_shell (see bug for test app) Review URL: https://codereview.chromium.org/838323003 Cr-Commit-Position: refs/heads/master@{#310780}
Diffstat (limited to 'storage')
-rw-r--r--storage/browser/fileapi/file_system_context.cc12
-rw-r--r--storage/browser/fileapi/isolated_file_system_backend.cc13
-rw-r--r--storage/browser/fileapi/isolated_file_system_backend.h11
3 files changed, 28 insertions, 8 deletions
diff --git a/storage/browser/fileapi/file_system_context.cc b/storage/browser/fileapi/file_system_context.cc
index 4b300ef..85a9317 100644
--- a/storage/browser/fileapi/file_system_context.cc
+++ b/storage/browser/fileapi/file_system_context.cc
@@ -150,7 +150,6 @@ FileSystemContext::FileSystemContext(
special_storage_policy,
options)),
sandbox_backend_(new SandboxFileSystemBackend(sandbox_delegate_.get())),
- isolated_backend_(new IsolatedFileSystemBackend()),
plugin_private_backend_(
new PluginPrivateFileSystemBackend(file_task_runner,
partition_path,
@@ -163,7 +162,6 @@ FileSystemContext::FileSystemContext(
is_incognito_(options.is_incognito()),
operation_runner_(new FileSystemOperationRunner(this)) {
RegisterBackend(sandbox_backend_.get());
- RegisterBackend(isolated_backend_.get());
RegisterBackend(plugin_private_backend_.get());
for (ScopedVector<FileSystemBackend>::const_iterator iter =
@@ -172,6 +170,16 @@ FileSystemContext::FileSystemContext(
RegisterBackend(*iter);
}
+ // If the embedder's additional backends already provide support for
+ // kFileSystemTypeNativeLocal and kFileSystemTypeNativeForPlatformApp then
+ // IsolatedFileSystemBackend does not need to handle them. For example, on
+ // Chrome OS the additional backend chromeos::FileSystemBackend handles these
+ // types.
+ isolated_backend_.reset(new IsolatedFileSystemBackend(
+ !ContainsKey(backend_map_, kFileSystemTypeNativeLocal),
+ !ContainsKey(backend_map_, kFileSystemTypeNativeForPlatformApp)));
+ RegisterBackend(isolated_backend_.get());
+
if (quota_manager_proxy) {
// Quota client assumes all backends have registered.
quota_manager_proxy->RegisterClient(CreateQuotaClient(
diff --git a/storage/browser/fileapi/isolated_file_system_backend.cc b/storage/browser/fileapi/isolated_file_system_backend.cc
index c9b31d3..823d404 100644
--- a/storage/browser/fileapi/isolated_file_system_backend.cc
+++ b/storage/browser/fileapi/isolated_file_system_backend.cc
@@ -29,8 +29,12 @@
namespace storage {
-IsolatedFileSystemBackend::IsolatedFileSystemBackend()
- : isolated_file_util_(new AsyncFileUtilAdapter(new LocalFileUtil())),
+IsolatedFileSystemBackend::IsolatedFileSystemBackend(
+ bool use_for_type_native_local,
+ bool use_for_type_platform_app)
+ : use_for_type_native_local_(use_for_type_native_local),
+ use_for_type_platform_app_(use_for_type_platform_app),
+ isolated_file_util_(new AsyncFileUtilAdapter(new LocalFileUtil())),
dragged_file_util_(new AsyncFileUtilAdapter(new DraggedFileUtil())),
transient_file_util_(new AsyncFileUtilAdapter(new TransientFileUtil())) {
}
@@ -44,11 +48,10 @@ bool IsolatedFileSystemBackend::CanHandleType(FileSystemType type) const {
case kFileSystemTypeDragged:
case kFileSystemTypeForTransientFile:
return true;
-#if !defined(OS_CHROMEOS)
case kFileSystemTypeNativeLocal:
+ return use_for_type_native_local_;
case kFileSystemTypeNativeForPlatformApp:
- return true;
-#endif
+ return use_for_type_platform_app_;
default:
return false;
}
diff --git a/storage/browser/fileapi/isolated_file_system_backend.h b/storage/browser/fileapi/isolated_file_system_backend.h
index 2c12379..bd13db4 100644
--- a/storage/browser/fileapi/isolated_file_system_backend.h
+++ b/storage/browser/fileapi/isolated_file_system_backend.h
@@ -15,7 +15,8 @@ class AsyncFileUtilAdapter;
class IsolatedFileSystemBackend : public FileSystemBackend {
public:
- IsolatedFileSystemBackend();
+ IsolatedFileSystemBackend(bool use_for_type_native_local,
+ bool use_for_type_platform_app);
~IsolatedFileSystemBackend() override;
// FileSystemBackend implementation.
@@ -55,6 +56,14 @@ class IsolatedFileSystemBackend : public FileSystemBackend {
FileSystemType type) const override;
private:
+ // Whether this object should handle native local filesystem types. Some
+ // platforms (e.g. Chrome OS) may provide a different FileSystemBackend to
+ // handle those types.
+ const bool use_for_type_native_local_;
+
+ // As above but for platform webapps.
+ const bool use_for_type_platform_app_;
+
scoped_ptr<AsyncFileUtilAdapter> isolated_file_util_;
scoped_ptr<AsyncFileUtilAdapter> dragged_file_util_;
scoped_ptr<AsyncFileUtilAdapter> transient_file_util_;