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

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

Issue 343073003: Files.app: Provide detailed change information on onDirectoryChanged event (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "chrome/browser/chromeos/drive/change_list_loader.h" 10 #include "chrome/browser/chromeos/drive/change_list_loader.h"
11 #include "chrome/browser/chromeos/drive/directory_loader.h" 11 #include "chrome/browser/chromeos/drive/directory_loader.h"
12 #include "chrome/browser/chromeos/drive/drive.pb.h" 12 #include "chrome/browser/chromeos/drive/drive.pb.h"
13 #include "chrome/browser/chromeos/drive/file_cache.h" 13 #include "chrome/browser/chromeos/drive/file_cache.h"
14 #include "chrome/browser/chromeos/drive/file_change.h"
14 #include "chrome/browser/chromeos/drive/file_system/copy_operation.h" 15 #include "chrome/browser/chromeos/drive/file_system/copy_operation.h"
15 #include "chrome/browser/chromeos/drive/file_system/create_directory_operation.h " 16 #include "chrome/browser/chromeos/drive/file_system/create_directory_operation.h "
16 #include "chrome/browser/chromeos/drive/file_system/create_file_operation.h" 17 #include "chrome/browser/chromeos/drive/file_system/create_file_operation.h"
17 #include "chrome/browser/chromeos/drive/file_system/download_operation.h" 18 #include "chrome/browser/chromeos/drive/file_system/download_operation.h"
18 #include "chrome/browser/chromeos/drive/file_system/get_file_for_saving_operatio n.h" 19 #include "chrome/browser/chromeos/drive/file_system/get_file_for_saving_operatio n.h"
19 #include "chrome/browser/chromeos/drive/file_system/move_operation.h" 20 #include "chrome/browser/chromeos/drive/file_system/move_operation.h"
20 #include "chrome/browser/chromeos/drive/file_system/open_file_operation.h" 21 #include "chrome/browser/chromeos/drive/file_system/open_file_operation.h"
21 #include "chrome/browser/chromeos/drive/file_system/remove_operation.h" 22 #include "chrome/browser/chromeos/drive/file_system/remove_operation.h"
22 #include "chrome/browser/chromeos/drive/file_system/search_operation.h" 23 #include "chrome/browser/chromeos/drive/file_system/search_operation.h"
23 #include "chrome/browser/chromeos/drive/file_system/touch_operation.h" 24 #include "chrome/browser/chromeos/drive/file_system/touch_operation.h"
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 783
783 drive::internal::SearchMetadata(blocking_task_runner_, 784 drive::internal::SearchMetadata(blocking_task_runner_,
784 resource_metadata_, 785 resource_metadata_,
785 query, 786 query,
786 options, 787 options,
787 at_most_num_matches, 788 at_most_num_matches,
788 callback); 789 callback);
789 } 790 }
790 791
791 void FileSystem::OnDirectoryChangedByOperation( 792 void FileSystem::OnDirectoryChangedByOperation(
792 const base::FilePath& directory_path) { 793 const FileChange& changed_files) {
793 OnDirectoryChanged(directory_path); 794 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
795
796 OnDirectoryChanged(changed_files);
794 } 797 }
795 798
796 void FileSystem::OnEntryUpdatedByOperation(const std::string& local_id) { 799 void FileSystem::OnEntryUpdatedByOperation(const std::string& local_id) {
797 sync_client_->AddUpdateTask(ClientContext(USER_INITIATED), local_id); 800 sync_client_->AddUpdateTask(ClientContext(USER_INITIATED), local_id);
798 } 801 }
799 802
800 void FileSystem::OnDriveSyncError(file_system::DriveSyncErrorType type, 803 void FileSystem::OnDriveSyncError(file_system::DriveSyncErrorType type,
801 const std::string& local_id) { 804 const std::string& local_id) {
802 base::FilePath* file_path = new base::FilePath; 805 base::FilePath* file_path = new base::FilePath;
803 base::PostTaskAndReplyWithResult( 806 base::PostTaskAndReplyWithResult(
(...skipping 13 matching lines...) Expand all
817 file_system::DriveSyncErrorType type, 820 file_system::DriveSyncErrorType type,
818 const base::FilePath* file_path, 821 const base::FilePath* file_path,
819 FileError error) { 822 FileError error) {
820 if (error != FILE_ERROR_OK) 823 if (error != FILE_ERROR_OK)
821 return; 824 return;
822 FOR_EACH_OBSERVER(FileSystemObserver, 825 FOR_EACH_OBSERVER(FileSystemObserver,
823 observers_, 826 observers_,
824 OnDriveSyncError(type, *file_path)); 827 OnDriveSyncError(type, *file_path));
825 } 828 }
826 829
827 void FileSystem::OnDirectoryChanged(const base::FilePath& directory_path) { 830 void FileSystem::OnDirectoryReloaded(const base::FilePath& directory_path) {
828 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 831 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
829 832
830 FOR_EACH_OBSERVER(FileSystemObserver, observers_, 833 FOR_EACH_OBSERVER(
831 OnDirectoryChanged(directory_path)); 834 FileSystemObserver, observers_, OnDirectoryChanged(directory_path, NULL));
835 }
836
837 void FileSystem::OnDirectoryChanged(const FileChange& changed_files) {
838 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
839 typedef std::map<base::FilePath, FileChange> FileChangeMap;
840
841 FileChangeMap map;
842 const FileChange::Map& changed_file_map = changed_files.map();
843 for (FileChange::Map::const_iterator it = changed_file_map.begin();
844 it != changed_file_map.end();
845 it++) {
846 const base::FilePath& path = it->first;
847 map[path.DirName()].Update(path, it->second);
848 }
849
kinaba 2014/06/23 05:37:43 What about moving this dispatch-by-directory code
yoshiki 2014/06/24 02:02:22 Done.
850 for (FileChangeMap::const_iterator it = map.begin(); it != map.end(); it++) {
851 FOR_EACH_OBSERVER(FileSystemObserver,
852 observers_,
853 OnDirectoryChanged(it->first, &(it->second)));
854 }
832 } 855 }
833 856
834 void FileSystem::OnLoadFromServerComplete() { 857 void FileSystem::OnLoadFromServerComplete() {
835 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 858 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
836 859
837 sync_client_->StartCheckingExistingPinnedFiles(); 860 sync_client_->StartCheckingExistingPinnedFiles();
838 } 861 }
839 862
840 void FileSystem::OnInitialLoadComplete() { 863 void FileSystem::OnInitialLoadComplete() {
841 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 864 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 FROM_HERE, 997 FROM_HERE,
975 base::Bind(&GetPathFromResourceIdOnBlockingPool, 998 base::Bind(&GetPathFromResourceIdOnBlockingPool,
976 resource_metadata_, 999 resource_metadata_,
977 resource_id, 1000 resource_id,
978 file_path), 1001 file_path),
979 base::Bind(&GetPathFromResourceIdAfterGetPath, 1002 base::Bind(&GetPathFromResourceIdAfterGetPath,
980 base::Owned(file_path), 1003 base::Owned(file_path),
981 callback)); 1004 callback));
982 } 1005 }
983 } // namespace drive 1006 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698