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

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

Issue 209042: Make Linux Breakpad initialization call to lsb_release asynchronous. Also wrap more... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 3 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/app/chrome_dll_main.cc ('k') | chrome/browser/gtk/first_run_dialog.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) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-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/browser_main.h" 5 #include "chrome/browser/browser_main.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/field_trial.h" 12 #include "base/field_trial.h"
13 #include "base/file_util.h" 13 #include "base/file_util.h"
14 #include "base/histogram.h" 14 #include "base/histogram.h"
15 #include "base/lazy_instance.h" 15 #include "base/lazy_instance.h"
16 #include "base/linux_util.h"
16 #include "base/scoped_nsautorelease_pool.h" 17 #include "base/scoped_nsautorelease_pool.h"
17 #include "base/path_service.h" 18 #include "base/path_service.h"
18 #include "base/process_util.h" 19 #include "base/process_util.h"
19 #include "base/string_piece.h" 20 #include "base/string_piece.h"
20 #include "base/string_util.h" 21 #include "base/string_util.h"
21 #include "base/sys_string_conversions.h" 22 #include "base/sys_string_conversions.h"
22 #include "base/system_monitor.h" 23 #include "base/system_monitor.h"
23 #include "base/time.h" 24 #include "base/time.h"
24 #include "base/tracked_objects.h" 25 #include "base/tracked_objects.h"
25 #include "base/values.h" 26 #include "base/values.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 #include "grit/generated_resources.h" 61 #include "grit/generated_resources.h"
61 #include "grit/net_resources.h" 62 #include "grit/net_resources.h"
62 #include "net/base/cookie_monster.h" 63 #include "net/base/cookie_monster.h"
63 #include "net/base/net_module.h" 64 #include "net/base/net_module.h"
64 #include "net/http/http_network_session.h" 65 #include "net/http/http_network_session.h"
65 #include "net/socket/client_socket_pool_base.h" 66 #include "net/socket/client_socket_pool_base.h"
66 67
67 #if defined(OS_POSIX) 68 #if defined(OS_POSIX)
68 // TODO(port): get rid of this include. It's used just to provide declarations 69 // TODO(port): get rid of this include. It's used just to provide declarations
69 // and stub definitions for classes we encouter during the porting effort. 70 // and stub definitions for classes we encouter during the porting effort.
70 #include "chrome/common/temp_scaffolding_stubs.h"
agl 2009/09/23 20:53:15 Make sure that the Mac tryservers are ok with this
71 #include <errno.h> 71 #include <errno.h>
72 #include <signal.h> 72 #include <signal.h>
73 #include <sys/resource.h> 73 #include <sys/resource.h>
74 #endif 74 #endif
75 75
76 #if defined(USE_LINUX_BREAKPAD)
77 #include "chrome/app/breakpad_linux.h"
78 #endif
79
76 #if defined(OS_LINUX) 80 #if defined(OS_LINUX)
77 #include "chrome/app/breakpad_linux.h" 81 #include "chrome/common/gtk_util.h"
78 #endif 82 #endif
79 83
80 // TODO(port): several win-only methods have been pulled out of this, but 84 // TODO(port): several win-only methods have been pulled out of this, but
81 // BrowserMain() as a whole needs to be broken apart so that it's usable by 85 // BrowserMain() as a whole needs to be broken apart so that it's usable by
82 // other platforms. For now, it's just a stub. This is a serious work in 86 // other platforms. For now, it's just a stub. This is a serious work in
83 // progress and should not be taken as an indication of a real refactoring. 87 // progress and should not be taken as an indication of a real refactoring.
84 88
85 #if defined(OS_WIN) 89 #if defined(OS_WIN)
86 #include <windows.h> 90 #include <windows.h>
87 #include <commctrl.h> 91 #include <commctrl.h>
(...skipping 17 matching lines...) Expand all
105 #include "chrome/installer/util/shell_util.h" 109 #include "chrome/installer/util/shell_util.h"
106 #include "chrome/installer/util/version.h" 110 #include "chrome/installer/util/version.h"
107 #include "net/base/net_util.h" 111 #include "net/base/net_util.h"
108 #include "net/base/sdch_manager.h" 112 #include "net/base/sdch_manager.h"
109 #include "net/base/winsock_init.h" 113 #include "net/base/winsock_init.h"
110 #include "net/http/http_network_layer.h" 114 #include "net/http/http_network_layer.h"
111 #include "printing/printed_document.h" 115 #include "printing/printed_document.h"
112 #include "sandbox/src/sandbox.h" 116 #include "sandbox/src/sandbox.h"
113 #endif // defined(OS_WIN) 117 #endif // defined(OS_WIN)
114 118
115 #if defined(OS_LINUX)
116 #include "chrome/common/gtk_util.h"
117 #endif
118
119 #if defined(TOOLKIT_VIEWS) 119 #if defined(TOOLKIT_VIEWS)
120 #include "chrome/browser/views/chrome_views_delegate.h" 120 #include "chrome/browser/views/chrome_views_delegate.h"
121 #include "views/focus/accelerator_handler.h" 121 #include "views/focus/accelerator_handler.h"
122 #endif 122 #endif
123 123
124 #if defined(OS_CHROMEOS) 124 #if defined(OS_CHROMEOS)
125 #include "chrome/browser/chromeos/external_cookie_handler.h" 125 #include "chrome/browser/chromeos/external_cookie_handler.h"
126 #endif 126 #endif
127 127
128 namespace { 128 namespace {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 ++it; 226 ++it;
227 } 227 }
228 } 228 }
229 #else 229 #else
230 // TODO(cpu): implement first run experience for other platforms. 230 // TODO(cpu): implement first run experience for other platforms.
231 void AddFirstRunNewTabs(BrowserInit* browser_init, 231 void AddFirstRunNewTabs(BrowserInit* browser_init,
232 const std::vector<std::wstring>& new_tabs) { 232 const std::vector<std::wstring>& new_tabs) {
233 } 233 }
234 #endif 234 #endif
235 235
236 #if defined(USE_LINUX_BREAKPAD)
237 class GetLinuxDistroTask : public Task {
238 public:
239 explicit GetLinuxDistroTask() {}
240
241 virtual void Run() {
242 base::GetLinuxDistro(); // Initialize base::linux_distro if needed.
243 }
244
245 DISALLOW_COPY_AND_ASSIGN(GetLinuxDistroTask);
246 };
247 #endif // USE_LINUX_BREAKPAD
236 } // namespace 248 } // namespace
237 249
238 // Main routine for running as the Browser process. 250 // Main routine for running as the Browser process.
239 int BrowserMain(const MainFunctionParams& parameters) { 251 int BrowserMain(const MainFunctionParams& parameters) {
240 const CommandLine& parsed_command_line = parameters.command_line_; 252 const CommandLine& parsed_command_line = parameters.command_line_;
241 base::ScopedNSAutoreleasePool* pool = parameters.autorelease_pool_; 253 base::ScopedNSAutoreleasePool* pool = parameters.autorelease_pool_;
242 254
243 #if defined(OS_LINUX)
244 // Needs to be called after we have chrome::DIR_USER_DATA.
245 if (!parsed_command_line.HasSwitch(switches::kGoogleInternalCrashReporting))
246 InitCrashReporter();
247 #endif
248
249 // WARNING: If we get a WM_ENDSESSION objects created on the stack here 255 // WARNING: If we get a WM_ENDSESSION objects created on the stack here
250 // are NOT deleted. If you need something to run during WM_ENDSESSION add it 256 // are NOT deleted. If you need something to run during WM_ENDSESSION add it
251 // to browser_shutdown::Shutdown or BrowserProcess::EndSession. 257 // to browser_shutdown::Shutdown or BrowserProcess::EndSession.
252 258
253 // TODO(beng, brettw): someday, break this out into sub functions with well 259 // TODO(beng, brettw): someday, break this out into sub functions with well
254 // defined roles (e.g. pre/post-profile startup, etc). 260 // defined roles (e.g. pre/post-profile startup, etc).
255 261
256 #ifdef TRACK_ALL_TASK_OBJECTS 262 #ifdef TRACK_ALL_TASK_OBJECTS
257 // Start tracking the creation and deletion of Task instance. 263 // Start tracking the creation and deletion of Task instance.
258 // This construction MUST be done before main_message_loop, so that it is 264 // This construction MUST be done before main_message_loop, so that it is
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 // see bug #1292702). 336 // see bug #1292702).
331 browser_process.reset(new FirstRunBrowserProcess(parsed_command_line)); 337 browser_process.reset(new FirstRunBrowserProcess(parsed_command_line));
332 is_first_run = false; 338 is_first_run = false;
333 } else { 339 } else {
334 browser_process.reset(new BrowserProcessImpl(parsed_command_line)); 340 browser_process.reset(new BrowserProcessImpl(parsed_command_line));
335 } 341 }
336 342
337 // BrowserProcessImpl's constructor should set g_browser_process. 343 // BrowserProcessImpl's constructor should set g_browser_process.
338 DCHECK(g_browser_process); 344 DCHECK(g_browser_process);
339 345
346 #if defined(USE_LINUX_BREAKPAD)
347 // Needs to be called after we have chrome::DIR_USER_DATA and
348 // g_browser_process.
349 if (!parsed_command_line.HasSwitch(switches::kGoogleInternalCrashReporting)) {
350 g_browser_process->file_thread()->message_loop()->PostTask(FROM_HERE,
351 new GetLinuxDistroTask());
352 InitCrashReporter();
353 }
354 #endif
355
340 #if defined(OS_WIN) 356 #if defined(OS_WIN)
341 // IMPORTANT: This piece of code needs to run as early as possible in the 357 // IMPORTANT: This piece of code needs to run as early as possible in the
342 // process because it will initialize the sandbox broker, which requires the 358 // process because it will initialize the sandbox broker, which requires the
343 // process to swap its window station. During this time all the UI will be 359 // process to swap its window station. During this time all the UI will be
344 // broken. This has to run before threads and windows are created. 360 // broken. This has to run before threads and windows are created.
345 sandbox::BrokerServices* broker_services = 361 sandbox::BrokerServices* broker_services =
346 parameters.sandbox_info_.BrokerServices(); 362 parameters.sandbox_info_.BrokerServices();
347 if (broker_services) { 363 if (broker_services) {
348 browser_process->InitBrokerServices(broker_services); 364 browser_process->InitBrokerServices(broker_services);
349 if (!parsed_command_line.HasSwitch(switches::kNoSandbox)) { 365 if (!parsed_command_line.HasSwitch(switches::kNoSandbox)) {
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 if (metrics) 857 if (metrics)
842 metrics->Stop(); 858 metrics->Stop();
843 859
844 // browser_shutdown takes care of deleting browser_process, so we need to 860 // browser_shutdown takes care of deleting browser_process, so we need to
845 // release it. 861 // release it.
846 browser_process.release(); 862 browser_process.release();
847 browser_shutdown::Shutdown(); 863 browser_shutdown::Shutdown();
848 864
849 return result_code; 865 return result_code;
850 } 866 }
OLDNEW
« no previous file with comments | « chrome/app/chrome_dll_main.cc ('k') | chrome/browser/gtk/first_run_dialog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698