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

Side by Side Diff: chrome/app/chrome_dll_main.cc

Issue 300010: Cleanup: change PIDs to base::ProcessId (or pid_t) (Closed)
Patch Set: Print out PID as int64 in case ProcessId type ever grows. Created 11 years, 2 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
« no previous file with comments | « base/process_util_posix.cc ('k') | chrome/browser/memory_details.h » ('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 // TODO(port): the ifdefs in here are a first step towards trying to determine 5 // TODO(port): the ifdefs in here are a first step towards trying to determine
6 // the correct abstraction for all the OS functionality required at this 6 // the correct abstraction for all the OS functionality required at this
7 // stage of process initialization. It should not be taken as a final 7 // stage of process initialization. It should not be taken as a final
8 // abstraction. 8 // abstraction.
9 9
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 execlp("man", "man", binary.BaseName().value().c_str(), NULL); 368 execlp("man", "man", binary.BaseName().value().c_str(), NULL);
369 PLOG(FATAL) << "execlp failed"; 369 PLOG(FATAL) << "execlp failed";
370 } 370 }
371 #endif 371 #endif
372 372
373 #if defined(OS_POSIX) 373 #if defined(OS_POSIX)
374 // Always ignore SIGPIPE. We check the return value of write(). 374 // Always ignore SIGPIPE. We check the return value of write().
375 CHECK(signal(SIGPIPE, SIG_IGN) != SIG_ERR); 375 CHECK(signal(SIGPIPE, SIG_IGN) != SIG_ERR);
376 #endif // OS_POSIX 376 #endif // OS_POSIX
377 377
378 int browser_pid; 378 base::ProcessId browser_pid;
379 if (process_type.empty()) { 379 if (process_type.empty()) {
380 browser_pid = base::GetCurrentProcId(); 380 browser_pid = base::GetCurrentProcId();
381 } else { 381 } else {
382 #if defined(OS_WIN) 382 #if defined(OS_WIN)
383 std::wstring channel_name = 383 std::wstring channel_name =
384 parsed_command_line.GetSwitchValue(switches::kProcessChannelID); 384 parsed_command_line.GetSwitchValue(switches::kProcessChannelID);
385 385
386 browser_pid = StringToInt(WideToASCII(channel_name)); 386 browser_pid =
387 static_cast<base::ProcessId>(StringToInt(WideToASCII(channel_name)));
387 DCHECK(browser_pid != 0); 388 DCHECK(browser_pid != 0);
388 #else 389 #else
389 browser_pid = base::GetCurrentProcId(); 390 browser_pid = base::GetCurrentProcId();
390 #endif 391 #endif
391 392
392 #if defined(OS_POSIX) 393 #if defined(OS_POSIX)
393 // When you hit Ctrl-C in a terminal running the browser 394 // When you hit Ctrl-C in a terminal running the browser
394 // process, a SIGINT is delivered to the entire process group. 395 // process, a SIGINT is delivered to the entire process group.
395 // When debugging the browser process via gdb, gdb catches the 396 // When debugging the browser process via gdb, gdb catches the
396 // SIGINT for the browser process (and dumps you back to the gdb 397 // SIGINT for the browser process (and dumps you back to the gdb
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 #endif // OS_MACOSX 449 #endif // OS_MACOSX
449 450
450 // Initialize the Stats Counters table. With this initialized, 451 // Initialize the Stats Counters table. With this initialized,
451 // the StatsViewer can be utilized to read counters outside of 452 // the StatsViewer can be utilized to read counters outside of
452 // Chrome. These lines can be commented out to effectively turn 453 // Chrome. These lines can be commented out to effectively turn
453 // counters 'off'. The table is created and exists for the life 454 // counters 'off'. The table is created and exists for the life
454 // of the process. It is not cleaned up. 455 // of the process. It is not cleaned up.
455 // TODO(port): we probably need to shut this down correctly to avoid 456 // TODO(port): we probably need to shut this down correctly to avoid
456 // leaking shared memory regions on posix platforms. 457 // leaking shared memory regions on posix platforms.
457 if (parsed_command_line.HasSwitch(switches::kEnableStatsTable)) { 458 if (parsed_command_line.HasSwitch(switches::kEnableStatsTable)) {
458 std::string statsfile = 459 std::string statsfile = StringPrintf("%s-%lld", chrome::kStatsFilename,
459 StringPrintf("%s-%d", chrome::kStatsFilename, browser_pid); 460 static_cast<int64>(browser_pid));
460 StatsTable *stats_table = new StatsTable(statsfile, 461 StatsTable *stats_table = new StatsTable(statsfile,
461 chrome::kStatsMaxThreads, chrome::kStatsMaxCounters); 462 chrome::kStatsMaxThreads, chrome::kStatsMaxCounters);
462 StatsTable::set_current(stats_table); 463 StatsTable::set_current(stats_table);
463 } 464 }
464 465
465 StatsScope<StatsCounterTimer> 466 StatsScope<StatsCounterTimer>
466 startup_timer(chrome::Counters::chrome_main()); 467 startup_timer(chrome::Counters::chrome_main());
467 468
468 // Enable the heap profiler as early as possible! 469 // Enable the heap profiler as early as possible!
469 EnableHeapProfiler(parsed_command_line); 470 EnableHeapProfiler(parsed_command_line);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 617
617 logging::CleanupChromeLogging(); 618 logging::CleanupChromeLogging();
618 619
619 #if defined(OS_MACOSX) && defined(GOOGLE_CHROME_BUILD) 620 #if defined(OS_MACOSX) && defined(GOOGLE_CHROME_BUILD)
620 // TODO(mark): See the TODO(mark) above at InitCrashReporter. 621 // TODO(mark): See the TODO(mark) above at InitCrashReporter.
621 DestructCrashReporter(); 622 DestructCrashReporter();
622 #endif // OS_MACOSX && GOOGLE_CHROME_BUILD 623 #endif // OS_MACOSX && GOOGLE_CHROME_BUILD
623 624
624 return rv; 625 return rv;
625 } 626 }
OLDNEW
« no previous file with comments | « base/process_util_posix.cc ('k') | chrome/browser/memory_details.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698