| 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 <set> | 7 #include <set> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 | 842 |
| 843 DCHECK(!update_timer_.IsRunning()); | 843 DCHECK(!update_timer_.IsRunning()); |
| 844 update_timer_.Start(FROM_HERE, | 844 update_timer_.Start(FROM_HERE, |
| 845 base::TimeDelta::FromSeconds( | 845 base::TimeDelta::FromSeconds( |
| 846 kGDataUpdateCheckIntervalInSec), | 846 kGDataUpdateCheckIntervalInSec), |
| 847 base::Bind(&GDataFileSystem::CheckForUpdates, | 847 base::Bind(&GDataFileSystem::CheckForUpdates, |
| 848 ui_weak_ptr_)); | 848 ui_weak_ptr_)); |
| 849 } | 849 } |
| 850 | 850 |
| 851 void GDataFileSystem::StopUpdates() { | 851 void GDataFileSystem::StopUpdates() { |
| 852 // If unmount request comes from filesystem side, this method may be called |
| 853 // twice. First is just after unmounting on filesystem, second is after |
| 854 // unmounting on filemanager on JS. In other words, if this is called from |
| 855 // GDataSystemService::RemoveDriveMountPoint(), this will be called again from |
| 856 // FileBrowserEventRouter::HandleRemoteUpdateRequestOnUIThread(). |
| 857 // We choose to stopping updates asynchronous without waiting for filemanager, |
| 858 // rather than waiting for completion of unmounting on filemanager. |
| 852 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 859 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 853 DCHECK(update_timer_.IsRunning()); | 860 if (update_timer_.IsRunning()) |
| 854 update_timer_.Stop(); | 861 update_timer_.Stop(); |
| 855 } | 862 } |
| 856 | 863 |
| 857 void GDataFileSystem::GetEntryInfoByResourceId( | 864 void GDataFileSystem::GetEntryInfoByResourceId( |
| 858 const std::string& resource_id, | 865 const std::string& resource_id, |
| 859 const GetEntryInfoWithFilePathCallback& callback) { | 866 const GetEntryInfoWithFilePathCallback& callback) { |
| 860 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || | 867 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || |
| 861 BrowserThread::CurrentlyOn(BrowserThread::IO)); | 868 BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 862 RunTaskOnUIThread( | 869 RunTaskOnUIThread( |
| 863 base::Bind(&GDataFileSystem::GetEntryInfoByResourceIdOnUIThread, | 870 base::Bind(&GDataFileSystem::GetEntryInfoByResourceIdOnUIThread, |
| 864 ui_weak_ptr_, | 871 ui_weak_ptr_, |
| (...skipping 2510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3375 GDataEntry* existing_entry) { | 3382 GDataEntry* existing_entry) { |
| 3376 if (existing_entry && | 3383 if (existing_entry && |
| 3377 // This should always match, but just in case. | 3384 // This should always match, but just in case. |
| 3378 existing_entry->parent() == parent_dir) { | 3385 existing_entry->parent() == parent_dir) { |
| 3379 parent_dir->RemoveEntry(existing_entry); | 3386 parent_dir->RemoveEntry(existing_entry); |
| 3380 } else { | 3387 } else { |
| 3381 LOG(ERROR) << "Entry for the existing file not found: " << resource_id; | 3388 LOG(ERROR) << "Entry for the existing file not found: " << resource_id; |
| 3382 } | 3389 } |
| 3383 } | 3390 } |
| 3384 | 3391 |
| 3392 void GDataFileSystem::NotifyFileSystemMounted() { |
| 3393 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 3394 |
| 3395 DVLOG(1) << "File System is mounted"; |
| 3396 // Notify the observers that the file system is mounted. |
| 3397 FOR_EACH_OBSERVER(GDataFileSystemInterface::Observer, observers_, |
| 3398 OnFileSystemMounted()); |
| 3399 } |
| 3400 |
| 3401 void GDataFileSystem::NotifyFileSystemToBeUnmounted() { |
| 3402 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 3403 |
| 3404 DVLOG(1) << "File System is to be unmounted"; |
| 3405 // Notify the observers that the file system is being unmounted. |
| 3406 FOR_EACH_OBSERVER(GDataFileSystemInterface::Observer, observers_, |
| 3407 OnFileSystemBeingUnmounted()); |
| 3408 } |
| 3409 |
| 3385 void GDataFileSystem::RunAndNotifyInitialLoadFinished( | 3410 void GDataFileSystem::RunAndNotifyInitialLoadFinished( |
| 3386 const FindEntryCallback& callback, | 3411 const FindEntryCallback& callback, |
| 3387 GDataFileError error, | 3412 GDataFileError error, |
| 3388 GDataEntry* entry) { | 3413 GDataEntry* entry) { |
| 3389 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 3414 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 3390 | 3415 |
| 3391 DVLOG(1) << "Initial load finished"; | 3416 DVLOG(1) << "Initial load finished"; |
| 3392 if (!callback.is_null()) | 3417 if (!callback.is_null()) |
| 3393 callback.Run(error, entry); | 3418 callback.Run(error, entry); |
| 3394 | 3419 |
| (...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4047 } | 4072 } |
| 4048 | 4073 |
| 4049 PlatformFileInfoProto entry_file_info; | 4074 PlatformFileInfoProto entry_file_info; |
| 4050 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); | 4075 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); |
| 4051 *entry_proto->mutable_file_info() = entry_file_info; | 4076 *entry_proto->mutable_file_info() = entry_file_info; |
| 4052 if (!callback.is_null()) | 4077 if (!callback.is_null()) |
| 4053 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); | 4078 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); |
| 4054 } | 4079 } |
| 4055 | 4080 |
| 4056 } // namespace gdata | 4081 } // namespace gdata |
| OLD | NEW |