OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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 #include <windows.h> | 5 #include <windows.h> |
6 #include <sddl.h> | 6 #include <sddl.h> |
7 | 7 |
8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 base::WaitableEvent browser_exited_; | 93 base::WaitableEvent browser_exited_; |
94 | 94 |
95 // The run loop for the main thread and its task runner. | 95 // The run loop for the main thread and its task runner. |
96 base::RunLoop* run_loop_; | 96 base::RunLoop* run_loop_; |
97 scoped_refptr<base::SequencedTaskRunner> main_thread_; | 97 scoped_refptr<base::SequencedTaskRunner> main_thread_; |
98 | 98 |
99 DISALLOW_COPY_AND_ASSIGN(BrowserMonitor); | 99 DISALLOW_COPY_AND_ASSIGN(BrowserMonitor); |
100 }; | 100 }; |
101 | 101 |
102 BrowserMonitor::BrowserMonitor(base::RunLoop* run_loop, | 102 BrowserMonitor::BrowserMonitor(base::RunLoop* run_loop, |
103 const base::char16* registry_path) : | 103 const base::char16* registry_path) |
104 browser_exited_(true, false), // manual reset, initially non-signalled. | 104 : exit_code_watcher_(registry_path), |
105 exit_code_watcher_(registry_path), | 105 end_session_watcher_window_( |
106 end_session_watcher_window_( | 106 base::Bind(&BrowserMonitor::OnEndSessionMessage, |
107 base::Bind(&BrowserMonitor::OnEndSessionMessage, | 107 base::Unretained(this))), |
108 base::Unretained(this))), | 108 background_thread_("BrowserWatcherThread"), |
109 background_thread_("BrowserWatcherThread"), | 109 browser_exited_(true, false), // manual reset, initially non-signalled. |
110 run_loop_(run_loop), | 110 run_loop_(run_loop), |
111 main_thread_(base::ThreadTaskRunnerHandle::Get()) { | 111 main_thread_(base::ThreadTaskRunnerHandle::Get()) { |
112 } | 112 } |
113 | 113 |
114 BrowserMonitor::~BrowserMonitor() { | 114 BrowserMonitor::~BrowserMonitor() { |
115 } | 115 } |
116 | 116 |
117 bool BrowserMonitor::StartWatching( | 117 bool BrowserMonitor::StartWatching( |
118 const base::char16* registry_path, | 118 const base::char16* registry_path, |
119 base::Process process, | 119 base::Process process, |
120 base::win::ScopedHandle on_initialized_event) { | 120 base::win::ScopedHandle on_initialized_event) { |
121 if (!exit_code_watcher_.Initialize(process.Pass())) | 121 if (!exit_code_watcher_.Initialize(process.Pass())) |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 | 419 |
420 // Wind logging down. | 420 // Wind logging down. |
421 logging::LogEventProvider::Uninitialize(); | 421 logging::LogEventProvider::Uninitialize(); |
422 | 422 |
423 return 0; | 423 return 0; |
424 } | 424 } |
425 | 425 |
426 static_assert( | 426 static_assert( |
427 base::is_same<decltype(&WatcherMain), ChromeWatcherMainFunction>::value, | 427 base::is_same<decltype(&WatcherMain), ChromeWatcherMainFunction>::value, |
428 "WatcherMain() has wrong type"); | 428 "WatcherMain() has wrong type"); |
OLD | NEW |