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

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

Issue 10051002: Merge 129631 - Add database recovery for FileSystemOriginDatabase (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1084/src/
Patch Set: Created 8 years, 8 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 | « webkit/fileapi/file_system_util.cc ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "webkit/fileapi/obfuscated_file_util.h" 5 #include "webkit/fileapi/obfuscated_file_util.h"
6 6
7 #include <queue> 7 #include <queue>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 13 matching lines...) Expand all
24 #include "webkit/fileapi/file_system_util.h" 24 #include "webkit/fileapi/file_system_util.h"
25 #include "webkit/fileapi/sandbox_mount_point_provider.h" 25 #include "webkit/fileapi/sandbox_mount_point_provider.h"
26 #include "webkit/quota/quota_manager.h" 26 #include "webkit/quota/quota_manager.h"
27 27
28 namespace fileapi { 28 namespace fileapi {
29 29
30 namespace { 30 namespace {
31 31
32 const int64 kFlushDelaySeconds = 10 * 60; // 10 minutes 32 const int64 kFlushDelaySeconds = 10 * 60; // 10 minutes
33 33
34 const char kOriginDatabaseName[] = "Origins";
35 const char kDirectoryDatabaseName[] = "Paths";
36
37 void InitFileInfo( 34 void InitFileInfo(
38 FileSystemDirectoryDatabase::FileInfo* file_info, 35 FileSystemDirectoryDatabase::FileInfo* file_info,
39 FileSystemDirectoryDatabase::FileId parent_id, 36 FileSystemDirectoryDatabase::FileId parent_id,
40 const FilePath::StringType& file_name) { 37 const FilePath::StringType& file_name) {
41 DCHECK(file_info); 38 DCHECK(file_info);
42 file_info->parent_id = parent_id; 39 file_info->parent_id = parent_id;
43 file_info->name = file_name; 40 file_info->name = file_name;
44 } 41 }
45 42
46 bool IsRootDirectory(const FileSystemPath& virtual_path) { 43 bool IsRootDirectory(const FileSystemPath& virtual_path) {
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 FileSystemDirectoryDatabase* database = iter->second; 981 FileSystemDirectoryDatabase* database = iter->second;
985 directories_.erase(iter); 982 directories_.erase(iter);
986 delete database; 983 delete database;
987 } 984 }
988 985
989 FilePath path = GetDirectoryForOriginAndType(origin, type, false); 986 FilePath path = GetDirectoryForOriginAndType(origin, type, false);
990 if (path.empty()) 987 if (path.empty())
991 return true; 988 return true;
992 if (!file_util::DirectoryExists(path)) 989 if (!file_util::DirectoryExists(path))
993 return true; 990 return true;
994 path = path.AppendASCII(kDirectoryDatabaseName);
995 return FileSystemDirectoryDatabase::DestroyDatabase(path); 991 return FileSystemDirectoryDatabase::DestroyDatabase(path);
996 } 992 }
997 993
998 // static 994 // static
999 int64 ObfuscatedFileUtil::ComputeFilePathCost(const FilePath& path) { 995 int64 ObfuscatedFileUtil::ComputeFilePathCost(const FilePath& path) {
1000 return GetPathQuotaUsage(1, VirtualPath::BaseName(path).value().size()); 996 return GetPathQuotaUsage(1, VirtualPath::BaseName(path).value().size());
1001 } 997 }
1002 998
1003 PlatformFileError ObfuscatedFileUtil::GetFileInfoInternal( 999 PlatformFileError ObfuscatedFileUtil::GetFileInfoInternal(
1004 FileSystemDirectoryDatabase* db, 1000 FileSystemDirectoryDatabase* db,
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 FilePath path = GetDirectoryForOriginAndType(origin, type, create); 1191 FilePath path = GetDirectoryForOriginAndType(origin, type, create);
1196 if (path.empty()) 1192 if (path.empty())
1197 return NULL; 1193 return NULL;
1198 if (!file_util::DirectoryExists(path)) { 1194 if (!file_util::DirectoryExists(path)) {
1199 if (!file_util::CreateDirectory(path)) { 1195 if (!file_util::CreateDirectory(path)) {
1200 LOG(WARNING) << "Failed to origin+type directory: " << path.value(); 1196 LOG(WARNING) << "Failed to origin+type directory: " << path.value();
1201 return NULL; 1197 return NULL;
1202 } 1198 }
1203 } 1199 }
1204 MarkUsed(); 1200 MarkUsed();
1205 path = path.AppendASCII(kDirectoryDatabaseName);
1206 FileSystemDirectoryDatabase* database = new FileSystemDirectoryDatabase(path); 1201 FileSystemDirectoryDatabase* database = new FileSystemDirectoryDatabase(path);
1207 directories_[key] = database; 1202 directories_[key] = database;
1208 return database; 1203 return database;
1209 } 1204 }
1210 1205
1211 FilePath ObfuscatedFileUtil::GetDirectoryForOrigin( 1206 FilePath ObfuscatedFileUtil::GetDirectoryForOrigin(
1212 const GURL& origin, bool create) { 1207 const GURL& origin, bool create) {
1213 if (!InitOriginDatabase(create)) 1208 if (!InitOriginDatabase(create))
1214 return FilePath(); 1209 return FilePath();
1215 FilePath directory_name; 1210 FilePath directory_name;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 bool ObfuscatedFileUtil::InitOriginDatabase(bool create) { 1250 bool ObfuscatedFileUtil::InitOriginDatabase(bool create) {
1256 if (!origin_database_.get()) { 1251 if (!origin_database_.get()) {
1257 if (!create && !file_util::DirectoryExists(file_system_directory_)) 1252 if (!create && !file_util::DirectoryExists(file_system_directory_))
1258 return false; 1253 return false;
1259 if (!file_util::CreateDirectory(file_system_directory_)) { 1254 if (!file_util::CreateDirectory(file_system_directory_)) {
1260 LOG(WARNING) << "Failed to create FileSystem directory: " << 1255 LOG(WARNING) << "Failed to create FileSystem directory: " <<
1261 file_system_directory_.value(); 1256 file_system_directory_.value();
1262 return false; 1257 return false;
1263 } 1258 }
1264 origin_database_.reset( 1259 origin_database_.reset(
1265 new FileSystemOriginDatabase( 1260 new FileSystemOriginDatabase(file_system_directory_));
1266 file_system_directory_.AppendASCII(kOriginDatabaseName)));
1267 } 1261 }
1268 return true; 1262 return true;
1269 } 1263 }
1270 1264
1271 } // namespace fileapi 1265 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698