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

Unified Diff: chrome/app/chrome_dll_main.cc

Issue 3051003: Fix stats table on linux. There were two problems:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/app/chrome_dll_main.cc
===================================================================
--- chrome/app/chrome_dll_main.cc (revision 52678)
+++ chrome/app/chrome_dll_main.cc (working copy)
@@ -413,6 +413,26 @@
}
#endif // defined(OS_MACOSX)
+void InitializeStatsTable(base::ProcessId browser_pid,
+ const CommandLine & parsed_command_line) {
+ // Initialize the Stats Counters table. With this initialized,
+ // the StatsViewer can be utilized to read counters outside of
+ // Chrome. These lines can be commented out to effectively turn
+ // counters 'off'. The table is created and exists for the life
+ // of the process. It is not cleaned up.
+ if (parsed_command_line.HasSwitch(switches::kEnableStatsTable) ||
+ parsed_command_line.HasSwitch(switches::kEnableBenchmarking)) {
+ // NOTIMPLEMENTED: we probably need to shut this down correctly to avoid
+ // leaking shared memory regions on posix platforms.
+ std::string statsfile =
+ StringPrintf("%s-%u", chrome::kStatsFilename,
+ static_cast<unsigned int>(browser_pid));
+ StatsTable *stats_table = new StatsTable(statsfile,
+ chrome::kStatsMaxThreads, chrome::kStatsMaxCounters);
+ StatsTable::set_current(stats_table);
+ }
+}
+
} // namespace
#if defined(OS_WIN)
@@ -556,8 +576,11 @@
browser_pid =
static_cast<base::ProcessId>(StringToInt(WideToASCII(channel_name)));
DCHECK_NE(browser_pid, 0u);
-#else
+#elif defined(OS_MACOSX)
browser_pid = base::GetCurrentProcId();
+#elif defined(OS_POSIX)
+ // On linux, we're in the zygote here; so we need the parent process' id.
+ browser_pid = base::GetParentProcessId(base::GetCurrentProcId());
#endif
#if defined(OS_POSIX)
@@ -618,22 +641,7 @@
InitCrashProcessInfo();
#endif // OS_MACOSX
- // Initialize the Stats Counters table. With this initialized,
- // the StatsViewer can be utilized to read counters outside of
- // Chrome. These lines can be commented out to effectively turn
- // counters 'off'. The table is created and exists for the life
- // of the process. It is not cleaned up.
- // TODO(port): we probably need to shut this down correctly to avoid
- // leaking shared memory regions on posix platforms.
- if (parsed_command_line.HasSwitch(switches::kEnableStatsTable) ||
- parsed_command_line.HasSwitch(switches::kEnableBenchmarking)) {
- std::string statsfile =
- StringPrintf("%s-%u", chrome::kStatsFilename,
- static_cast<unsigned int>(browser_pid));
- StatsTable *stats_table = new StatsTable(statsfile,
- chrome::kStatsMaxThreads, chrome::kStatsMaxCounters);
- StatsTable::set_current(stats_table);
- }
+ InitializeStatsTable(browser_pid, parsed_command_line);
StatsScope<StatsCounterTimer>
startup_timer(chrome::Counters::chrome_main());
@@ -796,6 +804,12 @@
// line so update it here with the new version.
const CommandLine& parsed_command_line =
*CommandLine::ForCurrentProcess();
+
+ // The StatsTable must be initialized in each process; we already
+ // initialized for the browser process, now we need to initialize
+ // within the new processes as well.
+ InitializeStatsTable(browser_pid, parsed_command_line);
Evan Martin 2010/11/22 22:19:22 Hey, remember this old change? I am touching this
Mike Belshe 2010/11/22 22:30:52 I can't recall exactly what was broken before - bu
Evan Martin 2010/11/22 22:32:31 Can you advise me how I can test whether my refact
+
MainFunctionParams main_params(parsed_command_line, sandbox_wrapper,
&autorelease_pool);
std::string process_type =
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698