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

Side by Side Diff: content/app/content_main_runner.cc

Issue 1610153002: Allocator cleanup: move tcmalloc-specific calls to base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup_nonbase_tcmalloc_1
Patch Set: rebase Created 4 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/public/app/content_main_runner.h" 5 #include "content/public/app/content_main_runner.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <string.h> 9 #include <string.h>
10 #include <string> 10 #include <string>
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) 108 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
109 #include "content/zygote/zygote_main.h" 109 #include "content/zygote/zygote_main.h"
110 #endif 110 #endif
111 111
112 #endif // OS_POSIX 112 #endif // OS_POSIX
113 113
114 #if defined(USE_NSS_CERTS) 114 #if defined(USE_NSS_CERTS)
115 #include "crypto/nss_util.h" 115 #include "crypto/nss_util.h"
116 #endif 116 #endif
117 117
118 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC)
119 extern "C" {
120 int tc_set_new_mode(int mode);
121 }
122 #endif
123
124 namespace content { 118 namespace content {
125 extern int GpuMain(const content::MainFunctionParams&); 119 extern int GpuMain(const content::MainFunctionParams&);
126 #if defined(ENABLE_PLUGINS) 120 #if defined(ENABLE_PLUGINS)
127 #if !defined(OS_LINUX) 121 #if !defined(OS_LINUX)
128 extern int PluginMain(const content::MainFunctionParams&); 122 extern int PluginMain(const content::MainFunctionParams&);
129 #endif 123 #endif
130 extern int PpapiPluginMain(const MainFunctionParams&); 124 extern int PpapiPluginMain(const MainFunctionParams&);
131 extern int PpapiBrokerMain(const MainFunctionParams&); 125 extern int PpapiBrokerMain(const MainFunctionParams&);
132 #endif 126 #endif
133 extern int RendererMain(const content::MainFunctionParams&); 127 extern int RendererMain(const content::MainFunctionParams&);
134 extern int UtilityMain(const MainFunctionParams&); 128 extern int UtilityMain(const MainFunctionParams&);
135 } // namespace content 129 } // namespace content
136 130
137 namespace content { 131 namespace content {
138 132
139 #if !defined(CHROME_MULTIPLE_DLL_CHILD) 133 #if !defined(CHROME_MULTIPLE_DLL_CHILD)
140 base::LazyInstance<ContentBrowserClient> 134 base::LazyInstance<ContentBrowserClient>
141 g_empty_content_browser_client = LAZY_INSTANCE_INITIALIZER; 135 g_empty_content_browser_client = LAZY_INSTANCE_INITIALIZER;
142 #endif // !CHROME_MULTIPLE_DLL_CHILD 136 #endif // !CHROME_MULTIPLE_DLL_CHILD
143 137
144 #if !defined(OS_IOS) && !defined(CHROME_MULTIPLE_DLL_BROWSER) 138 #if !defined(OS_IOS) && !defined(CHROME_MULTIPLE_DLL_BROWSER)
145 base::LazyInstance<ContentPluginClient> 139 base::LazyInstance<ContentPluginClient>
146 g_empty_content_plugin_client = LAZY_INSTANCE_INITIALIZER; 140 g_empty_content_plugin_client = LAZY_INSTANCE_INITIALIZER;
147 base::LazyInstance<ContentRendererClient> 141 base::LazyInstance<ContentRendererClient>
148 g_empty_content_renderer_client = LAZY_INSTANCE_INITIALIZER; 142 g_empty_content_renderer_client = LAZY_INSTANCE_INITIALIZER;
149 base::LazyInstance<ContentUtilityClient> 143 base::LazyInstance<ContentUtilityClient>
150 g_empty_content_utility_client = LAZY_INSTANCE_INITIALIZER; 144 g_empty_content_utility_client = LAZY_INSTANCE_INITIALIZER;
151 #endif // !OS_IOS && !CHROME_MULTIPLE_DLL_BROWSER 145 #endif // !OS_IOS && !CHROME_MULTIPLE_DLL_BROWSER
152 146
153 #if defined(OS_WIN)
154
155 #endif // defined(OS_WIN)
156
157 #if defined(OS_POSIX) && !defined(OS_IOS) 147 #if defined(OS_POSIX) && !defined(OS_IOS)
158 148
159 // Setup signal-handling state: resanitize most signals, ignore SIGPIPE. 149 // Setup signal-handling state: resanitize most signals, ignore SIGPIPE.
160 void SetupSignalHandlers() { 150 void SetupSignalHandlers() {
161 // Sanitise our signal handling state. Signals that were ignored by our 151 // Sanitise our signal handling state. Signals that were ignored by our
162 // parent will also be ignored by us. We also inherit our parent's sigmask. 152 // parent will also be ignored by us. We also inherit our parent's sigmask.
163 sigset_t empty_signal_set; 153 sigset_t empty_signal_set;
164 CHECK_EQ(0, sigemptyset(&empty_signal_set)); 154 CHECK_EQ(0, sigemptyset(&empty_signal_set));
165 CHECK_EQ(0, sigprocmask(SIG_SETMASK, &empty_signal_set, NULL)); 155 CHECK_EQ(0, sigprocmask(SIG_SETMASK, &empty_signal_set, NULL));
166 156
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 sandbox_info_ = *params.sandbox_info; 418 sandbox_info_ = *params.sandbox_info;
429 #else // !OS_WIN 419 #else // !OS_WIN
430 420
431 #if defined(OS_ANDROID) 421 #if defined(OS_ANDROID)
432 // See note at the initialization of ExitManager, below; basically, 422 // See note at the initialization of ExitManager, below; basically,
433 // only Android builds have the ctor/dtor handlers set up to use 423 // only Android builds have the ctor/dtor handlers set up to use
434 // TRACE_EVENT right away. 424 // TRACE_EVENT right away.
435 TRACE_EVENT0("startup,benchmark", "ContentMainRunnerImpl::Initialize"); 425 TRACE_EVENT0("startup,benchmark", "ContentMainRunnerImpl::Initialize");
436 #endif // OS_ANDROID 426 #endif // OS_ANDROID
437 427
438 // NOTE(willchan): One might ask why these TCMalloc-related calls are done
439 // here rather than in process_util_linux.cc with the definition of
440 // EnableTerminationOnOutOfMemory(). That's because base shouldn't have a
441 // dependency on TCMalloc. Really, we ought to have our allocator shim code
442 // implement this EnableTerminationOnOutOfMemory() function. Whateverz.
443 // This works for now.
444 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) 428 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC)
445 // For tcmalloc, we need to tell it to behave like new.
446 tc_set_new_mode(1);
447
448 // Provide optional hook for monitoring allocation quantities on a 429 // Provide optional hook for monitoring allocation quantities on a
449 // per-thread basis. Only set the hook if the environment indicates this 430 // per-thread basis. Only set the hook if the environment indicates this
450 // needs to be enabled. 431 // needs to be enabled.
451 const char* profiling = getenv(tracked_objects::kAlternateProfilerTime); 432 const char* profiling = getenv(tracked_objects::kAlternateProfilerTime);
452 if (profiling && 433 if (profiling &&
453 (atoi(profiling) == tracked_objects::TIME_SOURCE_TYPE_TCMALLOC)) { 434 (atoi(profiling) == tracked_objects::TIME_SOURCE_TYPE_TCMALLOC)) {
454 tracked_objects::SetAlternateTimeSource( 435 tracked_objects::SetAlternateTimeSource(
455 MallocExtension::GetBytesAllocatedOnCurrentThread, 436 MallocExtension::GetBytesAllocatedOnCurrentThread,
456 tracked_objects::TIME_SOURCE_TYPE_TCMALLOC); 437 tracked_objects::TIME_SOURCE_TYPE_TCMALLOC);
457 } 438 }
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 813
833 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); 814 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl);
834 }; 815 };
835 816
836 // static 817 // static
837 ContentMainRunner* ContentMainRunner::Create() { 818 ContentMainRunner* ContentMainRunner::Create() {
838 return new ContentMainRunnerImpl(); 819 return new ContentMainRunnerImpl();
839 } 820 }
840 821
841 } // namespace content 822 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698