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

Side by Side Diff: storage/browser/fileapi/dump_file_system.cc

Issue 636093002: Add SandboxPrioritizedOriginDatabase support for dump_file_system (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 2 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
« no previous file with comments | « no previous file | storage/browser/fileapi/sandbox_prioritized_origin_database.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 // A tool to dump HTML5 filesystem from CUI. 5 // A tool to dump HTML5 filesystem from CUI.
6 // 6 //
7 // Usage: 7 // Usage:
8 // 8 //
9 // ./out/Release/dump_file_system [options] <filesystem dir> [origin]... 9 // ./out/Release/dump_file_system [options] <filesystem dir> [origin]...
10 // 10 //
11 // If no origin is specified, this dumps all origins in the profile dir. 11 // If no origin is specified, this dumps all origins in the profile dir.
12 // For Chrome App, which has a separate storage directory, specify "primary"
13 // as the origin name.
12 // 14 //
13 // Available options: 15 // Available options:
14 // 16 //
15 // -t : dumps temporary files instead of persistent. 17 // -t : dumps temporary files instead of persistent.
16 // -s : dumps syncable files instead of persistent. 18 // -s : dumps syncable files instead of persistent.
17 // -l : more information will be displayed. 19 // -l : more information will be displayed.
18 // 20 //
19 // The format of -l option is: 21 // The format of -l option is:
20 // 22 //
21 // === ORIGIN origin_name origin_dir === 23 // === ORIGIN origin_name origin_dir ===
(...skipping 13 matching lines...) Expand all
35 #include <vector> 37 #include <vector>
36 38
37 #include "base/files/file_path.h" 39 #include "base/files/file_path.h"
38 #include "base/files/file_util.h" 40 #include "base/files/file_util.h"
39 #include "base/format_macros.h" 41 #include "base/format_macros.h"
40 #include "base/strings/stringprintf.h" 42 #include "base/strings/stringprintf.h"
41 #include "storage/browser/fileapi/obfuscated_file_util.h" 43 #include "storage/browser/fileapi/obfuscated_file_util.h"
42 #include "storage/browser/fileapi/sandbox_directory_database.h" 44 #include "storage/browser/fileapi/sandbox_directory_database.h"
43 #include "storage/browser/fileapi/sandbox_file_system_backend.h" 45 #include "storage/browser/fileapi/sandbox_file_system_backend.h"
44 #include "storage/browser/fileapi/sandbox_origin_database.h" 46 #include "storage/browser/fileapi/sandbox_origin_database.h"
47 #include "storage/browser/fileapi/sandbox_prioritized_origin_database.h"
45 #include "storage/common/fileapi/file_system_types.h" 48 #include "storage/common/fileapi/file_system_types.h"
46 #include "storage/common/fileapi/file_system_util.h" 49 #include "storage/common/fileapi/file_system_util.h"
47 50
48 namespace { 51 namespace {
49 52
50 bool g_opt_long; 53 bool g_opt_long;
51 const char* g_opt_fs_type = "p"; 54 const char* g_opt_fs_type = "p";
52 55
53 void ShowMessageAndExit(const std::string& msg) { 56 void ShowMessageAndExit(const std::string& msg) {
54 fprintf(stderr, "%s\n", msg.c_str()); 57 fprintf(stderr, "%s\n", msg.c_str());
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 directory_suffix, 127 directory_suffix,
125 id, 128 id,
126 size, 129 size,
127 FilePathToString(info.data_path).c_str()); 130 FilePathToString(info.data_path).c_str());
128 } else { 131 } else {
129 printf("%s%s\n", display_name, directory_suffix); 132 printf("%s%s\n", display_name, directory_suffix);
130 } 133 }
131 } 134 }
132 } 135 }
133 136
134 static void DumpOrigin(const base::FilePath& file_system_dir, 137 static base::FilePath GetOriginDir(const base::FilePath& file_system_dir,
135 const std::string& origin_name) { 138 const std::string& origin_name) {
139 if (base::PathExists(file_system_dir.Append(
140 SandboxPrioritizedOriginDatabase::kPrimaryOriginFile))) {
141 return base::FilePath(
142 SandboxPrioritizedOriginDatabase::kPrimaryOriginFile);
143 }
144
136 SandboxOriginDatabase origin_db(file_system_dir, NULL); 145 SandboxOriginDatabase origin_db(file_system_dir, NULL);
137 base::FilePath origin_dir; 146 base::FilePath origin_dir;
138 if (!origin_db.HasOriginPath(origin_name)) { 147 if (!origin_db.HasOriginPath(origin_name)) {
139 ShowMessageAndExit("Origin " + origin_name + " is not in " + 148 ShowMessageAndExit("Origin " + origin_name + " is not in " +
140 FilePathToString(file_system_dir)); 149 FilePathToString(file_system_dir));
141 } 150 }
142 151
143 if (!origin_db.GetPathForOrigin(origin_name, &origin_dir)) { 152 if (!origin_db.GetPathForOrigin(origin_name, &origin_dir)) {
144 ShowMessageAndExit("Failed to get path of origin " + origin_name + 153 ShowMessageAndExit("Failed to get path of origin " + origin_name +
145 " in " + FilePathToString(file_system_dir)); 154 " in " + FilePathToString(file_system_dir));
146 } 155 }
156
157 return origin_dir;
158 }
159
160 static void DumpOrigin(const base::FilePath& file_system_dir,
161 const std::string& origin_name) {
162 base::FilePath origin_dir = GetOriginDir(file_system_dir, origin_name);
147 DumpDirectoryTree(origin_name, file_system_dir.Append(origin_dir)); 163 DumpDirectoryTree(origin_name, file_system_dir.Append(origin_dir));
148 } 164 }
149 165
150 static void DumpFileSystem(const base::FilePath& file_system_dir) { 166 static void DumpFileSystem(const base::FilePath& file_system_dir) {
151 SandboxOriginDatabase origin_db(file_system_dir, NULL); 167 SandboxOriginDatabase origin_db(file_system_dir, NULL);
152 std::vector<SandboxOriginDatabase::OriginRecord> origins; 168 std::vector<SandboxOriginDatabase::OriginRecord> origins;
153 origin_db.ListAllOrigins(&origins); 169 origin_db.ListAllOrigins(&origins);
154 for (size_t i = 0; i < origins.size(); i++) { 170 for (size_t i = 0; i < origins.size(); i++) {
155 const SandboxOriginDatabase::OriginRecord& origin = origins[i]; 171 const SandboxOriginDatabase::OriginRecord& origin = origins[i];
156 DumpDirectoryTree(origin.origin, file_system_dir.Append(origin.path)); 172 DumpDirectoryTree(origin.origin, file_system_dir.Append(origin.path));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 211
196 if (argc == 2) { 212 if (argc == 2) {
197 storage::DumpFileSystem(file_system_dir); 213 storage::DumpFileSystem(file_system_dir);
198 } else { 214 } else {
199 for (int i = 2; i < argc; i++) { 215 for (int i = 2; i < argc; i++) {
200 storage::DumpOrigin(file_system_dir, argv[i]); 216 storage::DumpOrigin(file_system_dir, argv[i]);
201 } 217 }
202 } 218 }
203 return 0; 219 return 0;
204 } 220 }
OLDNEW
« no previous file with comments | « no previous file | storage/browser/fileapi/sandbox_prioritized_origin_database.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698