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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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/file_path.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/timer.h"
15
16 namespace base {
17 class SingleThreadTaskRunner;
18 class Thread;
19
20 namespace files {
21 class FilePathWatcher;
22 } // namespace files
23 } // namespace base
24
25 namespace remoting {
26
27 extern const char kHostConfigSwitchName[];
28 extern const FilePath::CharType kDefaultHostConfigFile[];
29
30 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.
31 public:
32 class Delegate {
33 public:
34 virtual ~Delegate();
35
36 // Called once after starting watching the configuration file and every time
37 // the file changes.
38 virtual void OnConfigUpdated(const std::string& config) = 0;
39
40 // Called when the configuration file watcher encountered an error.
41 virtual void OnConfigWatcherError() = 0;
42 };
43
44 // Creates a configuration file watcher that lives at the |io_task_runner|
45 // 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
46 DaemonConfigWatcher(
47 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
48 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
49 const base::WeakPtr<Delegate>& delegate);
50
51 virtual ~DaemonConfigWatcher();
52
53 // Starts watching |config_path|.
54 void Watch(const FilePath& config_path);
55
56 // Stops watching the configuration file.
57 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
58
59 private:
60 // Called every time the host configuration file is updated.
61 void OnConfigUpdated(const FilePath& path, bool error);
62
63 // Reads the configuration file and passes it to the delegate.
64 void ReloadConfig();
65
66 FilePath config_path_;
67
68 scoped_ptr<base::DelayTimer<DaemonConfigWatcher> > config_updated_timer_;
69
70 // Monitors the host configuration file changes.
71 scoped_ptr<base::files::FilePathWatcher> config_watcher_;
72
73 base::WeakPtr<Delegate> delegate_;
74
75 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
76 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
77
78 DISALLOW_COPY_AND_ASSIGN(DaemonConfigWatcher);
79 };
80
81 } // namespace remoting
82
83 #endif // REMOTING_HOST_DAEMON_CONFIG_WATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698