Changeset 150785 in webkit


Ignore:
Timestamp:
May 27, 2013 5:02:46 PM (11 years ago)
Author:
jonlee@apple.com
Message:

[WK2] Notifications clobber each other with multiple processes
https://bugs.webkit.org/show_bug.cgi?id=116428
<rdar://problem/13935191>

Reviewed by Darin Adler.

.:

  • ManualTests/notification-in-multiple-windows.html: Added.

Source/WebKit2:

With multiple processes, the notification IDs, when passed up to the UI process, can clobber
each other. To fix this, we need to maintain a global map of notification IDs. This map is
keyed by its own unique notification ID, and maps to a pair containing the web page ID and that
web page's ID for the notification.

Now that we maintain groups of notifications based on the web page, we no longer send IPC messages
from WebNotificationManager to WebNotificationManagerProxy; instead we send messages to the
WebPageProxy. This removes the need for WebNotificationManagerProxy to be a message receiver.

When a page closes, all of the web notifications are cleared out. However, by the time the
WebPage::close() is called, the connection between WebPage and WebPageProxy is destroyed. Since
the WebPage is told to close from the UI process anyway, we clear out the notifications separately,
instead of waiting for a message from the WebPage.

  • UIProcess/Notifications/WebNotificationManagerProxy.h: Update to take into account the

notification's web page. Remove inheritance of CoreIPC::MessageReceiver. Expose the original message
handlers as public functions, since they will be called from WebPageProxy. Add a new map that
associates a global ID with a notification ID that came from a web page.

There are now two flavors of clearNotifications(). One clears out all notifications associated

with a web page. This is called when the page is closed. The other clears out a subset of
notifications associated with a web page. This is called when notifications associated with a sub-frame
is closed.

  • UIProcess/Notifications/WebNotificationManagerProxy.messages.in: Removed. All messages from

the web process go to WebPageProxy now.

  • UIProcess/Notifications/WebNotificationManagerProxy.cpp: Update to take into account the

notification's web page.

(WebKit::generateGlobalNotificationID): The manager proxy now maintains its own global notification
ID generator.
(WebKit::WebNotificationManagerProxy::WebNotificationManagerProxy): The proxy is no longer a
message receiver. Remove code that registers it as such.

(WebKit::WebNotificationManagerProxy::show): Refactor to differentiate between the notification ID
that came from the web process, and the global notification ID the proxy maintains. Add the mapping
from the global ID to the (web page ID, notification ID) pair.
(WebKit::WebNotificationManagerProxy::cancel): Refactor to take into consideration the web page.
(WebKit::WebNotificationManagerProxy::didDestroyNotification): Refactor to take into consideration
the web page. Fixes a leak where we did not remove the item from the maps. This function is called
from the web process, when the ScriptExecutionContext is destroyed, so we remove it from our maps
before we pass the message along to the provider.

Helper functions that evaluate when a given notification in the map matches the desired parameters.
(WebKit::pageIDsMatch): The notification is associated with the provided page.
(WebKit::pageAndNotificationIDsMatch): The notification is associated with the provided page and is
contained within the list of provided notifications.

(WebKit::WebNotificationManagerProxy::clearNotifications): Changed to only remove notifications
associated with the provided web page, and could include a specific list of notifications. This latter
situation occurs if notifications were associated with an iframe, and that iframe was removed.
There is an O(n) walk that could be make more efficient using another hash map, but that's overhead
for a map that should be small in size anyway.

(WebKit::WebNotificationManagerProxy::providerDidShowNotification): Refactor to take into
consideration the web page.
(WebKit::WebNotificationManagerProxy::providerDidClickNotification): Refactor to take into
consideration the web page.
(WebKit::WebNotificationManagerProxy::providerDidCloseNotifications): Now we need to comb through
the list of global IDs and put them in buckets based on the notification's web pages. After that
is done we can send the DidCloseNotifications() to those pages' processes. There is a possible
extra optimization here where we group based on the page's process instead, to reduce the number
of messages sent to processes.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::close): When a web page is closed, we clear the notifications associated
with the page.
(WebKit::WebPageProxy::cancelNotification): Forward call to WebNotificationManagerProxy.
(WebKit::WebPageProxy::clearNotifications): Ditto.
(WebKit::WebPageProxy::didDestroyNotification): Ditto.

  • UIProcess/WebPageProxy.h:
  • UIProcess/WebPageProxy.messages.in:
  • WebProcess/Notifications/NotificationPermissionRequestManager.cpp:
  • WebProcess/Notifications/WebNotificationManager.cpp:

