Changeset 167039 in webkit


Ignore:
Timestamp:
Apr 9, 2014 3:13:07 PM (10 years ago)
Author:
barraclough@apple.com
Message:

Update SPI for managing tabs
https://bugs.webkit.org/show_bug.cgi?id=131453

Reviewed by Alexey Proskuryakov.

  • Configurations/WebKit2.xcconfig:
    • added AssertionServices
  • UIProcess/WebProcessProxy.h:
    • added m_assertion, m_assertionState.
  • UIProcess/ios/WebProcessProxyIOS.mm:

(WebKit::WebProcessProxy::updateProcessState):

  • create BKSProcessAssertion to take an assertion.
Location:
trunk/Source/WebKit2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r167038 r167039  
     12014-04-09  Gavin Barraclough  <baraclough@apple.com>
     2
     3        Update SPI for managing tabs
     4        https://bugs.webkit.org/show_bug.cgi?id=131453
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        * Configurations/WebKit2.xcconfig:
     9            - added AssertionServices
     10        * UIProcess/WebProcessProxy.h:
     11            - added m_assertion, m_assertionState.
     12        * UIProcess/ios/WebProcessProxyIOS.mm:
     13        (WebKit::WebProcessProxy::updateProcessState):
     14            - create BKSProcessAssertion to take an assertion.
     15
    1162014-04-09  Enrica Casucci  <enrica@apple.com>
    217
  • trunk/Source/WebKit2/Configurations/WebKit2.xcconfig

    r165514 r167039  
    3131
    3232FRAMEWORK_AND_LIBRARY_LDFLAGS = $(FRAMEWORK_AND_LIBRARY_LDFLAGS_$(PLATFORM_NAME));
    33 FRAMEWORK_AND_LIBRARY_LDFLAGS_iphonesimulator = -lobjc -framework CFNetwork -framework CoreFoundation -framework CoreGraphics -framework CorePDF -framework CoreText -framework Foundation -framework GraphicsServices -framework ImageIO -framework UIKit -framework OpenGLES -framework MobileAsset -framework WebKit -lMobileGestalt -lassertion_extension;
     33FRAMEWORK_AND_LIBRARY_LDFLAGS_iphonesimulator = -lobjc -framework AssertionServices -framework CFNetwork -framework CoreFoundation -framework CoreGraphics -framework CorePDF -framework CoreText -framework Foundation -framework GraphicsServices -framework ImageIO -framework UIKit -framework OpenGLES -framework MobileAsset -framework WebKit -lMobileGestalt -lassertion_extension;
    3434FRAMEWORK_AND_LIBRARY_LDFLAGS_iphoneos = $(FRAMEWORK_AND_LIBRARY_LDFLAGS_iphonesimulator) -framework IOSurface;
    3535FRAMEWORK_AND_LIBRARY_LDFLAGS_macosx = -framework ApplicationServices -framework Carbon -framework Cocoa -framework CoreServices -framework IOKit -framework CoreAudio -framework IOSurface -framework OpenGL;
  • trunk/Source/WebKit2/UIProcess/WebProcessProxy.h

    r166026 r167039  
    4747#endif
    4848
     49#if PLATFORM(IOS) && USE(XPC_SERVICES)
     50OBJC_CLASS BKSProcessAssertion;
     51enum ProcessAssertionState {
     52    AssertionBackground,
     53    AssertionForeground
     54};
     55#endif
     56
    4957namespace WebCore {
    5058class URL;
     
    217225
    218226    int m_numberOfTimesSuddenTerminationWasDisabled;
     227   
     228#if PLATFORM(IOS) && USE(XPC_SERVICES)
     229    RetainPtr<BKSProcessAssertion> m_assertion;
     230    ProcessAssertionState m_assertionState;
     231#endif
    219232};
    220233
  • trunk/Source/WebKit2/UIProcess/ios/WebProcessProxyIOS.mm

    r164879 r167039  
    2929#if PLATFORM(IOS)
    3030
    31 #import <assertion/extension_private.h>
     31#import <AssertionServices/BKSProcessAssertion.h>
    3232#import <WebCore/NotImplemented.h>
     33
     34const BKSProcessAssertionFlags BackgroundTabFlags = (BKSProcessAssertionAllowIdleSleep);
     35const BKSProcessAssertionFlags ForegroundTabFlags = (BKSProcessAssertionAllowIdleSleep | BKSProcessAssertionPreventTaskSuspend | BKSProcessAssertionWantsForegroundResourcePriority | BKSProcessAssertionPreventTaskThrottleDown);
    3336
    3437namespace WebKit {
     
    8285        return;
    8386
    84     assertion_extension_state_t extensionState = ASSERTION_EXTENSION_STATE_BACKGROUND;
     87    ProcessAssertionState assertionState = AssertionBackground;
    8588    for (const auto& page : m_pageMap.values()) {
    8689        if (page->isInWindow()) {
    87             extensionState = ASSERTION_EXTENSION_STATE_FOREGROUND;
     90            assertionState = AssertionForeground;
    8891            break;
    8992        }
    9093    }
    91 
    92     errno_t tabStateError = assertion_extension_set_state(xpcConnection, extensionState, NULL);
    93     ASSERT_UNUSED(tabStateError, !tabStateError);
     94    BKSProcessAssertionFlags flags = (assertionState == AssertionForeground) ? ForegroundTabFlags : BackgroundTabFlags;
     95   
     96    if (!m_assertion) {
     97        pid_t pid = xpc_connection_get_pid(xpcConnection);
     98        BKSProcessAssertionAcquisitionHandler handler = ^(BOOL acquired) {
     99            if (!acquired) {
     100                LOG_ERROR("Unable to acquire assertion for WebContent process %d", pid);
     101                ASSERT_NOT_REACHED();
     102            }
     103        };
     104        m_assertion = adoptNS([[BKSProcessAssertion alloc] initWithPID:pid flags:flags reason:BKSProcessAssertionReasonExtension name:@"Web content visible" withHandler:handler]);
     105    } else if (m_assertionState != assertionState)
     106        [m_assertion setFlags:flags];
     107   
     108    m_assertionState = assertionState;
    94109#endif
    95110}
Note: See TracChangeset for help on using the changeset viewer.