Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "storage/browser/fileapi/obfuscated_file_util.h" | 5 #include "storage/browser/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/files/file_util.h" | 11 #include "base/files/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/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/strings/string_util.h" | |
| 18 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
| 19 #include "base/strings/sys_string_conversions.h" | 20 #include "base/strings/sys_string_conversions.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 21 #include "base/time/time.h" | 22 #include "base/time/time.h" |
| 22 #include "storage/browser/fileapi/file_observers.h" | 23 #include "storage/browser/fileapi/file_observers.h" |
| 23 #include "storage/browser/fileapi/file_system_context.h" | 24 #include "storage/browser/fileapi/file_system_context.h" |
| 24 #include "storage/browser/fileapi/file_system_operation_context.h" | 25 #include "storage/browser/fileapi/file_system_operation_context.h" |
| 25 #include "storage/browser/fileapi/file_system_url.h" | 26 #include "storage/browser/fileapi/file_system_url.h" |
| 26 #include "storage/browser/fileapi/native_file_util.h" | 27 #include "storage/browser/fileapi/native_file_util.h" |
| 27 #include "storage/browser/fileapi/sandbox_file_system_backend.h" | 28 #include "storage/browser/fileapi/sandbox_file_system_backend.h" |
| (...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 899 if (origin_database_) { | 900 if (origin_database_) { |
| 900 origin_database_->RemovePathForOrigin( | 901 origin_database_->RemovePathForOrigin( |
| 901 storage::GetIdentifierFromOrigin(origin)); | 902 storage::GetIdentifierFromOrigin(origin)); |
| 902 } | 903 } |
| 903 if (!base::DeleteFile(origin_path, true /* recursive */)) | 904 if (!base::DeleteFile(origin_path, true /* recursive */)) |
| 904 return false; | 905 return false; |
| 905 | 906 |
| 906 return true; | 907 return true; |
| 907 } | 908 } |
| 908 | 909 |
| 910 bool ObfuscatedFileUtil::DeleteOriginDirectoryForPluginPrivateFileSystem( | |
| 911 const GURL& origin) { | |
| 912 // Delete the plugin private filesystems from the directory database. | |
| 913 const std::string key_prefix = storage::GetIdentifierFromOrigin(origin); | |
| 914 for (DirectoryMap::iterator iter = directories_.lower_bound(key_prefix); | |
| 915 iter != directories_.end();) { | |
| 916 if (!StartsWithASCII(iter->first, key_prefix, true)) | |
| 917 break; | |
| 918 SandboxDirectoryDatabase* database = iter->second; | |
| 919 directories_.erase(iter++); | |
| 920 delete database; | |
|
xhwang
2014/09/22 16:41:25
If you use ScopedPtrHashMap for DirectoryMap you d
nhiroki
2014/09/24 06:00:31
Good idea! I'll make a separate patch to replace t
nhiroki
2014/09/25 10:34:16
I tried to replace them with ScopedPtrHashMap in h
| |
| 921 } | |
| 922 | |
| 923 base::File::Error error = base::File::FILE_OK; | |
| 924 | |
| 925 // |origin_path| points to "/path/to/File System/Plugins/<origin>". | |
| 926 base::FilePath origin_path = GetDirectoryForOrigin(origin, false, &error); | |
| 927 if (!origin_path.empty()) { | |
| 928 if (!SandboxDirectoryDatabase::DestroyDatabase(origin_path, env_override_)) | |
| 929 return false; | |
| 930 if (!base::DeleteFile(origin_path, true /* recursive */)) | |
| 931 return false; | |
| 932 } | |
| 933 | |
| 934 // Delete the origin directory from the origin database. | |
| 935 InitOriginDatabase(origin, false); | |
| 936 if (origin_database_) { | |
| 937 origin_database_->RemovePathForOrigin( | |
| 938 storage::GetIdentifierFromOrigin(origin)); | |
| 939 } | |
| 940 return true; | |
| 941 } | |
| 942 | |
| 909 ObfuscatedFileUtil::AbstractOriginEnumerator* | 943 ObfuscatedFileUtil::AbstractOriginEnumerator* |
| 910 ObfuscatedFileUtil::CreateOriginEnumerator() { | 944 ObfuscatedFileUtil::CreateOriginEnumerator() { |
| 911 std::vector<SandboxOriginDatabase::OriginRecord> origins; | 945 std::vector<SandboxOriginDatabase::OriginRecord> origins; |
| 912 | 946 |
| 913 InitOriginDatabase(GURL(), false); | 947 InitOriginDatabase(GURL(), false); |
| 914 return new ObfuscatedOriginEnumerator( | 948 return new ObfuscatedOriginEnumerator( |
| 915 origin_database_.get(), file_system_directory_); | 949 origin_database_.get(), file_system_directory_); |
| 916 } | 950 } |
| 917 | 951 |
| 918 bool ObfuscatedFileUtil::DestroyDirectoryDatabase( | 952 bool ObfuscatedFileUtil::DestroyDirectoryDatabase( |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1415 } | 1449 } |
| 1416 return file.Pass(); | 1450 return file.Pass(); |
| 1417 } | 1451 } |
| 1418 | 1452 |
| 1419 bool ObfuscatedFileUtil::HasIsolatedStorage(const GURL& origin) { | 1453 bool ObfuscatedFileUtil::HasIsolatedStorage(const GURL& origin) { |
| 1420 return special_storage_policy_.get() && | 1454 return special_storage_policy_.get() && |
| 1421 special_storage_policy_->HasIsolatedStorage(origin); | 1455 special_storage_policy_->HasIsolatedStorage(origin); |
| 1422 } | 1456 } |
| 1423 | 1457 |
| 1424 } // namespace storage | 1458 } // namespace storage |
| OLD | NEW |