| 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 "chrome/browser/chromeos/gdata/gdata_file_system.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_file_system.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 | 866 |
| 867 { // Lock to use GetGDataFileInfoFromPath and returned pointer, but need to | 867 { // Lock to use GetGDataFileInfoFromPath and returned pointer, but need to |
| 868 // release before GetFromCache. | 868 // release before GetFromCache. |
| 869 base::AutoLock lock(lock_); | 869 base::AutoLock lock(lock_); |
| 870 GDataFileBase* file_base = GetGDataFileInfoFromPath(gdata_file_path); | 870 GDataFileBase* file_base = GetGDataFileInfoFromPath(gdata_file_path); |
| 871 | 871 |
| 872 if (!file_base || !file_base->AsGDataFile()) | 872 if (!file_base || !file_base->AsGDataFile()) |
| 873 return cache_file_path; | 873 return cache_file_path; |
| 874 | 874 |
| 875 GDataFile* file = file_base->AsGDataFile(); | 875 GDataFile* file = file_base->AsGDataFile(); |
| 876 resource = file->resource(); | 876 resource = file->resource_id(); |
| 877 md5 = file->file_md5(); | 877 md5 = file->file_md5(); |
| 878 } | 878 } |
| 879 | 879 |
| 880 if (!GetFromCache(resource, md5, &cache_file_path)) | 880 if (!GetFromCache(resource, md5, &cache_file_path)) |
| 881 cache_file_path.clear(); | 881 cache_file_path.clear(); |
| 882 | 882 |
| 883 return cache_file_path; | 883 return cache_file_path; |
| 884 } | 884 } |
| 885 | 885 |
| 886 void GDataFileSystem::OnCreateDirectoryCompleted( | 886 void GDataFileSystem::OnCreateDirectoryCompleted( |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 new ReadOnlyFindFileDelegate()); | 1074 new ReadOnlyFindFileDelegate()); |
| 1075 UnsafeFindFileByPath(file_path, update_delegate); | 1075 UnsafeFindFileByPath(file_path, update_delegate); |
| 1076 | 1076 |
| 1077 GDataFileBase* file = update_delegate->file(); | 1077 GDataFileBase* file = update_delegate->file(); |
| 1078 | 1078 |
| 1079 if (!file) | 1079 if (!file) |
| 1080 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 1080 return base::PLATFORM_FILE_ERROR_NOT_FOUND; |
| 1081 | 1081 |
| 1082 // If it's a file (only files have resource), remove it from cache. | 1082 // If it's a file (only files have resource), remove it from cache. |
| 1083 if (file->AsGDataFile()) { | 1083 if (file->AsGDataFile()) { |
| 1084 RemoveFromCache(file->AsGDataFile()->resource(), | 1084 RemoveFromCache(file->AsGDataFile()->resource_id(), |
| 1085 base::Bind(&GDataFileSystem::OnRemovedFromCache, | 1085 base::Bind(&GDataFileSystem::OnRemovedFromCache, |
| 1086 weak_ptr_factory_.GetWeakPtr())); | 1086 weak_ptr_factory_.GetWeakPtr())); |
| 1087 } | 1087 } |
| 1088 | 1088 |
| 1089 // You can't remove root element. | 1089 // You can't remove root element. |
| 1090 if (!file->parent()) | 1090 if (!file->parent()) |
| 1091 return base::PLATFORM_FILE_ERROR_ACCESS_DENIED; | 1091 return base::PLATFORM_FILE_ERROR_ACCESS_DENIED; |
| 1092 | 1092 |
| 1093 if (!file->parent()->RemoveFile(file)) | 1093 if (!file->parent()->RemoveFile(file)) |
| 1094 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 1094 return base::PLATFORM_FILE_ERROR_NOT_FOUND; |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1498 | 1498 |
| 1499 GDataFileSystemFactory::~GDataFileSystemFactory() { | 1499 GDataFileSystemFactory::~GDataFileSystemFactory() { |
| 1500 } | 1500 } |
| 1501 | 1501 |
| 1502 ProfileKeyedService* GDataFileSystemFactory::BuildServiceInstanceFor( | 1502 ProfileKeyedService* GDataFileSystemFactory::BuildServiceInstanceFor( |
| 1503 Profile* profile) const { | 1503 Profile* profile) const { |
| 1504 return new GDataFileSystem(profile, new DocumentsService); | 1504 return new GDataFileSystem(profile, new DocumentsService); |
| 1505 } | 1505 } |
| 1506 | 1506 |
| 1507 } // namespace gdata | 1507 } // namespace gdata |
| OLD | NEW |