diff options
author | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-15 04:32:57 +0000 |
---|---|---|
committer | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-15 04:32:57 +0000 |
commit | 295039bdf97f08bf5c1c1c136dd977b7e97ddd31 (patch) | |
tree | ae3b47308e7d2f2db903f6a61c193e7a8c9ec882 /webkit | |
parent | 1c33790ef99bf8301260b9144110e71e7723d0f4 (diff) | |
download | chromium_src-295039bdf97f08bf5c1c1c136dd977b7e97ddd31.zip chromium_src-295039bdf97f08bf5c1c1c136dd977b7e97ddd31.tar.gz chromium_src-295039bdf97f08bf5c1c1c136dd977b7e97ddd31.tar.bz2 |
Introduce MessagePump to represent the native message pump used to drive a
MessageLoop. A MessageLoop now has a MessagePump.
This will make it possible to port the MessagePump interface to other platforms
as well as to use an IO completion port for our worker threads on Windows.
Currently, there is only MessagePumpWin, which attempts to preserve the
pre-existing behavior of the MessageLoop.
API changes to MessageLoop:
1. MessageLoop::Quit means return from Run when the MessageLoop would
otherwise wait for more work.
2. MessageLoop::Quit can no longer be called outside the context of an active Run
call. So, things like this:
MessageLoop::current()->Quit();
MessageLoop::current()->Run();
are now:
MessageLoop::current()->RunAllPending();
3. MessageLoop::Quit can no longer be called from other threads. This means that
PostTask(..., new MessageLoop::QuitTask()) must be used explicitly to Quit across
thread boundaries.
4. No protection is made to deal with nested MessageLoops involving watched
objects or APCs. In fact, an assertion is added to flag such cases. This is a
temporary measure until object watching and APC facilities are removed in favor
of a MessagePump designed around an IO completion port.
As part of this CL, I also changed the automation system to use an
IPC::ChannelProxy instead of an IPC::Channel. This moves the automation IPC
onto Chrome's IO thread where it belongs. I also fixed some abuses of
RefCounted in the AutomationProvider class. It was deleting itself in some
cases! This led to having to fix the ownership model for AutomationProvider,
which explains the changes to AutomationProviderList and so on.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@928 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/bookmarklet_unittest.cc | 9 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell.cc | 6 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_main.cc | 9 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_test.cc | 5 |
4 files changed, 16 insertions, 13 deletions
diff --git a/webkit/glue/bookmarklet_unittest.cc b/webkit/glue/bookmarklet_unittest.cc index cadff00..a191dfe 100644 --- a/webkit/glue/bookmarklet_unittest.cc +++ b/webkit/glue/bookmarklet_unittest.cc @@ -60,14 +60,12 @@ TEST_F(BookmarkletTest, Redirect) { TEST_F(BookmarkletTest, NonEmptyResult) { test_shell_->LoadURL(L"javascript:false"); - MessageLoop::current()->Quit(); - MessageLoop::current()->Run(); + MessageLoop::current()->RunAllPending(); std::wstring text = test_shell_->GetDocumentText(); EXPECT_EQ(L"false", text); test_shell_->LoadURL(L"javascript:'hello world'"); - MessageLoop::current()->Quit(); - MessageLoop::current()->Run(); + MessageLoop::current()->RunAllPending(); text = test_shell_->GetDocumentText(); EXPECT_EQ(L"hello world", text); } @@ -77,8 +75,7 @@ TEST_F(BookmarkletTest, DocumentWrite) { L"javascript:document.open();" L"document.write('hello world');" L"document.close()"); - MessageLoop::current()->Quit(); - MessageLoop::current()->Run(); + MessageLoop::current()->RunAllPending(); std::wstring text = test_shell_->GetDocumentText(); EXPECT_EQ(L"hello world", text); } diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc index a256646..89585ae 100644 --- a/webkit/tools/test_shell/test_shell.cc +++ b/webkit/tools/test_shell/test_shell.cc @@ -769,8 +769,10 @@ LRESULT CALLBACK TestShell::WndProc(HWND hwnd, UINT message, WPARAM wParam, LPAR if (entry != TestShell::windowList()->end()) TestShell::windowList()->erase(entry); - if (TestShell::windowList()->empty() || shell->is_modal()) - MessageLoop::current()->Quit(); + if (TestShell::windowList()->empty() || shell->is_modal()) { + MessageLoop::current()->PostTask( + FROM_HERE, new MessageLoop::QuitTask()); + } delete shell; } return 0; diff --git a/webkit/tools/test_shell/test_shell_main.cc b/webkit/tools/test_shell/test_shell_main.cc index 6c71ecf..0d35724 100644 --- a/webkit/tools/test_shell/test_shell_main.cc +++ b/webkit/tools/test_shell/test_shell_main.cc @@ -340,11 +340,10 @@ int main(int argc, char* argv[]) MessageLoop::current()->Run(); } - // Flush any remaining messages. This ensures that any - // accumulated Task objects get destroyed before we exit, - // which avoids noise in purify leak-test results. - MessageLoop::current()->Quit(); - MessageLoop::current()->Run(); + // Flush any remaining messages. This ensures that any accumulated + // Task objects get destroyed before we exit, which avoids noise in + // purify leak-test results. + MessageLoop::current()->RunAllPending(); if (record_mode) base::EventRecorder::current()->StopRecording(); diff --git a/webkit/tools/test_shell/test_shell_test.cc b/webkit/tools/test_shell/test_shell_test.cc index 8b433d2..8f8b251 100644 --- a/webkit/tools/test_shell/test_shell_test.cc +++ b/webkit/tools/test_shell/test_shell_test.cc @@ -28,7 +28,9 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "webkit/tools/test_shell/test_shell_test.h" + #include "base/file_util.h" +#include "base/message_loop.h" #include "base/path_service.h" #include "base/string_util.h" @@ -56,6 +58,9 @@ void TestShellTest::TearDown() { test_shell_->LoadURL(L"about:blank"); DestroyWindow(test_shell_->mainWnd()); LayoutTestController::ClearShell(); + + // Flush the MessageLoop of any residual tasks. + MessageLoop::current()->RunAllPending(); } void TestShellTest::CreateEmptyWindow() { |