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

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: fix 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 // Returns always true as a quick fix for http://crbug.com/650268.
98 // TODO(oka): Ideally we should avoid to call the method if the underlying
99 // filesystem does not support file attributes, as tmpfs for ephemeral mode.
fukino 2016/10/12 10:34:29 Can we just return at the beginning of this functi
oka 2016/10/13 05:55:51 That's right. I updated the TODO comment.
97 FileAttributes flags = GetFileAttributes(path); 100 FileAttributes flags = GetFileAttributes(path);
98 if (flags < 0) return false; 101 if (flags < 0) {
102 // TODO(oka): false should be returned.
103 return true;
104 }
99 if ((flags & FS_NODUMP_FL) == FS_NODUMP_FL) return true; 105 if ((flags & FS_NODUMP_FL) == FS_NODUMP_FL) return true;
100 106
101 return SetFileAttributes(path, flags | FS_NODUMP_FL); 107 SetFileAttributes(path, flags | FS_NODUMP_FL);
108 // TODO(oka): Return value of the above method should be returned.
109 return true;
102 } 110 }
103 111
104 // Marks the cache file to be unremovable by cryptohome. 112 // Marks the cache file to be unremovable by cryptohome.
105 bool UnsetRemovable(const base::FilePath& path) { 113 bool UnsetRemovable(const base::FilePath& path) {
114 // Returns always true as a quick fix for http://crbug.com/650268.
115 // TODO(oka): Ideally we should avoid to call the method if the underlying
116 // filesystem does not support file attributes, as tmpfs for ephemeral mode.
106 FileAttributes flags = GetFileAttributes(path); 117 FileAttributes flags = GetFileAttributes(path);
107 if (flags < 0) return false; 118 if (flags < 0) {
119 // TODO(oka): false should be returned.
120 return true;
121 }
108 if ((flags & FS_NODUMP_FL) == 0) return true; 122 if ((flags & FS_NODUMP_FL) == 0) return true;
109 123
110 return SetFileAttributes(path, flags & ~FS_NODUMP_FL); 124 SetFileAttributes(path, flags & ~FS_NODUMP_FL);
125 // TODO(oka): Return value of the above method should be returned.
126 return true;
111 } 127 }
112 128
113 // Marks |path| as drive cache dir. 129 // Marks |path| as drive cache dir.
114 // Returns if the operation succeeded. 130 // Returns if the operation succeeded.
115 bool MarkAsDriveCacheDir(const base::FilePath& path) { 131 bool MarkAsDriveCacheDir(const base::FilePath& path) {
116 return SetRemovable(path) 132 return SetRemovable(path)
117 && SetExtendedFileAttributes(path, FileCache::kGCacheFilesAttribute, ""); 133 && SetExtendedFileAttributes(path, FileCache::kGCacheFilesAttribute, "");
118 } 134 }
119 135
120 class CacheInfoLatestCompare { 136 class CacheInfoLatestCompare {
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 } 658 }
643 if (it->HasError()) 659 if (it->HasError())
644 return false; 660 return false;
645 661
646 if (!RenameCacheFilesToNewFormat()) 662 if (!RenameCacheFilesToNewFormat())
647 return false; 663 return false;
648 664
649 // Run this every time to resolve inconsistency between metadata 665 // Run this every time to resolve inconsistency between metadata
650 // and file attributes which possibly occurs on abrupt power failure. 666 // and file attributes which possibly occurs on abrupt power failure.
651 if (!FixMetadataAndFileAttributes()) { 667 if (!FixMetadataAndFileAttributes()) {
652 return false; 668 // Returning true as a quick fix for http://crbug.com/650268.
669 // TODO(oka): Ideally we should avoid to call the method if the underlying
670 // filesystem does not support file attributes, as tmpfs for ephemeral mode.
671 return true;
653 } 672 }
654 673
655 return true; 674 return true;
656 } 675 }
657 676
658 void FileCache::Destroy() { 677 void FileCache::Destroy() {
659 DCHECK(thread_checker_.CalledOnValidThread()); 678 DCHECK(thread_checker_.CalledOnValidThread());
660 679
661 in_shutdown_.Set(); 680 in_shutdown_.Set();
662 681
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 924
906 bool FileCache::IsEvictable(const std::string& id, const ResourceEntry& entry) { 925 bool FileCache::IsEvictable(const std::string& id, const ResourceEntry& entry) {
907 return IsPresent(entry) && 926 return IsPresent(entry) &&
908 !entry.file_specific_info().cache_state().is_pinned() && 927 !entry.file_specific_info().cache_state().is_pinned() &&
909 !entry.file_specific_info().cache_state().is_dirty() && 928 !entry.file_specific_info().cache_state().is_dirty() &&
910 !mounted_files_.count(id); 929 !mounted_files_.count(id);
911 } 930 }
912 931
913 } // namespace internal 932 } // namespace internal
914 } // namespace drive 933 } // 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