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

Unified Diff: remoting/host/daemon_config_watcher.h

Issue 10855249: [Chromoting] The daemon process now starts the networking process and passes the host configuration… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback and rebased on top of https://chromiumcodereview.appspot.com/10829467/ Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: remoting/host/daemon_config_watcher.h
diff --git a/remoting/host/daemon_config_watcher.h b/remoting/host/daemon_config_watcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..7ac502830da0a1f84be47953aca1dc47bb9ac859
--- /dev/null
+++ b/remoting/host/daemon_config_watcher.h
@@ -0,0 +1,83 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef REMOTING_HOST_DAEMON_CONFIG_WATCHER_H_
+#define REMOTING_HOST_DAEMON_CONFIG_WATCHER_H_
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/file_path.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "base/timer.h"
+
+namespace base {
+class SingleThreadTaskRunner;
+class Thread;
+
+namespace files {
+class FilePathWatcher;
+} // namespace files
+} // namespace base
+
+namespace remoting {
+
+extern const char kHostConfigSwitchName[];
+extern const FilePath::CharType kDefaultHostConfigFile[];
+
+class DaemonConfigWatcher {
Wez 2012/08/24 22:20:38 I realise that we're only going to use this for re
alexeypa (please no reviews) 2012/08/27 23:16:41 Done. ConfigFileWatcher.
+ public:
+ class Delegate {
+ public:
+ virtual ~Delegate();
+
+ // Called once after starting watching the configuration file and every time
+ // the file changes.
+ virtual void OnConfigUpdated(const std::string& config) = 0;
+
+ // Called when the configuration file watcher encountered an error.
+ virtual void OnConfigWatcherError() = 0;
+ };
+
+ // Creates a configuration file watcher that lives at the |io_task_runner|
+ // thread but posts config file updates on on |main_task_runner|.
Wez 2012/08/24 22:20:38 nit: Clarify that this means |delegate| must be cr
alexeypa (please no reviews) 2012/08/27 23:16:41 It does not mean that. |delegate| can be created a
+ DaemonConfigWatcher(
+ scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
+ const base::WeakPtr<Delegate>& delegate);
+
+ virtual ~DaemonConfigWatcher();
+
+ // Starts watching |config_path|.
+ void Watch(const FilePath& config_path);
+
+ // Stops watching the configuration file.
+ void Stop(scoped_ptr<DaemonConfigWatcher> self);
Wez 2012/08/24 22:20:38 Why does the caller need to pass in a scoped_ptr t
alexeypa (please no reviews) 2012/08/27 23:16:41 It is needed to delete the object once the last ta
+
+ private:
+ // Called every time the host configuration file is updated.
+ void OnConfigUpdated(const FilePath& path, bool error);
+
+ // Reads the configuration file and passes it to the delegate.
+ void ReloadConfig();
+
+ FilePath config_path_;
+
+ scoped_ptr<base::DelayTimer<DaemonConfigWatcher> > config_updated_timer_;
+
+ // Monitors the host configuration file changes.
+ scoped_ptr<base::files::FilePathWatcher> config_watcher_;
+
+ base::WeakPtr<Delegate> delegate_;
+
+ scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
+ scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
+
+ DISALLOW_COPY_AND_ASSIGN(DaemonConfigWatcher);
+};
+
+} // namespace remoting
+
+#endif // REMOTING_HOST_DAEMON_CONFIG_WATCHER_H_

Powered by Google App Engine
This is Rietveld 408576698