summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-22 16:16:34 +0000
committerjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-22 16:16:34 +0000
commit3669d7d8f64445139731e73da773dbd2d4a81afb (patch)
tree639c3b714cdab1f82c7b2fb473e24fa88b1e4168
parent4ec1228218bfc88889f0214324493b927c4b356b (diff)
downloadchromium_src-3669d7d8f64445139731e73da773dbd2d4a81afb.zip
chromium_src-3669d7d8f64445139731e73da773dbd2d4a81afb.tar.gz
chromium_src-3669d7d8f64445139731e73da773dbd2d4a81afb.tar.bz2
Reland change to use a native MessagePump instead of a MessagePumpDefault.
Original CL: https://codereview.chromium.org/331513002/ The previous CL caused a bunch of LibJingle unit tests to fail because the tests were using a gtest death test which runs in the context of a fork()ed but not execu()ed process. A CF Message loop can't live in this environment. Explicitly construct a MessagePumpDefault for these tests. BUG=356804,385604 Review URL: https://codereview.chromium.org/331983002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@279013 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/message_loop/message_loop.cc10
-rw-r--r--base/message_loop/message_pump_default.h3
-rw-r--r--jingle/glue/chrome_async_socket_unittest.cc87
-rw-r--r--tools/valgrind/memcheck/suppressions_mac.txt26
4 files changed, 85 insertions, 41 deletions
diff --git a/base/message_loop/message_loop.cc b/base/message_loop/message_loop.cc
index dd1a393..ccece4d 100644
--- a/base/message_loop/message_loop.cc
+++ b/base/message_loop/message_loop.cc
@@ -229,6 +229,14 @@ scoped_ptr<MessagePump> MessageLoop::CreateMessagePumpForType(Type type) {
#define MESSAGE_PUMP_UI scoped_ptr<MessagePump>(new MessagePumpForUI())
#endif
+#if defined(OS_MACOSX)
+ // Use an OS native runloop on Mac to support timer coalescing.
+ #define MESSAGE_PUMP_DEFAULT \
+ scoped_ptr<MessagePump>(new MessagePumpCFRunLoop())
+#else
+ #define MESSAGE_PUMP_DEFAULT scoped_ptr<MessagePump>(new MessagePumpDefault())
+#endif
+
if (type == MessageLoop::TYPE_UI) {
if (message_pump_for_ui_factory_)
return message_pump_for_ui_factory_();
@@ -243,7 +251,7 @@ scoped_ptr<MessagePump> MessageLoop::CreateMessagePumpForType(Type type) {
#endif
DCHECK_EQ(MessageLoop::TYPE_DEFAULT, type);
- return scoped_ptr<MessagePump>(new MessagePumpDefault());
+ return MESSAGE_PUMP_DEFAULT;
}
void MessageLoop::AddDestructionObserver(
diff --git a/base/message_loop/message_pump_default.h b/base/message_loop/message_pump_default.h
index a9b83e8..19e7200 100644
--- a/base/message_loop/message_pump_default.h
+++ b/base/message_loop/message_pump_default.h
@@ -5,13 +5,14 @@
#ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_DEFAULT_H_
#define BASE_MESSAGE_LOOP_MESSAGE_PUMP_DEFAULT_H_
+#include "base/base_export.h"
#include "base/message_loop/message_pump.h"
#include "base/synchronization/waitable_event.h"
#include "base/time/time.h"
namespace base {
-class MessagePumpDefault : public MessagePump {
+class BASE_EXPORT MessagePumpDefault : public MessagePump {
public:
MessagePumpDefault();
virtual ~MessagePumpDefault();
diff --git a/jingle/glue/chrome_async_socket_unittest.cc b/jingle/glue/chrome_async_socket_unittest.cc
index db3d2b0..b3c81b1 100644
--- a/jingle/glue/chrome_async_socket_unittest.cc
+++ b/jingle/glue/chrome_async_socket_unittest.cc
@@ -11,6 +11,7 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
+#include "base/message_loop/message_pump_default.h"
#include "jingle/glue/resolving_client_socket_factory.h"
#include "net/base/address_list.h"
#include "net/base/net_errors.h"
@@ -143,7 +144,15 @@ class ChromeAsyncSocketTest
protected:
ChromeAsyncSocketTest()
: ssl_socket_data_provider_(net::ASYNC, net::OK),
- addr_("localhost", 35) {}
+ addr_("localhost", 35) {
+ // GTest death tests execute in a fork()ed but not exec()ed process.
+ // On OS X a CoreFoundation-backed message loop will exit with a
+ // __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__
+ // when called.
+ // Explicitly create a MessagePumpDefault which can run in this enivronment.
+ scoped_ptr<base::MessagePump> pump(new base::MessagePumpDefault());
+ message_loop_.reset(new base::MessageLoop(pump.Pass()));
+ }
virtual ~ChromeAsyncSocketTest() {}
@@ -182,7 +191,7 @@ class ChromeAsyncSocketTest
virtual void TearDown() {
// Run any tasks that we forgot to pump.
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectClosed();
ExpectNoSignal();
chrome_async_socket_.reset();
@@ -342,7 +351,7 @@ class ChromeAsyncSocketTest
EXPECT_TRUE(chrome_async_socket_->Connect(addr_));
ExpectNonErrorState(ChromeAsyncSocket::STATE_CONNECTING);
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
// We may not necessarily be open; may have been other events
// queued up.
ExpectSignalSocketState(
@@ -372,7 +381,7 @@ class ChromeAsyncSocketTest
EXPECT_EQ(kDummyData, DrainRead(1));
EXPECT_TRUE(chrome_async_socket_->StartTls("fakedomain.com"));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectSSLConnectSignal();
ExpectNoSignal();
ExpectNonErrorState(ChromeAsyncSocket::STATE_TLS_OPEN);
@@ -415,7 +424,7 @@ class ChromeAsyncSocketTest
}
// ChromeAsyncSocket expects a message loop.
- base::MessageLoop message_loop_;
+ scoped_ptr<base::MessageLoop> message_loop_;
AsyncSocketDataProvider async_socket_data_provider_;
net::SSLSocketDataProvider ssl_socket_data_provider_;
@@ -510,7 +519,7 @@ TEST_F(ChromeAsyncSocketTest, ImmediateConnectCloseBeforeRead) {
SignalSocketState::NoError(
SIGNAL_CLOSE, ChromeAsyncSocket::STATE_CLOSED));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
}
TEST_F(ChromeAsyncSocketTest, HangingConnect) {
@@ -532,14 +541,14 @@ TEST_F(ChromeAsyncSocketTest, PendingConnect) {
ExpectNonErrorState(ChromeAsyncSocket::STATE_CONNECTING);
ExpectNoSignal();
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectNonErrorState(ChromeAsyncSocket::STATE_OPEN);
ExpectSignalSocketState(
SignalSocketState::NoError(
SIGNAL_CONNECT, ChromeAsyncSocket::STATE_OPEN));
ExpectNoSignal();
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
DoCloseOpenedNoError();
}
@@ -552,14 +561,14 @@ TEST_F(ChromeAsyncSocketTest, PendingConnectCloseBeforeRead) {
net::MockConnect(net::ASYNC, net::OK));
EXPECT_TRUE(chrome_async_socket_->Connect(addr_));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectSignalSocketState(
SignalSocketState::NoError(
SIGNAL_CONNECT, ChromeAsyncSocket::STATE_OPEN));
DoCloseOpenedNoError();
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
}
TEST_F(ChromeAsyncSocketTest, PendingConnectError) {
@@ -567,7 +576,7 @@ TEST_F(ChromeAsyncSocketTest, PendingConnectError) {
net::MockConnect(net::ASYNC, net::ERR_TIMED_OUT));
EXPECT_TRUE(chrome_async_socket_->Connect(addr_));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectSignalSocketState(
SignalSocketState(
@@ -629,7 +638,7 @@ TEST_F(ChromeAsyncSocketTest, Read) {
EXPECT_EQ(kReadData, DrainRead(1));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
DoCloseOpenedNoError();
}
@@ -643,7 +652,7 @@ TEST_F(ChromeAsyncSocketTest, ReadTwice) {
EXPECT_EQ(kReadData, DrainRead(1));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
const char kReadData2[] = "mydatatoread2";
async_socket_data_provider_.AddRead(net::MockRead(kReadData2));
@@ -665,7 +674,7 @@ TEST_F(ChromeAsyncSocketTest, ReadError) {
EXPECT_EQ(kReadData, DrainRead(1));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
async_socket_data_provider_.AddRead(
net::MockRead(net::SYNCHRONOUS, net::ERR_TIMED_OUT));
@@ -699,7 +708,7 @@ TEST_F(ChromeAsyncSocketTest, PendingRead) {
EXPECT_EQ(kReadData, DrainRead(1));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
DoCloseOpenedNoError();
}
@@ -755,12 +764,12 @@ TEST_F(ChromeAsyncSocketTest, SyncWrite) {
DoOpenClosed();
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData, 3));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 3, 5));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 8,
arraysize(kWriteData) - 8));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectNoSignal();
@@ -778,12 +787,12 @@ TEST_F(ChromeAsyncSocketTest, AsyncWrite) {
net::MockWrite(net::ASYNC, kWriteData + 8, arraysize(kWriteData) - 8));
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData, 3));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 3, 5));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 8,
arraysize(kWriteData) - 8));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectNoSignal();
@@ -801,12 +810,12 @@ TEST_F(ChromeAsyncSocketTest, AsyncWriteError) {
net::MockWrite(net::ASYNC, net::ERR_TIMED_OUT));
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData, 3));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 3, 5));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 8,
arraysize(kWriteData) - 8));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectSignalSocketState(
SignalSocketState(
@@ -874,7 +883,7 @@ TEST_F(ChromeAsyncSocketTest, ImmediateSSLConnect) {
ExpectReadSignal();
EXPECT_TRUE(chrome_async_socket_->StartTls("fakedomain.com"));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectSSLConnectSignal();
ExpectNoSignal();
ExpectNonErrorState(ChromeAsyncSocket::STATE_TLS_OPEN);
@@ -889,7 +898,7 @@ TEST_F(ChromeAsyncSocketTest, DoubleSSLConnect) {
ExpectReadSignal();
EXPECT_TRUE(chrome_async_socket_->StartTls("fakedomain.com"));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectSSLConnectSignal();
ExpectNoSignal();
ExpectNonErrorState(ChromeAsyncSocket::STATE_TLS_OPEN);
@@ -913,7 +922,7 @@ TEST_F(ChromeAsyncSocketTest, FailedSSLConnect) {
ExpectReadSignal();
EXPECT_TRUE(chrome_async_socket_->StartTls("fakedomain.com"));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectSignalSocketState(
SignalSocketState(
SIGNAL_CLOSE, ChromeAsyncSocket::STATE_CLOSED,
@@ -941,7 +950,7 @@ TEST_F(ChromeAsyncSocketTest, ReadDuringSSLConnecting) {
EXPECT_TRUE(chrome_async_socket_->Read(buf, sizeof(buf), &len_read));
EXPECT_EQ(0U, len_read);
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectSSLConnectSignal();
ExpectSSLReadSignal();
ExpectNoSignal();
@@ -972,11 +981,11 @@ TEST_F(ChromeAsyncSocketTest, WriteDuringSSLConnecting) {
// TODO(akalin): Figure out how to test that the write happens
// *after* the SSL connect.
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectSSLConnectSignal();
ExpectNoSignal();
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
DoSSLCloseOpenedNoError();
}
@@ -1005,7 +1014,7 @@ TEST_F(ChromeAsyncSocketTest, SSLConnectDuringPostedWrite) {
EXPECT_FALSE(chrome_async_socket_->StartTls("fakedomain.com"));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
DoCloseOpened(
SignalSocketState(SIGNAL_CLOSE,
@@ -1020,14 +1029,14 @@ TEST_F(ChromeAsyncSocketTest, SSLConnectDuringPostedWrite) {
TEST_F(ChromeAsyncSocketTest, SSLRead) {
DoSSLOpenClosed();
async_socket_data_provider_.AddRead(net::MockRead(kReadData));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectSSLReadSignal();
ExpectNoSignal();
EXPECT_EQ(kReadData, DrainRead(1));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
DoSSLCloseOpenedNoError();
}
@@ -1043,12 +1052,12 @@ TEST_F(ChromeAsyncSocketTest, SSLSyncWrite) {
DoSSLOpenClosed();
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData, 3));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 3, 5));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 8,
arraysize(kWriteData) - 8));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectNoSignal();
@@ -1066,12 +1075,12 @@ TEST_F(ChromeAsyncSocketTest, SSLAsyncWrite) {
net::MockWrite(net::ASYNC, kWriteData + 8, arraysize(kWriteData) - 8));
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData, 3));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 3, 5));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
EXPECT_TRUE(chrome_async_socket_->Write(kWriteData + 8,
arraysize(kWriteData) - 8));
- message_loop_.RunUntilIdle();
+ message_loop_->RunUntilIdle();
ExpectNoSignal();
diff --git a/tools/valgrind/memcheck/suppressions_mac.txt b/tools/valgrind/memcheck/suppressions_mac.txt
index 9b6a978..de9fcbf 100644
--- a/tools/valgrind/memcheck/suppressions_mac.txt
+++ b/tools/valgrind/memcheck/suppressions_mac.txt
@@ -99,6 +99,19 @@
fun:-[NSBitmapImageRep(NSBitmapImageFileTypeExtensions) representationUsingType:properties:]
fun:_ZN3gfx8internal24Get1xPNGBytesFromNSImageEP7NSImage
}
+{
+ # See http://crbug.com/385604
+ bug_385604_a
+ Memcheck:Leak
+ fun:_Znw*
+ fun:_ZNK11AEEventImpl9duplicateEv
+ fun:AESendMessage
+ fun:_ZL35HIToolboxLSNotificationCallbackFunc18LSNotificationCodedPKvPK7__LSASNS1_11LSSessionIDS1_
+ fun:_ZL48LSScheduleNotificationReceiveMessageCallbackFuncP12__CFMachPortPvlS1_
+ fun:__CFMachPortPerform
+ fun:__CFRunLoopRun
+ ...
+}
# Intentional leaks in AppKit, for an OS-level cache. Only appear on the first
# run of each reboot. See also issues 105525, 257276, 340847.
{
@@ -2465,3 +2478,16 @@
fun:_ZN5media28VideoCaptureDeviceFactoryMac6CreateERKNS_18VideoCaptureDevice4NameE
fun:_ZN5media45VideoCaptureDeviceTest_OpenInvalidDevice_Test8TestBodyEv
}
+{
+ bug_385604_b
+ Memcheck:Leak
+ fun:calloc
+ fun:_ZN18hb_object_header_t6createEj
+ fun:_ZL16hb_object_createI9hb_face_tEPT_v
+ fun:hb_face_create_for_tables
+ fun:_ZN3gfx12_GLOBAL__N_118CreateHarfBuzzFaceEP10SkTypeface
+ fun:_ZN3gfx12_GLOBAL__N_118CreateHarfBuzzFontEP10SkTypefacei
+ fun:_ZN3gfx18RenderTextHarfBuzz8ShapeRunEPNS_8internal15TextRunHarfBuzzE
+ fun:_ZN3gfx18RenderTextHarfBuzz12EnsureLayoutEv
+ fun:_ZN3gfx41RenderTextTest_HarfBuzz_RunDirection_Test8TestBodyEv
+}