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

Side by Side Diff: content/browser/browser_main_loop.cc

Issue 9328011: Adding a command line flag to specify renderer process limit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding unit test for the command line parameter Created 8 years, 10 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) 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/browser_main_loop.h" 5 #include "content/browser/browser_main_loop.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/metrics/field_trial.h" 12 #include "base/metrics/field_trial.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/string_number_conversions.h"
14 #include "base/threading/thread_restrictions.h" 15 #include "base/threading/thread_restrictions.h"
15 #include "content/browser/browser_thread_impl.h" 16 #include "content/browser/browser_thread_impl.h"
16 #include "content/browser/download/download_file_manager.h" 17 #include "content/browser/download/download_file_manager.h"
17 #include "content/browser/download/save_file_manager.h" 18 #include "content/browser/download/save_file_manager.h"
18 #include "content/browser/in_process_webkit/webkit_thread.h" 19 #include "content/browser/in_process_webkit/webkit_thread.h"
19 #include "content/browser/plugin_service_impl.h" 20 #include "content/browser/plugin_service_impl.h"
20 #include "content/browser/renderer_host/resource_dispatcher_host.h" 21 #include "content/browser/renderer_host/resource_dispatcher_host.h"
21 #include "content/browser/trace_controller.h" 22 #include "content/browser/trace_controller.h"
22 #include "content/common/hi_res_timer_manager.h" 23 #include "content/common/hi_res_timer_manager.h"
23 #include "content/common/sandbox_policy.h" 24 #include "content/common/sandbox_policy.h"
24 #include "content/public/browser/browser_main_parts.h" 25 #include "content/public/browser/browser_main_parts.h"
25 #include "content/public/browser/browser_shutdown.h" 26 #include "content/public/browser/browser_shutdown.h"
26 #include "content/public/browser/content_browser_client.h" 27 #include "content/public/browser/content_browser_client.h"
28 #include "content/public/browser/render_process_host.h"
27 #include "content/public/common/content_switches.h" 29 #include "content/public/common/content_switches.h"
28 #include "content/public/common/main_function_params.h" 30 #include "content/public/common/main_function_params.h"
29 #include "content/public/common/result_codes.h" 31 #include "content/public/common/result_codes.h"
30 #include "crypto/nss_util.h" 32 #include "crypto/nss_util.h"
31 #include "net/base/network_change_notifier.h" 33 #include "net/base/network_change_notifier.h"
32 #include "net/base/ssl_config_service.h" 34 #include "net/base/ssl_config_service.h"
33 #include "net/socket/client_socket_factory.h" 35 #include "net/socket/client_socket_factory.h"
34 #include "net/socket/tcp_client_socket.h" 36 #include "net/socket/tcp_client_socket.h"
35 37
36 #if defined(OS_WIN) 38 #if defined(OS_WIN)
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 if (parsed_command_line_.HasSwitch( 263 if (parsed_command_line_.HasSwitch(
262 switches::kEnableDNSCertProvenanceChecking)) { 264 switches::kEnableDNSCertProvenanceChecking)) {
263 net::SSLConfigService::EnableDNSCertProvenanceChecking(); 265 net::SSLConfigService::EnableDNSCertProvenanceChecking();
264 } 266 }
265 267
266 // TODO(abarth): Should this move to InitializeNetworkOptions? This doesn't 268 // TODO(abarth): Should this move to InitializeNetworkOptions? This doesn't
267 // seem dependent on SSL initialization(). 269 // seem dependent on SSL initialization().
268 if (parsed_command_line_.HasSwitch(switches::kEnableTcpFastOpen)) 270 if (parsed_command_line_.HasSwitch(switches::kEnableTcpFastOpen))
269 net::set_tcp_fastopen_enabled(true); 271 net::set_tcp_fastopen_enabled(true);
270 272
273 if (parsed_command_line_.HasSwitch(switches::kRendererProcessLimit)) {
274 std::string limit_string = parsed_command_line_.GetSwitchValueASCII(
275 switches::kRendererProcessLimit);
276 size_t process_limit;
277 if (base::StringToSizeT(limit_string, &process_limit)) {
278 content::RenderProcessHost::SetMaxRendererProcessCount(process_limit);
279 }
280 }
281
271 if (parts_.get()) 282 if (parts_.get())
272 parts_->PostEarlyInitialization(); 283 parts_->PostEarlyInitialization();
273 } 284 }
274 285
275 void BrowserMainLoop::MainMessageLoopStart() { 286 void BrowserMainLoop::MainMessageLoopStart() {
276 if (parts_.get()) 287 if (parts_.get())
277 parts_->PreMainMessageLoopStart(); 288 parts_->PreMainMessageLoopStart();
278 289
279 #if defined(OS_WIN) 290 #if defined(OS_WIN)
280 // If we're running tests (ui_task is non-null), then the ResourceBundle 291 // If we're running tests (ui_task is non-null), then the ResourceBundle
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); 602 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task);
592 603
593 #if defined(OS_MACOSX) 604 #if defined(OS_MACOSX)
594 MessageLoopForUI::current()->Run(); 605 MessageLoopForUI::current()->Run();
595 #else 606 #else
596 MessageLoopForUI::current()->RunWithDispatcher(NULL); 607 MessageLoopForUI::current()->RunWithDispatcher(NULL);
597 #endif 608 #endif
598 } 609 }
599 610
600 } // namespace content 611 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698