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

Side by Side Diff: webkit/fileapi/dump_file_system.cc

Issue 14885021: Cleanup: Prefix HTML5 Sandbox FileSystem related files with 'sandbox_' (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « content/content_tests.gypi ('k') | webkit/fileapi/file_system_database_test_helper.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 //
(...skipping 20 matching lines...) Expand all
31 31
32 #include <stack> 32 #include <stack>
33 #include <string> 33 #include <string>
34 #include <utility> 34 #include <utility>
35 #include <vector> 35 #include <vector>
36 36
37 #include "base/file_util.h" 37 #include "base/file_util.h"
38 #include "base/files/file_path.h" 38 #include "base/files/file_path.h"
39 #include "base/format_macros.h" 39 #include "base/format_macros.h"
40 #include "base/stringprintf.h" 40 #include "base/stringprintf.h"
41 #include "webkit/fileapi/file_system_directory_database.h"
42 #include "webkit/fileapi/file_system_origin_database.h"
43 #include "webkit/fileapi/file_system_types.h" 41 #include "webkit/fileapi/file_system_types.h"
44 #include "webkit/fileapi/file_system_util.h" 42 #include "webkit/fileapi/file_system_util.h"
45 #include "webkit/fileapi/obfuscated_file_util.h" 43 #include "webkit/fileapi/obfuscated_file_util.h"
44 #include "webkit/fileapi/sandbox_directory_database.h"
46 #include "webkit/fileapi/sandbox_mount_point_provider.h" 45 #include "webkit/fileapi/sandbox_mount_point_provider.h"
46 #include "webkit/fileapi/sandbox_origin_database.h"
47 47
48 namespace { 48 namespace {
49 49
50 bool g_opt_long; 50 bool g_opt_long;
51 fileapi::FileSystemType g_opt_fs_type = fileapi::kFileSystemTypePersistent; 51 fileapi::FileSystemType g_opt_fs_type = fileapi::kFileSystemTypePersistent;
52 52
53 void ShowMessageAndExit(const std::string& msg) { 53 void ShowMessageAndExit(const std::string& msg) {
54 fprintf(stderr, "%s\n", msg.c_str()); 54 fprintf(stderr, "%s\n", msg.c_str());
55 exit(EXIT_FAILURE); 55 exit(EXIT_FAILURE);
56 } 56 }
(...skipping 12 matching lines...) Expand all
69 base::FilePath origin_dir) { 69 base::FilePath origin_dir) {
70 origin_dir = origin_dir.Append( 70 origin_dir = origin_dir.Append(
71 ObfuscatedFileUtil::GetDirectoryNameForType(g_opt_fs_type)); 71 ObfuscatedFileUtil::GetDirectoryNameForType(g_opt_fs_type));
72 72
73 printf("=== ORIGIN %s %s ===\n", 73 printf("=== ORIGIN %s %s ===\n",
74 origin_name.c_str(), FilePathToString(origin_dir).c_str()); 74 origin_name.c_str(), FilePathToString(origin_dir).c_str());
75 75
76 if (!file_util::DirectoryExists(origin_dir)) 76 if (!file_util::DirectoryExists(origin_dir))
77 return; 77 return;
78 78
79 FileSystemDirectoryDatabase directory_db(origin_dir); 79 SandboxDirectoryDatabase directory_db(origin_dir);
80 FileSystemDirectoryDatabase::FileId root_id; 80 SandboxDirectoryDatabase::FileId root_id;
81 if (!directory_db.GetFileWithPath(StringToFilePath("/"), &root_id)) 81 if (!directory_db.GetFileWithPath(StringToFilePath("/"), &root_id))
82 return; 82 return;
83 83
84 std::stack<std::pair<FileSystemDirectoryDatabase::FileId, 84 std::stack<std::pair<SandboxDirectoryDatabase::FileId,
85 std::string> > paths; 85 std::string> > paths;
86 paths.push(std::make_pair(root_id, "")); 86 paths.push(std::make_pair(root_id, ""));
87 while (!paths.empty()) { 87 while (!paths.empty()) {
88 FileSystemDirectoryDatabase::FileId id = paths.top().first; 88 SandboxDirectoryDatabase::FileId id = paths.top().first;
89 const std::string dirname = paths.top().second; 89 const std::string dirname = paths.top().second;
90 paths.pop(); 90 paths.pop();
91 91
92 FileSystemDirectoryDatabase::FileInfo info; 92 SandboxDirectoryDatabase::FileInfo info;
93 if (!directory_db.GetFileInfo(id, &info)) { 93 if (!directory_db.GetFileInfo(id, &info)) {
94 ShowMessageAndExit(base::StringPrintf("GetFileInfo failed for %"PRId64, 94 ShowMessageAndExit(base::StringPrintf("GetFileInfo failed for %"PRId64,
95 id)); 95 id));
96 } 96 }
97 97
98 const std::string name = 98 const std::string name =
99 dirname + "/" + FilePathToString(base::FilePath(info.name)); 99 dirname + "/" + FilePathToString(base::FilePath(info.name));
100 std::vector<FileSystemDirectoryDatabase::FileId> children; 100 std::vector<SandboxDirectoryDatabase::FileId> children;
101 if (info.is_directory()) { 101 if (info.is_directory()) {
102 if (!directory_db.ListChildren(id, &children)) { 102 if (!directory_db.ListChildren(id, &children)) {
103 ShowMessageAndExit(base::StringPrintf( 103 ShowMessageAndExit(base::StringPrintf(
104 "ListChildren failed for %s (%"PRId64")", 104 "ListChildren failed for %s (%"PRId64")",
105 info.name.c_str(), id)); 105 info.name.c_str(), id));
106 } 106 }
107 107
108 for (size_t j = children.size(); j; j--) 108 for (size_t j = children.size(); j; j--)
109 paths.push(make_pair(children[j-1], name)); 109 paths.push(make_pair(children[j-1], name));
110 } 110 }
(...skipping 16 matching lines...) Expand all
127 size, 127 size,
128 FilePathToString(info.data_path).c_str()); 128 FilePathToString(info.data_path).c_str());
129 } else { 129 } else {
130 printf("%s%s\n", display_name, directory_suffix); 130 printf("%s%s\n", display_name, directory_suffix);
131 } 131 }
132 } 132 }
133 } 133 }
134 134
135 static void DumpOrigin(const base::FilePath& file_system_dir, 135 static void DumpOrigin(const base::FilePath& file_system_dir,
136 const std::string& origin_name) { 136 const std::string& origin_name) {
137 FileSystemOriginDatabase origin_db(file_system_dir); 137 SandboxOriginDatabase origin_db(file_system_dir);
138 base::FilePath origin_dir; 138 base::FilePath origin_dir;
139 if (!origin_db.HasOriginPath(origin_name)) { 139 if (!origin_db.HasOriginPath(origin_name)) {
140 ShowMessageAndExit("Origin " + origin_name + " is not in " + 140 ShowMessageAndExit("Origin " + origin_name + " is not in " +
141 FilePathToString(file_system_dir)); 141 FilePathToString(file_system_dir));
142 } 142 }
143 143
144 if (!origin_db.GetPathForOrigin(origin_name, &origin_dir)) { 144 if (!origin_db.GetPathForOrigin(origin_name, &origin_dir)) {
145 ShowMessageAndExit("Failed to get path of origin " + origin_name + 145 ShowMessageAndExit("Failed to get path of origin " + origin_name +
146 " in " + FilePathToString(file_system_dir)); 146 " in " + FilePathToString(file_system_dir));
147 } 147 }
148 DumpDirectoryTree(origin_name, file_system_dir.Append(origin_dir)); 148 DumpDirectoryTree(origin_name, file_system_dir.Append(origin_dir));
149 } 149 }
150 150
151 static void DumpFileSystem(const base::FilePath& file_system_dir) { 151 static void DumpFileSystem(const base::FilePath& file_system_dir) {
152 FileSystemOriginDatabase origin_db(file_system_dir); 152 SandboxOriginDatabase origin_db(file_system_dir);
153 std::vector<FileSystemOriginDatabase::OriginRecord> origins; 153 std::vector<SandboxOriginDatabase::OriginRecord> origins;
154 origin_db.ListAllOrigins(&origins); 154 origin_db.ListAllOrigins(&origins);
155 for (size_t i = 0; i < origins.size(); i++) { 155 for (size_t i = 0; i < origins.size(); i++) {
156 const FileSystemOriginDatabase::OriginRecord& origin = origins[i]; 156 const SandboxOriginDatabase::OriginRecord& origin = origins[i];
157 DumpDirectoryTree(origin.origin, file_system_dir.Append(origin.path)); 157 DumpDirectoryTree(origin.origin, file_system_dir.Append(origin.path));
158 puts(""); 158 puts("");
159 } 159 }
160 } 160 }
161 161
162 } // namespace fileapi 162 } // namespace fileapi
163 163
164 int main(int argc, char* argv[]) { 164 int main(int argc, char* argv[]) {
165 const char* arg0 = argv[0]; 165 const char* arg0 = argv[0];
166 std::string username = "Default"; 166 std::string username = "Default";
(...skipping 29 matching lines...) Expand all
196 196
197 if (argc == 2) { 197 if (argc == 2) {
198 fileapi::DumpFileSystem(file_system_dir); 198 fileapi::DumpFileSystem(file_system_dir);
199 } else { 199 } else {
200 for (int i = 2; i < argc; i++) { 200 for (int i = 2; i < argc; i++) {
201 fileapi::DumpOrigin(file_system_dir, argv[i]); 201 fileapi::DumpOrigin(file_system_dir, argv[i]);
202 } 202 }
203 } 203 }
204 return 0; 204 return 0;
205 } 205 }
OLDNEW
« no previous file with comments | « content/content_tests.gypi ('k') | webkit/fileapi/file_system_database_test_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698