(WebKit::WebNotificationManager::cancel):
(WebKit::WebNotificationManager::clearNotifications):
(WebKit::WebNotificationManager::didDestroyNotification):

  • WebProcess/Notifications/NotificationPermissionRequestManager.cpp: Remove extraneous include.
  • CMakeLists.txt: Remove WebNotificationManagerProxy.messages.in and related files.
  • DerivedSources.pri: Ditto.
  • DerivedSources.make: Ditto.
  • GNUmakefile.list.am: Ditto.
  • WebKit2.xcodeproj/project.pbxproj: Ditto.
Location:
trunk
Files:
1 added
1 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r150767 r150785  
     12013-05-26  Jon Lee  <jonlee@apple.com>
     2
     3        [WK2] Notifications clobber each other with multiple processes
     4        https://bugs.webkit.org/show_bug.cgi?id=116428
     5        <rdar://problem/13935191>
     6
     7        Reviewed by Darin Adler.
     8
     9        * ManualTests/notification-in-multiple-windows.html: Added.
     10
    1112013-05-27  Patrick Gansterer  <paroga@webkit.org>
    212
  • trunk/Source/WebKit2/CMakeLists.txt

    r150679 r150785  
    552552    UIProcess/Downloads/DownloadProxy.messages.in
    553553
    554     UIProcess/Notifications/WebNotificationManagerProxy.messages.in
    555 
    556554    UIProcess/Plugins/PluginProcessProxy.messages.in
    557555
  • trunk/Source/WebKit2/ChangeLog

    r150774 r150785  
     12013-05-26  Jon Lee  <jonlee@apple.com>
     2
     3        [WK2] Notifications clobber each other with multiple processes
     4        https://bugs.webkit.org/show_bug.cgi?id=116428
     5        <rdar://problem/13935191>
     6
     7        Reviewed by Darin Adler.
     8
     9        With multiple processes, the notification IDs, when passed up to the UI process, can clobber
     10        each other. To fix this, we need to maintain a global map of notification IDs. This map is
     11        keyed by its own unique notification ID, and maps to a pair containing the web page ID and that
     12        web page's ID for the notification.
     13
     14        Now that we maintain groups of notifications based on the web page, we no longer send IPC messages
     15        from WebNotificationManager to WebNotificationManagerProxy; instead we send messages to the
     16        WebPageProxy. This removes the need for WebNotificationManagerProxy to be a message receiver.
     17
     18        When a page closes, all of the web notifications are cleared out. However, by the time the
     19        WebPage::close() is called, the connection between WebPage and WebPageProxy is destroyed. Since
     20        the WebPage is told to close from the UI process anyway, we clear out the notifications separately,
     21        instead of waiting for a message from the WebPage.
     22
     23        * UIProcess/Notifications/WebNotificationManagerProxy.h: Update to take into account the
     24        notification's web page. Remove inheritance of CoreIPC::MessageReceiver. Expose the original message
     25        handlers as public functions, since they will be called from WebPageProxy. Add a new map that
     26        associates a global ID with a notification ID that came from a web page.
     27            There are now two flavors of clearNotifications(). One clears out all notifications associated
     28        with a web page. This is called when the page is closed. The other clears out a subset of
     29        notifications associated with a web page. This is called when notifications associated with a sub-frame
     30        is closed.
     31        * UIProcess/Notifications/WebNotificationManagerProxy.messages.in: Removed. All messages from
     32        the web process go to WebPageProxy now.
     33
     34        * UIProcess/Notifications/WebNotificationManagerProxy.cpp: Update to take into account the
     35        notification's web page.
     36
     37        (WebKit::generateGlobalNotificationID): The manager proxy now maintains its own global notification
     38        ID generator.
     39        (WebKit::WebNotificationManagerProxy::WebNotificationManagerProxy): The proxy is no longer a
     40        message receiver. Remove code that registers it as such.
     41
     42        (WebKit::WebNotificationManagerProxy::show): Refactor to differentiate between the notification ID
     43        that came from the web process, and the global notification ID the proxy maintains. Add the mapping
     44        from the global ID to the (web page ID, notification ID) pair.
     45        (WebKit::WebNotificationManagerProxy::cancel): Refactor to take into consideration the web page.
     46        (WebKit::WebNotificationManagerProxy::didDestroyNotification): Refactor to take into consideration
     47        the web page. Fixes a leak where we did not remove the item from the maps. This function is called
     48        from the web process, when the ScriptExecutionContext is destroyed, so we remove it from our maps
     49        before we pass the message along to the provider.
     50
     51        Helper functions that evaluate when a given notification in the map matches the desired parameters.
     52        (WebKit::pageIDsMatch): The notification is associated with the provided page.
     53        (WebKit::pageAndNotificationIDsMatch): The notification is associated with the provided page and is
     54        contained within the list of provided notifications.
     55
     56        (WebKit::WebNotificationManagerProxy::clearNotifications): Changed to only remove notifications
     57        associated with the provided web page, and could include a specific list of notifications. This latter
     58        situation occurs if notifications were associated with an iframe, and that iframe was removed.
     59        There is an O(n) walk that could be make more efficient using another hash map, but that's overhead
     60        for a map that should be small in size anyway.
     61
     62        (WebKit::WebNotificationManagerProxy::providerDidShowNotification): Refactor to take into
     63        consideration the web page.
     64        (WebKit::WebNotificationManagerProxy::providerDidClickNotification): Refactor to take into
     65        consideration the web page.
     66        (WebKit::WebNotificationManagerProxy::providerDidCloseNotifications): Now we need to comb through
     67        the list of global IDs and put them in buckets based on the notification's web pages. After that
     68        is done we can send the DidCloseNotifications() to those pages' processes. There is a possible
     69        extra optimization here where we group based on the page's process instead, to reduce the number
     70        of messages sent to processes.
     71
     72        * UIProcess/WebPageProxy.cpp:
     73        (WebKit::WebPageProxy::close): When a web page is closed, we clear the notifications associated
     74        with the page.
     75        (WebKit::WebPageProxy::cancelNotification): Forward call to WebNotificationManagerProxy.
     76        (WebKit::WebPageProxy::clearNotifications): Ditto.
     77        (WebKit::WebPageProxy::didDestroyNotification): Ditto.
     78        * UIProcess/WebPageProxy.h:
     79        * UIProcess/WebPageProxy.messages.in:
     80
     81        * WebProcess/Notifications/NotificationPermissionRequestManager.cpp:
     82        * WebProcess/Notifications/WebNotificationManager.cpp:
     83        (WebKit::WebNotificationManager::cancel):
     84        (WebKit::WebNotificationManager::clearNotifications):
     85        (WebKit::WebNotificationManager::didDestroyNotification):
     86        * WebProcess/Notifications/NotificationPermissionRequestManager.cpp: Remove extraneous include.
     87
     88        * CMakeLists.txt: Remove WebNotificationManagerProxy.messages.in and related files.
     89        * DerivedSources.pri: Ditto.
     90        * DerivedSources.make: Ditto.
     91        * GNUmakefile.list.am: Ditto.
     92        * WebKit2.xcodeproj/project.pbxproj: Ditto.
     93
    1942013-05-27  Tim Horton  <timothy_horton@apple.com>
    295
  • trunk/Source/WebKit2/DerivedSources.make

    r150305 r150785  
    105105    WebMediaCacheManager \
    106106    WebMediaCacheManagerProxy \
    107     WebNotificationManagerProxy \
    108107    WebNotificationManager \
    109108    WebPage \
  • trunk/Source/WebKit2/DerivedSources.pri

    r150327 r150785  
    9898    WebNetworkInfoManager.messages.in \
    9999    WebNetworkInfoManagerProxy.messages.in \
    100     WebNotificationManagerProxy.messages.in \
    101100    WebNotificationManager.messages.in \
    102101    WebFullScreenManager.messages.in \
  • trunk/Source/WebKit2/GNUmakefile.list.am

    r150745 r150785  
    215215        DerivedSources/WebKit2/WebNotificationManagerMessageReceiver.cpp \
    216216        DerivedSources/WebKit2/WebNotificationManagerMessages.h \
    217         DerivedSources/WebKit2/WebNotificationManagerProxyMessageReceiver.cpp \
    218         DerivedSources/WebKit2/WebNotificationManagerProxyMessages.h \
    219217        DerivedSources/WebKit2/WebPageGroupProxyMessageReceiver.cpp \
    220218        DerivedSources/WebKit2/WebPageGroupProxyMessages.h \
  • trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp

    r150020 r150785  
    3232#include "WebNotification.h"
    3333#include "WebNotificationManagerMessages.h"
    34 #include "WebNotificationManagerProxyMessages.h"
    3534#include "WebPageProxy.h"
     35#include "WebProcessProxy.h"
    3636#include "WebSecurityOrigin.h"
    3737
     38using namespace std;
    3839using namespace WTF;
    3940using namespace WebCore;
     
    4142namespace WebKit {
    4243
     44static uint64_t generateGlobalNotificationID()
     45{
     46    static uint64_t uniqueGlobalNotificationID = 1;
     47    return uniqueGlobalNotificationID++;
     48}
     49
    4350const char* WebNotificationManagerProxy::supplementName()
    4451{
     
    5461    : WebContextSupplement(context)
    5562{
    56     WebContextSupplement::context()->addMessageReceiver(Messages::WebNotificationManagerProxy::messageReceiverName(), this);
    5763}
    5864
     
    7985    APIObject::deref();
    8086}
    81 
    82 // CoreIPC::MessageReceiver
    8387
    8488void WebNotificationManagerProxy::populateCopyOfNotificationPermissions(HashMap<String, bool>& permissions)
     
    97101}
    98102
    99 void WebNotificationManagerProxy::show(WebPageProxy* page, const String& title, const String& body, const String& iconURL, const String& tag, const String& lang, const String& dir, const String& originString, uint64_t notificationID)
    100 {
    101     if (!isNotificationIDValid(notificationID))
    102         return;
    103    
    104     RefPtr<WebNotification> notification = WebNotification::create(title, body, iconURL, tag, lang, dir, originString, notificationID);
    105     m_notifications.set(notificationID, notification);
    106     m_provider.show(page, notification.get());
    107 }
    108 
    109 void WebNotificationManagerProxy::cancel(uint64_t notificationID)
    110 {
    111     if (!isNotificationIDValid(notificationID))
    112         return;
    113 
    114     RefPtr<WebNotification> notification = m_notifications.get(notificationID);
    115     if (!notification)
    116         return;
    117 
    118     m_provider.cancel(notification.get());
    119 }
    120    
    121 void WebNotificationManagerProxy::didDestroyNotification(uint64_t notificationID)
    122 {
    123     if (!isNotificationIDValid(notificationID))
    124         return;
    125 
    126     RefPtr<WebNotification> notification = m_notifications.take(notificationID);
    127     if (!notification)
    128         return;
    129 
    130     m_provider.didDestroyNotification(notification.get());
    131 }
    132 
    133 void WebNotificationManagerProxy::clearNotifications(const Vector<uint64_t>& notificationIDs)
    134 {
    135     m_provider.clearNotifications(notificationIDs);
    136     size_t count = notificationIDs.size();
    137     for (size_t i = 0; i < count; ++i)
    138         m_notifications.remove(notificationIDs[i]);
    139 }
    140 
    141 void WebNotificationManagerProxy::providerDidShowNotification(uint64_t notificationID)
    142 {
    143     if (!context())
    144         return;
    145    
    146     context()->sendToAllProcesses(Messages::WebNotificationManager::DidShowNotification(notificationID));
    147 }
    148 
    149 void WebNotificationManagerProxy::providerDidClickNotification(uint64_t notificationID)
    150 {
    151     if (!context())
    152         return;
    153    
    154     context()->sendToAllProcesses(Messages::WebNotificationManager::DidClickNotification(notificationID));
    155 }
    156 
    157 
    158 void WebNotificationManagerProxy::providerDidCloseNotifications(ImmutableArray* notificationIDs)
    159 {
    160     if (!context())
    161         return;
    162    
    163     size_t size = notificationIDs->size();
    164    
    165     Vector<uint64_t> vectorNotificationIDs;
    166     vectorNotificationIDs.reserveInitialCapacity(size);
    167    
     103void WebNotificationManagerProxy::show(WebPageProxy* webPage, const String& title, const String& body, const String& iconURL, const String& tag, const String& lang, const String& dir, const String& originString, uint64_t pageNotificationID)
     104{
     105    uint64_t globalNotificationID = generateGlobalNotificationID();
     106    RefPtr<WebNotification> notification = WebNotification::create(title, body, iconURL, tag, lang, dir, originString, globalNotificationID);
     107    pair<uint64_t, uint64_t> notificationIDPair = make_pair(webPage->pageID(), pageNotificationID);
     108    m_globalNotificationMap.set(globalNotificationID, notificationIDPair);
     109    m_notifications.set(notificationIDPair, make_pair(globalNotificationID, notification));
     110    m_provider.show(webPage, notification.get());
     111}
     112
     113void WebNotificationManagerProxy::cancel(WebPageProxy* webPage, uint64_t pageNotificationID)
     114{
     115    if (WebNotification* notification = m_notifications.get(make_pair(webPage->pageID(), pageNotificationID)).second.get())
     116        m_provider.cancel(notification);
     117}
     118   
     119void WebNotificationManagerProxy::didDestroyNotification(WebPageProxy* webPage, uint64_t pageNotificationID)
     120{
     121    auto globalIDNotificationPair = m_notifications.take(make_pair(webPage->pageID(), pageNotificationID));
     122    if (uint64_t globalNotificationID = globalIDNotificationPair.first) {
     123        WebNotification* notification = globalIDNotificationPair.second.get();
     124        m_globalNotificationMap.remove(globalNotificationID);
     125        m_provider.didDestroyNotification(notification);
     126    }
     127}
     128
     129static bool pageIDsMatch(uint64_t pageID, uint64_t, uint64_t desiredPageID, const Vector<uint64_t>&)
     130{
     131    return pageID == desiredPageID;
     132}
     133
     134static bool pageAndNotificationIDsMatch(uint64_t pageID, uint64_t pageNotificationID, uint64_t desiredPageID, const Vector<uint64_t>& desiredPageNotificationIDs)
     135{
     136    return pageID == desiredPageID && desiredPageNotificationIDs.contains(pageNotificationID);
     137}
     138
     139void WebNotificationManagerProxy::clearNotifications(WebPageProxy* webPage)
     140{
     141    clearNotifications(webPage, Vector<uint64_t>(), pageIDsMatch);
     142}
     143
     144void WebNotificationManagerProxy::clearNotifications(WebPageProxy* webPage, const Vector<uint64_t>& pageNotificationIDs)
     145{
     146    clearNotifications(webPage, pageNotificationIDs, pageAndNotificationIDsMatch);
     147}
     148
     149void WebNotificationManagerProxy::clearNotifications(WebPageProxy* webPage, const Vector<uint64_t>& pageNotificationIDs, NotificationFilterFunction filterFunction)
     150{
     151    uint64_t targetPageID = webPage->pageID();
     152
     153    Vector<uint64_t> globalNotificationIDs;
     154    globalNotificationIDs.reserveCapacity(m_globalNotificationMap.size());
     155
     156    for (auto it = m_notifications.begin(), end = m_notifications.end(); it != end; ++it) {
     157        uint64_t webPageID = it->key.first;
     158        uint64_t pageNotificationID = it->key.second;
     159        if (!filterFunction(webPageID, pageNotificationID, targetPageID, pageNotificationIDs))
     160            continue;
     161
     162        uint64_t globalNotificationID = it->value.first;
     163        globalNotificationIDs.append(globalNotificationID);
     164    }
     165
     166    for (auto it = globalNotificationIDs.begin(), end = globalNotificationIDs.end(); it != end; ++it) {
     167        auto pageNotification = m_globalNotificationMap.take(*it);
     168        m_notifications.remove(pageNotification);
     169    }
     170
     171    m_provider.clearNotifications(globalNotificationIDs);
     172}
     173
     174void WebNotificationManagerProxy::providerDidShowNotification(uint64_t globalNotificationID)
     175{
     176    auto it = m_globalNotificationMap.find(globalNotificationID);
     177    if (it == m_globalNotificationMap.end())
     178        return;
     179
     180    uint64_t webPageID = it->value.first;
     181    WebPageProxy* webPage = WebProcessProxy::webPage(webPageID);
     182    if (!webPage)
     183        return;
     184
     185    uint64_t pageNotificationID = it->value.second;
     186    webPage->process()->send(Messages::WebNotificationManager::DidShowNotification(pageNotificationID), 0);
     187}
     188
     189void WebNotificationManagerProxy::providerDidClickNotification(uint64_t globalNotificationID)
     190{
     191    auto it = m_globalNotificationMap.find(globalNotificationID);
     192    if (it == m_globalNotificationMap.end())
     193        return;
     194   
     195    uint64_t webPageID = it->value.first;
     196    WebPageProxy* webPage = WebProcessProxy::webPage(webPageID);
     197    if (!webPage)
     198        return;
     199
     200    uint64_t pageNotificationID = it->value.second;
     201    webPage->process()->send(Messages::WebNotificationManager::DidClickNotification(pageNotificationID), 0);
     202}
     203
     204
     205void WebNotificationManagerProxy::providerDidCloseNotifications(ImmutableArray* globalNotificationIDs)
     206{
     207    HashMap<WebPageProxy*, Vector<uint64_t>> pageNotificationIDs;
     208   
     209    size_t size = globalNotificationIDs->size();
    168210    for (size_t i = 0; i < size; ++i) {
    169         uint64_t notificationID = notificationIDs->at<WebUInt64>(i)->value();
    170         vectorNotificationIDs.append(notificationID);
    171     }
    172    
    173     if (vectorNotificationIDs.size())
    174         context()->sendToAllProcesses(Messages::WebNotificationManager::DidCloseNotifications(vectorNotificationIDs));
     211        auto it = m_globalNotificationMap.find(globalNotificationIDs->at<WebUInt64>(i)->value());
     212        if (it == m_globalNotificationMap.end())
     213            continue;
     214
     215        if (WebPageProxy* webPage = WebProcessProxy::webPage(it->value.first)) {
     216            auto pageIt = pageNotificationIDs.find(webPage);
     217            if (pageIt == pageNotificationIDs.end()) {
     218                Vector<uint64_t> newVector;
     219                newVector.reserveInitialCapacity(size);
     220                pageIt = pageNotificationIDs.add(webPage, newVector).iterator;
     221            }
     222
     223            uint64_t pageNotificationID = it->value.second;
     224            pageIt->value.append(pageNotificationID);
     225        }
     226
     227        m_notifications.remove(it->value);
     228        m_globalNotificationMap.remove(it);
     229    }
     230
     231    for (auto it = pageNotificationIDs.begin(), end = pageNotificationIDs.end(); it != end; ++it)
     232        it->key->process()->send(Messages::WebNotificationManager::DidCloseNotifications(it->value), 0);
    175233}
    176234
  • trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h

    r150020 r150785  
    4444class WebSecurityOrigin;
    4545
    46 class WebNotificationManagerProxy : public TypedAPIObject<APIObject::TypeNotificationManager>, public WebContextSupplement, private CoreIPC::MessageReceiver {
     46class WebNotificationManagerProxy : public TypedAPIObject<APIObject::TypeNotificationManager>, public WebContextSupplement {
    4747public:
    4848
     
    5454    void populateCopyOfNotificationPermissions(HashMap<String, bool>&);
    5555
    56     void show(WebPageProxy*, const String& title, const String& body, const String& iconURL, const String& tag, const String& lang, const String& dir, const String& originString, uint64_t notificationID);
     56    void show(WebPageProxy*, const String& title, const String& body, const String& iconURL, const String& tag, const String& lang, const String& dir, const String& originString, uint64_t pageNotificationID);
     57    void cancel(WebPageProxy*, uint64_t pageNotificationID);
     58    void clearNotifications(WebPageProxy*);
     59    void clearNotifications(WebPageProxy*, const Vector<uint64_t>& pageNotificationIDs);
     60    void didDestroyNotification(WebPageProxy*, uint64_t pageNotificationID);
    5761
    5862    void providerDidShowNotification(uint64_t notificationID);
     
    6872    explicit WebNotificationManagerProxy(WebContext*);
    6973
     74    typedef bool (*NotificationFilterFunction)(uint64_t pageID, uint64_t pageNotificationID, uint64_t desiredPageID, const Vector<uint64_t>& desiredPageNotificationIDs);
     75    void clearNotifications(WebPageProxy*, const Vector<uint64_t>& pageNotificationIDs, NotificationFilterFunction);
     76
    7077    // WebContextSupplement
    7178    virtual void contextDestroyed() OVERRIDE;
     
    7380    virtual void derefWebContextSupplement() OVERRIDE;
    7481
    75     // CoreIPC::MessageReceiver
    76     virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) OVERRIDE;
    77    
    78     // Message handlers
    79     void cancel(uint64_t notificationID);
    80     void didDestroyNotification(uint64_t notificationID);
    81     void clearNotifications(const Vector<uint64_t>& notificationIDs);
    82 
    83     typedef HashMap<uint64_t, RefPtr<WebNotification>> WebNotificationMap;
    84    
    8582    WebNotificationProvider m_provider;
    86     WebNotificationMap m_notifications;
     83    // Pair comprised of web page ID and the web process's notification ID
     84    HashMap<uint64_t, pair<uint64_t, uint64_t>> m_globalNotificationMap;
     85    // Key pair comprised of web page ID and the web process's notification ID; value pair comprised of global notification ID, and notification object
     86    HashMap<pair<uint64_t, uint64_t>, pair<uint64_t, RefPtr<WebNotification>>> m_notifications;
    8787};
    8888
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r150624 r150785  
    592592
    593593    m_notificationPermissionRequestManager.invalidateRequests();
     594    m_process->context()->supplement<WebNotificationManagerProxy>()->clearNotifications(this);
    594595
    595596    m_toolTip = String();
     
    41044105}
    41054106
     4107void WebPageProxy::cancelNotification(uint64_t notificationID)
     4108{
     4109    m_process->context()->supplement<WebNotificationManagerProxy>()->cancel(this, notificationID);
     4110}
     4111
     4112void WebPageProxy::clearNotifications(const Vector<uint64_t>& notificationIDs)
     4113{
     4114    m_process->context()->supplement<WebNotificationManagerProxy>()->clearNotifications(this, notificationIDs);
     4115}
     4116
     4117void WebPageProxy::didDestroyNotification(uint64_t notificationID)
     4118{
     4119    m_process->context()->supplement<WebNotificationManagerProxy>()->didDestroyNotification(this, notificationID);
     4120}
     4121
    41064122float WebPageProxy::headerHeight(WebFrameProxy* frame)
    41074123{
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r150521 r150785  
    873873    void requestNotificationPermission(uint64_t notificationID, const String& originString);
    874874    void showNotification(const String& title, const String& body, const String& iconURL, const String& tag, const String& lang, const String& dir, const String& originString, uint64_t notificationID);
    875    
     875    void cancelNotification(uint64_t notificationID);
     876    void clearNotifications(const Vector<uint64_t>& notificationIDs);
     877    void didDestroyNotification(uint64_t notificationID);
     878
    876879#if USE(TILED_BACKING_STORE)
    877880    void pageDidRequestScroll(const WebCore::IntPoint&);
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in

    r150484 r150785  
    221221    RequestNotificationPermission(uint64_t requestID, WTF::String originIdentifier)
    222222    ShowNotification(WTF::String title, WTF::String body, WTF::String iconURL, WTF::String tag, WTF::String lang, WTF::String dir, WTF::String originIdentifier, uint64_t notificationID)
     223    CancelNotification(uint64_t notificationID)
     224    ClearNotifications(Vector<uint64_t> notificationIDs)
     225    DidDestroyNotification(uint64_t notificationID)
    223226
    224227    # Spelling and grammar messages
  • trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r150669 r150785  
    335335                31312620148FF82C00BA2A39 /* WebNotificationManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3131261B148FF82B00BA2A39 /* WebNotificationManager.cpp */; };
    336336                31312621148FF82C00BA2A39 /* WebNotificationManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 3131261C148FF82B00BA2A39 /* WebNotificationManager.h */; };
    337                 318BE1671473433700A8FBB2 /* WebNotificationManagerProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 318BE1651473433700A8FBB2 /* WebNotificationManagerProxyMessageReceiver.cpp */; };
    338                 318BE1681473433700A8FBB2 /* WebNotificationManagerProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 318BE1661473433700A8FBB2 /* WebNotificationManagerProxyMessages.h */; };
    339337                318BE17114743DB100A8FBB2 /* WKNotificationManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 318BE17014743DB100A8FBB2 /* WKNotificationManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
    340338                318BE17514743DD700A8FBB2 /* WKNotificationManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 318BE17414743DD600A8FBB2 /* WKNotificationManager.cpp */; };
     
    17911789                3131261C148FF82B00BA2A39 /* WebNotificationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebNotificationManager.h; sourceTree = "<group>"; };
    17921790                3131261D148FF82C00BA2A39 /* WebNotificationManager.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebNotificationManager.messages.in; sourceTree = "<group>"; };
    1793                 318BE1651473433700A8FBB2 /* WebNotificationManagerProxyMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebNotificationManagerProxyMessageReceiver.cpp; sourceTree = "<group>"; };
    1794                 318BE1661473433700A8FBB2 /* WebNotificationManagerProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebNotificationManagerProxyMessages.h; sourceTree = "<group>"; };
    17951791                318BE17014743DB100A8FBB2 /* WKNotificationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNotificationManager.h; sourceTree = "<group>"; };
    17961792                318BE17414743DD600A8FBB2 /* WKNotificationManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKNotificationManager.cpp; sourceTree = "<group>"; };
     
    18011797                31A2EC43148997BE00810D71 /* WebNotificationManagerProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebNotificationManagerProxy.cpp; sourceTree = "<group>"; };
    18021798                31A2EC44148997BF00810D71 /* WebNotificationManagerProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebNotificationManagerProxy.h; sourceTree = "<group>"; };
    1803                 31A2EC45148997BF00810D71 /* WebNotificationManagerProxy.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebNotificationManagerProxy.messages.in; sourceTree = "<group>"; };
    18041799                31A2EC46148997C000810D71 /* WebNotificationProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebNotificationProvider.cpp; sourceTree = "<group>"; };
    18051800                31A2EC47148997C100810D71 /* WebNotificationProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebNotificationProvider.h; sourceTree = "<group>"; };
     
    35673562                                31A2EC43148997BE00810D71 /* WebNotificationManagerProxy.cpp */,
    35683563                                31A2EC44148997BF00810D71 /* WebNotificationManagerProxy.h */,
    3569                                 31A2EC45148997BF00810D71 /* WebNotificationManagerProxy.messages.in */,
    35703564                                31A2EC46148997C000810D71 /* WebNotificationProvider.cpp */,
    35713565                                31A2EC47148997C100810D71 /* WebNotificationProvider.h */,
     
    51205114                                31BA9248148830810062EDB5 /* WebNotificationManagerMessageReceiver.cpp */,
    51215115                                31BA9249148830810062EDB5 /* WebNotificationManagerMessages.h */,
    5122                                 318BE1651473433700A8FBB2 /* WebNotificationManagerProxyMessageReceiver.cpp */,
    5123                                 318BE1661473433700A8FBB2 /* WebNotificationManagerProxyMessages.h */,
    51245116                                29D55DEF161BF9F10031A2E3 /* WebPageGroupProxyMessageReceiver.cpp */,
    51255117                                29D55DF0161BF9F10031A2E3 /* WebPageGroupProxyMessages.h */,
     
    56245616                                31BA924E148831260062EDB5 /* WebNotificationManagerMessages.h in Headers */,
    56255617                                31A2EC4B148997C200810D71 /* WebNotificationManagerProxy.h in Headers */,
    5626                                 318BE1681473433700A8FBB2 /* WebNotificationManagerProxyMessages.h in Headers */,
    56275618                                31A2EC4E148997C200810D71 /* WebNotificationProvider.h in Headers */,
    56285619                                BC33DD681238464600360F3F /* WebNumber.h in Headers */,
     
    69016892                                31BA924D148831260062EDB5 /* WebNotificationManagerMessageReceiver.cpp in Sources */,
    69026893                                31A2EC4A148997C200810D71 /* WebNotificationManagerProxy.cpp in Sources */,
    6903                                 318BE1671473433700A8FBB2 /* WebNotificationManagerProxyMessageReceiver.cpp in Sources */,
    69046894                                31A2EC4D148997C200810D71 /* WebNotificationProvider.cpp in Sources */,
    69056895                                BC857FB612B830E600EDEB2E /* WebOpenPanelParameters.cpp in Sources */,
  • trunk/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.cpp

    r138520 r150785  
    2828
    2929#include "WebCoreArgumentCoders.h"
    30 #include "WebNotificationManagerProxyMessages.h"
    3130#include "WebPage.h"
    3231#include "WebPageProxyMessages.h"
  • trunk/Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp

    r150669 r150785  
    3434#include "WebNotification.h"
    3535#include "WebNotificationManagerMessages.h"
    36 #include "WebNotificationManagerProxyMessages.h"
    3736#include "WebPageProxyMessages.h"
    3837#include <WebCore/Document.h>
     
    176175        return;
    177176   
    178     m_process->parentProcessConnection()->send(Messages::WebNotificationManagerProxy::Cancel(notificationID), 0);
     177    m_process->parentProcessConnection()->send(Messages::WebPageProxy::CancelNotification(notificationID), page->pageID());
    179178#else
    180179    UNUSED_PARAM(notification);
     
    189188    if (it == m_notificationContextMap.end())
    190189        return;
    191    
     190
    192191    Vector<uint64_t>& notificationIDs = it->value;
    193     m_process->parentProcessConnection()->send(Messages::WebNotificationManagerProxy::ClearNotifications(notificationIDs), 0);
     192    m_process->parentProcessConnection()->send(Messages::WebPageProxy::ClearNotifications(notificationIDs), page->pageID());
    194193    size_t count = notificationIDs.size();
    195194    for (size_t i = 0; i < count; ++i) {
     
    217216    m_notificationIDMap.remove(notificationID);
    218217    removeNotificationFromContextMap(notificationID, notification);
    219     m_process->parentProcessConnection()->send(Messages::WebNotificationManagerProxy::DidDestroyNotification(notificationID), 0);
     218    m_process->parentProcessConnection()->send(Messages::WebPageProxy::DidDestroyNotification(notificationID), page->pageID());
    220219#else
    221220    UNUSED_PARAM(notification);
Note: See TracChangeset for help on using the changeset viewer.