Bug 45822 - We should save messages that can't be sent when postMessageToInjectedBundle is called and send in ensureWebProcess
Summary: We should save messages that can't be sent when postMessageToInjectedBundle i...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Jessie Berlin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-15 09:25 PDT by Jessie Berlin
Modified: 2010-09-15 18:51 PDT (History)
4 users (show)

See Also:


Attachments
Save the messages in postMessageToInjectedBundle and send them in ensureWebProcess (2.74 KB, patch)
2010-09-15 16:46 PDT, Jessie Berlin
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jessie Berlin 2010-09-15 09:25:44 PDT
WebContext::registerURLSchemeAsEmptyDocument saves the URL Schemes that can't be registered immediately because the WebProcess is not valid at the time it is called and then sends those messages in WebContext::ensureWebProcess.

WebContext::postMessageToInjectedBundle should do the same with messages.
Comment 1 Jessie Berlin 2010-09-15 16:46:47 PDT
Created attachment 67741 [details]
Save the messages in postMessageToInjectedBundle and send them in ensureWebProcess
Comment 2 Jon Honeycutt 2010-09-15 18:17:34 PDT
Comment on attachment 67741 [details]
Save the messages in postMessageToInjectedBundle and send them in ensureWebProcess

> @@ -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];

I think you can make message a reference to avoid a copy.

> @@ -197,8 +203,10 @@ void WebContext::preferencesDidChange()
>  
>  void WebContext::postMessageToInjectedBundle(const String& messageName, APIObject* messageBody)
>  {
> -    if (!hasValidProcess())
> +    if (!hasValidProcess()) {
> +        m_pendingMessagesToPostToInjectedBundle.append(pair<String, RefPtr<APIObject> >(messageName, messageBody));

You can simplify this using make_pair(messageName, messageBody).

r=me
Comment 3 Jessie Berlin 2010-09-15 18:45:52 PDT
(In reply to comment #2)
> (From update of attachment 67741 [details])
> > @@ -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];
> 
> I think you can make message a reference to avoid a copy.

Done.

> 
> > @@ -197,8 +203,10 @@ void WebContext::preferencesDidChange()
> >  
> >  void WebContext::postMessageToInjectedBundle(const String& messageName, APIObject* messageBody)
> >  {
> > -    if (!hasValidProcess())
> > +    if (!hasValidProcess()) {
> > +        m_pendingMessagesToPostToInjectedBundle.append(pair<String, RefPtr<APIObject> >(messageName, messageBody));
> 
> You can simplify this using make_pair(messageName, messageBody).

Done.

> 
> r=me

Thanks!
Comment 4 Jessie Berlin 2010-09-15 18:51:35 PDT
Comment on attachment 67741 [details]
Save the messages in postMessageToInjectedBundle and send them in ensureWebProcess

Committed in r67593:
http://trac.webkit.org/changeset/67593