OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/field_trial.h" | 10 #include "base/field_trial.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 #include "grit/chromium_strings.h" | 49 #include "grit/chromium_strings.h" |
50 #include "grit/generated_resources.h" | 50 #include "grit/generated_resources.h" |
51 #include "grit/net_resources.h" | 51 #include "grit/net_resources.h" |
52 #include "net/base/net_module.h" | 52 #include "net/base/net_module.h" |
53 #include "net/http/http_network_session.h" | 53 #include "net/http/http_network_session.h" |
54 | 54 |
55 #if defined(OS_POSIX) | 55 #if defined(OS_POSIX) |
56 // TODO(port): get rid of this include. It's used just to provide declarations | 56 // TODO(port): get rid of this include. It's used just to provide declarations |
57 // and stub definitions for classes we encouter during the porting effort. | 57 // and stub definitions for classes we encouter during the porting effort. |
58 #include "chrome/common/temp_scaffolding_stubs.h" | 58 #include "chrome/common/temp_scaffolding_stubs.h" |
| 59 #include <signal.h> |
59 #endif | 60 #endif |
60 | 61 |
61 // TODO(port): several win-only methods have been pulled out of this, but | 62 // TODO(port): several win-only methods have been pulled out of this, but |
62 // BrowserMain() as a whole needs to be broken apart so that it's usable by | 63 // BrowserMain() as a whole needs to be broken apart so that it's usable by |
63 // other platforms. For now, it's just a stub. This is a serious work in | 64 // other platforms. For now, it's just a stub. This is a serious work in |
64 // progress and should not be taken as an indication of a real refactoring. | 65 // progress and should not be taken as an indication of a real refactoring. |
65 | 66 |
66 #if defined(OS_WIN) | 67 #if defined(OS_WIN) |
67 | 68 |
68 #include <windows.h> | 69 #include <windows.h> |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 } | 174 } |
174 | 175 |
175 void RunUIMessageLoop(BrowserProcess* browser_process) { | 176 void RunUIMessageLoop(BrowserProcess* browser_process) { |
176 #if defined(OS_WIN) | 177 #if defined(OS_WIN) |
177 MessageLoopForUI::current()->Run(browser_process->accelerator_handler()); | 178 MessageLoopForUI::current()->Run(browser_process->accelerator_handler()); |
178 #elif defined(OS_POSIX) | 179 #elif defined(OS_POSIX) |
179 MessageLoopForUI::current()->Run(); | 180 MessageLoopForUI::current()->Run(); |
180 #endif | 181 #endif |
181 } | 182 } |
182 | 183 |
| 184 #if defined(OS_POSIX) |
| 185 // See comment below, where sigaction is called. |
| 186 void SIGCHLDHandler(int signal) { |
| 187 } |
| 188 #endif |
| 189 |
183 } // namespace | 190 } // namespace |
184 | 191 |
185 // Main routine for running as the Browser process. | 192 // Main routine for running as the Browser process. |
186 int BrowserMain(const MainFunctionParams& parameters) { | 193 int BrowserMain(const MainFunctionParams& parameters) { |
187 const CommandLine& parsed_command_line = parameters.command_line_; | 194 const CommandLine& parsed_command_line = parameters.command_line_; |
188 base::ScopedNSAutoreleasePool* pool = parameters.autorelease_pool_; | 195 base::ScopedNSAutoreleasePool* pool = parameters.autorelease_pool_; |
189 | 196 |
190 // WARNING: If we get a WM_ENDSESSION objects created on the stack here | 197 // WARNING: If we get a WM_ENDSESSION objects created on the stack here |
191 // are NOT deleted. If you need something to run during WM_ENDSESSION add it | 198 // are NOT deleted. If you need something to run during WM_ENDSESSION add it |
192 // to browser_shutdown::Shutdown or BrowserProcess::EndSession. | 199 // to browser_shutdown::Shutdown or BrowserProcess::EndSession. |
193 | 200 |
194 // TODO(beng, brettw): someday, break this out into sub functions with well | 201 // TODO(beng, brettw): someday, break this out into sub functions with well |
195 // defined roles (e.g. pre/post-profile startup, etc). | 202 // defined roles (e.g. pre/post-profile startup, etc). |
196 | 203 |
197 #ifdef TRACK_ALL_TASK_OBJECTS | 204 #ifdef TRACK_ALL_TASK_OBJECTS |
198 // Start tracking the creation and deletion of Task instance. | 205 // Start tracking the creation and deletion of Task instance. |
199 // This construction MUST be done before main_message_loop, so that it is | 206 // This construction MUST be done before main_message_loop, so that it is |
200 // destroyed after the main_message_loop. | 207 // destroyed after the main_message_loop. |
201 tracked_objects::AutoTracking tracking_objects; | 208 tracked_objects::AutoTracking tracking_objects; |
202 #endif | 209 #endif |
203 | 210 |
| 211 #if defined(OS_POSIX) |
| 212 // We need to accept SIGCHLD, even though our handler is a no-op because |
| 213 // otherwise we cannot wait on children. (According to POSIX 2001.) |
| 214 struct sigaction action = {0}; |
| 215 action.sa_handler = SIGCHLDHandler; |
| 216 CHECK(sigaction(SIGCHLD, &action, NULL) == 0); |
| 217 #endif |
| 218 |
204 // Do platform-specific things (such as finishing initializing Cocoa) | 219 // Do platform-specific things (such as finishing initializing Cocoa) |
205 // prior to instantiating the message loop. This could be turned into a | 220 // prior to instantiating the message loop. This could be turned into a |
206 // broadcast notification. | 221 // broadcast notification. |
207 Platform::WillInitializeMainMessageLoop(parsed_command_line); | 222 Platform::WillInitializeMainMessageLoop(parsed_command_line); |
208 | 223 |
209 MessageLoop main_message_loop(MessageLoop::TYPE_UI); | 224 MessageLoop main_message_loop(MessageLoop::TYPE_UI); |
210 | 225 |
211 // Initialize the SystemMonitor | 226 // Initialize the SystemMonitor |
212 base::SystemMonitor::Start(); | 227 base::SystemMonitor::Start(); |
213 | 228 |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 if (metrics) | 629 if (metrics) |
615 metrics->Stop(); | 630 metrics->Stop(); |
616 | 631 |
617 // browser_shutdown takes care of deleting browser_process, so we need to | 632 // browser_shutdown takes care of deleting browser_process, so we need to |
618 // release it. | 633 // release it. |
619 browser_process.release(); | 634 browser_process.release(); |
620 browser_shutdown::Shutdown(); | 635 browser_shutdown::Shutdown(); |
621 | 636 |
622 return result_code; | 637 return result_code; |
623 } | 638 } |
OLD | NEW |