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