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

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

Issue 1977963002: [remoting host] Only watch for material changes to NSS DB files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 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
« no previous file with comments | « no previous file | remoting/host/linux/certificate_watcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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_LINUX_CERTIFICATE_WATCHER_H_ 5 #ifndef REMOTING_HOST_LINUX_CERTIFICATE_WATCHER_H_
6 #define REMOTING_HOST_LINUX_CERTIFICATE_WATCHER_H_ 6 #define REMOTING_HOST_LINUX_CERTIFICATE_WATCHER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/files/file_path_watcher.h" 11 #include "base/files/file_path_watcher.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/timer/timer.h" 14 #include "base/timer/timer.h"
15 #include "remoting/host/host_status_monitor.h" 15 #include "remoting/host/host_status_monitor.h"
16 #include "remoting/host/host_status_observer.h" 16 #include "remoting/host/host_status_observer.h"
17 17
18 namespace remoting { 18 namespace remoting {
19 19
20 class CertDbContentWatcher;
21
20 // This class watches the cert database and notifies the host to restart when 22 // This class watches the cert database and notifies the host to restart when
21 // a change of the database is detected. The runner script will restart the host 23 // a change of the database is detected. The runner script will restart the host
22 // when the host is killed then the new host will capture any new changes of the 24 // when the host is killed then the new host will capture any new changes of the
23 // database. 25 // database.
24 // 26 //
25 // Acceptable false positives will be caused by desktop sessions and other 27 // Acceptable false positives will be caused by desktop sessions and other
26 // external programs. 28 // external programs.
27 // 29 //
28 // Implements HostStatusObserver to defer restart action when the host is 30 // Implements HostStatusObserver to defer restart action when the host is
29 // connected to a client. 31 // connected to a client.
(...skipping 19 matching lines...) Expand all
49 51
50 // HostStatusObserver interface. 52 // HostStatusObserver interface.
51 void OnClientConnected(const std::string& jid) override; 53 void OnClientConnected(const std::string& jid) override;
52 void OnClientDisconnected(const std::string& jid) override; 54 void OnClientDisconnected(const std::string& jid) override;
53 55
54 // Will only work before the watcher starts. 56 // Will only work before the watcher starts.
55 void SetDelayForTests(const base::TimeDelta& delay); 57 void SetDelayForTests(const base::TimeDelta& delay);
56 void SetWatchPathForTests(const base::FilePath& watch_path); 58 void SetWatchPathForTests(const base::FilePath& watch_path);
57 59
58 private: 60 private:
61 friend class CertDbContentWatcher;
62
59 // Returns true if the watcher has started. 63 // Returns true if the watcher has started.
60 bool is_started() const; 64 bool is_started() const;
61 65
62 // Callback passed to |file_watcher_|. Runs in IO thread. 66 // Runs in the caller's thread. It will defer restarting the host if
63 static void OnCertDirectoryChanged( 67 // |inhibit_restart_scheduled_| flag is set to true.
64 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, 68 void DatabaseChanged();
65 base::WeakPtr<CertificateWatcher> watcher_, const base::FilePath& path,
66 bool error);
67
68 // Runs in the caller's thread.
69 void DirectoryChanged(const base::FilePath& path, bool error);
70
71 // Called by |restart_timer_| when it's time to reset the host.
72 // It will defer restart if |inhibit_restart_scheduled_| flag is set to true.
73 void OnTimer();
74 69
75 // Reference to the monitor 70 // Reference to the monitor
76 base::WeakPtr<HostStatusMonitor> monitor_; 71 base::WeakPtr<HostStatusMonitor> monitor_;
77 72
78 // Called when a restart is scheduled. 73 // Called when a restart is scheduled.
79 base::Closure restart_action_; 74 base::Closure restart_action_;
80 75
81 // The runner that runs everything other than the file watcher. 76 // The runner that runs everything other than the file watcher.
82 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; 77 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_;
83 78
84 // The runner that runs the file watcher. 79 // The runner that runs the file watcher.
85 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; 80 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
86 81
87 bool inhibit_mode_ = false; 82 bool inhibit_mode_ = false;
88 83
89 bool restart_pending_ = false; 84 bool restart_pending_ = false;
90 85
91 // Path of the certificate files/directories. 86 // Path of the certificate files/directories.
92 base::FilePath cert_watch_path_; 87 base::FilePath cert_watch_path_;
93 88
94 // The file watcher to watch changes inside the certificate folder. 89 // The watcher implementation that watches the files on the IO thread.
95 std::unique_ptr<base::FilePathWatcher> file_watcher_; 90 std::unique_ptr<CertDbContentWatcher> content_watcher_;
96 91
97 // The time to wait to restart when it is scheduled. 92 // The time to wait before re-reading the DB files after a change is
93 // detected.
98 base::TimeDelta delay_; 94 base::TimeDelta delay_;
99 95
100 // Timer to delay the restart action.
101 std::unique_ptr<base::DelayTimer> restart_timer_;
102
103 base::WeakPtrFactory<CertificateWatcher> weak_factory_; 96 base::WeakPtrFactory<CertificateWatcher> weak_factory_;
104 97
105 DISALLOW_COPY_AND_ASSIGN(CertificateWatcher); 98 DISALLOW_COPY_AND_ASSIGN(CertificateWatcher);
106 }; 99 };
107 100
108 } // namespace remoting 101 } // namespace remoting
109 102
110 #endif // REMOTING_HOST_LINUX_CERTIFICATE_WATCHER_H_ 103 #endif // REMOTING_HOST_LINUX_CERTIFICATE_WATCHER_H_
OLDNEW
« no previous file with comments | « no previous file | remoting/host/linux/certificate_watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698