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

Side by Side Diff: remoting/host/linux/certificate_watcher.h

Issue 1838313002: Restart the host when the third party auth certificate changes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewed Feedback from sergeyu@ Created 4 years, 8 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
OLDNEW
(Empty)
1 // Copyright 2016 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_LINUX_CERTIFICATE_WATCHER_H_
6 #define REMOTING_HOST_LINUX_CERTIFICATE_WATCHER_H_
7
8 #include "base/files/file_path.h"
9 #include "base/files/file_path_watcher.h"
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/timer/timer.h"
14 #include "remoting/base/auto_thread_task_runner.h"
15 #include "remoting/host/host_status_monitor.h"
16 #include "remoting/host/host_status_observer.h"
17
18 namespace remoting {
19
20 // This class watches the NSS database and kills the host when a change of the
Sergey Ulanov 2016/03/31 22:36:16 s/NSS database/certificate database/
Yuwei 2016/04/01 23:41:03 Done.
21 // database is detected. The runner script will restart the host when the host
22 // is killed then the new host will capture any new changes of the database.
23 //
24 // Acceptable false positives will be caused by desktop sessions and other
25 // external programs.
26 //
27 // Implements HostStatusObserver to defer restart action when the host is
28 // connected to a client.
29 class CertificateWatcher : public remoting::HostStatusObserver {
30 public:
31 CertificateWatcher(base::WeakPtr<HostStatusMonitor> monitor,
32 const base::Closure& restart_action);
33
34 ~CertificateWatcher() override;
35
36 // Starts at current thread.
37 void Start();
38
39 // HostStatusObserver interface.
40
Sergey Ulanov 2016/03/31 22:36:16 removw this empty line.
Yuwei 2016/04/01 23:41:03 Done.
41 void OnClientConnected(const std::string& jid) override;
42 void OnClientDisconnected(const std::string& jid) override;
43
44 // Changes the |inhibit_restart_scheduled_| flag
45 void SetInhibit(bool inhibit);
46
47 // Used for tests. No change will be made if the watcher has already started
Sergey Ulanov 2016/03/31 22:36:15 use ForTests suffix for test-only methods please.
Yuwei 2016/04/01 23:41:03 Done.
48 void SetDelay(const base::TimeDelta& delay);
49 void SetWatchPath(const base::FilePath& watch_path);
50 void SetRestartDeferredAction(const base::Closure& restart_action);
51
52 private:
53 // Callback passed to |file_watcher_|.
54 void OnCertDirectoryChanged(const base::FilePath& path, bool error);
55
56 // Called by |restart_timer_| when it's time to reset the host.
57 // It will defer restart if |inhibit_restart_scheduled_| flag is set to true.
58 void OnTimer();
59
60 bool inhibit_mode_ = false;
Sergey Ulanov 2016/03/31 22:36:15 move this below. Normally the values passed to the
Yuwei 2016/04/01 23:41:03 Done.
61
62 // Reference to the monitor
63 base::WeakPtr<HostStatusMonitor> monitor_;
64
65 // Path of the NSS files/directories.
66 base::FilePath nss_watch_path_;
67
68 // The file watcher to watch changes inside the certificate folder.
69 scoped_ptr<base::FilePathWatcher> file_watcher_;
70
71 // The time to wait to restart when it is scheduled.
72 base::TimeDelta delay_;
73
74 // Timer to delay the restart action.
75 scoped_ptr<base::DelayTimer> restart_timer_;
76
77 // Called when a restart is scheduled.
78 base::Closure restart_action_;
Sergey Ulanov 2016/03/31 22:36:16 move this after monitor_.
Yuwei 2016/04/01 23:41:03 Done.
79
80 // Called when the certificate is updated during inhibit mode.
81 // This is just for notification and it shouldn't restart the host.
82 base::Closure restart_deferred_action_;
83
84 DISALLOW_COPY_AND_ASSIGN(CertificateWatcher);
85 };
86
87 } // namespace remoting
88
89 #endif // REMOTING_HOST_LINUX_CERTIFICATE_WATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698