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

Unified Diff: chrome/browser/chromeos/extensions/file_browser_event_router.cc

Issue 10352004: gdata: Implement periodic file system update checks. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix compile error in mock_gdata_file_system.h Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/extensions/file_browser_event_router.cc
diff --git a/chrome/browser/chromeos/extensions/file_browser_event_router.cc b/chrome/browser/chromeos/extensions/file_browser_event_router.cc
index c3479feb361e067385b3f48596832237c6bd1297..ae6add89fb19dabc26a66e4263e847c0f290b788 100644
--- a/chrome/browser/chromeos/extensions/file_browser_event_router.cc
+++ b/chrome/browser/chromeos/extensions/file_browser_event_router.cc
@@ -166,6 +166,11 @@ bool FileBrowserEventRouter::AddFileWatch(
} else {
iter->second->AddExtension(extension_id);
}
+ if (is_remote_watch) {
+ gdata::GDataFileSystem* file_system = GetFileSystem();
+ if (file_system)
+ file_system->AddFileWatch(watch_path);
+ }
return true;
}
@@ -174,11 +179,13 @@ void FileBrowserEventRouter::RemoveFileWatch(
const std::string& extension_id) {
base::AutoLock lock(lock_);
FilePath watch_path = local_path;
+ bool is_remote_watch = false;
// Tweak watch path for remote sources - we need to drop leading /special
// directory from there in order to be able to pair these events with
// their change notifications.
if (gdata::util::GetSpecialRemoteRootPath().IsParent(watch_path)) {
watch_path = gdata::util::ExtractGDataPath(watch_path);
+ is_remote_watch = true;
}
WatcherMap::iterator iter = file_watchers_.find(watch_path);
if (iter == file_watchers_.end())
@@ -189,6 +196,11 @@ void FileBrowserEventRouter::RemoveFileWatch(
delete iter->second;
file_watchers_.erase(iter);
}
+ if (is_remote_watch) {
+ gdata::GDataFileSystem* file_system = GetFileSystem();
+ if (file_system)
+ file_system->RemoveFileWatch(watch_path);
+ }
}
void FileBrowserEventRouter::DiskChanged(
@@ -255,10 +267,7 @@ void FileBrowserEventRouter::MountCompleted(
if ((event_type == DiskMountManager::MOUNTING) !=
(error_code == chromeos::MOUNT_ERROR_NONE)) {
FilePath source_path(mount_info.source_path);
- gdata::GDataSystemService* system_service =
- gdata::GDataSystemServiceFactory::GetForProfile(profile_);
- gdata::GDataFileSystem* file_system =
- system_service ? system_service->file_system() : NULL;
+ gdata::GDataFileSystem* file_system = GetFileSystem();
if (file_system && file_system->IsUnderGDataCacheDirectory(source_path))
file_system->SetMountedState(source_path, false,
gdata::SetMountedStateCallback());
@@ -601,6 +610,12 @@ FileBrowserEventRouter::FileWatcherExtensions::GetVirtualPath() const {
return virtual_path_;
}
+gdata::GDataFileSystem* FileBrowserEventRouter::GetFileSystem() const {
+ gdata::GDataSystemService* system_service =
+ gdata::GDataSystemServiceFactory::GetForProfile(profile_);
+ return (system_service ? system_service->file_system() : NULL);
+}
+
bool FileBrowserEventRouter::FileWatcherExtensions::Watch
(const FilePath& path, FileWatcherDelegate* delegate) {
if (is_remote_file_system_)

Powered by Google App Engine
This is Rietveld 408576698