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

Side by Side Diff: components/drive/chromeos/file_cache.cc

Issue 2412063002: Fixed the bug that Drive doesn't appear on Files App on epehmeral mode. (Closed)
Patch Set: address comments. Created 4 years, 2 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
« no previous file with comments | « no previous file | 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 "components/drive/chromeos/file_cache.h" 5 #include "components/drive/chromeos/file_cache.h"
6 6
7 #include <linux/fs.h> 7 #include <linux/fs.h>
8 #include <sys/ioctl.h> 8 #include <sys/ioctl.h>
9 #include <sys/xattr.h> 9 #include <sys/xattr.h>
10 10
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 FileAttributes flags = 0; 87 FileAttributes flags = 0;
88 if (ioctl(file.GetPlatformFile(), FS_IOC_GETFLAGS, &flags) < 0) { 88 if (ioctl(file.GetPlatformFile(), FS_IOC_GETFLAGS, &flags) < 0) {
89 PLOG(ERROR) << "ioctl: " << path.value(); 89 PLOG(ERROR) << "ioctl: " << path.value();
90 return -1; 90 return -1;
91 } 91 }
92 return flags; 92 return flags;
93 } 93 }
94 94
95 // Marks the cache file to be removable by cryptohome. 95 // Marks the cache file to be removable by cryptohome.
96 bool SetRemovable(const base::FilePath& path) { 96 bool SetRemovable(const base::FilePath& path) {
97 // TODO(oka): This function always returns true as a quick fix for
98 // http://crbug.com/650268. Remove the hack by immediately returning true if
99 // underlying file system doesn't support file attributes, as tmpfs for
100 // ephemeral mode.
97 FileAttributes flags = GetFileAttributes(path); 101 FileAttributes flags = GetFileAttributes(path);
98 if (flags < 0) return false; 102 if (flags < 0) {
103 // TODO(oka): false should be returned.
hashimoto 2016/10/13 06:12:06 This can result in ignoring real errors and this s
oka 2016/10/14 02:36:43 Done. Thank you. I used xattr.
104 return true;
105 }
99 if ((flags & FS_NODUMP_FL) == FS_NODUMP_FL) return true; 106 if ((flags & FS_NODUMP_FL) == FS_NODUMP_FL) return true;
100 107
101 return SetFileAttributes(path, flags | FS_NODUMP_FL); 108 SetFileAttributes(path, flags | FS_NODUMP_FL);
109 // TODO(oka): Return value of the above method should be returned.
110 return true;
102 } 111 }
103 112
104 // Marks the cache file to be unremovable by cryptohome. 113 // Marks the cache file to be unremovable by cryptohome.
105 bool UnsetRemovable(const base::FilePath& path) { 114 bool UnsetRemovable(const base::FilePath& path) {
115 // TODO(oka): This function always returns true as a quick fix for
116 // http://crbug.com/650268. Remove the hack by immediately returning true if
117 // underlying file system doesn't support file attributes, as tmpfs for
118 // ephemeral mode.
106 FileAttributes flags = GetFileAttributes(path); 119 FileAttributes flags = GetFileAttributes(path);
107 if (flags < 0) return false; 120 if (flags < 0) {
121 // TODO(oka): false should be returned.
122 return true;
123 }
108 if ((flags & FS_NODUMP_FL) == 0) return true; 124 if ((flags & FS_NODUMP_FL) == 0) return true;
109 125
110 return SetFileAttributes(path, flags & ~FS_NODUMP_FL); 126 SetFileAttributes(path, flags & ~FS_NODUMP_FL);
127 // TODO(oka): Return value of the above method should be returned.
128 return true;
111 } 129 }
112 130
113 // Marks |path| as drive cache dir. 131 // Marks |path| as drive cache dir.
114 // Returns if the operation succeeded. 132 // Returns if the operation succeeded.
115 bool MarkAsDriveCacheDir(const base::FilePath& path) { 133 bool MarkAsDriveCacheDir(const base::FilePath& path) {
116 return SetRemovable(path) 134 return SetRemovable(path)
117 && SetExtendedFileAttributes(path, FileCache::kGCacheFilesAttribute, ""); 135 && SetExtendedFileAttributes(path, FileCache::kGCacheFilesAttribute, "");
118 } 136 }
119 137
120 class CacheInfoLatestCompare { 138 class CacheInfoLatestCompare {
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 } 660 }
643 if (it->HasError()) 661 if (it->HasError())
644 return false; 662 return false;
645 663
646 if (!RenameCacheFilesToNewFormat()) 664 if (!RenameCacheFilesToNewFormat())
647 return false; 665 return false;
648 666
649 // Run this every time to resolve inconsistency between metadata 667 // Run this every time to resolve inconsistency between metadata
650 // and file attributes which possibly occurs on abrupt power failure. 668 // and file attributes which possibly occurs on abrupt power failure.
651 if (!FixMetadataAndFileAttributes()) { 669 if (!FixMetadataAndFileAttributes()) {
652 return false; 670 // Returning true as a quick fix for http://crbug.com/650268.
671 // TODO(oka): We should avoid to call the method if the underlying
672 // filesystem does not support file attributes, as tmpfs for ephemeral mode.
673 return true;
653 } 674 }
654 675
655 return true; 676 return true;
656 } 677 }
657 678
658 void FileCache::Destroy() { 679 void FileCache::Destroy() {
659 DCHECK(thread_checker_.CalledOnValidThread()); 680 DCHECK(thread_checker_.CalledOnValidThread());
660 681
661 in_shutdown_.Set(); 682 in_shutdown_.Set();
662 683
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 926
906 bool FileCache::IsEvictable(const std::string& id, const ResourceEntry& entry) { 927 bool FileCache::IsEvictable(const std::string& id, const ResourceEntry& entry) {
907 return IsPresent(entry) && 928 return IsPresent(entry) &&
908 !entry.file_specific_info().cache_state().is_pinned() && 929 !entry.file_specific_info().cache_state().is_pinned() &&
909 !entry.file_specific_info().cache_state().is_dirty() && 930 !entry.file_specific_info().cache_state().is_dirty() &&
910 !mounted_files_.count(id); 931 !mounted_files_.count(id);
911 } 932 }
912 933
913 } // namespace internal 934 } // namespace internal
914 } // namespace drive 935 } // namespace drive
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698