diff options
author | jam <jam@chromium.org> | 2016-03-22 22:34:24 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-23 05:35:38 +0000 |
commit | 75c4422d8fdabd231f40a6c9235f4512f0170268 (patch) | |
tree | 95d8a4b3b54dc0ff1e22ad25e0fefcc7afb7d832 /content | |
parent | b746ad977e2ad04e17a0792bd313f6e9d7a4be74 (diff) | |
download | chromium_src-75c4422d8fdabd231f40a6c9235f4512f0170268.zip chromium_src-75c4422d8fdabd231f40a6c9235f4512f0170268.tar.gz chromium_src-75c4422d8fdabd231f40a6c9235f4512f0170268.tar.bz2 |
Remove logic for lazy initialization of WebKit.
See "Extensions impact on startup?" thread on (internal) chrome-fast mailing list from 8/14/2015 for background, which showed that effectively undoing this logic showed a 3% reduction on first_non_empty_paint_time. This lazy initialization used to be a performance win when it was added years ago, but has since become a performance drag. Since it's effectively not used now (since ChromeContentRendererClient::RenderThreadStarted always initializes WebKit through its call to RenderThread::RegisterExtension), just remove this unused logic.
Review URL: https://codereview.chromium.org/1821413003
Cr-Commit-Position: refs/heads/master@{#382795}
Diffstat (limited to 'content')
13 files changed, 69 insertions, 91 deletions
diff --git a/content/public/renderer/render_process_observer.h b/content/public/renderer/render_process_observer.h index f53ba65..30f855d 100644 --- a/content/public/renderer/render_process_observer.h +++ b/content/public/renderer/render_process_observer.h @@ -27,9 +27,6 @@ class CONTENT_EXPORT RenderProcessObserver { // Notification that the render process is shutting down. virtual void OnRenderProcessShutdown() {} - // Called right after the WebKit API is initialized. - virtual void WebKitInitialized() {} - // Called when the renderer cache of the plugin list has changed. virtual void PluginListChanged() {} diff --git a/content/public/renderer/render_thread.h b/content/public/renderer/render_thread.h index db554c1..7f88da9 100644 --- a/content/public/renderer/render_thread.h +++ b/content/public/renderer/render_thread.h @@ -75,10 +75,6 @@ class CONTENT_EXPORT RenderThread : virtual public ChildThread { virtual void SetResourceDispatcherDelegate( ResourceDispatcherDelegate* delegate) = 0; - // We initialize WebKit as late as possible. Call this to force - // initialization. - virtual void EnsureWebKitInitialized() = 0; - // Asks the host to create a block of shared memory for the renderer. // The shared memory allocated by the host is returned back. virtual scoped_ptr<base::SharedMemory> HostAllocateSharedMemoryBuffer( diff --git a/content/public/test/mock_render_thread.cc b/content/public/test/mock_render_thread.cc index 55b2269..0160c43 100644 --- a/content/public/test/mock_render_thread.cc +++ b/content/public/test/mock_render_thread.cc @@ -123,9 +123,6 @@ void MockRenderThread::SetResourceDispatcherDelegate( ResourceDispatcherDelegate* delegate) { } -void MockRenderThread::EnsureWebKitInitialized() { -} - void MockRenderThread::RecordAction(const base::UserMetricsAction& action) { } diff --git a/content/public/test/mock_render_thread.h b/content/public/test/mock_render_thread.h index 7b6c7d3..5301acf 100644 --- a/content/public/test/mock_render_thread.h +++ b/content/public/test/mock_render_thread.h @@ -63,7 +63,6 @@ class MockRenderThread : public RenderThread { void RemoveObserver(RenderProcessObserver* observer) override; void SetResourceDispatcherDelegate( ResourceDispatcherDelegate* delegate) override; - void EnsureWebKitInitialized() override; void RecordAction(const base::UserMetricsAction& action) override; void RecordComputedAction(const std::string& action) override; scoped_ptr<base::SharedMemory> HostAllocateSharedMemoryBuffer( diff --git a/content/renderer/dom_storage/dom_storage_dispatcher.cc b/content/renderer/dom_storage/dom_storage_dispatcher.cc index c80df04..05ac68d 100644 --- a/content/renderer/dom_storage/dom_storage_dispatcher.cc +++ b/content/renderer/dom_storage/dom_storage_dispatcher.cc @@ -299,8 +299,6 @@ bool DomStorageDispatcher::OnMessageReceived(const IPC::Message& msg) { void DomStorageDispatcher::OnStorageEvent( const DOMStorageMsg_Event_Params& params) { - RenderThreadImpl::current()->EnsureWebKitInitialized(); - WebStorageAreaImpl* originating_area = NULL; if (params.connection_id) { originating_area = WebStorageAreaImpl::FromConnectionId( diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc index c8a00e6..aa8f002 100644 --- a/content/renderer/render_thread_impl.cc +++ b/content/renderer/render_thread_impl.cc @@ -591,7 +591,9 @@ RenderThreadImpl* RenderThreadImpl::Create( const InProcessChildThreadParams& params) { scoped_ptr<scheduler::RendererScheduler> renderer_scheduler = scheduler::RendererScheduler::Create(); - return new RenderThreadImpl(params, std::move(renderer_scheduler)); + scoped_refptr<base::SingleThreadTaskRunner> test_task_counter; + return new RenderThreadImpl( + params, std::move(renderer_scheduler), test_task_counter); } // static @@ -608,14 +610,15 @@ RenderThreadImpl* RenderThreadImpl::current() { RenderThreadImpl::RenderThreadImpl( const InProcessChildThreadParams& params, - scoped_ptr<scheduler::RendererScheduler> scheduler) + scoped_ptr<scheduler::RendererScheduler> scheduler, + scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) : ChildThreadImpl(Options::Builder() .InBrowserProcess(params) .UseMojoChannel(ShouldUseMojoChannel()) .Build()), renderer_scheduler_(std::move(scheduler)), raster_worker_pool_(new RasterWorkerPool()) { - Init(); + Init(resource_task_queue); } // When we run plugins in process, we actually run them on the render thread, @@ -629,10 +632,12 @@ RenderThreadImpl::RenderThreadImpl( renderer_scheduler_(std::move(scheduler)), main_message_loop_(std::move(main_message_loop)), raster_worker_pool_(new RasterWorkerPool()) { - Init(); + scoped_refptr<base::SingleThreadTaskRunner> test_task_counter; + Init(test_task_counter); } -void RenderThreadImpl::Init() { +void RenderThreadImpl::Init( + scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) { TRACE_EVENT0("startup", "RenderThreadImpl::Init"); base::trace_event::TraceLog::GetInstance()->SetThreadSortIndex( @@ -649,6 +654,8 @@ void RenderThreadImpl::Init() { // Register this object as the main thread. ChildProcess::current()->set_main_thread(this); + InitializeWebKit(resource_task_queue); + // In single process the single process is all there is. notify_webkit_of_modal_loop_ = true; webkit_shared_timer_suspended_ = false; @@ -1155,21 +1162,6 @@ void RenderThreadImpl::SetResourceDispatcherDelegate( resource_dispatcher()->set_delegate(delegate); } -void RenderThreadImpl::SetResourceDispatchTaskQueue( - const scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) { - // Add a filter that forces resource messages to be dispatched via a - // particular task runner. - scoped_refptr<ResourceSchedulingFilter> filter( - new ResourceSchedulingFilter(resource_task_queue, resource_dispatcher())); - channel()->AddFilter(filter.get()); - resource_dispatcher()->SetResourceSchedulingFilter(filter); - - // The ChildResourceMessageFilter and the ResourceDispatcher need to use the - // same queue to ensure tasks are executed in the expected order. - child_resource_message_filter()->SetMainThreadTaskRunner(resource_task_queue); - resource_dispatcher()->SetMainThreadTaskRunner(resource_task_queue); -} - void RenderThreadImpl::InitializeCompositorThread() { #if defined(OS_ANDROID) SynchronousCompositorFactory* sync_compositor_factory = @@ -1233,9 +1225,9 @@ void RenderThreadImpl::InitializeCompositorThread() { synchronous_input_handler_proxy_client, renderer_scheduler_.get())); } -void RenderThreadImpl::EnsureWebKitInitialized() { - if (blink_platform_impl_) - return; +void RenderThreadImpl::InitializeWebKit( + scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) { + DCHECK(!blink_platform_impl_); const base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); @@ -1262,7 +1254,26 @@ void RenderThreadImpl::EnsureWebKitInitialized() { base::Bind(base::IgnoreResult(&RenderThreadImpl::OnMessageReceived), base::Unretained(this))); - SetResourceDispatchTaskQueue(renderer_scheduler_->LoadingTaskRunner()); + scoped_refptr<base::SingleThreadTaskRunner> resource_task_queue2; + if (resource_task_queue) { + resource_task_queue2 = resource_task_queue; + } else { + resource_task_queue2 = renderer_scheduler_->LoadingTaskRunner(); + } + // Add a filter that forces resource messages to be dispatched via a + // particular task runner. + scoped_refptr<ResourceSchedulingFilter> filter( + new ResourceSchedulingFilter( + resource_task_queue2, resource_dispatcher())); + channel()->AddFilter(filter.get()); + resource_dispatcher()->SetResourceSchedulingFilter(filter); + + // The ChildResourceMessageFilter and the ResourceDispatcher need to use the + // same queue to ensure tasks are executed in the expected order. + child_resource_message_filter()->SetMainThreadTaskRunner( + resource_task_queue2); + resource_dispatcher()->SetMainThreadTaskRunner(resource_task_queue2); + if (!command_line.HasSwitch(switches::kDisableThreadedCompositing) && !command_line.HasSwitch(switches::kUseRemoteCompositing)) InitializeCompositorThread(); @@ -1294,8 +1305,6 @@ void RenderThreadImpl::EnsureWebKitInitialized() { RenderMediaClient::Initialize(); - FOR_EACH_OBSERVER(RenderProcessObserver, observers_, WebKitInitialized()); - devtools_agent_message_filter_ = new DevToolsAgentFilter(); AddFilter(devtools_agent_message_filter_.get()); @@ -1378,7 +1387,6 @@ cc::SharedBitmapManager* RenderThreadImpl::GetSharedBitmapManager() { } void RenderThreadImpl::RegisterExtension(v8::Extension* extension) { - EnsureWebKitInitialized(); WebScriptController::registerExtension(extension); } @@ -1837,7 +1845,6 @@ void RenderThreadImpl::OnSetZoomLevelForCurrentURL(const std::string& scheme, } void RenderThreadImpl::OnCreateNewView(const ViewMsg_New_Params& params) { - EnsureWebKitInitialized(); CompositorDependencies* compositor_deps = this; // When bringing in render_view, also bring in webkit's glue and jsbindings. RenderViewImpl::Create(compositor_deps, params, false); @@ -1923,7 +1930,6 @@ GpuChannelHost* RenderThreadImpl::GetGpuChannel() { #if defined(ENABLE_PLUGINS) void RenderThreadImpl::OnPurgePluginListCache(bool reload_pages) { - EnsureWebKitInitialized(); // The call below will cause a GetPlugins call with refresh=true, but at this // point we already know that the browser has refreshed its list, so disable // refresh temporarily to prevent each renderer process causing the list to be @@ -1939,7 +1945,6 @@ void RenderThreadImpl::OnPurgePluginListCache(bool reload_pages) { void RenderThreadImpl::OnNetworkConnectionChanged( net::NetworkChangeNotifier::ConnectionType type, double max_bandwidth_mbps) { - EnsureWebKitInitialized(); bool online = type != net::NetworkChangeNotifier::CONNECTION_NONE; WebNetworkStateNotifier::setOnLine(online); FOR_EACH_OBSERVER( @@ -1962,7 +1967,6 @@ void RenderThreadImpl::OnUpdateTimezone(const std::string& zone_id) { #if defined(OS_ANDROID) void RenderThreadImpl::OnSetWebKitSharedTimersSuspended(bool suspend) { - EnsureWebKitInitialized(); if (suspend) { renderer_scheduler_->SuspendTimerQueue(); } else { @@ -1975,7 +1979,6 @@ void RenderThreadImpl::OnSetWebKitSharedTimersSuspended(bool suspend) { #if defined(OS_MACOSX) void RenderThreadImpl::OnUpdateScrollbarTheme( const ViewMsg_UpdateScrollbarTheme_Params& params) { - EnsureWebKitInitialized(); static_cast<WebScrollbarBehaviorImpl*>( blink_platform_impl_->scrollbarBehavior()) ->set_jump_on_track_click(params.jump_on_track_click); diff --git a/content/renderer/render_thread_impl.h b/content/renderer/render_thread_impl.h index cf98faf..f532662 100644 --- a/content/renderer/render_thread_impl.h +++ b/content/renderer/render_thread_impl.h @@ -180,7 +180,6 @@ class CONTENT_EXPORT RenderThreadImpl void RemoveObserver(RenderProcessObserver* observer) override; void SetResourceDispatcherDelegate( ResourceDispatcherDelegate* delegate) override; - void EnsureWebKitInitialized() override; scoped_ptr<base::SharedMemory> HostAllocateSharedMemoryBuffer( size_t buffer_size) override; cc::SharedBitmapManager* GetSharedBitmapManager() override; @@ -458,12 +457,12 @@ class CONTENT_EXPORT RenderThreadImpl StoragePartitionService* GetStoragePartitionService(); protected: - RenderThreadImpl(const InProcessChildThreadParams& params, - scoped_ptr<scheduler::RendererScheduler> scheduler); + RenderThreadImpl( + const InProcessChildThreadParams& params, + scoped_ptr<scheduler::RendererScheduler> scheduler, + scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue); RenderThreadImpl(scoped_ptr<base::MessageLoop> main_message_loop, scoped_ptr<scheduler::RendererScheduler> scheduler); - virtual void SetResourceDispatchTaskQueue( - const scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue); private: // ChildThread @@ -477,10 +476,13 @@ class CONTENT_EXPORT RenderThreadImpl scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override; scoped_ptr<base::SharedMemory> AllocateSharedMemory(size_t size) override; - void Init(); + void Init(scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue); void InitializeCompositorThread(); + void InitializeWebKit( + scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue); + void OnCreateNewFrame(FrameMsg_NewFrame_Params params); void OnCreateNewFrameProxy(int routing_id, int render_view_routing_id, diff --git a/content/renderer/render_thread_impl_browsertest.cc b/content/renderer/render_thread_impl_browsertest.cc index 67bc93a..f1b21a4 100644 --- a/content/renderer/render_thread_impl_browsertest.cc +++ b/content/renderer/render_thread_impl_browsertest.cc @@ -101,24 +101,18 @@ class TestTaskCounter : public base::SingleThreadTaskRunner { class RenderThreadImplForTest : public RenderThreadImpl { public: - RenderThreadImplForTest(const InProcessChildThreadParams& params, - scoped_ptr<scheduler::RendererScheduler> scheduler, - scoped_refptr<TestTaskCounter> test_task_counter) - : RenderThreadImpl(params, std::move(scheduler)), - test_task_counter_(test_task_counter) {} + RenderThreadImplForTest( + const InProcessChildThreadParams& params, + scoped_ptr<scheduler::RendererScheduler> scheduler, + scoped_refptr<base::SingleThreadTaskRunner>& test_task_counter) + : RenderThreadImpl(params, std::move(scheduler), test_task_counter) { + } ~RenderThreadImplForTest() override {} - void SetResourceDispatchTaskQueue( - const scoped_refptr<base::SingleThreadTaskRunner>&) override { - // Use our TestTaskCounter instead. - RenderThreadImpl::SetResourceDispatchTaskQueue(test_task_counter_); - } - using ChildThreadImpl::OnMessageReceived; private: - scoped_refptr<TestTaskCounter> test_task_counter_; }; #if defined(COMPILER_MSVC) @@ -185,15 +179,15 @@ class RenderThreadImplBrowserTest : public testing::Test { scoped_ptr<scheduler::RendererScheduler> renderer_scheduler = scheduler::RendererScheduler::Create(); InitializeMojo(); + scoped_refptr<base::SingleThreadTaskRunner> test_task_counter( + test_task_counter_.get()); thread_ = new RenderThreadImplForTest( InProcessChildThreadParams(test_helper_->GetChannelId(), test_helper_->GetIOTaskRunner(), test_helper_->GetMessagePipeHandle()), - std::move(renderer_scheduler), test_task_counter_); + std::move(renderer_scheduler), test_task_counter); cmd->InitFromArgv(old_argv); - thread_->EnsureWebKitInitialized(); - test_msg_filter_ = make_scoped_refptr( new QuitOnTestMsgFilter(test_helper_->GetMessageLoop())); thread_->AddFilter(test_msg_filter_.get()); diff --git a/content/renderer/service_worker/embedded_worker_dispatcher.cc b/content/renderer/service_worker/embedded_worker_dispatcher.cc index 7ed1a41..f4334ed 100644 --- a/content/renderer/service_worker/embedded_worker_dispatcher.cc +++ b/content/renderer/service_worker/embedded_worker_dispatcher.cc @@ -78,7 +78,6 @@ void EmbeddedWorkerDispatcher::OnStartWorker( const EmbeddedWorkerMsg_StartWorker_Params& params) { DCHECK(!workers_.Lookup(params.embedded_worker_id)); TRACE_EVENT0("ServiceWorker", "EmbeddedWorkerDispatcher::OnStartWorker"); - RenderThread::Get()->EnsureWebKitInitialized(); scoped_ptr<WorkerWrapper> wrapper( new WorkerWrapper(blink::WebEmbeddedWorker::create( new ServiceWorkerContextClient( diff --git a/content/shell/renderer/layout_test/layout_test_render_process_observer.cc b/content/shell/renderer/layout_test/layout_test_render_process_observer.cc index d62ae58..0ca0149 100644 --- a/content/shell/renderer/layout_test/layout_test_render_process_observer.cc +++ b/content/shell/renderer/layout_test/layout_test_render_process_observer.cc @@ -43,26 +43,7 @@ LayoutTestRenderProcessObserver::LayoutTestRenderProcessObserver() g_instance = this; RenderThread::Get()->AddObserver(this); EnableRendererLayoutTestMode(); -} - -LayoutTestRenderProcessObserver::~LayoutTestRenderProcessObserver() { - CHECK(g_instance == this); - g_instance = NULL; -} - -void LayoutTestRenderProcessObserver::SetTestDelegate( - test_runner::WebTestDelegate* delegate) { - test_interfaces_->SetDelegate(delegate); - test_delegate_ = delegate; -} - -void LayoutTestRenderProcessObserver::SetMainWindow(RenderView* view) { - BlinkTestRunner* test_runner = BlinkTestRunner::Get(view); - test_interfaces_->SetWebView(view->GetWebView(), test_runner->proxy()); - main_test_runner_ = test_runner; -} -void LayoutTestRenderProcessObserver::WebKitInitialized() { // We always expose GC to layout tests. std::string flags("--expose-gc"); v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size())); @@ -85,6 +66,23 @@ void LayoutTestRenderProcessObserver::WebKitInitialized() { } } +LayoutTestRenderProcessObserver::~LayoutTestRenderProcessObserver() { + CHECK(g_instance == this); + g_instance = NULL; +} + +void LayoutTestRenderProcessObserver::SetTestDelegate( + test_runner::WebTestDelegate* delegate) { + test_interfaces_->SetDelegate(delegate); + test_delegate_ = delegate; +} + +void LayoutTestRenderProcessObserver::SetMainWindow(RenderView* view) { + BlinkTestRunner* test_runner = BlinkTestRunner::Get(view); + test_interfaces_->SetWebView(view->GetWebView(), test_runner->proxy()); + main_test_runner_ = test_runner; +} + void LayoutTestRenderProcessObserver::OnRenderProcessShutdown() { test_interfaces_.reset(); } diff --git a/content/shell/renderer/layout_test/layout_test_render_process_observer.h b/content/shell/renderer/layout_test/layout_test_render_process_observer.h index 062ea5e..2787409 100644 --- a/content/shell/renderer/layout_test/layout_test_render_process_observer.h +++ b/content/shell/renderer/layout_test/layout_test_render_process_observer.h @@ -37,7 +37,6 @@ class LayoutTestRenderProcessObserver : public RenderProcessObserver { void SetMainWindow(RenderView* view); // RenderProcessObserver implementation. - void WebKitInitialized() override; void OnRenderProcessShutdown() override; bool OnControlMessageReceived(const IPC::Message& message) override; diff --git a/content/shell/renderer/shell_content_renderer_client.cc b/content/shell/renderer/shell_content_renderer_client.cc index c799904..c1d501c 100644 --- a/content/shell/renderer/shell_content_renderer_client.cc +++ b/content/shell/renderer/shell_content_renderer_client.cc @@ -6,7 +6,6 @@ #include "base/command_line.h" #include "components/web_cache/renderer/web_cache_render_process_observer.h" -#include "content/public/renderer/render_thread.h" #include "content/shell/renderer/shell_render_view_observer.h" #include "third_party/WebKit/public/web/WebView.h" #include "v8/include/v8.h" @@ -23,9 +22,7 @@ ShellContentRendererClient::~ShellContentRendererClient() { } void ShellContentRendererClient::RenderThreadStarted() { - RenderThread* thread = RenderThread::Get(); web_cache_observer_.reset(new web_cache::WebCacheRenderProcessObserver()); - thread->AddObserver(web_cache_observer_.get()); } void ShellContentRendererClient::RenderViewCreated(RenderView* render_view) { diff --git a/content/test/layouttest_support.cc b/content/test/layouttest_support.cc index 2843fb8..5ec52f6 100644 --- a/content/test/layouttest_support.cc +++ b/content/test/layouttest_support.cc @@ -98,7 +98,6 @@ RenderFrameImpl* CreateWebFrameTestProxy( // DirectWrite only has access to %WINDIR%\Fonts by default. For developer // side-loading, support kRegisterFontFiles to allow access to additional fonts. void RegisterSideloadedTypefaces(SkFontMgr* fontmgr) { - RenderThreadImpl::current()->EnsureWebKitInitialized(); std::vector<std::string> files = switches::GetSideloadFontFiles(); for (std::vector<std::string>::const_iterator i(files.begin()); i != files.end(); |