Title: [151646] trunk/Source/WebKit2
Revision
151646
Author
[email protected]
Date
2013-06-17 10:53:58 -0700 (Mon, 17 Jun 2013)

Log Message

<rdar://problem/13145014> Allow CoreIPC messages to transmit importance boosts

Transmitting the importance boost from the UI process to the web process is particularly
important when disabling process suppression on a web process, as it will minimize the
delays that can occur before the message instructing process suppression to be disabled
is processed by the web process.

We keep the importance boost alive for the duration of the CoreIPC message handler. We
achieve this by having an ImportanceAssertion object that owns the assertion, and whose
lifetime is tied to that of the MessageDecoder.

Reviewed by Anders Carlsson.

* Platform/CoreIPC/MessageDecoder.cpp:
(CoreIPC::MessageDecoder::setImportanceAssertion): Associate an importance assertion
with this message.
* Platform/CoreIPC/MessageDecoder.h:
* Platform/CoreIPC/mac/ConnectionMac.cpp:
(CoreIPC::Connection::open): Mark our receive port as allowing importance boosts to be received.
(CoreIPC::Connection::receiveSourceEventHandler):
* Platform/CoreIPC/mac/ImportanceAssertion.h:
(CoreIPC::ImportanceAssertion::create):
(CoreIPC::ImportanceAssertion::~ImportanceAssertion): Release the assertion.
(CoreIPC::ImportanceAssertion::ImportanceAssertion): Take an assertion if a boost was present in
the Mach message.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (151645 => 151646)


--- trunk/Source/WebKit2/ChangeLog	2013-06-17 16:40:22 UTC (rev 151645)
+++ trunk/Source/WebKit2/ChangeLog	2013-06-17 17:53:58 UTC (rev 151646)
@@ -1,5 +1,33 @@
 2013-06-17  Mark Rowe  <[email protected]>
 
+        <rdar://problem/13145014> Allow CoreIPC messages to transmit importance boosts
+
+        Transmitting the importance boost from the UI process to the web process is particularly
+        important when disabling process suppression on a web process, as it will minimize the
+        delays that can occur before the message instructing process suppression to be disabled
+        is processed by the web process.
+
+        We keep the importance boost alive for the duration of the CoreIPC message handler. We
+        achieve this by having an ImportanceAssertion object that owns the assertion, and whose
+        lifetime is tied to that of the MessageDecoder.
+
+        Reviewed by Anders Carlsson.
+
+        * Platform/CoreIPC/MessageDecoder.cpp:
+        (CoreIPC::MessageDecoder::setImportanceAssertion): Associate an importance assertion
+        with this message.
+        * Platform/CoreIPC/MessageDecoder.h:
+        * Platform/CoreIPC/mac/ConnectionMac.cpp:
+        (CoreIPC::Connection::open): Mark our receive port as allowing importance boosts to be received.
+        (CoreIPC::Connection::receiveSourceEventHandler):
+        * Platform/CoreIPC/mac/ImportanceAssertion.h:
+        (CoreIPC::ImportanceAssertion::create):
+        (CoreIPC::ImportanceAssertion::~ImportanceAssertion): Release the assertion.
+        (CoreIPC::ImportanceAssertion::ImportanceAssertion): Take an assertion if a boost was present in
+        the Mach message.
+
+2013-06-17  Mark Rowe  <[email protected]>
+
         <rdar://problem/14051357> Web processes sometimes remain in a suppressed
         state after their window is unoccluded.
 

Modified: trunk/Source/WebKit2/Platform/CoreIPC/MessageDecoder.cpp (151645 => 151646)


--- trunk/Source/WebKit2/Platform/CoreIPC/MessageDecoder.cpp	2013-06-17 16:40:22 UTC (rev 151645)
+++ trunk/Source/WebKit2/Platform/CoreIPC/MessageDecoder.cpp	2013-06-17 17:53:58 UTC (rev 151646)
@@ -31,6 +31,10 @@
 #include "MessageFlags.h"
 #include "StringReference.h"
 
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+#include "ImportanceAssertion.h"
+#endif
+
 namespace CoreIPC {
 
 PassOwnPtr<MessageDecoder> MessageDecoder::create(const DataReference& buffer)
@@ -73,4 +77,11 @@
     return m_messageFlags & DispatchMessageWhenWaitingForSyncReply;
 }
 
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+void MessageDecoder::setImportanceAssertion(PassOwnPtr<ImportanceAssertion> assertion)
+{
+    m_importanceAssertion = assertion;
+}
+#endif
+
 } // namespace CoreIPC

