2010-09-15 Jessie Berlin <jberlin@apple.com>
authorjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Sep 2010 01:50:37 +0000 (01:50 +0000)
committerjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Sep 2010 01:50:37 +0000 (01:50 +0000)
        Reviewed by Jon Honeycutt.

        We should save messages that can't be sent when postMessageToInjectedBundle is called and
        send them in ensureWebProcess.
        https://bugs.webkit.org/show_bug.cgi?id=45822

        * UIProcess/WebContext.cpp:
        (WebKit::WebContext::ensureWebProcess):
        Post any messages to the Injected Bundle that couldn't be sent earlier because the
        WebProcess hadn't been initialized yet.
        (WebKit::WebContext::postMessageToInjectedBundle):
        * UIProcess/WebContext.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@67593 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit2/ChangeLog
WebKit2/UIProcess/WebContext.cpp
WebKit2/UIProcess/WebContext.h

index 2d33a4a..9f7523c 100644 (file)
@@ -1,3 +1,18 @@
+2010-09-15  Jessie Berlin  <jberlin@apple.com>
+
+        Reviewed by Jon Honeycutt.
+
+        We should save messages that can't be sent when postMessageToInjectedBundle is called and
+        send them in ensureWebProcess.
+        https://bugs.webkit.org/show_bug.cgi?id=45822
+
+        * UIProcess/WebContext.cpp:
+        (WebKit::WebContext::ensureWebProcess):
+        Post any messages to the Injected Bundle that couldn't be sent earlier because the
+        WebProcess hadn't been initialized yet.
+        (WebKit::WebContext::postMessageToInjectedBundle):
+        * UIProcess/WebContext.h:
+
 2010-09-15  Simon Fraser  <simon.fraser@apple.com>
 
         Reviewed by Sam Weinig.
index abbe72a..6e014c8 100644 (file)
@@ -130,6 +130,12 @@ void WebContext::ensureWebProcess()
     for (HashSet<String>::iterator it = m_schemesToRegisterAsEmptyDocument.begin(), end = m_schemesToRegisterAsEmptyDocument.end(); it != end; ++it)
         m_process->send(WebProcessMessage::RegisterURLSchemeAsEmptyDocument, 0, CoreIPC::In(*it));
 
+    for (size_t i = 0; i != m_pendingMessagesToPostToInjectedBundle.size(); ++i) {
+        pair<String, RefPtr<APIObject> >* message = &m_pendingMessagesToPostToInjectedBundle[i];
+        m_process->send(InjectedBundleMessage::PostMessage, 0, CoreIPC::In(message->first, WebContextUserMessageEncoder(message->second.get())));
+    }
+    m_pendingMessagesToPostToInjectedBundle.clear();
+
     platformSetUpWebProcess();
 }
 
@@ -197,8 +203,10 @@ void WebContext::preferencesDidChange()
 
 void WebContext::postMessageToInjectedBundle(const String& messageName, APIObject* messageBody)
 {
-    if (!hasValidProcess())
+    if (!hasValidProcess()) {
+        m_pendingMessagesToPostToInjectedBundle.append(make_pair(messageName, messageBody));
         return;
+    }
 
     // FIXME: We should consider returning false from this function if the messageBody cannot
     // be encoded.
index ff08c12..e7d24d1 100644 (file)
@@ -136,6 +136,7 @@ private:
     VisitedLinkProvider m_visitedLinkProvider;
         
     HashSet<WTF::String> m_schemesToRegisterAsEmptyDocument;
+    Vector<pair<String, RefPtr<APIObject> > > m_pendingMessagesToPostToInjectedBundle;
 
 #if PLATFORM(WIN)
     bool m_shouldPaintNativeControls;