OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "chrome_frame/test/win_event_receiver.h" | 5 #include "chrome_frame/test/win_event_receiver.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 DWORD pid = 0; | 109 DWORD pid = 0; |
110 ::GetWindowThreadProcessId(hwnd, &pid); | 110 ::GetWindowThreadProcessId(hwnd, &pid); |
111 if (pid != 0) { | 111 if (pid != 0) { |
112 process_handle_ = ::OpenProcess(SYNCHRONIZE, FALSE, pid); | 112 process_handle_ = ::OpenProcess(SYNCHRONIZE, FALSE, pid); |
113 } | 113 } |
114 | 114 |
115 if (process_handle_ != NULL) { | 115 if (process_handle_ != NULL) { |
116 object_watcher_.StartWatching(process_handle_, this); | 116 object_watcher_.StartWatching(process_handle_, this); |
117 } else { | 117 } else { |
118 // Process is gone, so the window must be gone too. Notify our observer! | 118 // Process is gone, so the window must be gone too. Notify our observer! |
119 MessageLoop::current()->PostTask( | 119 base::MessageLoop::current()->PostTask( |
120 FROM_HERE, base::Bind(&ProcessExitObserver::OnObjectSignaled, | 120 FROM_HERE, base::Bind(&ProcessExitObserver::OnObjectSignaled, |
121 weak_factory_.GetWeakPtr(), HANDLE(NULL))); | 121 weak_factory_.GetWeakPtr(), HANDLE(NULL))); |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 WindowWatchdog::ProcessExitObserver::~ProcessExitObserver() { | 125 WindowWatchdog::ProcessExitObserver::~ProcessExitObserver() { |
126 if (process_handle_ != NULL) { | 126 if (process_handle_ != NULL) { |
127 ::CloseHandle(process_handle_); | 127 ::CloseHandle(process_handle_); |
128 } | 128 } |
129 } | 129 } |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 HandleOnOpen(hwnd); | 266 HandleOnOpen(hwnd); |
267 } else { | 267 } else { |
268 DCHECK(event == EVENT_OBJECT_DESTROY || event == EVENT_OBJECT_HIDE); | 268 DCHECK(event == EVENT_OBJECT_DESTROY || event == EVENT_OBJECT_HIDE); |
269 HandleOnClose(hwnd); | 269 HandleOnClose(hwnd); |
270 } | 270 } |
271 } | 271 } |
272 | 272 |
273 void WindowWatchdog::OnHwndProcessExited(HWND hwnd) { | 273 void WindowWatchdog::OnHwndProcessExited(HWND hwnd) { |
274 HandleOnClose(hwnd); | 274 HandleOnClose(hwnd); |
275 } | 275 } |
OLD | NEW |