| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/object_watcher.h" | 9 #include "base/win/object_watcher.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 | 11 |
| 12 #include "chrome_frame/function_stub.h" | 12 #include "chrome_frame/function_stub.h" |
| 13 | 13 |
| 14 // WinEventReceiver methods | 14 // WinEventReceiver methods |
| 15 WinEventReceiver::WinEventReceiver() | 15 WinEventReceiver::WinEventReceiver() |
| 16 : listener_(NULL), | 16 : listener_(NULL), |
| 17 hook_(NULL), | 17 hook_(NULL), |
| 18 hook_stub_(NULL) { | 18 hook_stub_(NULL) { |
| 19 } | 19 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } | 71 } |
| 72 | 72 |
| 73 // Notifies WindowWatchdog when the process owning a given window exits. | 73 // Notifies WindowWatchdog when the process owning a given window exits. |
| 74 // | 74 // |
| 75 // If the process terminates before its handle may be obtained, this class will | 75 // If the process terminates before its handle may be obtained, this class will |
| 76 // still properly notifyy the WindowWatchdog. | 76 // still properly notifyy the WindowWatchdog. |
| 77 // | 77 // |
| 78 // Notification is always delivered via a message loop task in the message loop | 78 // Notification is always delivered via a message loop task in the message loop |
| 79 // that is active when the instance is constructed. | 79 // that is active when the instance is constructed. |
| 80 class WindowWatchdog::ProcessExitObserver | 80 class WindowWatchdog::ProcessExitObserver |
| 81 : public base::ObjectWatcher::Delegate { | 81 : public base::win::ObjectWatcher::Delegate { |
| 82 public: | 82 public: |
| 83 // Initiates the process watch. Will always return without notifying the | 83 // Initiates the process watch. Will always return without notifying the |
| 84 // watchdog. | 84 // watchdog. |
| 85 ProcessExitObserver(WindowWatchdog* window_watchdog, HWND hwnd); | 85 ProcessExitObserver(WindowWatchdog* window_watchdog, HWND hwnd); |
| 86 virtual ~ProcessExitObserver(); | 86 virtual ~ProcessExitObserver(); |
| 87 | 87 |
| 88 // base::ObjectWatcher::Delegate implementation | 88 // base::ObjectWatcher::Delegate implementation |
| 89 virtual void OnObjectSignaled(HANDLE process_handle); | 89 virtual void OnObjectSignaled(HANDLE process_handle); |
| 90 | 90 |
| 91 private: | 91 private: |
| 92 WindowWatchdog* window_watchdog_; | 92 WindowWatchdog* window_watchdog_; |
| 93 HANDLE process_handle_; | 93 HANDLE process_handle_; |
| 94 HWND hwnd_; | 94 HWND hwnd_; |
| 95 | 95 |
| 96 ScopedRunnableMethodFactory<ProcessExitObserver> method_task_factory_; | 96 ScopedRunnableMethodFactory<ProcessExitObserver> method_task_factory_; |
| 97 base::ObjectWatcher object_watcher_; | 97 base::win::ObjectWatcher object_watcher_; |
| 98 | 98 |
| 99 DISALLOW_COPY_AND_ASSIGN(ProcessExitObserver); | 99 DISALLOW_COPY_AND_ASSIGN(ProcessExitObserver); |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 WindowWatchdog::ProcessExitObserver::ProcessExitObserver( | 102 WindowWatchdog::ProcessExitObserver::ProcessExitObserver( |
| 103 WindowWatchdog* window_watchdog, HWND hwnd) | 103 WindowWatchdog* window_watchdog, HWND hwnd) |
| 104 : window_watchdog_(window_watchdog), | 104 : window_watchdog_(window_watchdog), |
| 105 process_handle_(NULL), | 105 process_handle_(NULL), |
| 106 hwnd_(hwnd), | 106 hwnd_(hwnd), |
| 107 ALLOW_THIS_IN_INITIALIZER_LIST(method_task_factory_(this)) { | 107 ALLOW_THIS_IN_INITIALIZER_LIST(method_task_factory_(this)) { |
| (...skipping 158 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 |