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

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/event_router.cc

Issue 1118943005: [chrome/browser/chromeos/extensions] Deprecation of loop proxy usage with TTRH (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Review nit Created 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_manager/event_router.h" 5 #include "chrome/browser/chromeos/extensions/file_manager/event_router.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/message_loop/message_loop.h"
11 #include "base/prefs/pref_change_registrar.h" 10 #include "base/prefs/pref_change_registrar.h"
12 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
13 #include "base/stl_util.h" 12 #include "base/stl_util.h"
14 #include "base/thread_task_runner_handle.h" 13 #include "base/thread_task_runner_handle.h"
15 #include "base/threading/sequenced_worker_pool.h" 14 #include "base/threading/sequenced_worker_pool.h"
16 #include "base/values.h" 15 #include "base/values.h"
17 #include "chrome/browser/app_mode/app_mode_utils.h" 16 #include "chrome/browser/app_mode/app_mode_utils.h"
18 #include "chrome/browser/chromeos/drive/drive_integration_service.h" 17 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
19 #include "chrome/browser/chromeos/drive/file_change.h" 18 #include "chrome/browser/chromeos/drive/file_change.h"
20 #include "chrome/browser/chromeos/drive/file_system_interface.h" 19 #include "chrome/browser/chromeos/drive/file_system_interface.h"
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 if (is_on_drive) 456 if (is_on_drive)
458 watch_path = drive::util::ExtractDrivePath(watch_path); 457 watch_path = drive::util::ExtractDrivePath(watch_path);
459 458
460 WatcherMap::iterator iter = file_watchers_.find(watch_path); 459 WatcherMap::iterator iter = file_watchers_.find(watch_path);
461 if (iter == file_watchers_.end()) { 460 if (iter == file_watchers_.end()) {
462 scoped_ptr<FileWatcher> watcher(new FileWatcher(virtual_path)); 461 scoped_ptr<FileWatcher> watcher(new FileWatcher(virtual_path));
463 watcher->AddExtension(extension_id); 462 watcher->AddExtension(extension_id);
464 463
465 if (is_on_drive) { 464 if (is_on_drive) {
466 // For Drive, file watching is done via OnDirectoryChanged(). 465 // For Drive, file watching is done via OnDirectoryChanged().
467 base::MessageLoopProxy::current()->PostTask(FROM_HERE, 466 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
468 base::Bind(callback, true)); 467 base::Bind(callback, true));
469 } else { 468 } else {
470 // For local files, start watching using FileWatcher. 469 // For local files, start watching using FileWatcher.
471 watcher->WatchLocalFile( 470 watcher->WatchLocalFile(
472 watch_path, 471 watch_path,
473 base::Bind(&EventRouter::HandleFileWatchNotification, 472 base::Bind(&EventRouter::HandleFileWatchNotification,
474 weak_factory_.GetWeakPtr(), 473 weak_factory_.GetWeakPtr(),
475 static_cast<drive::FileChange*>(NULL)), 474 static_cast<drive::FileChange*>(NULL)),
476 callback); 475 callback);
477 } 476 }
478 477
479 file_watchers_[watch_path] = watcher.release(); 478 file_watchers_[watch_path] = watcher.release();
480 } else { 479 } else {
481 iter->second->AddExtension(extension_id); 480 iter->second->AddExtension(extension_id);
482 base::MessageLoopProxy::current()->PostTask(FROM_HERE, 481 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
483 base::Bind(callback, true)); 482 base::Bind(callback, true));
484 } 483 }
485 } 484 }
486 485
487 void EventRouter::RemoveFileWatch(const base::FilePath& local_path, 486 void EventRouter::RemoveFileWatch(const base::FilePath& local_path,
488 const std::string& extension_id) { 487 const std::string& extension_id) {
489 DCHECK_CURRENTLY_ON(BrowserThread::UI); 488 DCHECK_CURRENTLY_ON(BrowserThread::UI);
490 489
491 base::FilePath watch_path = local_path; 490 base::FilePath watch_path = local_path;
492 // Tweak watch path for remote sources - we need to drop leading /special 491 // Tweak watch path for remote sources - we need to drop leading /special
493 // directory from there in order to be able to pair these events with 492 // directory from there in order to be able to pair these events with
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 void EventRouter::SetDispatchDirectoryChangeEventImplForTesting( 909 void EventRouter::SetDispatchDirectoryChangeEventImplForTesting(
911 const DispatchDirectoryChangeEventImplCallback& callback) { 910 const DispatchDirectoryChangeEventImplCallback& callback) {
912 dispatch_directory_change_event_impl_ = callback; 911 dispatch_directory_change_event_impl_ = callback;
913 } 912 }
914 913
915 base::WeakPtr<EventRouter> EventRouter::GetWeakPtr() { 914 base::WeakPtr<EventRouter> EventRouter::GetWeakPtr() {
916 return weak_factory_.GetWeakPtr(); 915 return weak_factory_.GetWeakPtr();
917 } 916 }
918 917
919 } // namespace file_manager 918 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698