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

Side by Side 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: Use base timer class and other miscellaneous fixes Created 8 years, 7 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
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/extensions/file_browser_event_router.h" 5 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 extension_id, 159 extension_id,
160 is_remote_watch)); 160 is_remote_watch));
161 161
162 if (watch->Watch(watch_path, delegate_.get())) 162 if (watch->Watch(watch_path, delegate_.get()))
163 file_watchers_[watch_path] = watch.release(); 163 file_watchers_[watch_path] = watch.release();
164 else 164 else
165 return false; 165 return false;
166 } else { 166 } else {
167 iter->second->AddExtension(extension_id); 167 iter->second->AddExtension(extension_id);
168 } 168 }
169 if (is_remote_watch) {
170 gdata::GDataFileSystem* file_system = GetFileSystem();
satorux1 2012/05/03 19:41:34 Per your comment, we are not on UI thread here? If
hshi 2012/05/03 21:17:49 Done.
171 if (file_system)
172 file_system->RequestStartUpdates();
satorux1 2012/05/03 19:44:54 I have another idea. Wouldn't it be simpler just
satorux1 2012/05/03 19:47:41 I was assuming that FileBrowserEventRouter is crea
zel 2012/05/03 19:54:30 Lifetime of FileBrowserEventRouter is RefcountedPr
hshi 2012/05/03 21:17:49 I have moved this logic out to a separate task on
173 }
169 return true; 174 return true;
170 } 175 }
171 176
172 void FileBrowserEventRouter::RemoveFileWatch( 177 void FileBrowserEventRouter::RemoveFileWatch(
173 const FilePath& local_path, 178 const FilePath& local_path,
174 const std::string& extension_id) { 179 const std::string& extension_id) {
175 base::AutoLock lock(lock_); 180 base::AutoLock lock(lock_);
176 FilePath watch_path = local_path; 181 FilePath watch_path = local_path;
177 // Tweak watch path for remote sources - we need to drop leading /special 182 // Tweak watch path for remote sources - we need to drop leading /special
178 // directory from there in order to be able to pair these events with 183 // directory from there in order to be able to pair these events with
179 // their change notifications. 184 // their change notifications.
180 if (gdata::util::GetSpecialRemoteRootPath().IsParent(watch_path)) { 185 if (gdata::util::GetSpecialRemoteRootPath().IsParent(watch_path)) {
181 watch_path = gdata::util::ExtractGDataPath(watch_path); 186 watch_path = gdata::util::ExtractGDataPath(watch_path);
187 gdata::GDataFileSystem* file_system = GetFileSystem();
188 if (file_system)
189 file_system->RequestStopUpdates();
182 } 190 }
183 WatcherMap::iterator iter = file_watchers_.find(watch_path); 191 WatcherMap::iterator iter = file_watchers_.find(watch_path);
184 if (iter == file_watchers_.end()) 192 if (iter == file_watchers_.end())
185 return; 193 return;
186 // Remove the renderer process for this watch. 194 // Remove the renderer process for this watch.
187 iter->second->RemoveExtension(extension_id); 195 iter->second->RemoveExtension(extension_id);
188 if (iter->second->GetRefCount() == 0) { 196 if (iter->second->GetRefCount() == 0) {
189 delete iter->second; 197 delete iter->second;
190 file_watchers_.erase(iter); 198 file_watchers_.erase(iter);
191 } 199 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 notifications_->ManageNotificationsOnMountCompleted( 256 notifications_->ManageNotificationsOnMountCompleted(
249 disk->system_path_prefix(), disk->drive_label(), disk->is_parent(), 257 disk->system_path_prefix(), disk->drive_label(), disk->is_parent(),
250 error_code == chromeos::MOUNT_ERROR_NONE, 258 error_code == chromeos::MOUNT_ERROR_NONE,
251 error_code == chromeos::MOUNT_ERROR_UNSUPORTED_FILESYSTEM); 259 error_code == chromeos::MOUNT_ERROR_UNSUPORTED_FILESYSTEM);
252 } else if (mount_info.mount_type == chromeos::MOUNT_TYPE_ARCHIVE) { 260 } else if (mount_info.mount_type == chromeos::MOUNT_TYPE_ARCHIVE) {
253 // Clear the "mounted" state for archive files in gdata cache 261 // Clear the "mounted" state for archive files in gdata cache
254 // when mounting failed or unmounting succeeded. 262 // when mounting failed or unmounting succeeded.
255 if ((event_type == DiskMountManager::MOUNTING) != 263 if ((event_type == DiskMountManager::MOUNTING) !=
256 (error_code == chromeos::MOUNT_ERROR_NONE)) { 264 (error_code == chromeos::MOUNT_ERROR_NONE)) {
257 FilePath source_path(mount_info.source_path); 265 FilePath source_path(mount_info.source_path);
258 gdata::GDataSystemService* system_service = 266 gdata::GDataFileSystem* file_system = GetFileSystem();
259 gdata::GDataSystemServiceFactory::GetForProfile(profile_);
260 gdata::GDataFileSystem* file_system =
261 system_service ? system_service->file_system() : NULL;
262 if (file_system && file_system->IsUnderGDataCacheDirectory(source_path)) 267 if (file_system && file_system->IsUnderGDataCacheDirectory(source_path))
263 file_system->SetMountedState(source_path, false, 268 file_system->SetMountedState(source_path, false,
264 gdata::SetMountedStateCallback()); 269 gdata::SetMountedStateCallback());
265 } 270 }
266 } 271 }
267 } 272 }
268 273
269 void FileBrowserEventRouter::OnProgressUpdate( 274 void FileBrowserEventRouter::OnProgressUpdate(
270 const std::vector<gdata::GDataOperationRegistry::ProgressStatus>& list) { 275 const std::vector<gdata::GDataOperationRegistry::ProgressStatus>& list) {
271 scoped_ptr<ListValue> event_list( 276 scoped_ptr<ListValue> event_list(
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 unsigned int 599 unsigned int
595 FileBrowserEventRouter::FileWatcherExtensions::GetRefCount() const { 600 FileBrowserEventRouter::FileWatcherExtensions::GetRefCount() const {
596 return ref_count_; 601 return ref_count_;
597 } 602 }
598 603
599 const FilePath& 604 const FilePath&
600 FileBrowserEventRouter::FileWatcherExtensions::GetVirtualPath() const { 605 FileBrowserEventRouter::FileWatcherExtensions::GetVirtualPath() const {
601 return virtual_path_; 606 return virtual_path_;
602 } 607 }
603 608
609 gdata::GDataFileSystem* FileBrowserEventRouter::GetFileSystem() const {
610 gdata::GDataSystemService* system_service =
611 gdata::GDataSystemServiceFactory::GetForProfile(profile_);
612 return (system_service ? system_service->file_system() : NULL);
613 }
614
604 bool FileBrowserEventRouter::FileWatcherExtensions::Watch 615 bool FileBrowserEventRouter::FileWatcherExtensions::Watch
605 (const FilePath& path, FileWatcherDelegate* delegate) { 616 (const FilePath& path, FileWatcherDelegate* delegate) {
606 if (is_remote_file_system_) 617 if (is_remote_file_system_)
607 return true; 618 return true;
608 619
609 return file_watcher_->Watch(path, delegate); 620 return file_watcher_->Watch(path, delegate);
610 } 621 }
611 622
612 // static 623 // static
613 scoped_refptr<FileBrowserEventRouter> 624 scoped_refptr<FileBrowserEventRouter>
(...skipping 22 matching lines...) Expand all
636 return scoped_refptr<RefcountedProfileKeyedService>( 647 return scoped_refptr<RefcountedProfileKeyedService>(
637 new FileBrowserEventRouter(profile)); 648 new FileBrowserEventRouter(profile));
638 } 649 }
639 650
640 bool FileBrowserEventRouterFactory::ServiceHasOwnInstanceInIncognito() { 651 bool FileBrowserEventRouterFactory::ServiceHasOwnInstanceInIncognito() {
641 // Explicitly and always allow this router in guest login mode. see 652 // Explicitly and always allow this router in guest login mode. see
642 // chrome/browser/profiles/profile_keyed_base_factory.h comment 653 // chrome/browser/profiles/profile_keyed_base_factory.h comment
643 // for the details. 654 // for the details.
644 return true; 655 return true;
645 } 656 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698