| 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 <memory> |
| 7 #include <string> | 8 #include <string> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 11 #include "base/files/file_path_watcher.h" | 12 #include "base/files/file_path_watcher.h" |
| 12 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
| 17 #include "base/timer/timer.h" | 17 #include "base/timer/timer.h" |
| 18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 19 | 19 |
| 20 namespace remoting { | 20 namespace remoting { |
| 21 | 21 |
| 22 // The name of the command-line switch used to specify the host configuration | 22 // The name of the command-line switch used to specify the host configuration |
| 23 // file to use. | 23 // file to use. |
| 24 const char kHostConfigSwitchName[] = "host-config"; | 24 const char kHostConfigSwitchName[] = "host-config"; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 // Called to notify the delegate of updates/errors in the main thread. | 63 // Called to notify the delegate of updates/errors in the main thread. |
| 64 void NotifyUpdate(const std::string& config); | 64 void NotifyUpdate(const std::string& config); |
| 65 void NotifyError(); | 65 void NotifyError(); |
| 66 | 66 |
| 67 // Reads the configuration file and passes it to the delegate. | 67 // Reads the configuration file and passes it to the delegate. |
| 68 void ReloadConfig(); | 68 void ReloadConfig(); |
| 69 | 69 |
| 70 std::string config_; | 70 std::string config_; |
| 71 base::FilePath config_path_; | 71 base::FilePath config_path_; |
| 72 | 72 |
| 73 scoped_ptr<base::DelayTimer> config_updated_timer_; | 73 std::unique_ptr<base::DelayTimer> config_updated_timer_; |
| 74 | 74 |
| 75 // Number of times an attempt to read the configuration file failed. | 75 // Number of times an attempt to read the configuration file failed. |
| 76 int retries_; | 76 int retries_; |
| 77 | 77 |
| 78 // Monitors the host configuration file. | 78 // Monitors the host configuration file. |
| 79 scoped_ptr<base::FilePathWatcher> config_watcher_; | 79 std::unique_ptr<base::FilePathWatcher> config_watcher_; |
| 80 | 80 |
| 81 ConfigWatcher::Delegate* delegate_; | 81 ConfigWatcher::Delegate* delegate_; |
| 82 | 82 |
| 83 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 83 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| 84 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 84 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
| 85 | 85 |
| 86 base::WeakPtrFactory<ConfigFileWatcherImpl> weak_factory_; | 86 base::WeakPtrFactory<ConfigFileWatcherImpl> weak_factory_; |
| 87 | 87 |
| 88 DISALLOW_COPY_AND_ASSIGN(ConfigFileWatcherImpl); | 88 DISALLOW_COPY_AND_ASSIGN(ConfigFileWatcherImpl); |
| 89 }; | 89 }; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 if (config_ != config) { | 233 if (config_ != config) { |
| 234 config_ = config; | 234 config_ = config; |
| 235 main_task_runner_->PostTask( | 235 main_task_runner_->PostTask( |
| 236 FROM_HERE, | 236 FROM_HERE, |
| 237 base::Bind(&ConfigFileWatcherImpl::NotifyUpdate, | 237 base::Bind(&ConfigFileWatcherImpl::NotifyUpdate, |
| 238 weak_factory_.GetWeakPtr(), config_)); | 238 weak_factory_.GetWeakPtr(), config_)); |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 | 241 |
| 242 } // namespace remoting | 242 } // namespace remoting |
| OLD | NEW |