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

Side by Side Diff: remoting/host/config_file_watcher.cc

Issue 1355063004: Template methods on Timer classes instead of the classes themselves. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: timer: fixcaller Created 5 years, 2 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
« no previous file with comments | « remoting/host/clipboard_mac.mm ('k') | remoting/host/continue_window.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "remoting/host/config_file_watcher.h" 5 #include "remoting/host/config_file_watcher.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 // Called to notify the delegate of updates/errors in the main thread. 61 // Called to notify the delegate of updates/errors in the main thread.
62 void NotifyUpdate(const std::string& config); 62 void NotifyUpdate(const std::string& config);
63 void NotifyError(); 63 void NotifyError();
64 64
65 // Reads the configuration file and passes it to the delegate. 65 // Reads the configuration file and passes it to the delegate.
66 void ReloadConfig(); 66 void ReloadConfig();
67 67
68 std::string config_; 68 std::string config_;
69 base::FilePath config_path_; 69 base::FilePath config_path_;
70 70
71 scoped_ptr<base::DelayTimer<ConfigFileWatcherImpl> > config_updated_timer_; 71 scoped_ptr<base::DelayTimer> config_updated_timer_;
72 72
73 // Number of times an attempt to read the configuration file failed. 73 // Number of times an attempt to read the configuration file failed.
74 int retries_; 74 int retries_;
75 75
76 // Monitors the host configuration file. 76 // Monitors the host configuration file.
77 scoped_ptr<base::FilePathWatcher> config_watcher_; 77 scoped_ptr<base::FilePathWatcher> config_watcher_;
78 78
79 ConfigWatcher::Delegate* delegate_; 79 ConfigWatcher::Delegate* delegate_;
80 80
81 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; 81 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 base::Bind(&ConfigFileWatcherImpl::WatchOnIoThread, this)); 127 base::Bind(&ConfigFileWatcherImpl::WatchOnIoThread, this));
128 } 128 }
129 129
130 void ConfigFileWatcherImpl::WatchOnIoThread() { 130 void ConfigFileWatcherImpl::WatchOnIoThread() {
131 DCHECK(io_task_runner_->BelongsToCurrentThread()); 131 DCHECK(io_task_runner_->BelongsToCurrentThread());
132 DCHECK(!config_updated_timer_); 132 DCHECK(!config_updated_timer_);
133 DCHECK(!config_watcher_); 133 DCHECK(!config_watcher_);
134 134
135 // Create the timer that will be used for delayed-reading the configuration 135 // Create the timer that will be used for delayed-reading the configuration
136 // file. 136 // file.
137 config_updated_timer_.reset(new base::DelayTimer<ConfigFileWatcherImpl>( 137 config_updated_timer_.reset(
138 FROM_HERE, base::TimeDelta::FromSeconds(2), this, 138 new base::DelayTimer(FROM_HERE, base::TimeDelta::FromSeconds(2), this,
139 &ConfigFileWatcherImpl::ReloadConfig)); 139 &ConfigFileWatcherImpl::ReloadConfig));
140 140
141 // Start watching the configuration file. 141 // Start watching the configuration file.
142 config_watcher_.reset(new base::FilePathWatcher()); 142 config_watcher_.reset(new base::FilePathWatcher());
143 if (!config_watcher_->Watch( 143 if (!config_watcher_->Watch(
144 config_path_, false, 144 config_path_, false,
145 base::Bind(&ConfigFileWatcherImpl::OnConfigUpdated, this))) { 145 base::Bind(&ConfigFileWatcherImpl::OnConfigUpdated, this))) {
146 PLOG(ERROR) << "Couldn't watch file '" << config_path_.value() << "'"; 146 PLOG(ERROR) << "Couldn't watch file '" << config_path_.value() << "'";
147 main_task_runner_->PostTask( 147 main_task_runner_->PostTask(
148 FROM_HERE, 148 FROM_HERE,
149 base::Bind(&ConfigFileWatcherImpl::NotifyError, 149 base::Bind(&ConfigFileWatcherImpl::NotifyError,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 if (config_ != config) { 231 if (config_ != config) {
232 config_ = config; 232 config_ = config;
233 main_task_runner_->PostTask( 233 main_task_runner_->PostTask(
234 FROM_HERE, 234 FROM_HERE,
235 base::Bind(&ConfigFileWatcherImpl::NotifyUpdate, 235 base::Bind(&ConfigFileWatcherImpl::NotifyUpdate,
236 weak_factory_.GetWeakPtr(), config_)); 236 weak_factory_.GetWeakPtr(), config_));
237 } 237 }
238 } 238 }
239 239
240 } // namespace remoting 240 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/clipboard_mac.mm ('k') | remoting/host/continue_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698