diff options
author | boliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-08 19:09:02 +0000 |
---|---|---|
committer | boliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-08 19:09:02 +0000 |
commit | 79a92b5368fb4935e0b223a87f1d4552e4dbaf93 (patch) | |
tree | a822cde4e2665c37c3fea95d91aa9f864a3d2545 /content | |
parent | aaead3a736537e8295c3e34bb100e70913855c16 (diff) | |
download | chromium_src-79a92b5368fb4935e0b223a87f1d4552e4dbaf93.zip chromium_src-79a92b5368fb4935e0b223a87f1d4552e4dbaf93.tar.gz chromium_src-79a92b5368fb4935e0b223a87f1d4552e4dbaf93.tar.bz2 |
Destroy InputHandlerManager after compositor thread
InputHandlerManager uses Unretained(this) to post tasks to compositor
thread which means it needs to outlive the compositor thread.
Added a test that is flaky without this fix.
BUG=226261
Review URL: https://chromiumcodereview.appspot.com/13650004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192857 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/content_tests.gypi | 1 | ||||
-rw-r--r-- | content/renderer/render_thread_impl.cc | 1 | ||||
-rw-r--r-- | content/renderer/render_thread_impl_browsertest.cc | 62 |
3 files changed, 64 insertions, 0 deletions
diff --git a/content/content_tests.gypi b/content/content_tests.gypi index ab5af6e..eb5e975 100644 --- a/content/content_tests.gypi +++ b/content/content_tests.gypi @@ -780,6 +780,7 @@ 'renderer/pepper/pepper_file_chooser_host_unittest.cc', 'renderer/pepper/pepper_graphics_2d_host_unittest.cc', 'renderer/pepper/pepper_url_request_unittest.cc', + 'renderer/render_thread_impl_browsertest.cc', 'renderer/render_view_browsertest.cc', 'renderer/render_view_browsertest_mac.mm', 'renderer/render_widget_browsertest.cc', diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc index c35a2c5..0c4212b 100644 --- a/content/renderer/render_thread_impl.cc +++ b/content/renderer/render_thread_impl.cc @@ -438,6 +438,7 @@ RenderThreadImpl::~RenderThreadImpl() { compositor_output_surface_filter_ = NULL; } + compositor_thread_.reset(); if (input_handler_manager_.get()) { RemoveFilter(input_handler_manager_->GetMessageFilter()); input_handler_manager_.reset(); diff --git a/content/renderer/render_thread_impl_browsertest.cc b/content/renderer/render_thread_impl_browsertest.cc new file mode 100644 index 0000000..79eb6bc --- /dev/null +++ b/content/renderer/render_thread_impl_browsertest.cc @@ -0,0 +1,62 @@ +// Copyright 2013 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 "base/command_line.h" +#include "content/public/common/content_switches.h" +#include "content/public/renderer/content_renderer_client.h" +#include "content/renderer/render_process_impl.h" +#include "content/renderer/render_thread_impl.h" +#include "content/test/mock_render_process.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace content { +namespace { + +class RenderThreadImplBrowserTest : public testing::Test { + public: + virtual ~RenderThreadImplBrowserTest() {} +}; + +class DummyListener : public IPC::Listener { + public: + virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { + return true; + } +}; + +void CheckRenderThreadInputHandlerManager(RenderThreadImpl* thread) { + ASSERT_TRUE(thread->input_handler_manager()); +} + +// Check that InputHandlerManager outlives compositor thread because it uses +// raw pointers to post tasks. +TEST_F(RenderThreadImplBrowserTest, + InputHandlerManagerDestroyedAfterCompositorThread) { + CommandLine::ForCurrentProcess()->AppendSwitch( + switches::kEnableThreadedCompositing); + + ContentRendererClient content_renderer_client; + SetRendererClientForTesting(&content_renderer_client); + MessageLoopForIO message_loop_; + + std::string channel_id = IPC::Channel::GenerateVerifiedChannelID( + std::string()); + DummyListener dummy_listener; + IPC::Channel channel(channel_id, IPC::Channel::MODE_SERVER, &dummy_listener); + ASSERT_TRUE(channel.Connect()); + + scoped_ptr<MockRenderProcess> mock_process(new MockRenderProcess); + // Owned by mock_process. + RenderThreadImpl* thread = new RenderThreadImpl(channel_id); + thread->EnsureWebKitInitialized(); + + ASSERT_TRUE(thread->input_handler_manager()); + + thread->compositor_message_loop_proxy()->PostTask( + FROM_HERE, + base::Bind(&CheckRenderThreadInputHandlerManager, thread)); +} + +} // namespace +} // namespace content |