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

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: 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
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 CertificateWatcherImpl;
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 CertificateWatcherImpl;
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.
63 static void OnCertDirectoryChanged(
64 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
65 base::WeakPtr<CertificateWatcher> watcher_, const base::FilePath& path,
66 bool error);
67
68 // Runs in the caller's thread. 66 // Runs in the caller's thread.
69 void DirectoryChanged(const base::FilePath& path, bool error); 67 void DatabaseChanged(const base::FilePath& path, bool error);
70 68
71 // Called by |restart_timer_| when it's time to reset the host. 69 // 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. 70 // It will defer restart if |inhibit_restart_scheduled_| flag is set to true.
73 void OnTimer(); 71 void OnTimer();
74 72
75 // Reference to the monitor 73 // Reference to the monitor
76 base::WeakPtr<HostStatusMonitor> monitor_; 74 base::WeakPtr<HostStatusMonitor> monitor_;
77 75
78 // Called when a restart is scheduled. 76 // Called when a restart is scheduled.
79 base::Closure restart_action_; 77 base::Closure restart_action_;
80 78
81 // The runner that runs everything other than the file watcher. 79 // The runner that runs everything other than the file watcher.
82 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; 80 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_;
83 81
84 // The runner that runs the file watcher. 82 // The runner that runs the file watcher.
85 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; 83 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
86 84
87 bool inhibit_mode_ = false; 85 bool inhibit_mode_ = false;
88 86
89 bool restart_pending_ = false; 87 bool restart_pending_ = false;
90 88
91 // Path of the certificate files/directories. 89 // Path of the certificate files/directories.
92 base::FilePath cert_watch_path_; 90 base::FilePath cert_watch_path_;
93 91
94 // The file watcher to watch changes inside the certificate folder. 92 // The watcher implementation that watches the files on the IO thread.
95 std::unique_ptr<base::FilePathWatcher> file_watcher_; 93 std::unique_ptr<CertificateWatcherImpl> watcher_impl_;
96 94
97 // The time to wait to restart when it is scheduled. 95 // The time to wait to restart when it is scheduled.
98 base::TimeDelta delay_; 96 base::TimeDelta delay_;
99 97
100 // Timer to delay the restart action. 98 // Timer to delay the restart action.
101 std::unique_ptr<base::DelayTimer> restart_timer_; 99 std::unique_ptr<base::DelayTimer> restart_timer_;
102 100
103 base::WeakPtrFactory<CertificateWatcher> weak_factory_; 101 base::WeakPtrFactory<CertificateWatcher> weak_factory_;
104 102
105 DISALLOW_COPY_AND_ASSIGN(CertificateWatcher); 103 DISALLOW_COPY_AND_ASSIGN(CertificateWatcher);
106 }; 104 };
107 105
108 } // namespace remoting 106 } // namespace remoting
109 107
110 #endif // REMOTING_HOST_LINUX_CERTIFICATE_WATCHER_H_ 108 #endif // REMOTING_HOST_LINUX_CERTIFICATE_WATCHER_H_
OLDNEW
« no previous file with comments | « no previous file | remoting/host/linux/certificate_watcher.cc » ('j') | remoting/host/linux/certificate_watcher.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698