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

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

Issue 8376001: UI test for browser termination with beforeunload handler. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: BrowserTestBeforeUnload only for cros Created 9 years, 1 month 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 | « no previous file | chrome/browser/ui/tests/browser_uitest.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/chrome_browser_main_posix.h" 5 #include "chrome/browser/chrome_browser_main_posix.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <limits.h> 8 #include <limits.h>
9 #include <signal.h> 9 #include <signal.h>
10 #include <sys/resource.h> 10 #include <sys/resource.h>
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 asm(""); 98 asm("");
99 sleep(UINT_MAX); 99 sleep(UINT_MAX);
100 } 100 }
101 101
102 NOINLINE void ShutdownFDClosedError() { 102 NOINLINE void ShutdownFDClosedError() {
103 // Ensure function isn't optimized away. 103 // Ensure function isn't optimized away.
104 asm(""); 104 asm("");
105 sleep(UINT_MAX); 105 sleep(UINT_MAX);
106 } 106 }
107 107
108 NOINLINE void CloseAllBrowsersAndExitPosted() { 108 NOINLINE void ExitPosted() {
109 // Ensure function isn't optimized away. 109 // Ensure function isn't optimized away.
110 asm(""); 110 asm("");
111 sleep(UINT_MAX); 111 sleep(UINT_MAX);
112 } 112 }
113 113
114 void ShutdownDetector::ThreadMain() { 114 void ShutdownDetector::ThreadMain() {
115 base::PlatformThread::SetName("CrShutdownDetector"); 115 base::PlatformThread::SetName("CrShutdownDetector");
116 116
117 int signal; 117 int signal;
118 size_t bytes_read = 0; 118 size_t bytes_read = 0;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 154
155 // We really should be dead by now. For whatever reason, we're not. Exit 155 // We really should be dead by now. For whatever reason, we're not. Exit
156 // immediately, with the exit status set to the signal number with bit 8 156 // immediately, with the exit status set to the signal number with bit 8
157 // set. On the systems that we care about, this exit status is what is 157 // set. On the systems that we care about, this exit status is what is
158 // normally used to indicate an exit by this signal's default handler. 158 // normally used to indicate an exit by this signal's default handler.
159 // This mechanism isn't a de jure standard, but even in the worst case, it 159 // This mechanism isn't a de jure standard, but even in the worst case, it
160 // should at least result in an immediate exit. 160 // should at least result in an immediate exit.
161 RAW_LOG(WARNING, "Still here, exiting really ungracefully."); 161 RAW_LOG(WARNING, "Still here, exiting really ungracefully.");
162 _exit(signal | (1 << 7)); 162 _exit(signal | (1 << 7));
163 } 163 }
164 CloseAllBrowsersAndExitPosted(); 164 ExitPosted();
165 } 165 }
166 166
167 // Sets the file descriptor soft limit to |max_descriptors| or the OS hard 167 // Sets the file descriptor soft limit to |max_descriptors| or the OS hard
168 // limit, whichever is lower. 168 // limit, whichever is lower.
169 void SetFileDescriptorLimit(unsigned int max_descriptors) { 169 void SetFileDescriptorLimit(unsigned int max_descriptors) {
170 struct rlimit limits; 170 struct rlimit limits;
171 if (getrlimit(RLIMIT_NOFILE, &limits) == 0) { 171 if (getrlimit(RLIMIT_NOFILE, &limits) == 0) {
172 unsigned int new_limit = max_descriptors; 172 unsigned int new_limit = max_descriptors;
173 if (limits.rlim_max > 0 && limits.rlim_max < max_descriptors) { 173 if (limits.rlim_max > 0 && limits.rlim_max < max_descriptors) {
174 new_limit = limits.rlim_max; 174 new_limit = limits.rlim_max;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 // And SIGHUP, for when the terminal disappears. On shutdown, many Linux 254 // And SIGHUP, for when the terminal disappears. On shutdown, many Linux
255 // distros send SIGHUP, SIGTERM, and then SIGKILL. 255 // distros send SIGHUP, SIGTERM, and then SIGKILL.
256 action.sa_handler = SIGHUPHandler; 256 action.sa_handler = SIGHUPHandler;
257 CHECK(sigaction(SIGHUP, &action, NULL) == 0); 257 CHECK(sigaction(SIGHUP, &action, NULL) == 0);
258 258
259 #if defined(TOOLKIT_USES_GTK) && !defined(OS_CHROMEOS) 259 #if defined(TOOLKIT_USES_GTK) && !defined(OS_CHROMEOS)
260 printing::PrintingContextCairo::SetCreatePrintDialogFunction( 260 printing::PrintingContextCairo::SetCreatePrintDialogFunction(
261 &PrintDialogGtk::CreatePrintDialog); 261 &PrintDialogGtk::CreatePrintDialog);
262 #endif 262 #endif
263 } 263 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/tests/browser_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698