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

Side by Side Diff: chrome/browser/chromeos/drive/file_system.cc

Issue 16628003: drive: Remove FileCacheObserver::OnCacheCommitted (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix PinAndUnpin Created 7 years, 6 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 | Annotate | Revision Log
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 "chrome/browser/chromeos/drive/file_system.h" 5 #include "chrome/browser/chromeos/drive/file_system.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/platform_file.h" 10 #include "base/platform_file.h"
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 options, 710 options,
711 at_most_num_matches, 711 at_most_num_matches,
712 callback); 712 callback);
713 } 713 }
714 714
715 void FileSystem::OnDirectoryChangedByOperation( 715 void FileSystem::OnDirectoryChangedByOperation(
716 const base::FilePath& directory_path) { 716 const base::FilePath& directory_path) {
717 OnDirectoryChanged(directory_path); 717 OnDirectoryChanged(directory_path);
718 } 718 }
719 719
720 void FileSystem::OnCacheFileUploadNeededByOperation(
721 const std::string& resource_id) {
722 sync_client_->AddUploadTask(resource_id);
723 }
724
720 void FileSystem::OnDirectoryChanged(const base::FilePath& directory_path) { 725 void FileSystem::OnDirectoryChanged(const base::FilePath& directory_path) {
721 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 726 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
722 727
723 FOR_EACH_OBSERVER(FileSystemObserver, observers_, 728 FOR_EACH_OBSERVER(FileSystemObserver, observers_,
724 OnDirectoryChanged(directory_path)); 729 OnDirectoryChanged(directory_path));
725 } 730 }
726 731
727 void FileSystem::OnLoadFromServerComplete() { 732 void FileSystem::OnLoadFromServerComplete() {
728 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 733 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
729 734
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 base::Bind(callback, FILE_ERROR_NOT_FOUND)); 954 base::Bind(callback, FILE_ERROR_NOT_FOUND));
950 return; 955 return;
951 } 956 }
952 957
953 // Step 1 of CloseFile: Get resource_id and md5 for |file_path|. 958 // Step 1 of CloseFile: Get resource_id and md5 for |file_path|.
954 resource_metadata_->GetResourceEntryByPathOnUIThread( 959 resource_metadata_->GetResourceEntryByPathOnUIThread(
955 file_path, 960 file_path,
956 base::Bind(&FileSystem::CloseFileAfterGetResourceEntry, 961 base::Bind(&FileSystem::CloseFileAfterGetResourceEntry,
957 weak_ptr_factory_.GetWeakPtr(), 962 weak_ptr_factory_.GetWeakPtr(),
958 file_path, 963 file_path,
959 base::Bind(&FileSystem::CloseFileFinalize, 964 callback));
960 weak_ptr_factory_.GetWeakPtr(),
961 file_path,
962 callback)));
963 } 965 }
964 966
965 void FileSystem::CloseFileAfterGetResourceEntry( 967 void FileSystem::CloseFileAfterGetResourceEntry(
966 const base::FilePath& file_path, 968 const base::FilePath& file_path,
967 const FileOperationCallback& callback, 969 const FileOperationCallback& callback,
968 FileError error, 970 FileError error,
969 scoped_ptr<ResourceEntry> entry) { 971 scoped_ptr<ResourceEntry> entry) {
970 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 972 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
971 DCHECK(!callback.is_null()); 973 DCHECK(!callback.is_null());
972 974
973 if (entry.get() && !entry->has_file_specific_info()) 975 if (entry.get() && !entry->has_file_specific_info())
974 error = FILE_ERROR_NOT_FOUND; 976 error = FILE_ERROR_NOT_FOUND;
975 977
976 if (error != FILE_ERROR_OK) { 978 // Step 2 of CloseFile: Trigger upload.
977 callback.Run(error); 979 // TODO(benchan,kinaba): Call ClearDirtyInCache if the file has not been
978 return; 980 // modified. Come up with a way to detect the intactness effectively, or
979 } 981 // provide a method for user to declare it when calling CloseFile().
980 982 if (error == FILE_ERROR_OK)
981 // Step 2 of CloseFile: Commit the modification in cache. This will trigger 983 sync_client_->AddUploadTask(entry->resource_id());
982 // background upload.
983 // TODO(benchan,kinaba): Call ClearDirtyInCache instead of CommitDirtyInCache
984 // if the file has not been modified. Come up with a way to detect the
985 // intactness effectively, or provide a method for user to declare it when
986 // calling CloseFile().
987 cache_->CommitDirtyOnUIThread(entry->resource_id(),
988 entry->file_specific_info().md5(),
989 callback);
990 }
991
992 void FileSystem::CloseFileFinalize(const base::FilePath& file_path,
993 const FileOperationCallback& callback,
994 FileError result) {
995 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
996 DCHECK(!callback.is_null());
997 984
998 // Step 3 of CloseFile. 985 // Step 3 of CloseFile.
999 // All the invocation of |callback| from operations initiated from CloseFile 986 // All the invocation of |callback| from operations initiated from CloseFile
1000 // must go through here. Removes the |file_path| from the remembered set so 987 // must go through here. Removes the |file_path| from the remembered set so
1001 // that subsequent operations can open the file again. 988 // that subsequent operations can open the file again.
1002 open_files_.erase(file_path); 989 open_files_.erase(file_path);
1003 990
1004 // Then invokes the user-supplied callback function. 991 // Then invokes the user-supplied callback function.
1005 callback.Run(result); 992 callback.Run(error);
1006 } 993 }
1007 994
1008 void FileSystem::CheckLocalModificationAndRun( 995 void FileSystem::CheckLocalModificationAndRun(
1009 scoped_ptr<ResourceEntry> entry, 996 scoped_ptr<ResourceEntry> entry,
1010 const GetResourceEntryCallback& callback) { 997 const GetResourceEntryCallback& callback) {
1011 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 998 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1012 DCHECK(entry.get()); 999 DCHECK(entry.get());
1013 DCHECK(!callback.is_null()); 1000 DCHECK(!callback.is_null());
1014 1001
1015 // For entries that will never be cached, use the original resource entry 1002 // For entries that will never be cached, use the original resource entry
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 return; 1089 return;
1103 } 1090 }
1104 1091
1105 PlatformFileInfoProto entry_file_info; 1092 PlatformFileInfoProto entry_file_info;
1106 util::ConvertPlatformFileInfoToResourceEntry(*file_info, &entry_file_info); 1093 util::ConvertPlatformFileInfoToResourceEntry(*file_info, &entry_file_info);
1107 *entry->mutable_file_info() = entry_file_info; 1094 *entry->mutable_file_info() = entry_file_info;
1108 callback.Run(FILE_ERROR_OK, entry.Pass()); 1095 callback.Run(FILE_ERROR_OK, entry.Pass());
1109 } 1096 }
1110 1097
1111 } // namespace drive 1098 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/file_system.h ('k') | chrome/browser/chromeos/drive/file_system/copy_operation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698