summaryrefslogtreecommitdiffstats
path: root/remoting/host
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-13 01:05:14 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-13 01:05:14 +0000
commit4042351108ffdc7f845755e0530a4b902a8a9f8c (patch)
tree4f1e9f5933de447146427a6392e6741ea7a9694d /remoting/host
parentaa4e993420e2b0f1d8b14b2c3894d1336f47082b (diff)
downloadchromium_src-4042351108ffdc7f845755e0530a4b902a8a9f8c.zip
chromium_src-4042351108ffdc7f845755e0530a4b902a8a9f8c.tar.gz
chromium_src-4042351108ffdc7f845755e0530a4b902a8a9f8c.tar.bz2
remoting: Switch PolicyWatcherLinux to use the callback interface of FilePathWatcher.
BUG=130980 R=simonmorris@chromium.org Review URL: https://codereview.chromium.org/11359157 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167274 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host')
-rw-r--r--remoting/host/policy_hack/policy_watcher_linux.cc48
1 files changed, 9 insertions, 39 deletions
diff --git a/remoting/host/policy_hack/policy_watcher_linux.cc b/remoting/host/policy_hack/policy_watcher_linux.cc
index 99de8b0..09c1623 100644
--- a/remoting/host/policy_hack/policy_watcher_linux.cc
+++ b/remoting/host/policy_hack/policy_watcher_linux.cc
@@ -69,8 +69,9 @@ class PolicyWatcherLinux : public PolicyWatcher {
if (!config_dir_.empty() &&
!watcher_->Watch(
config_dir_,
- new FilePathWatcherDelegate(weak_factory_.GetWeakPtr()))) {
- OnFilePathError(config_dir_);
+ base::Bind(&PolicyWatcherLinux::OnFilePathChanged,
+ weak_factory_.GetWeakPtr()))) {
+ OnFilePathChanged(config_dir_, true);
}
// There might have been changes to the directory in the time between
@@ -87,47 +88,16 @@ class PolicyWatcherLinux : public PolicyWatcher {
watcher_.reset();
}
- // Called by FilePathWatcherDelegate.
- virtual void OnFilePathError(const FilePath& path) {
- LOG(ERROR) << "PolicyWatcherLinux on " << path.value()
- << " failed.";
- }
-
- // Called by FilePathWatcherDelegate.
- virtual void OnFilePathChanged(const FilePath& path) {
+ private:
+ void OnFilePathChanged(const FilePath& path, bool error) {
DCHECK(OnPolicyWatcherThread());
- Reload();
+ if (!error)
+ Reload();
+ else
+ LOG(ERROR) << "PolicyWatcherLinux on " << path.value() << " failed.";
}
- private:
- // Needed to avoid refcounting PolicyWatcherLinux.
- class FilePathWatcherDelegate :
- public base::files::FilePathWatcher::Delegate {
- public:
- FilePathWatcherDelegate(base::WeakPtr<PolicyWatcherLinux> policy_watcher)
- : policy_watcher_(policy_watcher) {
- }
-
- virtual void OnFilePathError(const FilePath& path) {
- if (policy_watcher_) {
- policy_watcher_->OnFilePathError(path);
- }
- }
-
- virtual void OnFilePathChanged(const FilePath& path) {
- if (policy_watcher_) {
- policy_watcher_->OnFilePathChanged(path);
- }
- }
-
- protected:
- virtual ~FilePathWatcherDelegate() {}
-
- private:
- base::WeakPtr<PolicyWatcherLinux> policy_watcher_;
- };
-
base::Time GetLastModification() {
DCHECK(OnPolicyWatcherThread());
base::Time last_modification = base::Time();