| 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 #ifndef REMOTING_HOST_DAEMON_CONFIG_WATCHER_H_ | 5 #ifndef REMOTING_HOST_DAEMON_CONFIG_WATCHER_H_ |
| 6 #define REMOTING_HOST_DAEMON_CONFIG_WATCHER_H_ | 6 #define REMOTING_HOST_DAEMON_CONFIG_WATCHER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 | 12 |
| 13 namespace base { | 13 namespace base { |
| 14 class SingleThreadTaskRunner; | 14 class SingleThreadTaskRunner; |
| 15 } // namespace base | 15 } // namespace base |
| 16 | 16 |
| 17 namespace remoting { | 17 namespace remoting { |
| 18 | 18 |
| 19 extern const char kHostConfigSwitchName[]; | 19 extern const char kHostConfigSwitchName[]; |
| 20 extern const FilePath::CharType kDefaultHostConfigFile[]; | 20 extern const base::FilePath::CharType kDefaultHostConfigFile[]; |
| 21 | 21 |
| 22 class ConfigFileWatcherImpl; | 22 class ConfigFileWatcherImpl; |
| 23 | 23 |
| 24 class ConfigFileWatcher { | 24 class ConfigFileWatcher { |
| 25 public: | 25 public: |
| 26 class Delegate { | 26 class Delegate { |
| 27 public: | 27 public: |
| 28 virtual ~Delegate(); | 28 virtual ~Delegate(); |
| 29 | 29 |
| 30 // Called once after starting watching the configuration file and every time | 30 // Called once after starting watching the configuration file and every time |
| 31 // the file changes. | 31 // the file changes. |
| 32 virtual void OnConfigUpdated(const std::string& serialized_config) = 0; | 32 virtual void OnConfigUpdated(const std::string& serialized_config) = 0; |
| 33 | 33 |
| 34 // Called when the configuration file watcher encountered an error. | 34 // Called when the configuration file watcher encountered an error. |
| 35 virtual void OnConfigWatcherError() = 0; | 35 virtual void OnConfigWatcherError() = 0; |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 // Creates a configuration file watcher that lives at the |io_task_runner| | 38 // Creates a configuration file watcher that lives at the |io_task_runner| |
| 39 // thread but posts config file updates on on |main_task_runner|. | 39 // thread but posts config file updates on on |main_task_runner|. |
| 40 ConfigFileWatcher( | 40 ConfigFileWatcher( |
| 41 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 41 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 42 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, | 42 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
| 43 Delegate* delegate); | 43 Delegate* delegate); |
| 44 virtual ~ConfigFileWatcher(); | 44 virtual ~ConfigFileWatcher(); |
| 45 | 45 |
| 46 // Starts watching |config_path|. | 46 // Starts watching |config_path|. |
| 47 void Watch(const FilePath& config_path); | 47 void Watch(const base::FilePath& config_path); |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 scoped_refptr<ConfigFileWatcherImpl> impl_; | 50 scoped_refptr<ConfigFileWatcherImpl> impl_; |
| 51 | 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(ConfigFileWatcher); | 52 DISALLOW_COPY_AND_ASSIGN(ConfigFileWatcher); |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 } // namespace remoting | 55 } // namespace remoting |
| 56 | 56 |
| 57 #endif // REMOTING_HOST_DAEMON_CONFIG_WATCHER_H_ | 57 #endif // REMOTING_HOST_DAEMON_CONFIG_WATCHER_H_ |
| OLD | NEW |