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

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

Issue 8113035: Remove RenderProcessHost::is_extension_process (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/lazy_instance.h" 6 #include "base/lazy_instance.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/metrics/stats_counters.h" 9 #include "base/metrics/stats_counters.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 12 matching lines...) Expand all
23 #include "chrome/common/chrome_version_info.h" 23 #include "chrome/common/chrome_version_info.h"
24 #include "chrome/common/logging_chrome.h" 24 #include "chrome/common/logging_chrome.h"
25 #include "chrome/common/profiling.h" 25 #include "chrome/common/profiling.h"
26 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
27 #include "chrome/plugin/chrome_content_plugin_client.h" 27 #include "chrome/plugin/chrome_content_plugin_client.h"
28 #include "chrome/renderer/chrome_content_renderer_client.h" 28 #include "chrome/renderer/chrome_content_renderer_client.h"
29 #include "chrome/utility/chrome_content_utility_client.h" 29 #include "chrome/utility/chrome_content_utility_client.h"
30 #include "content/app/content_main.h" 30 #include "content/app/content_main.h"
31 #include "content/app/content_main_delegate.h" 31 #include "content/app/content_main_delegate.h"
32 #include "content/browser/renderer_host/render_process_host.h" 32 #include "content/browser/renderer_host/render_process_host.h"
33 #include "content/renderer/renderer_main.h" 33 #include "content/renderer/renderer_main.h"
jam 2011/10/04 16:59:22 this isn't needed anymore. we now actually don't e
jochen (gone - plz use gerrit) 2011/10/04 18:50:19 Done.
34 #include "content/common/content_client.h" 34 #include "content/common/content_client.h"
35 #include "content/common/content_counters.h" 35 #include "content/common/content_counters.h"
36 #include "content/common/content_paths.h" 36 #include "content/common/content_paths.h"
37 #include "content/common/content_switches.h" 37 #include "content/common/content_switches.h"
38 #include "media/base/media.h" 38 #include "media/base/media.h"
39 #include "ui/base/resource/resource_bundle.h" 39 #include "ui/base/resource/resource_bundle.h"
40 #include "ui/base/ui_base_switches.h" 40 #include "ui/base/ui_base_switches.h"
41 41
42 #if defined(OS_WIN) 42 #if defined(OS_WIN)
43 #include <algorithm> 43 #include <algorithm>
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 score = kMiscScore; 227 score = kMiscScore;
228 #ifndef DISABLE_NACL 228 #ifndef DISABLE_NACL
229 } else if (process_type == switches::kNaClLoaderProcess) { 229 } else if (process_type == switches::kNaClLoaderProcess) {
230 score = kPluginScore; 230 score = kPluginScore;
231 #endif 231 #endif
232 } else if (process_type == switches::kZygoteProcess || 232 } else if (process_type == switches::kZygoteProcess ||
233 process_type.empty()) { 233 process_type.empty()) {
234 // For zygotes and unlabeled process types, we want to still make 234 // For zygotes and unlabeled process types, we want to still make
235 // them killable by the OOM killer. 235 // them killable by the OOM killer.
236 score = kZygoteScore; 236 score = kZygoteScore;
237 } else if (process_type == switches::kExtensionProcess || 237 } else if (process_type == switches::kRendererProcess) {
238 process_type == switches::kRendererProcess) { 238 LOG(WARNING) << "process type 'renderer' "
239 LOG(WARNING) << "process type '" << process_type << "' "
240 << "should be created through the zygote."; 239 << "should be created through the zygote.";
241 // When debugging, these process types can end up being run 240 // When debugging, this process type can end up being run directly, but
242 // directly, but this isn't the typical path for assigning the OOM 241 // this isn't the typical path for assigning the OOM score for it. Still,
243 // score for them. Still, we want to assign a score that is 242 // we want to assign a score that is somewhat representative for debugging.
244 // somewhat representative for debugging.
245 score = kRendererScore; 243 score = kRendererScore;
246 } else { 244 } else {
247 NOTREACHED() << "Unknown process type"; 245 NOTREACHED() << "Unknown process type";
248 } 246 }
249 if (score > -1) 247 if (score > -1)
250 base::AdjustOOMScore(base::GetCurrentProcId(), score); 248 base::AdjustOOMScore(base::GetCurrentProcId(), score);
251 } 249 }
252 #endif // defined(OS_LINUX) 250 #endif // defined(OS_LINUX)
253 251
254 // Enable the heap profiler if the appropriate command-line switch is 252 // Enable the heap profiler if the appropriate command-line switch is
(...skipping 11 matching lines...) Expand all
266 &g_chrome_content_renderer_client.Get()); 264 &g_chrome_content_renderer_client.Get());
267 } 265 }
268 266
269 void InitializeChromeContentClient(const std::string& process_type) { 267 void InitializeChromeContentClient(const std::string& process_type) {
270 if (process_type.empty()) { 268 if (process_type.empty()) {
271 content::GetContentClient()->set_browser( 269 content::GetContentClient()->set_browser(
272 &g_chrome_content_browser_client.Get()); 270 &g_chrome_content_browser_client.Get());
273 } else if (process_type == switches::kPluginProcess) { 271 } else if (process_type == switches::kPluginProcess) {
274 content::GetContentClient()->set_plugin( 272 content::GetContentClient()->set_plugin(
275 &g_chrome_content_plugin_client.Get()); 273 &g_chrome_content_plugin_client.Get());
276 } else if (process_type == switches::kRendererProcess || 274 } else if (process_type == switches::kRendererProcess) {
277 process_type == switches::kExtensionProcess) {
278 InitializeChromeContentRendererClient(); 275 InitializeChromeContentRendererClient();
279 } else if (process_type == switches::kUtilityProcess) { 276 } else if (process_type == switches::kUtilityProcess) {
280 content::GetContentClient()->set_utility( 277 content::GetContentClient()->set_utility(
281 &g_chrome_content_utility_client.Get()); 278 &g_chrome_content_utility_client.Get());
282 } 279 }
283 } 280 }
284 281
285 // Returns true if this subprocess type needs the ResourceBundle initialized 282 // Returns true if this subprocess type needs the ResourceBundle initialized
286 // and resources loaded. 283 // and resources loaded.
287 bool SubprocessNeedsResourceBundle(const std::string& process_type) { 284 bool SubprocessNeedsResourceBundle(const std::string& process_type) {
288 return 285 return
289 #if defined(OS_WIN) || defined(OS_MACOSX) 286 #if defined(OS_WIN) || defined(OS_MACOSX)
290 // Windows needs resources for the default/null plugin. 287 // Windows needs resources for the default/null plugin.
291 // Mac needs them for the plugin process name. 288 // Mac needs them for the plugin process name.
292 process_type == switches::kPluginProcess || 289 process_type == switches::kPluginProcess ||
293 #endif 290 #endif
294 #if defined(OS_POSIX) && !defined(OS_MACOSX) 291 #if defined(OS_POSIX) && !defined(OS_MACOSX)
295 // The zygote process opens the resources for the renderers. 292 // The zygote process opens the resources for the renderers.
296 process_type == switches::kZygoteProcess || 293 process_type == switches::kZygoteProcess ||
297 #endif 294 #endif
298 #if defined(OS_MACOSX) 295 #if defined(OS_MACOSX)
299 // Mac needs them to for scrollbar related images. 296 // Mac needs them to for scrollbar related images.
300 process_type == switches::kWorkerProcess || 297 process_type == switches::kWorkerProcess ||
301 #endif 298 #endif
302 process_type == switches::kRendererProcess || 299 process_type == switches::kRendererProcess ||
303 process_type == switches::kExtensionProcess ||
304 process_type == switches::kUtilityProcess; 300 process_type == switches::kUtilityProcess;
305 } 301 }
306 302
307 #if defined(OS_MACOSX) 303 #if defined(OS_MACOSX)
308 // Update the name shown in Activity Monitor so users are less likely to ask 304 // Update the name shown in Activity Monitor so users are less likely to ask
309 // why Chrome has so many processes. 305 // why Chrome has so many processes.
310 void SetMacProcessName(const std::string& process_type) { 306 void SetMacProcessName(const std::string& process_type) {
311 // Don't worry about the browser process, its gets the stock name. 307 // Don't worry about the browser process, its gets the stock name.
312 int name_id = 0; 308 int name_id = 0;
313 if (process_type == switches::kRendererProcess) { 309 if (process_type == switches::kRendererProcess) {
314 name_id = IDS_RENDERER_APP_NAME; 310 name_id = IDS_RENDERER_APP_NAME;
315 } else if (process_type == switches::kPluginProcess || 311 } else if (process_type == switches::kPluginProcess ||
316 process_type == switches::kPpapiPluginProcess) { 312 process_type == switches::kPpapiPluginProcess) {
317 name_id = IDS_PLUGIN_APP_NAME; 313 name_id = IDS_PLUGIN_APP_NAME;
318 } else if (process_type == switches::kExtensionProcess) {
319 name_id = IDS_WORKER_APP_NAME;
jam 2011/10/04 16:59:22 do we want to use this in the "process_type == swi
jochen (gone - plz use gerrit) 2011/10/04 18:50:19 Done.
320 } else if (process_type == switches::kUtilityProcess) { 314 } else if (process_type == switches::kUtilityProcess) {
321 name_id = IDS_UTILITY_APP_NAME; 315 name_id = IDS_UTILITY_APP_NAME;
322 } 316 }
323 if (name_id) { 317 if (name_id) {
324 NSString* app_name = l10n_util::GetNSString(name_id); 318 NSString* app_name = l10n_util::GetNSString(name_id);
325 base::mac::SetProcessName(base::mac::NSToCFCast(app_name)); 319 base::mac::SetProcessName(base::mac::NSToCFCast(app_name));
326 } 320 }
327 } 321 }
328 322
329 #endif // defined(OS_MACOSX) 323 #endif // defined(OS_MACOSX)
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 // AdjustLinuxOOMScore function too. 633 // AdjustLinuxOOMScore function too.
640 #if defined(OS_LINUX) 634 #if defined(OS_LINUX)
641 AdjustLinuxOOMScore(process_type); 635 AdjustLinuxOOMScore(process_type);
642 #endif 636 #endif
643 } 637 }
644 638
645 virtual int RunProcess( 639 virtual int RunProcess(
646 const std::string& process_type, 640 const std::string& process_type,
647 const MainFunctionParams& main_function_params) OVERRIDE { 641 const MainFunctionParams& main_function_params) OVERRIDE {
648 static const MainFunction kMainFunctions[] = { 642 static const MainFunction kMainFunctions[] = {
649 // An extension process is just a renderer process. We use a different
650 // command line argument to differentiate crash reports.
651 { switches::kExtensionProcess, RendererMain },
652 { switches::kServiceProcess, ServiceProcessMain }, 643 { switches::kServiceProcess, ServiceProcessMain },
653 #if defined(OS_MACOSX) 644 #if defined(OS_MACOSX)
654 { switches::kRelauncherProcess, 645 { switches::kRelauncherProcess,
655 mac_relauncher::internal::RelauncherMain }, 646 mac_relauncher::internal::RelauncherMain },
656 #endif 647 #endif
657 #if !defined(DISABLE_NACL) 648 #if !defined(DISABLE_NACL)
658 { switches::kNaClLoaderProcess, NaClMain }, 649 { switches::kNaClLoaderProcess, NaClMain },
659 #endif // DISABLE_NACL 650 #endif // DISABLE_NACL
660 }; 651 };
661 652
(...skipping 14 matching lines...) Expand all
676 667
677 #if defined(OS_MACOSX) && defined(GOOGLE_CHROME_BUILD) 668 #if defined(OS_MACOSX) && defined(GOOGLE_CHROME_BUILD)
678 // TODO(mark): See the TODO(mark) at InitCrashReporter. 669 // TODO(mark): See the TODO(mark) at InitCrashReporter.
679 DestructCrashReporter(); 670 DestructCrashReporter();
680 #endif // OS_MACOSX && GOOGLE_CHROME_BUILD 671 #endif // OS_MACOSX && GOOGLE_CHROME_BUILD
681 } 672 }
682 673
683 #if defined(OS_MACOSX) 674 #if defined(OS_MACOSX)
684 virtual bool ProcessRegistersWithSystemProcess( 675 virtual bool ProcessRegistersWithSystemProcess(
685 const std::string& process_type) OVERRIDE { 676 const std::string& process_type) OVERRIDE {
686 return process_type == switches::kNaClLoaderProcess || 677 return process_type == switches::kNaClLoaderProcess;
687 process_type == switches::kExtensionProcess;
688 } 678 }
689 679
690 virtual bool ShouldSendMachPort(const std::string& process_type) OVERRIDE { 680 virtual bool ShouldSendMachPort(const std::string& process_type) OVERRIDE {
691 return process_type != switches::kRelauncherProcess && 681 return process_type != switches::kRelauncherProcess &&
692 process_type != switches::kServiceProcess; 682 process_type != switches::kServiceProcess;
693 } 683 }
694 684
695 virtual bool DelaySandboxInitialization( 685 virtual bool DelaySandboxInitialization(
696 const std::string& process_type) OVERRIDE { 686 const std::string& process_type) OVERRIDE {
697 // Extensions are really renderers.
698 // NaClLoader does this in NaClMainPlatformDelegate::EnableSandbox(). 687 // NaClLoader does this in NaClMainPlatformDelegate::EnableSandbox().
699 // No sandbox needed for relauncher. 688 // No sandbox needed for relauncher.
700 return process_type == switches::kExtensionProcess || 689 return process_type == switches::kNaClLoaderProcess ||
701 process_type == switches::kNaClLoaderProcess ||
702 process_type == switches::kRelauncherProcess; 690 process_type == switches::kRelauncherProcess;
703 } 691 }
704 #elif defined(OS_POSIX) 692 #elif defined(OS_POSIX)
705 virtual ZygoteForkDelegate* ZygoteStarting() OVERRIDE { 693 virtual ZygoteForkDelegate* ZygoteStarting() OVERRIDE {
706 // Each Renderer we spawn will re-attempt initialization of the media 694 // Each Renderer we spawn will re-attempt initialization of the media
707 // libraries, at which point failure will be detected and handled, so 695 // libraries, at which point failure will be detected and handled, so
708 // we do not need to cope with initialization failures here. 696 // we do not need to cope with initialization failures here.
709 FilePath media_path; 697 FilePath media_path;
710 if (PathService::Get(chrome::DIR_MEDIA_LIBS, &media_path)) 698 if (PathService::Get(chrome::DIR_MEDIA_LIBS, &media_path))
711 media::InitializeMediaLibrary(media_path); 699 media::InitializeMediaLibrary(media_path);
(...skipping 30 matching lines...) Expand all
742 DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance, 730 DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance,
743 sandbox::SandboxInterfaceInfo* sandbox_info) { 731 sandbox::SandboxInterfaceInfo* sandbox_info) {
744 ChromeMainDelegate chrome_main_delegate; 732 ChromeMainDelegate chrome_main_delegate;
745 return content::ContentMain(instance, sandbox_info, &chrome_main_delegate); 733 return content::ContentMain(instance, sandbox_info, &chrome_main_delegate);
746 #elif defined(OS_POSIX) 734 #elif defined(OS_POSIX)
747 int ChromeMain(int argc, const char** argv) { 735 int ChromeMain(int argc, const char** argv) {
748 ChromeMainDelegate chrome_main_delegate; 736 ChromeMainDelegate chrome_main_delegate;
749 return content::ContentMain(argc, argv, &chrome_main_delegate); 737 return content::ContentMain(argc, argv, &chrome_main_delegate);
750 #endif 738 #endif
751 } 739 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698