diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-07 00:58:04 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-07 00:58:04 +0000 |
commit | f967b723292a0988bb3789094d5e1641caa0c2f8 (patch) | |
tree | c707a6fed79ed5fabc4d7e01d1089eff6bac3e0c /content | |
parent | 557d842f64c7a8e33c0fceaf564506917b4a10b8 (diff) | |
download | chromium_src-f967b723292a0988bb3789094d5e1641caa0c2f8.zip chromium_src-f967b723292a0988bb3789094d5e1641caa0c2f8.tar.gz chromium_src-f967b723292a0988bb3789094d5e1641caa0c2f8.tar.bz2 |
Start moving code from BrowserMain to content, so that it can be reused by all embedders of content. I've based the refactoring on the existing BrowserMainParts. This is the first step; I didn't want to do it all at the same time because it would be too big. Remaining tasks:-rename the browser_main files in chrome to chrome_browser_main-move the OS specific implementations of BrowserMainParts that are needed for content-finish splitting the remaining BrowserMain function (now that's in TemporaryContinue())BUG=90445
Review URL: http://codereview.chromium.org/7779040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99884 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/app/content_main.cc | 52 | ||||
-rw-r--r-- | content/browser/browser_main.cc | 319 | ||||
-rw-r--r-- | content/browser/browser_main.h | 133 | ||||
-rw-r--r-- | content/browser/content_browser_client.h | 12 | ||||
-rw-r--r-- | content/browser/mock_content_browser_client.cc | 5 | ||||
-rw-r--r-- | content/browser/mock_content_browser_client.h | 2 | ||||
-rw-r--r-- | content/common/content_constants.cc | 13 | ||||
-rw-r--r-- | content/common/content_constants.h | 4 | ||||
-rw-r--r-- | content/common/content_switches.cc | 30 | ||||
-rw-r--r-- | content/common/content_switches.h | 7 | ||||
-rw-r--r-- | content/content_browser.gypi | 2 |
11 files changed, 574 insertions, 5 deletions
diff --git a/content/app/content_main.cc b/content/app/content_main.cc index 971766d..eacb2bd 100644 --- a/content/app/content_main.cc +++ b/content/app/content_main.cc @@ -12,15 +12,19 @@ #include "base/logging.h" #include "base/mac/scoped_nsautorelease_pool.h" #include "base/memory/scoped_ptr.h" +#include "base/metrics/stats_table.h" #include "base/process_util.h" #include "base/stringprintf.h" +#include "base/string_number_conversions.h" #include "content/app/content_main_delegate.h" +#include "content/common/content_constants.h" #include "content/common/content_paths.h" #include "content/common/content_switches.h" #include "content/common/main_function_params.h" #include "content/common/sandbox_init_wrapper.h" #include "content/common/set_process_title.h" #include "crypto/nss_util.h" +#include "ipc/ipc_switches.h" #include "ui/base/ui_base_switches.h" #include "ui/base/ui_base_paths.h" @@ -53,6 +57,7 @@ int tc_set_new_mode(int mode); } #endif +extern int BrowserMain(const MainFunctionParams&); extern int RendererMain(const MainFunctionParams&); extern int GpuMain(const MainFunctionParams&); extern int PluginMain(const MainFunctionParams&); @@ -184,6 +189,27 @@ void CommonSubprocessInit(const std::string& process_type) { #endif } +void InitializeStatsTable(base::ProcessId browser_pid, + const CommandLine& 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 (command_line.HasSwitch(switches::kEnableStatsTable) || + 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 = + base::StringPrintf("%s-%u", + content::kStatsFilename, + static_cast<unsigned int>(browser_pid)); + base::StatsTable* stats_table = new base::StatsTable(statsfile, + content::kStatsMaxThreads, content::kStatsMaxCounters); + base::StatsTable::set_current(stats_table); + } +} + // We dispatch to a process-type-specific FooMain() based on a command-line // flag. This struct is used to build a table of (flag, main function) pairs. struct MainFunction { @@ -217,6 +243,13 @@ int RunZygote(const MainFunctionParams& main_function_params, // line so update it here with the new version. const CommandLine& 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. + pid_t browser_pid = base::GetParentProcessId( + base::GetParentProcessId(base::GetCurrentProcId())); + InitializeStatsTable(browser_pid, command_line); + MainFunctionParams main_params(command_line, main_function_params.sandbox_info_, main_function_params.autorelease_pool_); @@ -244,6 +277,7 @@ int RunNamedProcessTypeMain(const std::string& process_type, const MainFunctionParams& main_function_params, content::ContentMainDelegate* delegate) { static const MainFunction kMainFunctions[] = { + { "", BrowserMain }, { switches::kRendererProcess, RendererMain }, { switches::kPluginProcess, PluginMain }, { switches::kWorkerProcess, WorkerMain }, @@ -389,6 +423,24 @@ int ContentMain(int argc, CHECK(icu_util::Initialize()); + base::ProcessId browser_pid = base::GetCurrentProcId(); + if (command_line.HasSwitch(switches::kProcessChannelID)) { +#if defined(OS_WIN) || defined(OS_MACOSX) + std::string channel_name = + command_line.GetSwitchValueASCII(switches::kProcessChannelID); + + int browser_pid_int; + base::StringToInt(channel_name, &browser_pid_int); + browser_pid = static_cast<base::ProcessId>(browser_pid_int); + DCHECK_NE(browser_pid_int, 0); +#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 + } + + InitializeStatsTable(browser_pid, command_line); + if (delegate) delegate->PreSandboxStartup(); if (!process_type.empty()) diff --git a/content/browser/browser_main.cc b/content/browser/browser_main.cc new file mode 100644 index 0000000..7d7a599 --- /dev/null +++ b/content/browser/browser_main.cc @@ -0,0 +1,319 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/browser/browser_main.h" + +#include "base/allocator/allocator_shim.h" +#include "base/command_line.h" +#include "base/debug/trace_event.h" +#include "base/logging.h" +#include "base/metrics/field_trial.h" +#include "base/metrics/histogram.h" +#include "base/system_monitor/system_monitor.h" +#include "content/browser/browser_thread.h" +#include "content/browser/content_browser_client.h" +#include "content/common/content_switches.h" +#include "content/common/hi_res_timer_manager.h" +#include "content/common/main_function_params.h" +#include "content/common/sandbox_policy.h" +#include "net/base/network_change_notifier.h" +#include "net/base/ssl_config_service.h" +#include "net/socket/tcp_client_socket.h" + +#if defined(OS_WIN) +#include <windows.h> +#include <commctrl.h> +#include <shellapi.h> + +#include "sandbox/src/sandbox.h" +#endif + +#if defined(OS_POSIX) && !defined(OS_MACOSX) +#include <dbus/dbus-glib.h> +#endif + +#if defined(TOOLKIT_USES_GTK) +#include "ui/gfx/gtk_util.h" +#endif + +namespace { + +// Windows-specific initialization code for the sandbox broker services. This +// is just a NOP on non-Windows platforms to reduce ifdefs later on. +void InitializeBrokerServices(const MainFunctionParams& parameters, + const CommandLine& parsed_command_line) { +#if defined(OS_WIN) + sandbox::BrokerServices* broker_services = + parameters.sandbox_info_.BrokerServices(); + if (broker_services) { + sandbox::InitBrokerServices(broker_services); + if (!parsed_command_line.HasSwitch(switches::kNoSandbox)) { + bool use_winsta = !parsed_command_line.HasSwitch( + switches::kDisableAltWinstation); + // Precreate the desktop and window station used by the renderers. + sandbox::TargetPolicy* policy = broker_services->CreatePolicy(); + sandbox::ResultCode result = policy->CreateAlternateDesktop(use_winsta); + CHECK(sandbox::SBOX_ERROR_FAILED_TO_SWITCH_BACK_WINSTATION != result); + policy->Release(); + } + } +#endif +} + +#if defined(TOOLKIT_USES_GTK) +static void GLibLogHandler(const gchar* log_domain, + GLogLevelFlags log_level, + const gchar* message, + gpointer userdata) { + if (!log_domain) + log_domain = "<unknown>"; + if (!message) + message = "<no message>"; + + if (strstr(message, "Loading IM context type") || + strstr(message, "wrong ELF class: ELFCLASS64")) { + // http://crbug.com/9643 + // Until we have a real 64-bit build or all of these 32-bit package issues + // are sorted out, don't fatal on ELF 32/64-bit mismatch warnings and don't + // spam the user with more than one of them. + static bool alerted = false; + if (!alerted) { + LOG(ERROR) << "Bug 9643: " << log_domain << ": " << message; + alerted = true; + } + } else if (strstr(message, "Theme file for default has no") || + strstr(message, "Theme directory") || + strstr(message, "theme pixmap")) { + LOG(ERROR) << "GTK theme error: " << message; + } else if (strstr(message, "gtk_drag_dest_leave: assertion")) { + LOG(ERROR) << "Drag destination deleted: http://crbug.com/18557"; + } else if (strstr(message, "Out of memory") && + strstr(log_domain, "<unknown>")) { + LOG(ERROR) << "DBus call timeout or out of memory: " + << "http://crosbug.com/15496"; + } else { + LOG(DFATAL) << log_domain << ": " << message; + } +} + +static void SetUpGLibLogHandler() { + // Register GLib-handled assertions to go through our logging system. + const char* kLogDomains[] = { NULL, "Gtk", "Gdk", "GLib", "GLib-GObject" }; + for (size_t i = 0; i < arraysize(kLogDomains); i++) { + g_log_set_handler(kLogDomains[i], + static_cast<GLogLevelFlags>(G_LOG_FLAG_RECURSION | + G_LOG_FLAG_FATAL | + G_LOG_LEVEL_ERROR | + G_LOG_LEVEL_CRITICAL | + G_LOG_LEVEL_WARNING), + GLibLogHandler, + NULL); + } +} +#endif + +} // namespace + +namespace content { + +BrowserMainParts::BrowserMainParts(const MainFunctionParams& parameters) + : parameters_(parameters), + parsed_command_line_(parameters.command_line_) { +} + +BrowserMainParts::~BrowserMainParts() { +} + +void BrowserMainParts::EarlyInitialization() { + PreEarlyInitialization(); + + if (parsed_command_line().HasSwitch(switches::kEnableBenchmarking)) + base::FieldTrial::EnableBenchmarking(); + + InitializeSSL(); + + if (parsed_command_line().HasSwitch(switches::kDisableSSLFalseStart)) + net::SSLConfigService::DisableFalseStart(); + if (parsed_command_line().HasSwitch(switches::kEnableSSLCachedInfo)) + net::SSLConfigService::EnableCachedInfo(); + if (parsed_command_line().HasSwitch(switches::kEnableOriginBoundCerts)) + net::SSLConfigService::EnableOriginBoundCerts(); + if (parsed_command_line().HasSwitch( + switches::kEnableDNSCertProvenanceChecking)) { + net::SSLConfigService::EnableDNSCertProvenanceChecking(); + } + + // TODO(abarth): Should this move to InitializeNetworkOptions? This doesn't + // seem dependent on InitializeSSL(). + if (parsed_command_line().HasSwitch(switches::kEnableTcpFastOpen)) + net::set_tcp_fastopen_enabled(true); + + PostEarlyInitialization(); +} + +void BrowserMainParts::MainMessageLoopStart() { + PreMainMessageLoopStart(); + + main_message_loop_.reset(new MessageLoop(MessageLoop::TYPE_UI)); + + // TODO(viettrungluu): should these really go before setting the thread name? + system_monitor_.reset(new base::SystemMonitor); + hi_res_timer_manager_.reset(new HighResolutionTimerManager); + + InitializeMainThread(); + + network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); + + PostMainMessageLoopStart(); +} + +void BrowserMainParts::InitializeMainThread() { + const char* kThreadName = "CrBrowserMain"; + base::PlatformThread::SetName(kThreadName); + main_message_loop().set_thread_name(kThreadName); + + // Register the main thread by instantiating it, but don't call any methods. + main_thread_.reset(new BrowserThread(BrowserThread::UI, + MessageLoop::current())); +} + +void BrowserMainParts::InitializeToolkit() { + // TODO(evan): this function is rather subtle, due to the variety + // of intersecting ifdefs we have. To keep it easy to follow, there + // are no #else branches on any #ifs. + +#if defined(TOOLKIT_USES_GTK) + // We want to call g_thread_init(), but in some codepaths (tests) it + // is possible it has already been called. In older versions of + // GTK, it is an error to call g_thread_init twice; unfortunately, + // the API to tell whether it has been called already was also only + // added in a newer version of GTK! Thankfully, this non-intuitive + // check is actually equivalent and sufficient to work around the + // error. + if (!g_thread_supported()) + g_thread_init(NULL); + // Glib type system initialization. Needed at least for gconf, + // used in net/proxy/proxy_config_service_linux.cc. Most likely + // this is superfluous as gtk_init() ought to do this. It's + // definitely harmless, so retained as a reminder of this + // requirement for gconf. + g_type_init(); + // We use glib-dbus for geolocation and it's possible other libraries + // (e.g. gnome-keyring) will use it, so initialize its threading here + // as well. + dbus_g_thread_init(); + gfx::GtkInitFromCommandLine(parameters().command_line_); + SetUpGLibLogHandler(); +#endif + +#if defined(TOOLKIT_GTK) + // It is important for this to happen before the first run dialog, as it + // styles the dialog as well. + gfx::InitRCStyles(); +#endif + +#if defined(OS_WIN) + // Init common control sex. + INITCOMMONCONTROLSEX config; + config.dwSize = sizeof(config); + config.dwICC = ICC_WIN95_CLASSES; + if (!InitCommonControlsEx(&config)) + LOG_GETLASTERROR(FATAL); +#endif + + ToolkitInitialized(); +} + +void BrowserMainParts::PreEarlyInitialization() { +} + +void BrowserMainParts::PostEarlyInitialization() { +} + +void BrowserMainParts::PreMainMessageLoopStart() { +} + +void BrowserMainParts::PostMainMessageLoopStart() { +} + +void BrowserMainParts::InitializeSSL() { +} + +void BrowserMainParts::ToolkitInitialized() { +} + +int BrowserMainParts::TemporaryContinue() { + return 0; +} + +} // namespace content + +// Main routine for running as the Browser process. +int BrowserMain(const MainFunctionParams& parameters) { + TRACE_EVENT_BEGIN_ETW("BrowserMain", 0, ""); + + scoped_ptr<content::BrowserMainParts> parts( + content::GetContentClient()->browser()->CreateBrowserMainParts( + parameters)); + + parts->EarlyInitialization(); + + // Must happen before we try to use a message loop or display any UI. + parts->InitializeToolkit(); + + parts->MainMessageLoopStart(); + + // WARNING: If we get a WM_ENDSESSION, objects created on the stack here + // are NOT deleted. If you need something to run during WM_ENDSESSION add it + // to browser_shutdown::Shutdown or BrowserProcess::EndSession. + + // !!!!!!!!!! READ ME !!!!!!!!!! + // I (viettrungluu) am in the process of refactoring |BrowserMain()|. If you + // need to add something above this comment, read the documentation in + // browser_main.h. If you need to add something below, please do the + // following: + // - Figure out where you should add your code. Do NOT just pick a random + // location "which works". + // - Document the dependencies apart from compile-time-checkable ones. What + // must happen before your new code is executed? Does your new code need to + // run before something else? Are there performance reasons for executing + // your code at that point? + // - If you need to create a (persistent) object, heap allocate it and keep a + // |scoped_ptr| to it rather than allocating it on the stack. Otherwise + // I'll have to convert your code when I refactor. + // - Unless your new code is just a couple of lines, factor it out into a + // function with a well-defined purpose. Do NOT just add it inline in + // |BrowserMain()|. + // Thanks! + + // TODO(viettrungluu): put the remainder into BrowserMainParts + const CommandLine& parsed_command_line = parameters.command_line_; + +#if defined(OS_WIN) && !defined(NO_TCMALLOC) + // When linking shared libraries, NO_TCMALLOC is defined, and dynamic + // allocator selection is not supported. + + // Make this call before going multithreaded, or spawning any subprocesses. + base::allocator::SetupSubprocessAllocator(); +#endif // OS_WIN + + // The broker service initialization needs to run early because it will + // initialize the sandbox broker, which requires the process to swap its + // window station. During this time all the UI will be broken. This has to + // run before threads and windows are created. + InitializeBrokerServices(parameters, parsed_command_line); + + // Initialize histogram statistics gathering system. + base::StatisticsRecorder statistics; + + // TODO(jam): bring the content parts from this chrome function here. + int result_code = parts->TemporaryContinue(); + + // Release BrowserMainParts here, before shutting down CrosLibrary, since + // some of the classes initialized there have CrosLibrary dependencies. + parts.reset(NULL); + + TRACE_EVENT_END_ETW("BrowserMain", 0, 0); + return result_code; +} diff --git a/content/browser/browser_main.h b/content/browser/browser_main.h new file mode 100644 index 0000000..931bd9a --- /dev/null +++ b/content/browser/browser_main.h @@ -0,0 +1,133 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_BROWSER_BROWSER_MAIN_H_ +#define CONTENT_BROWSER_BROWSER_MAIN_H_ +#pragma once + +#include "base/basictypes.h" +#include "base/memory/scoped_ptr.h" + +class BrowserThread; +class CommandLine; +class HighResolutionTimerManager; +class MessageLoop; +struct MainFunctionParams; + +namespace base { +class SystemMonitor; +} + +namespace net { +class NetworkChangeNotifier; +} + +namespace content { + +// BrowserMainParts: +// This class contains different "stages" to be executed in |BrowserMain()|, +// mostly initialization. This is made into a class rather than just functions +// so each stage can create and maintain state. Each part is represented by a +// single method (e.g., "EarlyInitialization()"), which does the following: +// - calls a method (e.g., "PreEarlyInitialization()") which individual +// platforms can override to provide platform-specific code which is to be +// executed before the common code; +// - calls various methods for things common to all platforms (for that given +// stage); and +// - calls a method (e.g., "PostEarlyInitialization()") for platform-specific +// code to be called after the common code. +// As indicated above, platforms should override the default "Pre...()" and +// "Post...()" methods when necessary; they need not call the superclass's +// implementation (which is empty). +// +// Parts: +// - EarlyInitialization: things which should be done as soon as possible on +// program start (such as setting up signal handlers) and things to be done +// at some generic time before the start of the main message loop. +// - MainMessageLoopStart: things beginning with the start of the main message +// loop and ending with initialization of the main thread; platform-specific +// things which should be done immediately before the start of the main +// message loop should go in |PreMainMessageLoopStart()|. +// - (more to come) +// +// How to add stuff (to existing parts): +// - Figure out when your new code should be executed. What must happen +// before/after your code is executed? Are there performance reasons for +// running your code at a particular time? Document these things! +// - Split out any platform-specific bits. Please avoid #ifdefs it at all +// possible. You have two choices for platform-specific code: (1) Execute it +// from one of the platform-specific |Pre/Post...()| methods; do this if the +// code is unique to a platform type. Or (2) execute it from one of the +// "parts" (e.g., |EarlyInitialization()|) and provide platform-specific +// implementations of your code (in a virtual method); do this if you need to +// provide different implementations across most/all platforms. +// - Unless your new code is just one or two lines, put it into a separate +// method with a well-defined purpose. (Likewise, if you're adding to an +// existing chunk which makes it longer than one or two lines, please move +// the code out into a separate method.) +class BrowserMainParts { + public: + explicit BrowserMainParts(const MainFunctionParams& parameters); + virtual ~BrowserMainParts(); + + // Parts to be called by |BrowserMain()|. + void EarlyInitialization(); + void MainMessageLoopStart(); + void InitializeToolkit(); + + // Temporary function since not all the code from chrome is moved over yet. + virtual int TemporaryContinue(); + + protected: + // Methods to be overridden to provide platform-specific code; these + // correspond to the "parts" above. + virtual void PreEarlyInitialization(); + virtual void PostEarlyInitialization(); + virtual void PreMainMessageLoopStart(); + virtual void PostMainMessageLoopStart(); + + // Used to initialize NSPR where appropriate. + virtual void InitializeSSL(); + + // Allows an embedder to do any extra toolkit initialization. + virtual void ToolkitInitialized(); + + // Accessors for data members (below) ---------------------------------------- + const MainFunctionParams& parameters() const { + return parameters_; + } + const CommandLine& parsed_command_line() const { + return parsed_command_line_; + } + MessageLoop& main_message_loop() const { + return *main_message_loop_; + } + + private: + void InitializeMainThread(); + + // Members initialized on construction --------------------------------------- + + const MainFunctionParams& parameters_; + const CommandLine& parsed_command_line_; + + // Members initialized in |MainMessageLoopStart()| --------------------------- + scoped_ptr<MessageLoop> main_message_loop_; + scoped_ptr<base::SystemMonitor> system_monitor_; + scoped_ptr<HighResolutionTimerManager> hi_res_timer_manager_; + scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; + scoped_ptr<BrowserThread> main_thread_; + + DISALLOW_COPY_AND_ASSIGN(BrowserMainParts); +}; + +// Perform platform-specific work that needs to be done after the main event +// loop has ended. The embedder must be sure to call this. +// TODO(jam): change this so that content calls it so that we don't depend on +// the embedder. +void DidEndMainMessageLoop(); + +} // namespace content + +#endif // CONTENT_BROWSER_BROWSER_MAIN_H_ diff --git a/content/browser/content_browser_client.h b/content/browser/content_browser_client.h index 7fdff59..32fa117 100644 --- a/content/browser/content_browser_client.h +++ b/content/browser/content_browser_client.h @@ -32,8 +32,13 @@ class TabContents; class TabContentsView; class WorkerProcessHost; struct DesktopNotificationHostMsg_Show_Params; +struct MainFunctionParams; struct WebPreferences; +namespace content { +class BrowserMainParts; +} + namespace crypto { class CryptoModuleBlockingPasswordDelegate; } @@ -59,6 +64,7 @@ class Clipboard; namespace content { class BrowserContext; +class BrowserMainParts; class ResourceContext; class WebUIFactory; @@ -74,6 +80,12 @@ class ContentBrowserClient { public: virtual ~ContentBrowserClient() {} + // Allows the embedder to return a customed BrowserMainParts implementation + // for the browser staratup code. Can return NULL, in which case the default + // is used. + virtual BrowserMainParts* CreateBrowserMainParts( + const MainFunctionParams& parameters) = 0; + virtual TabContentsView* CreateTabContentsView(TabContents* tab_contents) = 0; // Notifies that a new RenderHostView has been created. diff --git a/content/browser/mock_content_browser_client.cc b/content/browser/mock_content_browser_client.cc index c47f2c5..1ab31c9 100644 --- a/content/browser/mock_content_browser_client.cc +++ b/content/browser/mock_content_browser_client.cc @@ -19,6 +19,11 @@ namespace content { MockContentBrowserClient::~MockContentBrowserClient() { } +BrowserMainParts* MockContentBrowserClient::CreateBrowserMainParts( + const MainFunctionParams& parameters) { + return NULL; +} + TabContentsView* MockContentBrowserClient::CreateTabContentsView( TabContents* tab_contents) { return new TestTabContentsView; diff --git a/content/browser/mock_content_browser_client.h b/content/browser/mock_content_browser_client.h index e2831dd..4320592 100644 --- a/content/browser/mock_content_browser_client.h +++ b/content/browser/mock_content_browser_client.h @@ -18,6 +18,8 @@ class MockContentBrowserClient : public ContentBrowserClient { public: virtual ~MockContentBrowserClient(); + virtual BrowserMainParts* CreateBrowserMainParts( + const MainFunctionParams& parameters) OVERRIDE; virtual TabContentsView* CreateTabContentsView( TabContents* tab_contents) OVERRIDE; virtual void RenderViewHostCreated( diff --git a/content/common/content_constants.cc b/content/common/content_constants.cc index 6835362..da22264 100644 --- a/content/common/content_constants.cc +++ b/content/common/content_constants.cc @@ -16,6 +16,15 @@ const size_t kMaxURLDisplayChars = 32 * 1024; const char kDefaultPluginRenderViewId[] = "PluginRenderViewId"; const char kDefaultPluginRenderProcessId[] = "PluginRenderProcessId"; -} // namespace content +#if defined(GOOGLE_CHROME_BUILD) +const wchar_t kBrowserAppName[] = L"Chrome"; +const char kStatsFilename[] = "ChromeStats2"; +#else +const wchar_t kBrowserAppName[] = L"Chromium"; +const char kStatsFilename[] = "ChromiumStats2"; +#endif + +const int kStatsMaxThreads = 32; +const int kStatsMaxCounters = 3000; -#undef FPL +} // namespace content diff --git a/content/common/content_constants.h b/content/common/content_constants.h index 1c8b680..ad900d0 100644 --- a/content/common/content_constants.h +++ b/content/common/content_constants.h @@ -35,6 +35,10 @@ extern const size_t kMaxURLDisplayChars; extern const char kDefaultPluginRenderViewId[]; extern const char kDefaultPluginRenderProcessId[]; +extern const char kStatsFilename[]; +extern const int kStatsMaxThreads; +extern const int kStatsMaxCounters; + } // namespace content #endif // CONTENT_COMMON_CHROME_CONSTANTS_H_ diff --git a/content/common/content_switches.cc b/content/common/content_switches.cc index 8657e95..70527a8 100644 --- a/content/common/content_switches.cc +++ b/content/common/content_switches.cc @@ -17,6 +17,12 @@ const char kAllowRunningInsecureContent[] = "allow-running-insecure-content"; // Allows debugging of sandboxed processes (see zygote_main_linux.cc). const char kAllowSandboxDebugging[] = "allow-sandbox-debugging"; +// Causes the browser process to throw an assertion on startup. +const char kBrowserAssertTest[] = "assert-test"; + +// Causes the browser process to crash on startup. +const char kBrowserCrashTest[] = "crash-test"; + // Path to the exe to run for the renderer and plugin subprocesses. const char kBrowserSubprocessPath[] = "browser-subprocess-path"; @@ -117,9 +123,6 @@ const char kDisableLocalStorage[] = "disable-local-storage"; // builds. const char kDisableLogging[] = "disable-logging"; -// Disable smooth scrolling for testing. -const char kDisableSmoothScrolling[] = "disable-smooth-scrolling"; - // Prevent plugins from running. const char kDisablePlugins[] = "disable-plugins"; @@ -129,6 +132,12 @@ const char kDisablePopupBlocking[] = "disable-popup-blocking"; // Turns off the accessibility in the renderer. const char kDisableRendererAccessibility[] = "disable-renderer-accessibility"; +// Disable False Start in SSL and TLS connections. +const char kDisableSSLFalseStart[] = "disable-ssl-false-start"; + +// Disable smooth scrolling for testing. +const char kDisableSmoothScrolling[] = "disable-smooth-scrolling"; + // Disable the seccomp sandbox (Linux only) const char kDisableSeccompSandbox[] = "disable-seccomp-sandbox"; @@ -168,6 +177,11 @@ const char kEnableAccessibilityLogging[] = "enable-accessibility-logging"; // Enables the benchmarking extensions. const char kEnableBenchmarking[] = "enable-benchmarking"; +// Enable DNS side checking of certificates. Still experimental, should only +// be used by developers at the current time. +const char kEnableDNSCertProvenanceChecking[] = + "enable-dns-cert-provenance-checking"; + // Enables device motion events. const char kEnableDeviceMotion[] = "enable-device-motion"; @@ -190,9 +204,15 @@ const char kEnableMediaStream[] = "enable-media-stream"; // assumed to be sRGB. const char kEnableMonitorProfile[] = "enable-monitor-profile"; +// Enables TLS origin bound certificate extension. +const char kEnableOriginBoundCerts[] = "enable-origin-bound-certs"; + // Enable caching of pre-parsed JS script data. See http://crbug.com/32407. const char kEnablePreparsedJsCaching[] = "enable-preparsed-js-caching"; +// Enables TLS cached info extension. +const char kEnableSSLCachedInfo[] = "enable-ssl-cached-info"; + // Cause the OS X sandbox write to syslog every time an access to a resource // is denied by the sandbox. const char kEnableSandboxLogging[] = "enable-sandbox-logging"; @@ -203,6 +223,10 @@ const char kEnableSeccompSandbox[] = "enable-seccomp-sandbox"; // Enables StatsTable, logging statistics to a global named shared memory table. const char kEnableStatsTable[] = "enable-stats-table"; +// Enable use of experimental TCP sockets API for sending data in the +// SYN packet. +const char kEnableTcpFastOpen[] = "enable-tcp-fastopen"; + // Enables support for fullscreen video. Current implementation is // incomplete and this flag is used for development and testing. const char kEnableVideoFullscreen[] = "enable-video-fullscreen"; diff --git a/content/common/content_switches.h b/content/common/content_switches.h index c11bb6f..653ba77 100644 --- a/content/common/content_switches.h +++ b/content/common/content_switches.h @@ -15,6 +15,8 @@ namespace switches { extern const char kAllowFileAccessFromFiles[]; extern const char kAllowRunningInsecureContent[]; extern const char kAllowSandboxDebugging[]; +extern const char kBrowserAssertTest[]; +extern const char kBrowserCrashTest[]; extern const char kBrowserSubprocessPath[]; // TODO(jam): this doesn't belong in content. extern const char kChromeFrame[]; @@ -50,6 +52,7 @@ extern const char kDisableSmoothScrolling[]; extern const char kDisablePlugins[]; extern const char kDisablePopupBlocking[]; extern const char kDisableRendererAccessibility[]; +extern const char kDisableSSLFalseStart[]; extern const char kDisableSeccompSandbox[]; extern const char kDisableSessionStorage[]; extern const char kDisableSharedWorkers[]; @@ -62,16 +65,20 @@ extern const char kEnableAcceleratedDrawing[]; extern const char kEnableAccessibility[]; extern const char kEnableAccessibilityLogging[]; extern const char kEnableBenchmarking[]; +extern const char kEnableDNSCertProvenanceChecking[]; extern const char kEnableDeviceMotion[]; extern const char kEnableFullScreen[]; extern const char kEnableGPUPlugin[]; extern const char kEnableLogging[]; extern const char kEnableMediaStream[]; extern const char kEnableMonitorProfile[]; +extern const char kEnableOriginBoundCerts[]; extern const char kEnablePreparsedJsCaching[]; +extern const char kEnableSSLCachedInfo[]; extern const char kEnableSandboxLogging[]; extern const char kEnableSeccompSandbox[]; extern const char kEnableStatsTable[]; +extern const char kEnableTcpFastOpen[]; extern const char kEnableVideoFullscreen[]; extern const char kEnableVideoLogging[]; extern const char kEnableWebIntents[]; diff --git a/content/content_browser.gypi b/content/content_browser.gypi index 21d16c5..f153a44 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -56,6 +56,8 @@ 'browser/browser_child_process_host.cc', 'browser/browser_child_process_host.h', 'browser/browser_context.h', + 'browser/browser_main.cc', + 'browser/browser_main.h', 'browser/browser_message_filter.cc', 'browser/browser_message_filter.h', 'browser/browser_thread.cc', |