Changeset 211551 in webkit
- Timestamp:
- Feb 2, 2017 12:33:29 AM (7 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 added
- 1 deleted
- 14 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r211550 r211551 1 2017-02-02 Yongjun Zhang <yongjun_zhang@apple.com> 2 3 In iOS, we should take background assertion when accessing localstorage databases. 4 https://bugs.webkit.org/show_bug.cgi?id=165478 5 6 Move WebSQLiteDatabaseTrackerClient from WebKitLegacy to WebCore so that it can be accessible from 7 WebKit1 and WebKit2. Previously, to avoid dependencies on UIKit, WebKitLegacy introduced several 8 global methods for UIKit to setup the start/end background task blocks on runtime (WebKitSetStartBackgroundTaskBlock, 9 WebKitSetInvalidWebBackgroundTaskIdentifier and WebKitSetEndBackgroundTaskBlock). Since we have to 10 move the background task handling to WebCore, to avoid adding WebCore dependencies on UIKit, this 11 patch introdues a new WebCore class WebBackgroundTaskController which holds the start/end background 12 task blocks. The existing WebKitSetStartBackgroundTaskBlock and WebKitSetEndBackgroundTaskBlock methods 13 in WebKit1 will use WebBackgroundTaskController to store the blocks set by UIKit. 14 15 Reviewed by Brady Eidson. 16 17 No new test since this is code refactoring. 18 19 * WebCore.xcodeproj/project.pbxproj: Add a new class WebBackgroundTaskController to the project. Also move 20 WebSQLiteDatabaseTrackerClient from WebKitLegacy to WebCore. 21 * platform/ios/WebBackgroundTaskController.h: Use properties to hold the blocks for starting or ending background tasks. 22 * platform/ios/WebBackgroundTaskController.mm: 23 (+[WebBackgroundTaskController sharedController]): 24 (-[WebBackgroundTaskController dealloc]): 25 (-[WebBackgroundTaskController startBackgroundTaskWithExpirationHandler:]): Start a background task with a expiration handler; 26 to start the background task, we will use backgroundTaskStartBlock set up by UIKit. 27 (-[WebBackgroundTaskController endBackgroundTaskWithIdentifier:]): Call backgroundTaskEndBlack to end a background task. 28 * platform/ios/WebSQLiteDatabaseTrackerClient.h: Copied from Source/WebKit/ios/Storage/WebSQLiteDatabaseTrackerClient.h. 29 * platform/ios/WebSQLiteDatabaseTrackerClient.mm: Copied from Source/WebKit/ios/Storage/WebSQLiteDatabaseTrackerClient.mm. 30 (WebCore::WebSQLiteDatabaseTrackerClient::sharedWebSQLiteDatabaseTrackerClient): Make WebSQLiteDatabaseTrackerClient a singleton. 31 (WebCore::WebSQLiteDatabaseTrackerClient::WebSQLiteDatabaseTrackerClient): 32 (WebCore::WebSQLiteDatabaseTrackerClient::~WebSQLiteDatabaseTrackerClient): 33 (WebCore::WebSQLiteDatabaseTrackerClient::willBeginFirstTransaction): Use a utility class WebDatabaseTransactionBackgroundTaskController 34 to schedule database transaction background task. 35 (WebCore::WebSQLiteDatabaseTrackerClient::didFinishLastTransaction): Use WebDatabaseTransactionBackgroundTaskController to stop 36 databas transaction background task. 37 (transactionBackgroundTaskIdentifierLock: Moved from Source/WebKit/mac/Storage/WebDatabaseManager.mm. 38 (setTransactionBackgroundTaskIdentifier): Ditto. 39 (getTransactionBackgroundTaskIdentifier): Ditto. 40 (+[WebDatabaseTransactionBackgroundTaskController startBackgroundTask]): Ditto. 41 (+[WebDatabaseTransactionBackgroundTaskController endBackgroundTask]): Ditto. 42 1 43 2017-02-01 Zan Dobersek <zdobersek@igalia.com> 2 44 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r211539 r211551 1012 1012 1CCDF5BE1990332400BCEBAD /* SVGToOTFFontConversion.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CCDF5BC1990332400BCEBAD /* SVGToOTFFontConversion.h */; }; 1013 1013 1CFAE3230A6D6A3F0032593D /* libobjc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1CFAE3220A6D6A3F0032593D /* libobjc.dylib */; }; 1014 1F36EA9C1E21BA1700621E25 /* WebBackgroundTaskController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F36EA9A1E21BA1700621E25 /* WebBackgroundTaskController.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1015 1F36EA9D1E21BA1700621E25 /* WebBackgroundTaskController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1F36EA9B1E21BA1700621E25 /* WebBackgroundTaskController.mm */; }; 1014 1016 1F3C3BEA135CAF3C00B8C1AC /* MediaControls.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1F3C3BE8135CAF3C00B8C1AC /* MediaControls.cpp */; }; 1015 1017 1F3C3BEB135CAF3C00B8C1AC /* MediaControls.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F3C3BE9135CAF3C00B8C1AC /* MediaControls.h */; }; 1018 1F4B419B1E2301C900AC037F /* WebSQLiteDatabaseTrackerClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1F8756B01E22BEEF0042C40D /* WebSQLiteDatabaseTrackerClient.mm */; }; 1016 1019 1F72BF0A187FD4490009BCB3 /* TileControllerMemoryHandlerIOS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1F72BF08187FD4270009BCB3 /* TileControllerMemoryHandlerIOS.cpp */; }; 1017 1020 1F72BF0B187FD45C0009BCB3 /* TileControllerMemoryHandlerIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F72BF09187FD4270009BCB3 /* TileControllerMemoryHandlerIOS.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1021 1F8756B21E22C3350042C40D /* WebSQLiteDatabaseTrackerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F8756B11E22BEEF0042C40D /* WebSQLiteDatabaseTrackerClient.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1018 1022 1FAFBF1815A5FA6E00083A20 /* UTIUtilities.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1FAFBF1715A5FA5200083A20 /* UTIUtilities.mm */; }; 1019 1023 1FAFBF1915A5FA7400083A20 /* UTIUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 1FAFBF1615A5FA5200083A20 /* UTIUtilities.h */; }; … … 8156 8160 1CDD45E60BA9C84600F90147 /* Base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = "<group>"; }; 8157 8161 1CFAE3220A6D6A3F0032593D /* libobjc.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libobjc.dylib; path = /usr/lib/libobjc.dylib; sourceTree = "<absolute>"; }; 8162 1F36EA9A1E21BA1700621E25 /* WebBackgroundTaskController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebBackgroundTaskController.h; sourceTree = "<group>"; }; 8163 1F36EA9B1E21BA1700621E25 /* WebBackgroundTaskController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebBackgroundTaskController.mm; sourceTree = "<group>"; }; 8158 8164 1F3C3BE8135CAF3C00B8C1AC /* MediaControls.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaControls.cpp; sourceTree = "<group>"; }; 8159 8165 1F3C3BE9135CAF3C00B8C1AC /* MediaControls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaControls.h; sourceTree = "<group>"; }; 8160 8166 1F72BF08187FD4270009BCB3 /* TileControllerMemoryHandlerIOS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TileControllerMemoryHandlerIOS.cpp; sourceTree = "<group>"; }; 8161 8167 1F72BF09187FD4270009BCB3 /* TileControllerMemoryHandlerIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TileControllerMemoryHandlerIOS.h; sourceTree = "<group>"; }; 8168 1F8756B01E22BEEF0042C40D /* WebSQLiteDatabaseTrackerClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebSQLiteDatabaseTrackerClient.mm; sourceTree = "<group>"; }; 8169 1F8756B11E22BEEF0042C40D /* WebSQLiteDatabaseTrackerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSQLiteDatabaseTrackerClient.h; sourceTree = "<group>"; }; 8162 8170 1FAFBF1615A5FA5200083A20 /* UTIUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UTIUtilities.h; sourceTree = "<group>"; }; 8163 8171 1FAFBF1715A5FA5200083A20 /* UTIUtilities.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UTIUtilities.mm; sourceTree = "<group>"; }; … … 19939 19947 CDA29A2C1CBF73FC00901CCF /* WebAVPlayerController.h */, 19940 19948 CDA29A2D1CBF73FC00901CCF /* WebAVPlayerController.mm */, 19949 1F36EA9A1E21BA1700621E25 /* WebBackgroundTaskController.h */, 19950 1F36EA9B1E21BA1700621E25 /* WebBackgroundTaskController.mm */, 19941 19951 31403797124BEA7F00AF40E4 /* WebCoreMotionManager.h */, 19942 19952 31403798124BEA7F00AF40E4 /* WebCoreMotionManager.mm */, … … 19948 19958 CDA29A2E1CBF73FC00901CCF /* WebPlaybackSessionInterfaceAVKit.h */, 19949 19959 CDA29A2F1CBF73FC00901CCF /* WebPlaybackSessionInterfaceAVKit.mm */, 19960 1F8756B01E22BEEF0042C40D /* WebSQLiteDatabaseTrackerClient.mm */, 19961 1F8756B11E22BEEF0042C40D /* WebSQLiteDatabaseTrackerClient.h */, 19950 19962 3F42B31B1881191B00278AAC /* WebVideoFullscreenControllerAVKit.h */, 19951 19963 3F42B31C1881191B00278AAC /* WebVideoFullscreenControllerAVKit.mm */, … … 25634 25646 937FF3D51A1012D6008EBA31 /* DictionaryLookup.h in Headers */, 25635 25647 2D5646B01B8F8493003C4994 /* DictionaryPopupInfo.h in Headers */, 25648 1F36EA9C1E21BA1700621E25 /* WebBackgroundTaskController.h in Headers */, 25636 25649 FDAF19991513D131008DB0C3 /* DirectConvolver.h in Headers */, 25637 25650 7EDAAFC919A2CCDC0034DFD1 /* DiskCacheMonitorCocoa.h in Headers */, … … 25728 25741 4F1534E011B533020021FD86 /* EditingBehaviorTypes.h in Headers */, 25729 25742 3AC648B2129E146500C3EB25 /* EditingBoundary.h in Headers */, 25743 1F8756B21E22C3350042C40D /* WebSQLiteDatabaseTrackerClient.h in Headers */, 25730 25744 9BAB6C6C12550631001626D4 /* EditingStyle.h in Headers */, 25731 25745 4B3043CD0AE0373B00A82647 /* Editor.h in Headers */, … … 30626 30640 B2FA3DDA0AB75A6F000E5AC4 /* JSSVGPathSegList.cpp in Sources */, 30627 30641 B2FA3DDC0AB75A6F000E5AC4 /* JSSVGPathSegMovetoAbs.cpp in Sources */, 30642 1F36EA9D1E21BA1700621E25 /* WebBackgroundTaskController.mm in Sources */, 30628 30643 B2FA3DDE0AB75A6F000E5AC4 /* JSSVGPathSegMovetoRel.cpp in Sources */, 30629 30644 B2FA3DE00AB75A6F000E5AC4 /* JSSVGPatternElement.cpp in Sources */, … … 32149 32164 93F19B0308245E59001E9ABC /* XSLStyleSheetLibxslt.cpp in Sources */, 32150 32165 E1F1E82F0C3C2BB9006DB391 /* XSLTExtensions.cpp in Sources */, 32166 1F4B419B1E2301C900AC037F /* WebSQLiteDatabaseTrackerClient.mm in Sources */, 32151 32167 93F19B0408245E59001E9ABC /* XSLTProcessor.cpp in Sources */, 32152 32168 93F19B0508245E59001E9ABC /* XSLTProcessorLibxslt.cpp in Sources */, -
trunk/Source/WebCore/platform/ios/WebBackgroundTaskController.h
r211550 r211551 1 1 /* 2 * Copyright (C) 2010 Apple Inc. All Rights Reserved.2 * Copyright (C) 2010, 2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 #if PLATFORM(IOS) 27 27 28 #import "WebSQLiteDatabaseTrackerClient.h" 28 WEBCORE_EXPORT @interface WebBackgroundTaskController : NSObject 29 29 30 #import "WebDatabaseManagerInternal.h" 31 #import "WebDatabaseManagerPrivate.h" 30 @property (nonatomic) NSUInteger invalidBackgroundTaskIdentifier; 31 @property (nonatomic, copy) NSUInteger (^backgroundTaskStartBlock)(void (^)()); 32 @property (nonatomic, copy) void (^backgroundTaskEndBlock)(NSUInteger); 32 33 33 #import <WebCore/SQLiteDatabaseTracker.h> 34 + (WebBackgroundTaskController *)sharedController; 34 35 35 using namespace WebCore; 36 - (NSUInteger)startBackgroundTaskWithExpirationHandler:(void (^)())handler; 37 - (void)endBackgroundTaskWithIdentifier:(NSUInteger)identifier; 36 38 37 WebSQLiteDatabaseTrackerClient* WebSQLiteDatabaseTrackerClient::sharedWebSQLiteDatabaseTrackerClient() 38 { 39 static WebSQLiteDatabaseTrackerClient* sharedClient = new WebSQLiteDatabaseTrackerClient(); 40 return sharedClient; 41 } 39 @end 42 40 43 void WebSQLiteDatabaseTrackerClient::willBeginFirstTransaction() 44 { 45 [WebDatabaseManager willBeginFirstTransaction]; 46 } 47 48 void WebSQLiteDatabaseTrackerClient::didFinishLastTransaction() 49 { 50 [WebDatabaseManager didFinishLastTransaction]; 51 } 52 53 #endif // PLATFORM(IOS) 41 #endif -
trunk/Source/WebCore/platform/ios/WebBackgroundTaskController.mm
r211550 r211551 1 1 /* 2 * Copyright (C) 201 0 Apple Inc. All Rights Reserved.2 * Copyright (C) 2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #import "config.h" 27 #import "WebBackgroundTaskController.h" 28 26 29 #if PLATFORM(IOS) 27 30 28 #import "WebSQLiteDatabaseTrackerClient.h" 31 @implementation WebBackgroundTaskController 29 32 30 #import "WebDatabaseManagerInternal.h" 31 #import "WebDatabaseManagerPrivate.h" 32 33 #import <WebCore/SQLiteDatabaseTracker.h> 34 35 using namespace WebCore; 36 37 WebSQLiteDatabaseTrackerClient* WebSQLiteDatabaseTrackerClient::sharedWebSQLiteDatabaseTrackerClient() 33 + (WebBackgroundTaskController *)sharedController 38 34 { 39 static WebSQLiteDatabaseTrackerClient* sharedClient = new WebSQLiteDatabaseTrackerClient(); 40 return sharedClient; 35 static WebBackgroundTaskController *sharedController; 36 if (!sharedController) 37 sharedController = [[self alloc] init]; 38 return sharedController; 41 39 } 42 40 43 void WebSQLiteDatabaseTrackerClient::willBeginFirstTransaction() 41 - (void)dealloc 44 42 { 45 [ WebDatabaseManager willBeginFirstTransaction];43 [super dealloc]; 46 44 } 47 45 48 void WebSQLiteDatabaseTrackerClient::didFinishLastTransaction() 46 - (NSUInteger)startBackgroundTaskWithExpirationHandler:(void (^)())handler 49 47 { 50 [WebDatabaseManager didFinishLastTransaction]; 48 if (!_backgroundTaskStartBlock) 49 return _invalidBackgroundTaskIdentifier; 50 return _backgroundTaskStartBlock(handler); 51 51 } 52 52 53 #endif // PLATFORM(IOS) 53 - (void)endBackgroundTaskWithIdentifier:(NSUInteger)identifier 54 { 55 if (!_backgroundTaskEndBlock) 56 return; 57 _backgroundTaskEndBlock(identifier); 58 } 59 60 @end 61 62 #endif -
trunk/Source/WebCore/platform/ios/WebSQLiteDatabaseTrackerClient.h
r211550 r211551 24 24 */ 25 25 26 # import <WebCore/SQLiteDatabaseTrackerClient.h>26 #pragma once 27 27 28 class WebSQLiteDatabaseTrackerClient : public WebCore::SQLiteDatabaseTrackerClient { 28 #include "PlatformExportMacros.h" 29 30 #if PLATFORM(IOS) 31 32 #include "SQLiteDatabaseTrackerClient.h" 33 #include <wtf/NeverDestroyed.h> 34 #include <wtf/Noncopyable.h> 35 36 namespace WebCore { 37 38 class WebSQLiteDatabaseTrackerClient final : public SQLiteDatabaseTrackerClient { 39 WTF_MAKE_NONCOPYABLE(WebSQLiteDatabaseTrackerClient); 29 40 public: 30 static WebSQLiteDatabaseTrackerClient* sharedWebSQLiteDatabaseTrackerClient(); 31 32 ~WebSQLiteDatabaseTrackerClient() override { } 41 WEBCORE_EXPORT static WebSQLiteDatabaseTrackerClient& sharedWebSQLiteDatabaseTrackerClient(); 33 42 34 43 void willBeginFirstTransaction() override; … … 36 45 37 46 private: 38 WebSQLiteDatabaseTrackerClient() { } 47 friend class NeverDestroyed<WebSQLiteDatabaseTrackerClient>; 48 WebSQLiteDatabaseTrackerClient(); 49 virtual ~WebSQLiteDatabaseTrackerClient(); 39 50 }; 51 52 } 53 54 #endif -
trunk/Source/WebKit/ChangeLog
r210835 r211551 1 2017-02-02 Yongjun Zhang <yongjun_zhang@apple.com> 2 3 In iOS, we should take background assertion when accessing localstorage databases. 4 https://bugs.webkit.org/show_bug.cgi?id=165478 5 6 Reviewed by Brady Eidson. 7 8 * WebKit.xcodeproj/project.pbxproj: Moved WebSQLiteDatabaseTrackerClient to WebCore. 9 1 10 2017-01-17 Antti Koivisto <antti@apple.com> 2 11 -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r209896 r211551 705 705 A10C1D3D18202FC50036883A /* WebUIKitSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D2E18202FC50036883A /* WebUIKitSupport.h */; settings = {ATTRIBUTES = (Private, ); }; }; 706 706 A10C1D3E18202FC50036883A /* WebUIKitSupport.mm in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D2F18202FC50036883A /* WebUIKitSupport.mm */; }; 707 A10C1D4218202FEF0036883A /* WebSQLiteDatabaseTrackerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D4018202FEF0036883A /* WebSQLiteDatabaseTrackerClient.h */; };708 A10C1D4318202FEF0036883A /* WebSQLiteDatabaseTrackerClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D4118202FEF0036883A /* WebSQLiteDatabaseTrackerClient.mm */; };709 707 A10C1D5F1820300E0036883A /* PopupMenuIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = A10C1D451820300E0036883A /* PopupMenuIOS.h */; }; 710 708 A10C1D601820300E0036883A /* PopupMenuIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = A10C1D461820300E0036883A /* PopupMenuIOS.mm */; }; … … 1450 1448 A10C1D2E18202FC50036883A /* WebUIKitSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebUIKitSupport.h; path = ios/Misc/WebUIKitSupport.h; sourceTree = SOURCE_ROOT; }; 1451 1449 A10C1D2F18202FC50036883A /* WebUIKitSupport.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebUIKitSupport.mm; path = ios/Misc/WebUIKitSupport.mm; sourceTree = SOURCE_ROOT; }; 1452 A10C1D4018202FEF0036883A /* WebSQLiteDatabaseTrackerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebSQLiteDatabaseTrackerClient.h; path = ios/Storage/WebSQLiteDatabaseTrackerClient.h; sourceTree = SOURCE_ROOT; };1453 A10C1D4118202FEF0036883A /* WebSQLiteDatabaseTrackerClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebSQLiteDatabaseTrackerClient.mm; path = ios/Storage/WebSQLiteDatabaseTrackerClient.mm; sourceTree = SOURCE_ROOT; };1454 1450 A10C1D451820300E0036883A /* PopupMenuIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PopupMenuIOS.h; path = ios/WebCoreSupport/PopupMenuIOS.h; sourceTree = SOURCE_ROOT; }; 1455 1451 A10C1D461820300E0036883A /* PopupMenuIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PopupMenuIOS.mm; path = ios/WebCoreSupport/PopupMenuIOS.mm; sourceTree = SOURCE_ROOT; }; … … 1891 1887 isa = PBXGroup; 1892 1888 children = ( 1893 A10C1D3F18202FDC0036883A /* ios */,1894 1889 1A6B31241A51F3A900422975 /* StorageAreaImpl.cpp */, 1895 1890 1A6B31251A51F3A900422975 /* StorageAreaImpl.h */, … … 2136 2131 A10C1D2E18202FC50036883A /* WebUIKitSupport.h */, 2137 2132 A10C1D2F18202FC50036883A /* WebUIKitSupport.mm */, 2138 );2139 name = ios;2140 sourceTree = "<group>";2141 };2142 A10C1D3F18202FDC0036883A /* ios */ = {2143 isa = PBXGroup;2144 children = (2145 A10C1D4018202FEF0036883A /* WebSQLiteDatabaseTrackerClient.h */,2146 A10C1D4118202FEF0036883A /* WebSQLiteDatabaseTrackerClient.mm */,2147 2133 ); 2148 2134 name = ios; … … 3181 3167 2DD632C219E5D1F0002E9C7B /* WebSelectionServiceController.h in Headers */, 3182 3168 2D25396618CE85C200270222 /* WebSharingServicePickerController.h in Headers */, 3183 A10C1D4218202FEF0036883A /* WebSQLiteDatabaseTrackerClient.h in Headers */,3184 3169 3AE15D5012DBDED4009323C8 /* WebStorageManagerInternal.h in Headers */, 3185 3170 3AB02B0012C132B200FBB694 /* WebStorageManagerPrivate.h in Headers */, … … 3698 3683 2DD632C319E5D1F0002E9C7B /* WebSelectionServiceController.mm in Sources */, 3699 3684 2D25396718CE85C200270222 /* WebSharingServicePickerController.mm in Sources */, 3700 A10C1D4318202FEF0036883A /* WebSQLiteDatabaseTrackerClient.mm in Sources */,3701 3685 3AB02AF612C1319B00FBB694 /* WebStorageManager.mm in Sources */, 3702 3686 1A591D451A2E91BB000907C4 /* WebStorageNamespaceProvider.cpp in Sources */, -
trunk/Source/WebKit/ios/ChangeLog
r211156 r211551 1 2017-02-02 Yongjun Zhang <yongjun_zhang@apple.com> 2 3 In iOS, we should take background assertion when accessing localstorage databases. 4 https://bugs.webkit.org/show_bug.cgi?id=165478 5 6 Move application background task handling code from WebKit to WebCore. 7 8 Reviewed by Brady Eidson. 9 10 * Misc/WebUIKitSupport.h: Remove several methods that only used internally for background 11 task handling. They are not needed in WebKit any more since background task handling 12 is moved to WebCore and wrapped in WebBackgroundTaskController class. 13 * Misc/WebUIKitSupport.mm: 14 (WebKitSetInvalidWebBackgroundTaskIdentifier): Instead of storing the value in a static global 15 variable, save it in WebBackgroundTaskController. 16 (WebKitSetStartBackgroundTaskBlock): Ditto. 17 (WebKitSetEndBackgroundTaskBlock): Ditto. 18 1 19 2017-01-25 Aakash Jain <aakash_jain@apple.com> 2 20 -
trunk/Source/WebKit/ios/Misc/WebUIKitSupport.h
r187107 r211551 46 46 void WebKitSetEndBackgroundTaskBlock(EndBackgroundTaskBlock); 47 47 48 // These methods are what WebKit uses to start/stop background tasks after UIKit has set things up.49 WebBackgroundTaskIdentifier invalidWebBackgroundTaskIdentifier();50 WebBackgroundTaskIdentifier startBackgroundTask(VoidBlock);51 void endBackgroundTask(WebBackgroundTaskIdentifier);52 53 48 // This method gives WebKit the notifications to listen to so it knows about app Suspend/Resume 54 49 void WebKitSetBackgroundAndForegroundNotificationNames(NSString *, NSString *); -
trunk/Source/WebKit/ios/Misc/WebUIKitSupport.mm
r211156 r211551 38 38 #import <WebCore/ResourceRequest.h> 39 39 #import <WebCore/Settings.h> 40 #import <WebCore/WebBackgroundTaskController.h> 40 41 #import <WebCore/WebCoreSystemInterface.h> 41 42 #import <WebCore/WebCoreThreadSystemInterface.h> … … 133 134 } 134 135 135 static WebBackgroundTaskIdentifier invalidTaskIdentifier = 0;136 static StartBackgroundTaskBlock startBackgroundTaskBlock = 0;137 static EndBackgroundTaskBlock endBackgroundTaskBlock = 0;138 139 136 void WebKitSetInvalidWebBackgroundTaskIdentifier(WebBackgroundTaskIdentifier taskIdentifier) 140 137 { 141 invalidTaskIdentifier = taskIdentifier;138 [[WebBackgroundTaskController sharedController] setInvalidBackgroundTaskIdentifier:taskIdentifier]; 142 139 } 143 140 144 141 void WebKitSetStartBackgroundTaskBlock(StartBackgroundTaskBlock startBlock) 145 142 { 146 Block_release(startBackgroundTaskBlock); 147 startBackgroundTaskBlock = Block_copy(startBlock); 143 [[WebBackgroundTaskController sharedController] setBackgroundTaskStartBlock:startBlock]; 148 144 } 149 145 150 146 void WebKitSetEndBackgroundTaskBlock(EndBackgroundTaskBlock endBlock) 151 147 { 152 Block_release(endBackgroundTaskBlock); 153 endBackgroundTaskBlock = Block_copy(endBlock); 154 } 155 156 WebBackgroundTaskIdentifier invalidWebBackgroundTaskIdentifier() 157 { 158 return invalidTaskIdentifier; 159 } 160 161 WebBackgroundTaskIdentifier startBackgroundTask(VoidBlock expirationHandler) 162 { 163 if (!startBackgroundTaskBlock) 164 return invalidTaskIdentifier; 165 return startBackgroundTaskBlock(expirationHandler); 166 } 167 168 void endBackgroundTask(WebBackgroundTaskIdentifier taskIdentifier) 169 { 170 if (!endBackgroundTaskBlock) 171 return; 172 endBackgroundTaskBlock(taskIdentifier); 148 [[WebBackgroundTaskController sharedController] setBackgroundTaskEndBlock:endBlock]; 173 149 } 174 150 -
trunk/Source/WebKit/mac/ChangeLog
r211492 r211551 1 2017-02-02 Yongjun Zhang <yongjun_zhang@apple.com> 2 3 In iOS, we should take background assertion when accessing localstorage databases. 4 https://bugs.webkit.org/show_bug.cgi?id=165478 5 6 Move database transaction background task handling code from WebDatabaseManager to 7 WebCore's WebSQLiteDatabaseTrackerClient. 8 9 Reviewed by Brady Eidson. 10 11 * Storage/WebDatabaseManager.mm: 12 * Storage/WebDatabaseManagerInternal.h: Remove a category for background task handling. 13 * WebCoreSupport/WebApplicationCache.mm: 14 (+[WebApplicationCache initializeWithBundleIdentifier:]): Use WebCore::WebSQLiteDatabaseTrackerClient. 15 * WebView/WebView.mm: 16 (-[WebView _commonInitializationWithFrameName:groupName:]): Ditto. 17 1 18 2017-02-01 Wenson Hsieh <wenson_hsieh@apple.com> 2 19 -
trunk/Source/WebKit/mac/Storage/WebDatabaseManager.mm
r208727 r211551 235 235 @end 236 236 237 #if PLATFORM(IOS)238 239 @implementation WebDatabaseManager (WebDatabaseManagerInternal)240 241 static Lock& transactionBackgroundTaskIdentifierLock()242 {243 static NeverDestroyed<Lock> mutex;244 return mutex;245 }246 247 static WebBackgroundTaskIdentifier transactionBackgroundTaskIdentifier;248 249 static void setTransactionBackgroundTaskIdentifier(WebBackgroundTaskIdentifier identifier)250 {251 transactionBackgroundTaskIdentifier = identifier;252 }253 254 static WebBackgroundTaskIdentifier getTransactionBackgroundTaskIdentifier()255 {256 static dispatch_once_t pred;257 dispatch_once(&pred, ^{258 setTransactionBackgroundTaskIdentifier(invalidWebBackgroundTaskIdentifier());259 });260 261 return transactionBackgroundTaskIdentifier;262 }263 264 + (void)willBeginFirstTransaction265 {266 [self startBackgroundTask];267 }268 269 + (void)didFinishLastTransaction270 {271 [self endBackgroundTask];272 }273 274 + (void)startBackgroundTask275 {276 LockHolder lock(transactionBackgroundTaskIdentifierLock());277 278 // If there's already an existing background task going on, there's no need to start a new one.279 if (getTransactionBackgroundTaskIdentifier() != invalidWebBackgroundTaskIdentifier())280 return;281 282 setTransactionBackgroundTaskIdentifier(startBackgroundTask(^ {283 DatabaseTracker::singleton().closeAllDatabases(CurrentQueryBehavior::Interrupt);284 [WebDatabaseManager endBackgroundTask];285 }));286 }287 288 + (void)endBackgroundTask289 {290 LockHolder lock(transactionBackgroundTaskIdentifierLock());291 292 // It is possible that we were unable to start the background task when the first transaction began.293 // Don't try to end the task in that case.294 // It is also possible we finally finish the last transaction right when the background task expires295 // and this will end up being called twice for the same background task. transactionBackgroundTaskIdentifier296 // will be invalid for the second caller.297 if (getTransactionBackgroundTaskIdentifier() == invalidWebBackgroundTaskIdentifier())298 return;299 300 endBackgroundTask(getTransactionBackgroundTaskIdentifier());301 setTransactionBackgroundTaskIdentifier(invalidWebBackgroundTaskIdentifier());302 }303 304 @end305 306 #endif // PLATFORM(IOS)307 308 237 static NSString *databasesDirectoryPath() 309 238 { -
trunk/Source/WebKit/mac/Storage/WebDatabaseManagerInternal.h
r187926 r211551 28 28 29 29 #import "WebDatabaseManagerPrivate.h" 30 31 #if PLATFORM(IOS)32 @interface WebDatabaseManager (WebDatabaseManagerInternal)33 + (void)willBeginFirstTransaction;34 + (void)didFinishLastTransaction;35 + (void)startBackgroundTask;36 + (void)endBackgroundTask;37 @end38 39 #endif -
trunk/Source/WebKit/mac/WebCoreSupport/WebApplicationCache.mm
r199829 r211551 34 34 35 35 #if PLATFORM(IOS) 36 #import "WebSQLiteDatabaseTrackerClient.h"37 36 #import <WebCore/RuntimeApplicationChecks.h> 38 37 #import <WebCore/SQLiteDatabaseTracker.h> 38 #import <WebCore/WebSQLiteDatabaseTrackerClient.h> 39 39 #endif 40 40 … … 55 55 return; 56 56 57 SQLiteDatabaseTracker::setClient( WebSQLiteDatabaseTrackerClient::sharedWebSQLiteDatabaseTrackerClient());57 SQLiteDatabaseTracker::setClient(&WebSQLiteDatabaseTrackerClient::sharedWebSQLiteDatabaseTrackerClient()); 58 58 59 59 ASSERT(!overrideBundleIdentifier); -
trunk/Source/WebKit/mac/WebView/WebView.mm
r211492 r211551 258 258 #import "WebPluginController.h" 259 259 #import "WebPolicyDelegatePrivate.h" 260 #import "WebSQLiteDatabaseTrackerClient.h"261 260 #import "WebStorageManagerPrivate.h" 262 261 #import "WebUIKitSupport.h" … … 281 280 #import <WebCore/WebCoreThreadRun.h> 282 281 #import <WebCore/WebEvent.h> 282 #import <WebCore/WebSQLiteDatabaseTrackerClient.h> 283 283 #import <WebCore/WebVideoFullscreenControllerAVKit.h> 284 284 #import <libkern/OSAtomic.h> … … 1315 1315 #if PLATFORM(IOS) 1316 1316 // Set the WebSQLiteDatabaseTrackerClient. 1317 SQLiteDatabaseTracker::setClient( WebSQLiteDatabaseTrackerClient::sharedWebSQLiteDatabaseTrackerClient());1317 SQLiteDatabaseTracker::setClient(&WebSQLiteDatabaseTrackerClient::sharedWebSQLiteDatabaseTrackerClient()); 1318 1318 1319 1319 if ([standardPreferences databasesEnabled]) -
trunk/Source/WebKit2/ChangeLog
r211547 r211551 1 2017-02-02 Yongjun Zhang <yongjun_zhang@apple.com> 2 3 In iOS, we should take background assertion when accessing localstorage databases. 4 https://bugs.webkit.org/show_bug.cgi?id=165478 5 6 Just like in WebKit1, when initializing a WKWebView, initialize the database transaction 7 tracker client. Also, we should set up the start and end background task blocks here. In 8 WebKit1, this is done inside UIKit. 9 10 Reviewed by Brady Eidson. 11 12 * UIProcess/API/Cocoa/WKWebView.mm: 13 (-[WKWebView _initializeWithConfiguration:]): 14 (-[WKWebView _setUpSQLiteDatabaseTrackerClient]): Set up the start/end background task blocks 15 and database transaction tracker client. 16 1 17 2017-02-01 Wenson Hsieh <wenson_hsieh@apple.com> 2 18 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
r211541 r211551 96 96 #import <WebCore/PlatformScreen.h> 97 97 #import <WebCore/RuntimeApplicationChecks.h> 98 #import <WebCore/SQLiteDatabaseTracker.h> 98 99 #import <WebCore/Settings.h> 99 100 #import <WebCore/TextStream.h> 100 101 #import <WebCore/ValidationBubble.h> 102 #import <WebCore/WebBackgroundTaskController.h> 103 #import <WebCore/WebSQLiteDatabaseTrackerClient.h> 101 104 #import <WebCore/WritingMode.h> 102 105 #import <wtf/HashMap.h> … … 555 558 #endif 556 559 560 #if PLATFORM(IOS) 561 [self _setUpSQLiteDatabaseTrackerClient]; 562 #endif 563 557 564 pageToViewMap().add(_page.get(), self); 565 } 566 567 - (void)_setUpSQLiteDatabaseTrackerClient 568 { 569 #if PLATFORM(IOS) 570 WebBackgroundTaskController *controller = [WebBackgroundTaskController sharedController]; 571 if (controller.backgroundTaskStartBlock) 572 return; 573 574 controller.backgroundTaskStartBlock = ^NSUInteger (void (^expirationHandler)()) 575 { 576 return [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:expirationHandler]; 577 }; 578 controller.backgroundTaskEndBlock = ^(UIBackgroundTaskIdentifier taskIdentifier) 579 { 580 [[UIApplication sharedApplication] endBackgroundTask:taskIdentifier]; 581 }; 582 controller.invalidBackgroundTaskIdentifier = UIBackgroundTaskInvalid; 583 584 WebCore::SQLiteDatabaseTracker::setClient(&WebCore::WebSQLiteDatabaseTrackerClient::sharedWebSQLiteDatabaseTrackerClient()); 585 #endif 558 586 } 559 587
Note: See TracChangeset
for help on using the changeset viewer.