diff options
author | tzik <tzik@chromium.org> | 2014-10-20 05:38:18 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-20 12:38:30 +0000 |
commit | 5f318980ce040fb8b21529e8ecc5fdbec883159f (patch) | |
tree | ef5628693afb837c49f509980fa47580cf5357dc /storage | |
parent | bb1e5752f4c39a37892097460afce447226c457c (diff) | |
download | chromium_src-5f318980ce040fb8b21529e8ecc5fdbec883159f.zip chromium_src-5f318980ce040fb8b21529e8ecc5fdbec883159f.tar.gz chromium_src-5f318980ce040fb8b21529e8ecc5fdbec883159f.tar.bz2 |
Add SandboxPrioritizedOriginDatabase support for dump_file_system
Origin database of FileSystem API performs special handling for Apps V2.
This CL updates dump_file_system to support it.
BUG=421330
NOTRY=True
Review URL: https://codereview.chromium.org/636093002
Cr-Commit-Position: refs/heads/master@{#300254}
Diffstat (limited to 'storage')
3 files changed, 29 insertions, 7 deletions
diff --git a/storage/browser/fileapi/dump_file_system.cc b/storage/browser/fileapi/dump_file_system.cc index 49a2fa3..0c999c8 100644 --- a/storage/browser/fileapi/dump_file_system.cc +++ b/storage/browser/fileapi/dump_file_system.cc @@ -9,6 +9,8 @@ // ./out/Release/dump_file_system [options] <filesystem dir> [origin]... // // If no origin is specified, this dumps all origins in the profile dir. +// For Chrome App, which has a separate storage directory, specify "primary" +// as the origin name. // // Available options: // @@ -42,6 +44,7 @@ #include "storage/browser/fileapi/sandbox_directory_database.h" #include "storage/browser/fileapi/sandbox_file_system_backend.h" #include "storage/browser/fileapi/sandbox_origin_database.h" +#include "storage/browser/fileapi/sandbox_prioritized_origin_database.h" #include "storage/common/fileapi/file_system_types.h" #include "storage/common/fileapi/file_system_util.h" @@ -131,8 +134,14 @@ static void DumpDirectoryTree(const std::string& origin_name, } } -static void DumpOrigin(const base::FilePath& file_system_dir, - const std::string& origin_name) { +static base::FilePath GetOriginDir(const base::FilePath& file_system_dir, + const std::string& origin_name) { + if (base::PathExists(file_system_dir.Append( + SandboxPrioritizedOriginDatabase::kPrimaryOriginFile))) { + return base::FilePath( + SandboxPrioritizedOriginDatabase::kPrimaryOriginFile); + } + SandboxOriginDatabase origin_db(file_system_dir, NULL); base::FilePath origin_dir; if (!origin_db.HasOriginPath(origin_name)) { @@ -144,6 +153,13 @@ static void DumpOrigin(const base::FilePath& file_system_dir, ShowMessageAndExit("Failed to get path of origin " + origin_name + " in " + FilePathToString(file_system_dir)); } + + return origin_dir; +} + +static void DumpOrigin(const base::FilePath& file_system_dir, + const std::string& origin_name) { + base::FilePath origin_dir = GetOriginDir(file_system_dir, origin_name); DumpDirectoryTree(origin_name, file_system_dir.Append(origin_dir)); } diff --git a/storage/browser/fileapi/sandbox_prioritized_origin_database.cc b/storage/browser/fileapi/sandbox_prioritized_origin_database.cc index 80ccd27..c55ad42 100644 --- a/storage/browser/fileapi/sandbox_prioritized_origin_database.cc +++ b/storage/browser/fileapi/sandbox_prioritized_origin_database.cc @@ -5,7 +5,6 @@ #include "storage/browser/fileapi/sandbox_prioritized_origin_database.h" #include "base/files/file.h" -#include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/logging.h" #include "base/pickle.h" @@ -14,13 +13,16 @@ namespace storage { -namespace { - -const base::FilePath::CharType kPrimaryDirectory[] = +const base::FilePath::CharType* +SandboxPrioritizedOriginDatabase::kPrimaryDirectory = FILE_PATH_LITERAL("primary"); -const base::FilePath::CharType kPrimaryOriginFile[] = + +const base::FilePath::CharType* +SandboxPrioritizedOriginDatabase::kPrimaryOriginFile = FILE_PATH_LITERAL("primary.origin"); +namespace { + bool WritePrimaryOriginFile(const base::FilePath& path, const std::string& origin) { base::File file(path, base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_WRITE); diff --git a/storage/browser/fileapi/sandbox_prioritized_origin_database.h b/storage/browser/fileapi/sandbox_prioritized_origin_database.h index 438b0b14..4309bb3 100644 --- a/storage/browser/fileapi/sandbox_prioritized_origin_database.h +++ b/storage/browser/fileapi/sandbox_prioritized_origin_database.h @@ -8,6 +8,7 @@ #include <string> #include <vector> +#include "base/files/file_path.h" #include "base/memory/scoped_ptr.h" #include "storage/browser/fileapi/sandbox_origin_database_interface.h" @@ -24,6 +25,9 @@ class SandboxOriginDatabase; class STORAGE_EXPORT_PRIVATE SandboxPrioritizedOriginDatabase : public SandboxOriginDatabaseInterface { public: + static const base::FilePath::CharType* kPrimaryDirectory; + static const base::FilePath::CharType* kPrimaryOriginFile; + SandboxPrioritizedOriginDatabase(const base::FilePath& file_system_directory, leveldb::Env* env_override); virtual ~SandboxPrioritizedOriginDatabase(); |