OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/format_macros.h" | 12 #include "base/format_macros.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 #include "base/string_number_conversions.h" | 16 #include "base/string_number_conversions.h" |
17 #include "base/stringprintf.h" | 17 #include "base/stringprintf.h" |
18 #include "base/sys_string_conversions.h" | 18 #include "base/sys_string_conversions.h" |
19 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
20 #include "webkit/fileapi/file_system_context.h" | 20 #include "webkit/fileapi/file_system_context.h" |
21 #include "webkit/fileapi/file_system_operation_context.h" | 21 #include "webkit/fileapi/file_system_operation_context.h" |
22 #include "webkit/fileapi/file_system_path_manager.h" | |
23 #include "webkit/fileapi/file_system_quota_util.h" | 22 #include "webkit/fileapi/file_system_quota_util.h" |
24 #include "webkit/fileapi/file_system_util.h" | 23 #include "webkit/fileapi/file_system_util.h" |
25 #include "webkit/fileapi/sandbox_mount_point_provider.h" | 24 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
26 #include "webkit/quota/quota_manager.h" | 25 #include "webkit/quota/quota_manager.h" |
27 | 26 |
28 namespace { | 27 namespace { |
29 | 28 |
30 const int64 kFlushDelaySeconds = 10 * 60; // 10 minutes | 29 const int64 kFlushDelaySeconds = 10 * 60; // 10 minutes |
31 | 30 |
32 const char kOriginDatabaseName[] = "Origins"; | 31 const char kOriginDatabaseName[] = "Origins"; |
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 ObfuscatedFileUtil::CreateOriginEnumerator() { | 985 ObfuscatedFileUtil::CreateOriginEnumerator() { |
987 std::vector<FileSystemOriginDatabase::OriginRecord> origins; | 986 std::vector<FileSystemOriginDatabase::OriginRecord> origins; |
988 | 987 |
989 InitOriginDatabase(false); | 988 InitOriginDatabase(false); |
990 return new ObfuscatedOriginEnumerator( | 989 return new ObfuscatedOriginEnumerator( |
991 origin_database_.get(), file_system_directory_); | 990 origin_database_.get(), file_system_directory_); |
992 } | 991 } |
993 | 992 |
994 bool ObfuscatedFileUtil::DestroyDirectoryDatabase( | 993 bool ObfuscatedFileUtil::DestroyDirectoryDatabase( |
995 const GURL& origin, FileSystemType type) { | 994 const GURL& origin, FileSystemType type) { |
996 std::string type_string = | 995 std::string type_string = GetFileSystemTypeString(type); |
997 FileSystemPathManager::GetFileSystemTypeString(type); | |
998 if (type_string.empty()) { | 996 if (type_string.empty()) { |
999 LOG(WARNING) << "Unknown filesystem type requested:" << type; | 997 LOG(WARNING) << "Unknown filesystem type requested:" << type; |
1000 return true; | 998 return true; |
1001 } | 999 } |
1002 std::string key = GetOriginIdentifierFromURL(origin) + type_string; | 1000 std::string key = GetOriginIdentifierFromURL(origin) + type_string; |
1003 DirectoryMap::iterator iter = directories_.find(key); | 1001 DirectoryMap::iterator iter = directories_.find(key); |
1004 if (iter != directories_.end()) { | 1002 if (iter != directories_.end()) { |
1005 FileSystemDirectoryDatabase* database = iter->second; | 1003 FileSystemDirectoryDatabase* database = iter->second; |
1006 directories_.erase(iter); | 1004 directories_.erase(iter); |
1007 delete database; | 1005 delete database; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1178 // This removes the root, including the trailing slash, leaving a relative | 1176 // This removes the root, including the trailing slash, leaving a relative |
1179 // path. | 1177 // path. |
1180 return FilePath(local_path.value().substr(root.value().length() + 1)); | 1178 return FilePath(local_path.value().substr(root.value().length() + 1)); |
1181 } | 1179 } |
1182 | 1180 |
1183 // TODO: How to do the whole validation-without-creation thing? We may not have | 1181 // TODO: How to do the whole validation-without-creation thing? We may not have |
1184 // quota even to create the database. Ah, in that case don't even get here? | 1182 // quota even to create the database. Ah, in that case don't even get here? |
1185 // Still doesn't answer the quota issue, though. | 1183 // Still doesn't answer the quota issue, though. |
1186 FileSystemDirectoryDatabase* ObfuscatedFileUtil::GetDirectoryDatabase( | 1184 FileSystemDirectoryDatabase* ObfuscatedFileUtil::GetDirectoryDatabase( |
1187 const GURL& origin, FileSystemType type, bool create) { | 1185 const GURL& origin, FileSystemType type, bool create) { |
1188 std::string type_string = | 1186 std::string type_string = GetFileSystemTypeString(type); |
1189 FileSystemPathManager::GetFileSystemTypeString(type); | |
1190 if (type_string.empty()) { | 1187 if (type_string.empty()) { |
1191 LOG(WARNING) << "Unknown filesystem type requested:" << type; | 1188 LOG(WARNING) << "Unknown filesystem type requested:" << type; |
1192 return NULL; | 1189 return NULL; |
1193 } | 1190 } |
1194 std::string key = GetOriginIdentifierFromURL(origin) + type_string; | 1191 std::string key = GetOriginIdentifierFromURL(origin) + type_string; |
1195 DirectoryMap::iterator iter = directories_.find(key); | 1192 DirectoryMap::iterator iter = directories_.find(key); |
1196 if (iter != directories_.end()) { | 1193 if (iter != directories_.end()) { |
1197 MarkUsed(); | 1194 MarkUsed(); |
1198 return iter->second; | 1195 return iter->second; |
1199 } | 1196 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1268 return false; | 1265 return false; |
1269 } | 1266 } |
1270 origin_database_.reset( | 1267 origin_database_.reset( |
1271 new FileSystemOriginDatabase( | 1268 new FileSystemOriginDatabase( |
1272 file_system_directory_.AppendASCII(kOriginDatabaseName))); | 1269 file_system_directory_.AppendASCII(kOriginDatabaseName))); |
1273 } | 1270 } |
1274 return true; | 1271 return true; |
1275 } | 1272 } |
1276 | 1273 |
1277 } // namespace fileapi | 1274 } // namespace fileapi |
OLD | NEW |