OLD | NEW |
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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 // If the writer moves the new configuration file into place atomically, | 173 // If the writer moves the new configuration file into place atomically, |
174 // this delay may not be necessary. | 174 // this delay may not be necessary. |
175 if (!error && config_path_ == path) | 175 if (!error && config_path_ == path) |
176 config_updated_timer_->Reset(); | 176 config_updated_timer_->Reset(); |
177 } | 177 } |
178 | 178 |
179 void ConfigFileWatcherImpl::ReloadConfig() { | 179 void ConfigFileWatcherImpl::ReloadConfig() { |
180 DCHECK(io_task_runner_->BelongsToCurrentThread()); | 180 DCHECK(io_task_runner_->BelongsToCurrentThread()); |
181 | 181 |
182 std::string config; | 182 std::string config; |
183 if (!file_util::ReadFileToString(config_path_, &config)) { | 183 if (!base::ReadFileToString(config_path_, &config)) { |
184 #if defined(OS_WIN) | 184 #if defined(OS_WIN) |
185 // EACCESS may indicate a locking or sharing violation. Retry a few times | 185 // EACCESS may indicate a locking or sharing violation. Retry a few times |
186 // before reporting an error. | 186 // before reporting an error. |
187 if (errno == EACCES && retries_ < kMaxRetries) { | 187 if (errno == EACCES && retries_ < kMaxRetries) { |
188 PLOG(WARNING) << "Failed to read '" << config_path_.value() << "'"; | 188 PLOG(WARNING) << "Failed to read '" << config_path_.value() << "'"; |
189 | 189 |
190 retries_ += 1; | 190 retries_ += 1; |
191 config_updated_timer_->Reset(); | 191 config_updated_timer_->Reset(); |
192 return; | 192 return; |
193 } | 193 } |
(...skipping 13 matching lines...) Expand all Loading... |
207 if (config_ != config) { | 207 if (config_ != config) { |
208 config_ = config; | 208 config_ = config; |
209 main_task_runner_->PostTask( | 209 main_task_runner_->PostTask( |
210 FROM_HERE, | 210 FROM_HERE, |
211 base::Bind(&ConfigFileWatcher::Delegate::OnConfigUpdated, delegate_, | 211 base::Bind(&ConfigFileWatcher::Delegate::OnConfigUpdated, delegate_, |
212 config_)); | 212 config_)); |
213 } | 213 } |
214 } | 214 } |
215 | 215 |
216 } // namespace remoting | 216 } // namespace remoting |
OLD | NEW |