Modified: trunk/Source/WebKit2/Platform/CoreIPC/MessageDecoder.h (151645 => 151646)


--- trunk/Source/WebKit2/Platform/CoreIPC/MessageDecoder.h	2013-06-17 16:40:22 UTC (rev 151645)
+++ trunk/Source/WebKit2/Platform/CoreIPC/MessageDecoder.h	2013-06-17 17:53:58 UTC (rev 151646)
@@ -32,6 +32,7 @@
 namespace CoreIPC {
 
 class DataReference;
+class ImportanceAssertion;
 
 class MessageDecoder : public ArgumentDecoder {
 public:
@@ -45,12 +46,20 @@
     bool isSyncMessage() const;
     bool shouldDispatchMessageWhenWaitingForSyncReply() const;
 
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+    void setImportanceAssertion(PassOwnPtr<ImportanceAssertion>);
+#endif
+
 private:
     MessageDecoder(const DataReference& buffer, Vector<Attachment>&);
 
     uint8_t m_messageFlags;
     StringReference m_messageReceiverName;
     StringReference m_messageName;
+
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+    OwnPtr<ImportanceAssertion> m_importanceAssertion;
+#endif
 };
 
 } // namespace CoreIPC

Modified: trunk/Source/WebKit2/Platform/CoreIPC/mac/ConnectionMac.cpp (151645 => 151646)


--- trunk/Source/WebKit2/Platform/CoreIPC/mac/ConnectionMac.cpp	2013-06-17 16:40:22 UTC (rev 151645)
+++ trunk/Source/WebKit2/Platform/CoreIPC/mac/ConnectionMac.cpp	2013-06-17 17:53:58 UTC (rev 151646)
@@ -27,6 +27,7 @@
 #include "Connection.h"
 
 #include "DataReference.h"
+#include "ImportanceAssertion.h"
 #include "MachPort.h"
 #include "MachUtilities.h"
 #include <WebCore/RunLoop.h>
@@ -133,6 +134,10 @@
         // Create the receive port.
         mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &m_receivePort);
 
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+        mach_port_set_attributes(mach_task_self(), m_receivePort, MACH_PORT_IMPORTANCE_RECEIVER, (mach_port_info_t)0, 0);
+#endif
+
         m_isConnected = true;
         
         // Send the initialize message, which contains a send right for the server to use.
@@ -405,6 +410,10 @@
     OwnPtr<MessageDecoder> decoder = createMessageDecoder(header);
     ASSERT(decoder);
 
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+    decoder->setImportanceAssertion(ImportanceAssertion::create(header));
+#endif
+
     if (decoder->messageReceiverName() == "IPC" && decoder->messageName() == "InitializeConnection") {
         ASSERT(m_isServer);
         ASSERT(!m_isConnected);

Copied: trunk/Source/WebKit2/Platform/CoreIPC/mac/ImportanceAssertion.h (from rev 151645, trunk/Source/WebKit2/Platform/CoreIPC/MessageDecoder.h) (0 => 151646)


--- trunk/Source/WebKit2/Platform/CoreIPC/mac/ImportanceAssertion.h	                        (rev 0)
+++ trunk/Source/WebKit2/Platform/CoreIPC/mac/ImportanceAssertion.h	2013-06-17 17:53:58 UTC (rev 151646)
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+#ifndef ImportanceAssertion_h
+#define ImportanceAssertion_h
+
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+
+#include <wtf/PassOwnPtr.h>
+
+#if __has_include(<libproc_internal.h>)
+#include <libproc_internal.h>
+#endif
+
+extern "C" int proc_importance_assertion_begin_with_msg(mach_msg_header_t*, mach_msg_trailer_t*, uint64_t*);
+extern "C" int proc_importance_assertion_complete(uint64_t assertion_handle);
+
+namespace CoreIPC {
+
+class ImportanceAssertion {
+    WTF_MAKE_NONCOPYABLE(ImportanceAssertion);
+
+public:
+    static PassOwnPtr<ImportanceAssertion> create(mach_msg_header_t* header)
+    {
+        return adoptPtr(new ImportanceAssertion(header));
+    }
+
+    ~ImportanceAssertion()
+    {
+        proc_importance_assertion_complete(m_assertion);
+    }
+
+private:
+    ImportanceAssertion(mach_msg_header_t* header)
+        : m_assertion(0)
+    {
+        proc_importance_assertion_begin_with_msg(header, 0, &m_assertion);
+    }
+
+    uint64_t m_assertion;
+};
+
+}
+
+#endif // __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+
+#endif // ImportanceAssertion_h
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to