Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/browser/android/content_startup_flags.h" | 5 #include "content/browser/android/content_startup_flags.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "cc/base/switches.h" | 11 #include "cc/base/switches.h" |
| 12 #include "content/public/browser/render_process_host.h" | 12 #include "content/public/browser/render_process_host.h" |
| 13 #include "content/public/common/content_constants.h" | 13 #include "content/public/common/content_constants.h" |
| 14 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
| 15 #include "gpu/command_buffer/service/gpu_switches.h" | 15 #include "gpu/command_buffer/service/gpu_switches.h" |
| 16 #include "ui/base/ui_base_switches.h" | 16 #include "ui/base/ui_base_switches.h" |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 | 19 |
| 20 void SetContentCommandLineFlags(int max_render_process_count, | 20 void SetContentCommandLineFlags(int max_render_process_count, |
| 21 const std::string& plugin_descriptor) { | 21 const std::string& plugin_descriptor) { |
| 22 // May be called multiple times, to cover all possible program entry points. | 22 // May be called multiple times, to cover all possible program entry points. |
| 23 static bool already_initialized = false; | 23 static bool already_initialized = false; |
| 24 if (already_initialized) | 24 if (already_initialized) |
| 25 return; | 25 return; |
| 26 already_initialized = true; | 26 already_initialized = true; |
| 27 | 27 |
| 28 CommandLine* parsed_command_line = CommandLine::ForCurrentProcess(); | 28 CommandLine* parsed_command_line = CommandLine::ForCurrentProcess(); |
| 29 | 29 |
| 30 int command_line_renderer_limit = -1; | |
| 30 if (parsed_command_line->HasSwitch(switches::kRendererProcessLimit)) { | 31 if (parsed_command_line->HasSwitch(switches::kRendererProcessLimit)) { |
| 31 std::string limit = parsed_command_line->GetSwitchValueASCII( | 32 std::string limit = parsed_command_line->GetSwitchValueASCII( |
| 32 switches::kRendererProcessLimit); | 33 switches::kRendererProcessLimit); |
| 33 int value; | 34 int value; |
| 34 if (base::StringToInt(limit, &value)) | 35 if (base::StringToInt(limit, &value)) |
| 35 max_render_process_count = value; | 36 command_line_renderer_limit = value; |
| 36 } | 37 } |
| 37 | 38 |
| 38 if (max_render_process_count <= 0) { | 39 if (command_line_renderer_limit != -1) { |
|
aberent
2014/01/24 21:29:09
What happens if command_line_render_limit is set b
kbalazs
2014/01/29 16:55:43
I think the command line should override everythin
| |
| 40 int limit = std::min(command_line_renderer_limit, | |
| 41 static_cast<int>(kMaxRendererProcessCount)); | |
| 42 RenderProcessHost::SetMaxRendererProcessCount(limit); | |
| 43 } else if (max_render_process_count <= 0) { | |
| 39 // Need to ensure the command line flag is consistent as a lot of chrome | 44 // Need to ensure the command line flag is consistent as a lot of chrome |
| 40 // internal code checks this directly, but it wouldn't normally get set when | 45 // internal code checks this directly, but it wouldn't normally get set when |
| 41 // we are implementing an embedded WebView. | 46 // we are implementing an embedded WebView. |
| 42 parsed_command_line->AppendSwitch(switches::kSingleProcess); | 47 parsed_command_line->AppendSwitch(switches::kSingleProcess); |
| 43 } else { | 48 } else { |
| 44 max_render_process_count = | 49 int default_maximum = RenderProcessHost::GetMaxRendererProcessCount(); |
|
aberent
2014/01/24 21:29:09
If I am reading this right then GetMaxRendererProc
kbalazs
2014/01/29 16:55:43
Yes, this was my intent. This is consistent with t
| |
| 45 std::min(max_render_process_count, | 50 DCHECK(default_maximum <= kMaxRendererProcessCount); |
| 46 static_cast<int>(content::kMaxRendererProcessCount)); | 51 if (max_render_process_count < default_maximum) { |
| 47 content::RenderProcessHost::SetMaxRendererProcessCount( | 52 content::RenderProcessHost::SetMaxRendererProcessCount( |
|
aberent
2014/01/24 21:29:09
Why content::RenderProcessHost here, but simply Re
kbalazs
2014/01/29 16:55:43
by mistake
| |
| 48 max_render_process_count); | 53 max_render_process_count); |
| 54 } | |
| 49 } | 55 } |
| 50 | 56 |
| 51 parsed_command_line->AppendSwitch(switches::kForceCompositingMode); | 57 parsed_command_line->AppendSwitch(switches::kForceCompositingMode); |
| 52 parsed_command_line->AppendSwitch(switches::kAllowWebUICompositing); | 58 parsed_command_line->AppendSwitch(switches::kAllowWebUICompositing); |
| 53 parsed_command_line->AppendSwitch(switches::kEnableThreadedCompositing); | 59 parsed_command_line->AppendSwitch(switches::kEnableThreadedCompositing); |
| 54 parsed_command_line->AppendSwitch( | 60 parsed_command_line->AppendSwitch( |
| 55 switches::kEnableCompositingForFixedPosition); | 61 switches::kEnableCompositingForFixedPosition); |
| 56 parsed_command_line->AppendSwitch(switches::kEnableAcceleratedOverflowScroll); | 62 parsed_command_line->AppendSwitch(switches::kEnableAcceleratedOverflowScroll); |
| 57 parsed_command_line->AppendSwitch( | 63 parsed_command_line->AppendSwitch( |
| 58 switches::kEnableAcceleratedScrollableFrames); | 64 switches::kEnableAcceleratedScrollableFrames); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 } | 98 } |
| 93 | 99 |
| 94 // Disable profiler timing by default. | 100 // Disable profiler timing by default. |
| 95 if (!parsed_command_line->HasSwitch(switches::kProfilerTiming)) { | 101 if (!parsed_command_line->HasSwitch(switches::kProfilerTiming)) { |
| 96 parsed_command_line->AppendSwitchASCII( | 102 parsed_command_line->AppendSwitchASCII( |
| 97 switches::kProfilerTiming, switches::kProfilerTimingDisabledValue); | 103 switches::kProfilerTiming, switches::kProfilerTimingDisabledValue); |
| 98 } | 104 } |
| 99 } | 105 } |
| 100 | 106 |
| 101 } // namespace content | 107 } // namespace content |
| OLD | NEW |