⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 242662 in webkit


Ignore:
Timestamp:
Mar 8, 2019, 3:58:52 PM (7 years ago)
Author:
beidson@apple.com
Message:

Have the UIProcess take the UnboundedNetworking assertion when downloads are in progress.
https://bugs.webkit.org/show_bug.cgi?id=195468

Reviewed by Andy Estes.

  • UIProcess/Downloads/DownloadProxyMap.cpp:

(WebKit::DownloadProxyMap::DownloadProxyMap):
(WebKit::DownloadProxyMap::createDownloadProxy): If this is the first download, and the process has the entitlement,

take the assertion.

(WebKit::DownloadProxyMap::downloadFinished):
(WebKit::DownloadProxyMap::processDidClose):

  • UIProcess/Downloads/DownloadProxyMap.h:
Location:
trunk/Source/WebKit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r242652 r242662  
     12019-03-08  Brady Eidson  <beidson@apple.com>
     2
     3        Have the UIProcess take the UnboundedNetworking assertion when downloads are in progress.
     4        https://bugs.webkit.org/show_bug.cgi?id=195468
     5
     6        Reviewed by Andy Estes.
     7
     8        * UIProcess/Downloads/DownloadProxyMap.cpp:
     9        (WebKit::DownloadProxyMap::DownloadProxyMap):
     10        (WebKit::DownloadProxyMap::createDownloadProxy): If this is the first download, and the process has the entitlement,
     11          take the assertion.
     12        (WebKit::DownloadProxyMap::downloadFinished):
     13        (WebKit::DownloadProxyMap::processDidClose):
     14        * UIProcess/Downloads/DownloadProxyMap.h:
     15
    1162019-03-08  Chris Dumez  <cdumez@apple.com>
    217
  • trunk/Source/WebKit/UIProcess/Downloads/DownloadProxyMap.cpp

    r240683 r242662  
    3131#include "DownloadProxyMessages.h"
    3232#include "MessageReceiverMap.h"
     33#include "ProcessAssertion.h"
    3334#include <wtf/StdLibExtras.h>
     35
     36#if PLATFORM(COCOA)
     37#include <wtf/cocoa/Entitlements.h>
     38#endif
    3439
    3540namespace WebKit {
     
    3742DownloadProxyMap::DownloadProxyMap(NetworkProcessProxy& process)
    3843    : m_process(&process)
     44#if PLATFORM(COCOA)
     45    , m_shouldTakeAssertion(WTF::processHasEntitlement("com.apple.multitasking.systemappassertions"))
     46#endif
    3947{
    4048}
     
    4957    auto downloadProxy = DownloadProxy::create(*this, processPool, resourceRequest);
    5058    m_downloads.set(downloadProxy->downloadID(), downloadProxy.copyRef());
     59
     60    if (m_downloads.size() == 1 && m_shouldTakeAssertion) {
     61        ASSERT(!m_downloadAssertion);
     62        m_downloadAssertion = std::make_unique<ProcessAssertion>(getCurrentProcessID(), "WebKit downloads"_s, AssertionState::UnboundedNetworking);
     63    }
    5164
    5265    m_process->addMessageReceiver(Messages::DownloadProxy::messageReceiverName(), downloadProxy->downloadID().downloadID(), downloadProxy.get());
     
    6477    downloadProxy->invalidate();
    6578    m_downloads.remove(downloadID);
     79
     80    if (m_downloads.isEmpty() && m_shouldTakeAssertion) {
     81        ASSERT(m_downloadAssertion);
     82        m_downloadAssertion = nullptr;
     83    }
    6684}
    6785
     
    7694
    7795    m_downloads.clear();
     96    m_downloadAssertion = nullptr;
    7897    m_process = nullptr;
    7998}
  • trunk/Source/WebKit/UIProcess/Downloads/DownloadProxyMap.h

    r241183 r242662  
    3838class DownloadProxy;
    3939class NetworkProcessProxy;
     40class ProcessAssertion;
    4041class WebProcessPool;
    4142
     
    5859    NetworkProcessProxy* m_process;
    5960    HashMap<DownloadID, RefPtr<DownloadProxy>> m_downloads;
     61
     62    bool m_shouldTakeAssertion { false };
     63    std::unique_ptr<ProcessAssertion> m_downloadAssertion;
    6064};
    6165
Note: See TracChangeset for help on using the changeset viewer.