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

Side by Side Diff: chrome/browser/process_singleton_win.cc

Issue 155772: This CL implements the second TODO item of issue 12343:... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/process_singleton_linux_uitest.cc ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/browser/process_singleton.h" 5 #include "chrome/browser/process_singleton.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/win_util.h" 8 #include "app/win_util.h"
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/process_util.h" 11 #include "base/process_util.h"
12 #include "base/win_util.h" 12 #include "base/win_util.h"
13 #include "chrome/browser/browser_init.h" 13 #include "chrome/browser/browser_init.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/profile.h" 15 #include "chrome/browser/profile.h"
16 #include "chrome/browser/profile_manager.h" 16 #include "chrome/browser/profile_manager.h"
17 #include "chrome/common/chrome_constants.h" 17 #include "chrome/common/chrome_constants.h"
18 #include "chrome/common/chrome_paths.h" 18 #include "chrome/common/chrome_paths.h"
19 #include "chrome/common/result_codes.h" 19 #include "chrome/common/result_codes.h"
20 #include "grit/chromium_strings.h" 20 #include "grit/chromium_strings.h"
21 #include "grit/generated_resources.h" 21 #include "grit/generated_resources.h"
22 22
23 const int ProcessSingleton::kTimeoutInSeconds;
24
23 namespace { 25 namespace {
24 26
25 // Checks the visibility of the enumerated window and signals once a visible 27 // Checks the visibility of the enumerated window and signals once a visible
26 // window has been found. 28 // window has been found.
27 BOOL CALLBACK BrowserWindowEnumeration(HWND window, LPARAM param) { 29 BOOL CALLBACK BrowserWindowEnumeration(HWND window, LPARAM param) {
28 bool* result = reinterpret_cast<bool*>(param); 30 bool* result = reinterpret_cast<bool*>(param);
29 *result = IsWindowVisible(window) != 0; 31 *result = IsWindowVisible(window) != 0;
30 // Stops enumeration if a visible window has been found. 32 // Stops enumeration if a visible window has been found.
31 return !*result; 33 return !*result;
32 } 34 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 DWORD process_id = 0; 73 DWORD process_id = 0;
72 DWORD thread_id = GetWindowThreadProcessId(remote_window_, &process_id); 74 DWORD thread_id = GetWindowThreadProcessId(remote_window_, &process_id);
73 // It is possible that the process owning this window may have died by now. 75 // It is possible that the process owning this window may have died by now.
74 if (!thread_id || !process_id) { 76 if (!thread_id || !process_id) {
75 remote_window_ = NULL; 77 remote_window_ = NULL;
76 return false; 78 return false;
77 } 79 }
78 80
79 AllowSetForegroundWindow(process_id); 81 AllowSetForegroundWindow(process_id);
80 82
81 // Gives 20 seconds timeout for the current browser process to respond.
82 const int kTimeout = 20000;
83 COPYDATASTRUCT cds; 83 COPYDATASTRUCT cds;
84 cds.dwData = 0; 84 cds.dwData = 0;
85 cds.cbData = static_cast<DWORD>((to_send.length() + 1) * sizeof(wchar_t)); 85 cds.cbData = static_cast<DWORD>((to_send.length() + 1) * sizeof(wchar_t));
86 cds.lpData = const_cast<wchar_t*>(to_send.c_str()); 86 cds.lpData = const_cast<wchar_t*>(to_send.c_str());
87 DWORD_PTR result = 0; 87 DWORD_PTR result = 0;
88 if (SendMessageTimeout(remote_window_, 88 if (SendMessageTimeout(remote_window_,
89 WM_COPYDATA, 89 WM_COPYDATA,
90 NULL, 90 NULL,
91 reinterpret_cast<LPARAM>(&cds), 91 reinterpret_cast<LPARAM>(&cds),
92 SMTO_ABORTIFHUNG, 92 SMTO_ABORTIFHUNG,
93 kTimeout, 93 kTimeoutInSeconds * 1000,
94 &result)) { 94 &result)) {
95 // It is possible that the process owning this window may have died by now. 95 // It is possible that the process owning this window may have died by now.
96 if (!result) { 96 if (!result) {
97 remote_window_ = NULL; 97 remote_window_ = NULL;
98 return false; 98 return false;
99 } 99 }
100 return true; 100 return true;
101 } 101 }
102 102
103 // It is possible that the process owning this window may have died by now. 103 // It is possible that the process owning this window may have died by now.
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 switch (message) { 259 switch (message) {
260 case WM_COPYDATA: 260 case WM_COPYDATA:
261 return OnCopyData(reinterpret_cast<HWND>(wparam), 261 return OnCopyData(reinterpret_cast<HWND>(wparam),
262 reinterpret_cast<COPYDATASTRUCT*>(lparam)); 262 reinterpret_cast<COPYDATASTRUCT*>(lparam));
263 default: 263 default:
264 break; 264 break;
265 } 265 }
266 266
267 return ::DefWindowProc(hwnd, message, wparam, lparam); 267 return ::DefWindowProc(hwnd, message, wparam, lparam);
268 } 268 }
OLDNEW
« no previous file with comments | « chrome/browser/process_singleton_linux_uitest.cc ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698