summaryrefslogtreecommitdiffstats
path: root/Source/WebKit2/Platform
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/Platform')
-rw-r--r--Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.cpp14
-rw-r--r--Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.cpp14
-rw-r--r--Source/WebKit2/Platform/CoreIPC/Connection.cpp139
-rw-r--r--Source/WebKit2/Platform/CoreIPC/Connection.h14
-rw-r--r--Source/WebKit2/Platform/CoreIPC/MessageID.h6
-rw-r--r--Source/WebKit2/Platform/Logging.cpp12
-rw-r--r--Source/WebKit2/Platform/Logging.h10
-rw-r--r--Source/WebKit2/Platform/Module.cpp3
-rw-r--r--Source/WebKit2/Platform/Module.h7
-rw-r--r--Source/WebKit2/Platform/WorkQueue.h2
-rw-r--r--Source/WebKit2/Platform/cg/CGUtilities.cpp34
-rw-r--r--Source/WebKit2/Platform/cg/CGUtilities.h1
-rw-r--r--Source/WebKit2/Platform/mac/Logging.mac.mm49
-rw-r--r--Source/WebKit2/Platform/mac/ModuleMac.mm17
-rw-r--r--Source/WebKit2/Platform/mac/RunLoopMac.mm19
-rw-r--r--Source/WebKit2/Platform/qt/SharedMemoryQt.cpp2
-rw-r--r--Source/WebKit2/Platform/win/WorkQueueWin.cpp2
17 files changed, 236 insertions, 109 deletions
diff --git a/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.cpp b/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.cpp
index 4664806..44f9a9f 100644
--- a/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.cpp
+++ b/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.cpp
@@ -145,7 +145,7 @@ bool ArgumentDecoder::decodeBytes(uint8_t* buffer, size_t bufferSize)
bool ArgumentDecoder::decodeBool(bool& result)
{
- if (!alignBufferPosition(__alignof(result), sizeof(result)))
+ if (!alignBufferPosition(sizeof(result), sizeof(result)))
return false;
result = *reinterpret_cast<bool*>(m_bufferPos);
@@ -155,7 +155,7 @@ bool ArgumentDecoder::decodeBool(bool& result)
bool ArgumentDecoder::decodeUInt32(uint32_t& result)
{
- if (!alignBufferPosition(__alignof(result), sizeof(result)))
+ if (!alignBufferPosition(sizeof(result), sizeof(result)))
return false;
result = *reinterpret_cast<uint32_t*>(m_bufferPos);
@@ -165,7 +165,7 @@ bool ArgumentDecoder::decodeUInt32(uint32_t& result)
bool ArgumentDecoder::decodeUInt64(uint64_t& result)
{
- if (!alignBufferPosition(__alignof(result), sizeof(result)))
+ if (!alignBufferPosition(sizeof(result), sizeof(result)))
return false;
result = *reinterpret_cast<uint64_t*>(m_bufferPos);
@@ -175,7 +175,7 @@ bool ArgumentDecoder::decodeUInt64(uint64_t& result)
bool ArgumentDecoder::decodeInt32(int32_t& result)
{
- if (!alignBufferPosition(__alignof(result), sizeof(result)))
+ if (!alignBufferPosition(sizeof(result), sizeof(result)))
return false;
result = *reinterpret_cast<uint32_t*>(m_bufferPos);
@@ -185,7 +185,7 @@ bool ArgumentDecoder::decodeInt32(int32_t& result)
bool ArgumentDecoder::decodeInt64(int64_t& result)
{
- if (!alignBufferPosition(__alignof(result), sizeof(result)))
+ if (!alignBufferPosition(sizeof(result), sizeof(result)))
return false;
result = *reinterpret_cast<uint64_t*>(m_bufferPos);
@@ -195,7 +195,7 @@ bool ArgumentDecoder::decodeInt64(int64_t& result)
bool ArgumentDecoder::decodeFloat(float& result)
{
- if (!alignBufferPosition(__alignof(result), sizeof(result)))
+ if (!alignBufferPosition(sizeof(result), sizeof(result)))
return false;
result = *reinterpret_cast<float*>(m_bufferPos);
@@ -205,7 +205,7 @@ bool ArgumentDecoder::decodeFloat(float& result)
bool ArgumentDecoder::decodeDouble(double& result)
{
- if (!alignBufferPosition(__alignof(result), sizeof(result)))
+ if (!alignBufferPosition(sizeof(result), sizeof(result)))
return false;
result = *reinterpret_cast<double*>(m_bufferPos);
diff --git a/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.cpp b/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.cpp
index aa71b0f..fb0b68b 100644
--- a/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.cpp
+++ b/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.cpp
@@ -97,49 +97,49 @@ void ArgumentEncoder::encodeBytes(const uint8_t* bytes, size_t size)
void ArgumentEncoder::encodeBool(bool n)
{
- uint8_t* buffer = grow(__alignof(n), sizeof(n));
+ uint8_t* buffer = grow(sizeof(n), sizeof(n));
*reinterpret_cast<bool*>(buffer) = n;
}
void ArgumentEncoder::encodeUInt32(uint32_t n)
{
- uint8_t* buffer = grow(__alignof(n), sizeof(n));
+ uint8_t* buffer = grow(sizeof(n), sizeof(n));
*reinterpret_cast<uint32_t*>(buffer) = n;
}
void ArgumentEncoder::encodeUInt64(uint64_t n)
{
- uint8_t* buffer = grow(__alignof(n), sizeof(n));
+ uint8_t* buffer = grow(sizeof(n), sizeof(n));
*reinterpret_cast<uint64_t*>(buffer) = n;
}
void ArgumentEncoder::encodeInt32(int32_t n)
{
- uint8_t* buffer = grow(__alignof(n), sizeof(n));
+ uint8_t* buffer = grow(sizeof(n), sizeof(n));
*reinterpret_cast<int32_t*>(buffer) = n;
}
void ArgumentEncoder::encodeInt64(int64_t n)
{
- uint8_t* buffer = grow(__alignof(n), sizeof(n));
+ uint8_t* buffer = grow(sizeof(n), sizeof(n));
*reinterpret_cast<int64_t*>(buffer) = n;
}
void ArgumentEncoder::encodeFloat(float n)
{
- uint8_t* buffer = grow(__alignof(n), sizeof(n));
+ uint8_t* buffer = grow(sizeof(n), sizeof(n));
*reinterpret_cast<float*>(buffer) = n;
}
void ArgumentEncoder::encodeDouble(double n)
{
- uint8_t* buffer = grow(__alignof(n), sizeof(n));
+ uint8_t* buffer = grow(sizeof(n), sizeof(n));
*reinterpret_cast<double*>(buffer) = n;
}
diff --git a/Source/WebKit2/Platform/CoreIPC/Connection.cpp b/Source/WebKit2/Platform/CoreIPC/Connection.cpp
index 281ccb6..a65f065 100644
--- a/Source/WebKit2/Platform/CoreIPC/Connection.cpp
+++ b/Source/WebKit2/Platform/CoreIPC/Connection.cpp
@@ -36,14 +36,11 @@ using namespace std;
namespace CoreIPC {
-class Connection::SyncMessageState : public RefCounted<Connection::SyncMessageState> {
+class Connection::SyncMessageState : public ThreadSafeRefCounted<Connection::SyncMessageState> {
public:
static PassRefPtr<SyncMessageState> getOrCreate(RunLoop*);
~SyncMessageState();
- void beginWaitForSyncReply();
- void endWaitForSyncReply();
-
void wakeUpClientRunLoop()
{
m_waitForSyncReplySemaphore.signal();
@@ -76,16 +73,18 @@ private:
return syncMessageStateMapMutex;
}
+ void dispatchMessageAndResetDidScheduleDispatchMessagesWork();
+
RunLoop* m_runLoop;
BinarySemaphore m_waitForSyncReplySemaphore;
- // Protects m_waitForSyncReplyCount and m_messagesToDispatchWhileWaitingForSyncReply.
+ // Protects m_didScheduleDispatchMessagesWork and m_messagesToDispatchWhileWaitingForSyncReply.
Mutex m_mutex;
- unsigned m_waitForSyncReplyCount;
+ bool m_didScheduleDispatchMessagesWork;
struct ConnectionAndIncomingMessage {
- Connection* connection;
+ RefPtr<Connection> connection;
IncomingMessage incomingMessage;
};
Vector<ConnectionAndIncomingMessage> m_messagesToDispatchWhileWaitingForSyncReply;
@@ -109,7 +108,7 @@ PassRefPtr<Connection::SyncMessageState> Connection::SyncMessageState::getOrCrea
Connection::SyncMessageState::SyncMessageState(RunLoop* runLoop)
: m_runLoop(runLoop)
- , m_waitForSyncReplyCount(0)
+ , m_didScheduleDispatchMessagesWork(false)
{
}
@@ -121,49 +120,27 @@ Connection::SyncMessageState::~SyncMessageState()
syncMessageStateMap().remove(m_runLoop);
}
-void Connection::SyncMessageState::beginWaitForSyncReply()
-{
- ASSERT(RunLoop::current() == m_runLoop);
-
- MutexLocker locker(m_mutex);
- m_waitForSyncReplyCount++;
-}
-
-void Connection::SyncMessageState::endWaitForSyncReply()
-{
- ASSERT(RunLoop::current() == m_runLoop);
-
- MutexLocker locker(m_mutex);
- ASSERT(m_waitForSyncReplyCount);
- --m_waitForSyncReplyCount;
-
- if (m_waitForSyncReplyCount)
- return;
-
- // Dispatch any remaining incoming sync messages.
- for (size_t i = 0; i < m_messagesToDispatchWhileWaitingForSyncReply.size(); ++i) {
- ConnectionAndIncomingMessage& connectionAndIncomingMessage = m_messagesToDispatchWhileWaitingForSyncReply[i];
- connectionAndIncomingMessage.connection->enqueueIncomingMessage(connectionAndIncomingMessage.incomingMessage);
- }
-
- m_messagesToDispatchWhileWaitingForSyncReply.clear();
-}
-
bool Connection::SyncMessageState::processIncomingMessage(Connection* connection, IncomingMessage& incomingMessage)
{
MessageID messageID = incomingMessage.messageID();
- if (!messageID.isSync() && !messageID.shouldDispatchMessageWhenWaitingForSyncReply())
- return false;
-
- MutexLocker locker(m_mutex);
- if (!m_waitForSyncReplyCount)
+ if (!messageID.shouldDispatchMessageWhenWaitingForSyncReply())
return false;
ConnectionAndIncomingMessage connectionAndIncomingMessage;
connectionAndIncomingMessage.connection = connection;
connectionAndIncomingMessage.incomingMessage = incomingMessage;
- m_messagesToDispatchWhileWaitingForSyncReply.append(connectionAndIncomingMessage);
+ {
+ MutexLocker locker(m_mutex);
+
+ if (!m_didScheduleDispatchMessagesWork) {
+ m_runLoop->scheduleWork(WorkItem::create(this, &SyncMessageState::dispatchMessageAndResetDidScheduleDispatchMessagesWork));
+ m_didScheduleDispatchMessagesWork = true;
+ }
+
+ m_messagesToDispatchWhileWaitingForSyncReply.append(connectionAndIncomingMessage);
+ }
+
wakeUpClientRunLoop();
return true;
@@ -186,6 +163,17 @@ void Connection::SyncMessageState::dispatchMessages()
}
}
+void Connection::SyncMessageState::dispatchMessageAndResetDidScheduleDispatchMessagesWork()
+{
+ {
+ MutexLocker locker(m_mutex);
+ ASSERT(m_didScheduleDispatchMessagesWork);
+ m_didScheduleDispatchMessagesWork = false;
+ }
+
+ dispatchMessages();
+}
+
PassRefPtr<Connection> Connection::createServerConnection(Identifier identifier, Client* client, RunLoop* clientRunLoop)
{
return adoptRef(new Connection(identifier, true, client, clientRunLoop));
@@ -200,11 +188,13 @@ Connection::Connection(Identifier identifier, bool isServer, Client* client, Run
: m_client(client)
, m_isServer(isServer)
, m_syncRequestID(0)
+ , m_onlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage(false)
, m_didCloseOnConnectionWorkQueueCallback(0)
, m_isConnected(false)
, m_connectionQueue("com.apple.CoreIPC.ReceiveQueue")
, m_clientRunLoop(clientRunLoop)
, m_inDispatchMessageCount(0)
+ , m_inDispatchMessageMarkedDispatchWhenWaitingForSyncReplyCount(0)
, m_didReceiveInvalidMessage(false)
, m_syncMessageState(SyncMessageState::getOrCreate(clientRunLoop))
, m_shouldWaitForSyncReplies(true)
@@ -221,6 +211,13 @@ Connection::~Connection()
m_connectionQueue.invalidate();
}
+void Connection::setOnlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage(bool flag)
+{
+ ASSERT(!m_isConnected);
+
+ m_onlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage = flag;
+}
+
void Connection::setDidCloseOnConnectionWorkQueueCallback(DidCloseOnConnectionWorkQueueCallback callback)
{
ASSERT(!m_isConnected);
@@ -265,7 +262,9 @@ bool Connection::sendMessage(MessageID messageID, PassOwnPtr<ArgumentEncoder> ar
if (!isValid())
return false;
- if (messageSendFlags & DispatchMessageEvenWhenWaitingForSyncReply)
+ if (messageSendFlags & DispatchMessageEvenWhenWaitingForSyncReply
+ && (!m_onlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage
+ || m_inDispatchMessageMarkedDispatchWhenWaitingForSyncReplyCount))
messageID = messageID.messageIDWithAddedFlags(MessageID::DispatchMessageWhenWaitingForSyncReply);
MutexLocker locker(m_outgoingMessagesLock);
@@ -357,12 +356,8 @@ PassOwnPtr<ArgumentDecoder> Connection::sendSyncMessage(MessageID messageID, uin
m_pendingSyncReplies.append(PendingSyncReply(syncRequestID));
}
- // We have to begin waiting for the sync reply before sending the message, in case the other side
- // would have sent a request before us, which would lead to a deadlock.
- m_syncMessageState->beginWaitForSyncReply();
-
// First send the message.
- sendMessage(messageID, encoder);
+ sendMessage(messageID.messageIDWithAddedFlags(MessageID::SyncMessage), encoder, DispatchMessageEvenWhenWaitingForSyncReply);
// Then wait for a reply. Waiting for a reply could involve dispatching incoming sync messages, so
// keep an extra reference to the connection here in case it's invalidated.
@@ -376,9 +371,7 @@ PassOwnPtr<ArgumentDecoder> Connection::sendSyncMessage(MessageID messageID, uin
m_pendingSyncReplies.removeLast();
}
- m_syncMessageState->endWaitForSyncReply();
-
- if (!reply)
+ if (!reply && m_client)
m_client->didFailToSendSyncMessage(this);
return reply.release();
@@ -415,19 +408,41 @@ PassOwnPtr<ArgumentDecoder> Connection::waitForSyncReply(uint64_t syncRequestID,
return 0;
}
-void Connection::processIncomingMessage(MessageID messageID, PassOwnPtr<ArgumentDecoder> arguments)
+void Connection::processIncomingSyncReply(PassOwnPtr<ArgumentDecoder> arguments)
{
- // Check if this is a sync reply.
- if (messageID == MessageID(CoreIPCMessage::SyncMessageReply)) {
- MutexLocker locker(m_syncReplyStateMutex);
- ASSERT(!m_pendingSyncReplies.isEmpty());
+ MutexLocker locker(m_syncReplyStateMutex);
+ ASSERT(!m_pendingSyncReplies.isEmpty());
+
+ // Go through the stack of sync requests that have pending replies and see which one
+ // this reply is for.
+ for (size_t i = m_pendingSyncReplies.size(); i > 0; --i) {
+ PendingSyncReply& pendingSyncReply = m_pendingSyncReplies[i - 1];
+
+ if (pendingSyncReply.syncRequestID != arguments->destinationID())
+ continue;
- PendingSyncReply& pendingSyncReply = m_pendingSyncReplies.last();
- ASSERT(pendingSyncReply.syncRequestID == arguments->destinationID());
+ ASSERT(!pendingSyncReply.replyDecoder);
pendingSyncReply.replyDecoder = arguments.leakPtr();
pendingSyncReply.didReceiveReply = true;
- m_syncMessageState->wakeUpClientRunLoop();
+
+ // We got a reply to the last send message, wake up the client run loop so it can be processed.
+ if (i == m_pendingSyncReplies.size())
+ m_syncMessageState->wakeUpClientRunLoop();
+
+ return;
+ }
+
+ // We got a reply for a message we never sent.
+ // FIXME: Dispatch a didReceiveInvalidMessage callback on the client.
+ ASSERT_NOT_REACHED();
+}
+
+void Connection::processIncomingMessage(MessageID messageID, PassOwnPtr<ArgumentDecoder> arguments)
+{
+ // Check if this is a sync reply.
+ if (messageID == MessageID(CoreIPCMessage::SyncMessageReply)) {
+ processIncomingSyncReply(arguments);
return;
}
@@ -569,6 +584,9 @@ void Connection::dispatchMessage(IncomingMessage& message)
m_inDispatchMessageCount++;
+ if (message.messageID().shouldDispatchMessageWhenWaitingForSyncReply())
+ m_inDispatchMessageMarkedDispatchWhenWaitingForSyncReplyCount++;
+
bool oldDidReceiveInvalidMessage = m_didReceiveInvalidMessage;
m_didReceiveInvalidMessage = false;
@@ -580,6 +598,9 @@ void Connection::dispatchMessage(IncomingMessage& message)
m_didReceiveInvalidMessage |= arguments->isInvalid();
m_inDispatchMessageCount--;
+ if (message.messageID().shouldDispatchMessageWhenWaitingForSyncReply())
+ m_inDispatchMessageMarkedDispatchWhenWaitingForSyncReplyCount--;
+
if (m_didReceiveInvalidMessage && m_client)
m_client->didReceiveInvalidMessage(this, message.messageID());
diff --git a/Source/WebKit2/Platform/CoreIPC/Connection.h b/Source/WebKit2/Platform/CoreIPC/Connection.h
index eaa2ab9..b6a2415 100644
--- a/Source/WebKit2/Platform/CoreIPC/Connection.h
+++ b/Source/WebKit2/Platform/CoreIPC/Connection.h
@@ -72,7 +72,7 @@ enum MessageSendFlags {
} \
while (0)
-class Connection : public ThreadSafeShared<Connection> {
+class Connection : public ThreadSafeRefCounted<Connection> {
public:
class MessageReceiver {
protected:
@@ -114,6 +114,8 @@ public:
void setShouldCloseConnectionOnProcessTermination(WebKit::PlatformProcessIdentifier);
#endif
+ void setOnlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage(bool);
+
// The set callback will be called on the connection work queue when the connection is closed,
// before didCall is called on the client thread. Must be called before the connection is opened.
// In the future we might want a more generic way to handle sync or async messages directly
@@ -191,6 +193,8 @@ private:
// Called on the connection work queue.
void processIncomingMessage(MessageID, PassOwnPtr<ArgumentDecoder>);
+ void processIncomingSyncReply(PassOwnPtr<ArgumentDecoder>);
+
bool canSendOutgoingMessages() const;
bool platformCanSendOutgoingMessages() const;
void sendOutgoingMessages();
@@ -212,13 +216,15 @@ private:
bool m_isServer;
uint64_t m_syncRequestID;
+ bool m_onlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage;
DidCloseOnConnectionWorkQueueCallback m_didCloseOnConnectionWorkQueueCallback;
bool m_isConnected;
WorkQueue m_connectionQueue;
RunLoop* m_clientRunLoop;
- uint32_t m_inDispatchMessageCount;
+ unsigned m_inDispatchMessageCount;
+ unsigned m_inDispatchMessageMarkedDispatchWhenWaitingForSyncReplyCount;
bool m_didReceiveInvalidMessage;
// Incoming messages.
@@ -336,7 +342,7 @@ template<typename T> bool Connection::sendSync(const T& message, const typename
argumentEncoder->encode(message);
// Now send the message and wait for a reply.
- OwnPtr<ArgumentDecoder> replyDecoder = sendSyncMessage(MessageID(T::messageID, MessageID::SyncMessage), syncRequestID, argumentEncoder.release(), timeout);
+ OwnPtr<ArgumentDecoder> replyDecoder = sendSyncMessage(MessageID(T::messageID), syncRequestID, argumentEncoder.release(), timeout);
if (!replyDecoder)
return false;
@@ -367,7 +373,7 @@ inline bool Connection::deprecatedSendSync(E messageID, uint64_t destinationID,
argumentEncoder->encode(arguments);
// Now send the message and wait for a reply.
- OwnPtr<ArgumentDecoder> replyDecoder = sendSyncMessage(MessageID(messageID, MessageID::SyncMessage), syncRequestID, argumentEncoder.release(), timeout);
+ OwnPtr<ArgumentDecoder> replyDecoder = sendSyncMessage(MessageID(messageID), syncRequestID, argumentEncoder.release(), timeout);
if (!replyDecoder)
return false;
diff --git a/Source/WebKit2/Platform/CoreIPC/MessageID.h b/Source/WebKit2/Platform/CoreIPC/MessageID.h
index 83154ec..2afb168 100644
--- a/Source/WebKit2/Platform/CoreIPC/MessageID.h
+++ b/Source/WebKit2/Platform/CoreIPC/MessageID.h
@@ -42,9 +42,12 @@ enum MessageClass {
MessageClassWebApplicationCacheManager,
MessageClassWebCookieManager,
MessageClassWebDatabaseManager,
+ MessageClassWebFullScreenManager,
MessageClassWebGeolocationManagerProxy,
+ MessageClassWebIconDatabaseProxy,
MessageClassWebInspector,
MessageClassWebKeyValueStorageManager,
+ MessageClassWebMediaCacheManager,
MessageClassWebPage,
MessageClassWebProcess,
MessageClassWebResourceCacheManager,
@@ -58,9 +61,12 @@ enum MessageClass {
MessageClassWebContextLegacy,
MessageClassWebCookieManagerProxy,
MessageClassWebDatabaseManagerProxy,
+ MessageClassWebFullScreenManagerProxy,
MessageClassWebGeolocationManager,
+ MessageClassWebIconDatabase,
MessageClassWebInspectorProxy,
MessageClassWebKeyValueStorageManagerProxy,
+ MessageClassWebMediaCacheManagerProxy,
MessageClassWebPageProxy,
MessageClassWebProcessProxy,
MessageClassWebProcessProxyLegacy,
diff --git a/Source/WebKit2/Platform/Logging.cpp b/Source/WebKit2/Platform/Logging.cpp
index 184821c..9093415 100644
--- a/Source/WebKit2/Platform/Logging.cpp
+++ b/Source/WebKit2/Platform/Logging.cpp
@@ -28,15 +28,20 @@
#if !LOG_DISABLED
+namespace WebKit {
+
WTFLogChannel LogSessionState = { 0x00000001, "WebKit2LogLevel", WTFLogChannelOff };
WTFLogChannel LogContextMenu = { 0x00000002, "WebKit2LogLevel", WTFLogChannelOff };
WTFLogChannel LogTextInput = { 0x00000004, "WebKit2LogLevel", WTFLogChannelOff };
WTFLogChannel LogView = { 0x00000008, "WebKit2LogLevel", WTFLogChannelOff };
+WTFLogChannel LogIconDatabase = { 0x00000010, "WebKit2LogLevel", WTFLogChannelOff };
-static inline void initializeLogChannel(WTFLogChannel* channel)
+#if !PLATFORM(MAC)
+void initializeLogChannel(WTFLogChannel* channel)
{
- // FIXME: This is a build fix. Each platform will need to define their own initializeLogChannel().
+ // FIXME: Each platform will need to define their own initializeLogChannel().
}
+#endif
void initializeLogChannelsIfNecessary()
{
@@ -46,9 +51,12 @@ void initializeLogChannelsIfNecessary()
haveInitializedLogChannels = true;
initializeLogChannel(&LogContextMenu);
+ initializeLogChannel(&LogIconDatabase);
initializeLogChannel(&LogSessionState);
initializeLogChannel(&LogTextInput);
initializeLogChannel(&LogView);
}
+} // namespace WebKit
+
#endif // LOG_DISABLED
diff --git a/Source/WebKit2/Platform/Logging.h b/Source/WebKit2/Platform/Logging.h
index b2cc391..098bc68 100644
--- a/Source/WebKit2/Platform/Logging.h
+++ b/Source/WebKit2/Platform/Logging.h
@@ -23,8 +23,8 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef Logging_h
-#define Logging_h
+#ifndef WebKitLogging_h
+#define WebKitLogging_h
#include <wtf/Assertions.h>
@@ -34,16 +34,18 @@
#define LOG_CHANNEL_PREFIX Log
#endif
-EXTERN_C_BEGIN
+namespace WebKit {
extern WTFLogChannel LogContextMenu;
+extern WTFLogChannel LogIconDatabase;
extern WTFLogChannel LogSessionState;
extern WTFLogChannel LogTextInput;
extern WTFLogChannel LogView;
+void initializeLogChannel(WTFLogChannel*);
void initializeLogChannelsIfNecessary(void);
-EXTERN_C_END
+} // namespace WebKit
#endif // LOG_DISABLED
diff --git a/Source/WebKit2/Platform/Module.cpp b/Source/WebKit2/Platform/Module.cpp
index 33ffbe0..a78db29 100644
--- a/Source/WebKit2/Platform/Module.cpp
+++ b/Source/WebKit2/Platform/Module.cpp
@@ -33,6 +33,9 @@ Module::Module(const String& path)
#if PLATFORM(WIN)
, m_module(0)
#endif
+#if PLATFORM(MAC) && !defined(__LP64__)
+ , m_bundleResourceMap(-1)
+#endif
{
}
diff --git a/Source/WebKit2/Platform/Module.h b/Source/WebKit2/Platform/Module.h
index 47899e9..b58e18a 100644
--- a/Source/WebKit2/Platform/Module.h
+++ b/Source/WebKit2/Platform/Module.h
@@ -56,12 +56,19 @@ public:
template<typename FunctionType> FunctionType functionPointer(const char* functionName) const;
+#if PLATFORM(MAC) && !defined(__LP64__)
+ CFBundleRefNum bundleResourceMap();
+#endif
+
private:
void* platformFunctionPointer(const char* functionName) const;
String m_path;
#if PLATFORM(MAC)
RetainPtr<CFBundleRef> m_bundle;
+#if !defined(__LP64__)
+ CFBundleRefNum m_bundleResourceMap;
+#endif
#elif PLATFORM(WIN)
HMODULE m_module;
#elif PLATFORM(QT)
diff --git a/Source/WebKit2/Platform/WorkQueue.h b/Source/WebKit2/Platform/WorkQueue.h
index 441d625..99f77ae 100644
--- a/Source/WebKit2/Platform/WorkQueue.h
+++ b/Source/WebKit2/Platform/WorkQueue.h
@@ -106,7 +106,7 @@ private:
dispatch_queue_t m_dispatchQueue;
#endif
#elif PLATFORM(WIN)
- class WorkItemWin : public ThreadSafeShared<WorkItemWin> {
+ class WorkItemWin : public ThreadSafeRefCounted<WorkItemWin> {
public:
static PassRefPtr<WorkItemWin> create(PassOwnPtr<WorkItem>, WorkQueue*);
virtual ~WorkItemWin();
diff --git a/Source/WebKit2/Platform/cg/CGUtilities.cpp b/Source/WebKit2/Platform/cg/CGUtilities.cpp
index e57206d..6cde8ee 100644
--- a/Source/WebKit2/Platform/cg/CGUtilities.cpp
+++ b/Source/WebKit2/Platform/cg/CGUtilities.cpp
@@ -29,37 +29,29 @@
#include <wtf/RetainPtr.h>
namespace WebKit {
-
-void paintBitmapContext(CGContextRef context, CGContextRef bitmapContext, CGPoint destination, CGRect source)
-{
- void* bitmapData = CGBitmapContextGetData(bitmapContext);
- ASSERT(bitmapData);
-
- size_t imageWidth = CGBitmapContextGetWidth(bitmapContext);
- size_t imageHeight = CGBitmapContextGetHeight(bitmapContext);
-
- size_t bytesPerRow = CGBitmapContextGetBytesPerRow(bitmapContext);
-
- RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateWithData(0, bitmapData, bytesPerRow * imageHeight, 0));
- RetainPtr<CGImageRef> image(AdoptCF, CGImageCreate(imageWidth, imageHeight,
- CGBitmapContextGetBitsPerComponent(bitmapContext),
- CGBitmapContextGetBitsPerPixel(bitmapContext),
- bytesPerRow,
- CGBitmapContextGetColorSpace(bitmapContext),
- CGBitmapContextGetBitmapInfo(bitmapContext),
- dataProvider.get(), 0, false, kCGRenderingIntentDefault));
+void paintImage(CGContextRef context, CGImageRef image, CGPoint destination, CGRect source)
+{
CGContextSaveGState(context);
CGContextClipToRect(context, CGRectMake(destination.x, destination.y, source.size.width, source.size.height));
CGContextScaleCTM(context, 1, -1);
+ size_t imageHeight = CGImageGetHeight(image);
+ size_t imageWidth = CGImageGetWidth(image);
+
CGFloat destX = destination.x - source.origin.x;
CGFloat destY = -static_cast<CGFloat>(imageHeight) - destination.y + source.origin.y;
- CGContextDrawImage(context, CGRectMake(destX, destY, imageWidth, imageHeight), image.get());
+ CGContextDrawImage(context, CGRectMake(destX, destY, imageWidth, imageHeight), image);
CGContextRestoreGState(context);
}
-
+
+void paintBitmapContext(CGContextRef context, CGContextRef bitmapContext, CGPoint destination, CGRect source)
+{
+ RetainPtr<CGImageRef> image(AdoptCF, CGBitmapContextCreateImage(bitmapContext));
+ paintImage(context, image.get(), destination, source);
+}
+
} // namespace WebKit
diff --git a/Source/WebKit2/Platform/cg/CGUtilities.h b/Source/WebKit2/Platform/cg/CGUtilities.h
index 3dca654..82cf6dd 100644
--- a/Source/WebKit2/Platform/cg/CGUtilities.h
+++ b/Source/WebKit2/Platform/cg/CGUtilities.h
@@ -28,6 +28,7 @@
namespace WebKit {
+void paintImage(CGContextRef, CGImageRef, CGPoint destination, CGRect source);
void paintBitmapContext(CGContextRef, CGContextRef bitmapContext, CGPoint destination, CGRect source);
} // namespace WebKit
diff --git a/Source/WebKit2/Platform/mac/Logging.mac.mm b/Source/WebKit2/Platform/mac/Logging.mac.mm
new file mode 100644
index 0000000..6e45828
--- /dev/null
+++ b/Source/WebKit2/Platform/mac/Logging.mac.mm
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "Logging.h"
+
+namespace WebKit {
+
+#ifndef NDEBUG
+
+void initializeLogChannel(WTFLogChannel* channel)
+{
+ channel->state = WTFLogChannelOff;
+ NSString *logLevelString = [[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithUTF8String:channel->defaultName]];
+ if (!logLevelString)
+ return;
+
+ unsigned logLevel;
+ if (![[NSScanner scannerWithString:logLevelString] scanHexInt:&logLevel])
+ NSLog(@"unable to parse hex value for %s (%@), logging is off", channel->defaultName, logLevelString);
+ if ((logLevel & channel->mask) == channel->mask)
+ channel->state = WTFLogChannelOn;
+}
+
+#endif
+
+} // namespace WebKit
diff --git a/Source/WebKit2/Platform/mac/ModuleMac.mm b/Source/WebKit2/Platform/mac/ModuleMac.mm
index 078e7ee..1ec60f3 100644
--- a/Source/WebKit2/Platform/mac/ModuleMac.mm
+++ b/Source/WebKit2/Platform/mac/ModuleMac.mm
@@ -48,6 +48,13 @@ bool Module::load()
void Module::unload()
{
+ ASSERT(m_bundle);
+
+#if !defined(__LP64__)
+ if (m_bundleResourceMap != -1)
+ CFBundleCloseBundleResourceMap(m_bundle.get(), m_bundleResourceMap);
+#endif
+
// See the comment in Module.h for why we leak the bundle here.
m_bundle.releaseRef();
}
@@ -60,4 +67,14 @@ void* Module::platformFunctionPointer(const char* functionName) const
return CFBundleGetFunctionPointerForName(m_bundle.get(), functionNameString.get());
}
+#if !defined(__LP64__)
+CFBundleRefNum Module::bundleResourceMap()
+{
+ if (m_bundleResourceMap == -1)
+ m_bundleResourceMap = CFBundleOpenBundleResourceMap(m_bundle.get());
+
+ return m_bundleResourceMap;
+}
+#endif
+
}
diff --git a/Source/WebKit2/Platform/mac/RunLoopMac.mm b/Source/WebKit2/Platform/mac/RunLoopMac.mm
index 8258550..828c57f 100644
--- a/Source/WebKit2/Platform/mac/RunLoopMac.mm
+++ b/Source/WebKit2/Platform/mac/RunLoopMac.mm
@@ -30,7 +30,14 @@
void RunLoop::performWork(void* context)
{
- static_cast<RunLoop*>(context)->performWork();
+ // Wrap main thread in an Autorelease pool. Sending messages can call
+ // into objc code and accumulate memory.
+ if (current() == main()) {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ static_cast<RunLoop*>(context)->performWork();
+ [pool drain];
+ } else
+ static_cast<RunLoop*>(context)->performWork();
}
RunLoop::RunLoop()
@@ -91,7 +98,15 @@ void RunLoop::wakeUp()
void RunLoop::TimerBase::timerFired(CFRunLoopTimerRef, void* context)
{
TimerBase* timer = static_cast<TimerBase*>(context);
- timer->fired();
+
+ // Wrap main thread in an Autorelease pool. The timer can call
+ // into objc code and accumulate memory outside of the main event loop.
+ if (current() == main()) {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ timer->fired();
+ [pool drain];
+ } else
+ timer->fired();
}
RunLoop::TimerBase::TimerBase(RunLoop* runLoop)
diff --git a/Source/WebKit2/Platform/qt/SharedMemoryQt.cpp b/Source/WebKit2/Platform/qt/SharedMemoryQt.cpp
index 91af533..8d5d70f 100644
--- a/Source/WebKit2/Platform/qt/SharedMemoryQt.cpp
+++ b/Source/WebKit2/Platform/qt/SharedMemoryQt.cpp
@@ -101,7 +101,7 @@ void SharedMemory::Handle::adoptFromAttachment(int fileDescriptor, size_t size)
PassRefPtr<SharedMemory> SharedMemory::create(size_t size)
{
- QString tempName = QDir::temp().filePath("qwkshm.XXXXXX");
+ QString tempName = QDir::temp().filePath(QLatin1String("qwkshm.XXXXXX"));
QByteArray tempNameCSTR = tempName.toLocal8Bit();
char* tempNameC = tempNameCSTR.data();
diff --git a/Source/WebKit2/Platform/win/WorkQueueWin.cpp b/Source/WebKit2/Platform/win/WorkQueueWin.cpp
index 0a89225..44e9885 100644
--- a/Source/WebKit2/Platform/win/WorkQueueWin.cpp
+++ b/Source/WebKit2/Platform/win/WorkQueueWin.cpp
@@ -210,7 +210,7 @@ void WorkQueue::scheduleWork(PassOwnPtr<WorkItem> item)
::QueueUserWorkItem(workThreadCallback, this, WT_EXECUTEDEFAULT);
}
-struct TimerContext : public ThreadSafeShared<TimerContext> {
+struct TimerContext : public ThreadSafeRefCounted<TimerContext> {
static PassRefPtr<TimerContext> create() { return adoptRef(new TimerContext); }
WorkQueue* queue;