Chromium Code Reviews| Index: chrome/browser/process_singleton_win.cc |
| diff --git a/chrome/browser/process_singleton_win.cc b/chrome/browser/process_singleton_win.cc |
| index 335215680f0d1063b90260fcd4b1e7b9e39a3248..9e0b279cbbf3a092c44407adee7b2bdcdcf4c60a 100644 |
| --- a/chrome/browser/process_singleton_win.cc |
| +++ b/chrome/browser/process_singleton_win.cc |
| @@ -26,14 +26,19 @@ |
| #include "chrome/browser/chrome_process_finder_win.h" |
| #include "chrome/browser/shell_integration.h" |
| #include "chrome/browser/ui/simple_message_box.h" |
| +#include "chrome/chrome_watcher/kasko_util.h" |
| +#include "chrome/common/channel_info.h" |
| #include "chrome/common/chrome_constants.h" |
| #include "chrome/common/chrome_paths.h" |
| #include "chrome/common/chrome_paths_internal.h" |
| #include "chrome/common/chrome_switches.h" |
| #include "chrome/grit/chromium_strings.h" |
| +#include "chrome/installer/util/util_constants.h" |
| #include "chrome/installer/util/wmi.h" |
| +#include "components/version_info/version_info.h" |
| #include "content/public/common/result_codes.h" |
| #include "net/base/escape.h" |
| +#include "third_party/kasko/kasko_features.h" |
| #include "ui/base/l10n/l10n_util.h" |
| #include "ui/gfx/win/hwnd_util.h" |
| @@ -249,15 +254,59 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcess() { |
| break; |
| } |
| + // The window is hung. |
| DWORD process_id = 0; |
| DWORD thread_id = ::GetWindowThreadProcessId(remote_window_, &process_id); |
| if (!thread_id || !process_id) { |
| remote_window_ = NULL; |
| return PROCESS_NONE; |
| } |
| + |
| + // Get a handle to the process that created the window. This is racy. It's |
| + // possible the original process exited and that the process id was recycled. |
| + // Double check the window is still associated with an id. |
| base::Process process = base::Process::Open(process_id); |
| + process_id = 0; |
| + thread_id = ::GetWindowThreadProcessId(remote_window_, &process_id); |
|
Sigurður Ásgeirsson
2016/04/01 17:27:17
this is still racy, as you have the same problem w
Sigurður Ásgeirsson
2016/04/01 17:27:17
It's also worth noting here that we nominate the o
manzagop (departed)
2016/04/04 21:38:37
As discussed, it's hard to avoid the issues with H
manzagop (departed)
2016/04/04 21:38:38
Done.
|
| + if (!thread_id || !process_id) { |
| + remote_window_ = NULL; |
| + return PROCESS_NONE; |
| + } |
| + DCHECK_EQ(process.Pid(), process_id); |
| + |
| +#if BUILDFLAG(ENABLE_KASKO) |
| +#if BUILDFLAG(ENABLE_KASKO_FAILED_RDV_REPORTS) |
| + // Capture a failed rendez-vous hang report of the other process. Kasko needs |
| + // the exception context to live either in the dumper of the dumpee. This |
| + // means we cannot rely on kasko reporters from either browser watcher, and |
| + // instead spin up a new reporter. Note that we will exit shortly after |
| + // capturing the report, meaning the report may not get uploaded by this |
| + // reporter. |
| + // TODO(manzagop): add a metric for the number of captured hang reports, for |
| + // comparison with uploaded count? |
| + |
| + // Only report on canary (or unspecified). |
| + const version_info::Channel channel = chrome::GetChannel(); |
| + if (channel == version_info::Channel::UNKNOWN || |
| + channel == version_info::Channel::CANARY) { |
| + base::FilePath data_base_dir; |
| + chrome::GetDefaultUserDataDirectory(&data_base_dir); |
| + base::string16 endpoint = |
| + L"chrome_kasko_hangs_" + |
| + base::UintToString16(base::Process::Current().Pid()); |
| + |
| + bool launched_kasko = |
|
Sigurður Ásgeirsson
2016/04/01 17:27:17
it's worth adding some running commentary here, wi
manzagop (departed)
2016/04/04 21:38:37
Done.
|
| + InitializeKaskoReporter(endpoint, data_base_dir.value().c_str()); |
| + if (launched_kasko) { |
| + DumpHungProcess(thread_id, installer::kChromeChannelCanary, L"failed-rdv", |
| + process); |
| + ShutdownKaskoReporter(); |
| + } |
| + } |
| +#endif // BUILDFLAG(ENABLE_KASKO_FAILED_RDV_REPORTS) |
| +#endif // BUILDFLAG(ENABLE_KASKO) |
| - // The window is hung. Scan for every window to find a visible one. |
| + // Scan for every window to find a visible one. |
| bool visible_window = false; |
| ::EnumThreadWindows(thread_id, |
| &BrowserWindowEnumeration, |