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

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

Issue 579083004: FileSystem: Modify ObfucatedFileUtil to delete contents of the plugin private filesystem (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: address xhwang@'s comment Created 6 years, 3 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
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 "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 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 base::FilePath origin_type_path = GetDirectoryForOriginAndType( 862 base::FilePath origin_type_path = GetDirectoryForOriginAndType(
862 origin, type_string, false, &error); 863 origin, type_string, false, &error);
863 if (origin_type_path.empty()) 864 if (origin_type_path.empty())
864 return true; 865 return true;
865 if (error != base::File::FILE_ERROR_NOT_FOUND) { 866 if (error != base::File::FILE_ERROR_NOT_FOUND) {
866 // TODO(dmikurube): Consider the return value of DestroyDirectoryDatabase. 867 // TODO(dmikurube): Consider the return value of DestroyDirectoryDatabase.
867 // We ignore its error now since 1) it doesn't matter the final result, and 868 // We ignore its error now since 1) it doesn't matter the final result, and
868 // 2) it always returns false in Windows because of LevelDB's 869 // 2) it always returns false in Windows because of LevelDB's
869 // implementation. 870 // implementation.
870 // Information about failure would be useful for debugging. 871 // Information about failure would be useful for debugging.
871 if (!type_string.empty()) 872 if (!type_string.empty())
kinuko 2014/09/24 15:51:37 These '!type_string.empty()' conditions (here and
nhiroki 2014/09/25 10:34:16 I chose the latter way and made this function usab
872 DestroyDirectoryDatabase(origin, type_string); 873 DestroyDirectoryDatabase(origin, type_string);
873 if (!base::DeleteFile(origin_type_path, true /* recursive */)) 874 if (!base::DeleteFile(origin_type_path, true /* recursive */))
874 return false; 875 return false;
875 } 876 }
876 877
877 base::FilePath origin_path = VirtualPath::DirName(origin_type_path); 878 base::FilePath origin_path = VirtualPath::DirName(origin_type_path);
878 DCHECK_EQ(origin_path.value(), 879 DCHECK_EQ(origin_path.value(),
879 GetDirectoryForOrigin(origin, false, NULL).value()); 880 GetDirectoryForOrigin(origin, false, NULL).value());
880 881
881 if (!type_string.empty()) { 882 if (!type_string.empty()) {
(...skipping 17 matching lines...) Expand all
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(
kinuko 2014/09/24 15:51:37 So far we hadn't introduced the term 'plugin' in t
nhiroki 2014/09/25 10:34:16 You're right. We don't have to add a specialized f
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++);
tzik 2014/09/24 18:48:12 As we chatted locally. (Sorry, I forget to leave t
nhiroki 2014/09/25 10:34:16 "http://example.com/12" -> "http://example.com:12"
920 delete database;
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 }
kinuko 2014/09/24 15:51:37 I wonder if supporting type_string.empty() case in
nhiroki 2014/09/25 10:34:16 (Removed entirely this function)
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
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
OLDNEW
« no previous file with comments | « storage/browser/fileapi/obfuscated_file_util.h ('k') | storage/browser/fileapi/plugin_private_file_system_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698