Changeset 184105 in webkit
- Timestamp:
- May 11, 2015, 10:27:13 AM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 30 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r184104 r184105 1 2015-05-11 Daniel Bates <dabates@apple.com> 2 3 [iOS] Close all open databases in expiration handler of process assertion 4 https://bugs.webkit.org/show_bug.cgi?id=144661 5 <rdar://problem/20845052> 6 7 Reviewed by Darin Adler. 8 9 Expose functionality in WebCore to close all open databases. Closing a SQLite database 10 will interrupt any in-progress database transactions. 11 12 * Modules/webdatabase/AbstractDatabaseServer.h: 13 * Modules/webdatabase/DatabaseManager.cpp: 14 (WebCore::DatabaseManager::closeAllDatabases): Added; turns around and calls DatabaseServer::closeAllDatabases(). 15 * Modules/webdatabase/DatabaseManager.h: Export DatabaseManager::closeAllDatabases() so that 16 we can call in from WebKit2. 17 * Modules/webdatabase/DatabaseServer.cpp: 18 (WebCore::DatabaseServer::closeAllDatabases): Added; turns around and calls DatabaseTracker::closeAllDatabases(). 19 * Modules/webdatabase/DatabaseServer.h: 20 * Modules/webdatabase/DatabaseTracker.cpp: 21 (WebCore::DatabaseTracker::closeAllDatabases): Added; closes all open databases. 22 * Modules/webdatabase/DatabaseTracker.h: Export DatabaseTracker::closeAllDatabases() so that 23 we can call in from Legacy WebKit. 24 1 25 2015-05-11 Antti Koivisto <antti@apple.com> 2 26 -
trunk/Source/WebCore/Modules/webdatabase/AbstractDatabaseServer.h
r183909 r184105 58 58 virtual PassRefPtr<DatabaseBackendBase> openDatabase(RefPtr<DatabaseContext>&, const String& name, const String& expectedVersion, const String& displayName, unsigned long estimatedSize, bool setVersionInNewDatabase, DatabaseError&, String& errorMessage, OpenAttempt = FirstTryToOpenDatabase) = 0; 59 59 60 virtual void closeAllDatabases() = 0; 61 60 62 virtual bool hasEntryForOrigin(SecurityOrigin*) = 0; 61 63 virtual void origins(Vector<RefPtr<SecurityOrigin>>& result) = 0; -
trunk/Source/WebCore/Modules/webdatabase/DatabaseManager.cpp
r183909 r184105 403 403 } 404 404 405 void DatabaseManager::closeAllDatabases() 406 { 407 m_server->closeAllDatabases(); 408 } 409 405 410 void DatabaseManager::interruptAllDatabasesForContext(ScriptExecutionContext* context) 406 411 { -
trunk/Source/WebCore/Modules/webdatabase/DatabaseManager.h
r183909 r184105 86 86 87 87 WEBCORE_EXPORT bool hasOpenDatabases(ScriptExecutionContext*); 88 89 WEBCORE_EXPORT void closeAllDatabases(); 90 88 91 void stopDatabases(ScriptExecutionContext*, DatabaseTaskSynchronizer*); 89 92 -
trunk/Source/WebCore/Modules/webdatabase/DatabaseServer.cpp
r183909 r184105 118 118 } 119 119 120 void DatabaseServer::closeAllDatabases() 121 { 122 DatabaseTracker::tracker().closeAllDatabases(); 123 } 124 120 125 void DatabaseServer::interruptAllDatabasesForContext(const DatabaseContext* context) 121 126 { -
trunk/Source/WebCore/Modules/webdatabase/DatabaseServer.h
r183909 r184105 47 47 virtual PassRefPtr<DatabaseBackendBase> openDatabase(RefPtr<DatabaseContext>&, const String& name, const String& expectedVersion, const String& displayName, unsigned long estimatedSize, bool setVersionInNewDatabase, DatabaseError&, String& errorMessage, OpenAttempt); 48 48 49 void closeAllDatabases() override; 50 49 51 virtual bool hasEntryForOrigin(SecurityOrigin*); 50 52 virtual void origins(Vector<RefPtr<SecurityOrigin>>& result); -
trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp
r182365 r184105 305 305 maxSize = databaseFileSize; 306 306 return maxSize; 307 } 308 309 void DatabaseTracker::closeAllDatabases() 310 { 311 Vector<Ref<Database>> openDatabases; 312 { 313 MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard); 314 if (!m_openDatabaseMap) 315 return; 316 for (auto& nameMap : m_openDatabaseMap->values()) { 317 for (auto& set : nameMap->values()) { 318 for (auto& database : *set) 319 openDatabases.append(*database); 320 } 321 } 322 } 323 for (auto& database : openDatabases) 324 database->close(); 307 325 } 308 326 -
trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.h
r181837 r184105 74 74 75 75 unsigned long long getMaxSizeForDatabase(const Database*); 76 77 WEBCORE_EXPORT void closeAllDatabases(); 76 78 77 79 void interruptAllDatabasesForContext(const DatabaseContext*); -
trunk/Source/WebKit/mac/ChangeLog
r184056 r184105 1 2015-05-11 Daniel Bates <dabates@apple.com> 2 3 [iOS] Close all open databases in expiration handler of process assertion 4 https://bugs.webkit.org/show_bug.cgi?id=144661 5 <rdar://problem/20845052> 6 7 Reviewed by Darin Adler. 8 9 For Legacy WebKit, close all open databases when the process assertion expiration 10 handler is called. 11 12 * Storage/WebDatabaseManager.mm: 13 (+[WebDatabaseManager startBackgroundTask]): Call DatabaseTracker::tracker().closeAllDatabases() 14 in the expiration handler to close all open databases. As a side effect of closing 15 a database all in-progress database transactions are interrupted. 16 1 17 2015-05-10 Sungmann Cho <sungmann.cho@navercorp.com> 2 18 -
trunk/Source/WebKit/mac/Storage/WebDatabaseManager.mm
r180704 r184105 268 268 return; 269 269 270 setTransactionBackgroundTaskIdentifier(startBackgroundTask(^ { [WebDatabaseManager endBackgroundTask]; })); 270 setTransactionBackgroundTaskIdentifier(startBackgroundTask(^ { 271 DatabaseTracker::tracker().closeAllDatabases(); 272 [WebDatabaseManager endBackgroundTask]; 273 })); 271 274 } 272 275 -
trunk/Source/WebKit2/ChangeLog
r184066 r184105 1 2015-05-11 Daniel Bates <dabates@apple.com> 2 3 [iOS] Close all open databases in expiration handler of process assertion 4 https://bugs.webkit.org/show_bug.cgi?id=144661 5 <rdar://problem/20845052> 6 7 Reviewed by Darin Adler. 8 9 For WebKit2, close all open databases when the process assertion expiration 10 handler is called. 11 12 When the process assertion expiration handler is called we dispatch a synchronous 13 message called ProcessWillSuspendImminently to the {Web, Network} processes to inform 14 them that they will be suspended imminently. The {Web, Network} process will always 15 service this message regardless if they were waiting for another message. In the 16 WebProcess, we will close all open databases among other tasks upon receiving this 17 message. In the NetworkProcess, we will purge some data from memory. 18 19 * NetworkProcess/NetworkProcess.cpp: 20 (WebKit::NetworkProcess::didReceiveSyncMessage): Modified to call NetworkProcess::didReceiveSyncNetworkProcessMessage() 21 to process the synchronous ProcessWillSuspendImminently message. 22 (WebKit::NetworkProcess::processWillSuspendImminently): Added; free some memory. 23 * NetworkProcess/NetworkProcess.h: 24 * NetworkProcess/NetworkProcess.messages.in: Added synchronous message ProcessWillSuspendImminently. 25 * Shared/ChildProcessProxy.h: 26 (WebKit::ChildProcessProxy::sendSync): Added parameter sendSyncFlags so that we can send 27 a sync message with flag IPC::InterruptWaitingIfSyncMessageArrives to cause the {Web, Network}Process 28 to process the message regardless of whether it is waiting for another message. 29 * UIProcess/Network/NetworkProcessProxy.cpp: 30 (WebKit::NetworkProcessProxy::sendProcessWillSuspendImminently): Added. Sends the message 31 ProcessWillSuspendImminently to the NetworkProcess. 32 * UIProcess/Network/NetworkProcessProxy.h: 33 * UIProcess/ProcessAssertion.cpp: 34 (WebKit::ProcessAndUIAssertion::setClient): Added. 35 * UIProcess/ProcessAssertion.h: Added abstract class ProcessAssertionClient. 36 (WebKit::ProcessAssertionClient::~ProcessAssertionClient): Added. 37 (WebKit::ProcessAssertion::setClient): Added. 38 (WebKit::ProcessAssertion::client): Added. 39 * UIProcess/ProcessThrottler.cpp: 40 (WebKit::ProcessThrottler::didConnectToProcess): 41 (WebKit::ProcessThrottler::assertionWillExpireImminently): Added; implements the ProcessAssertionClient 42 interface. Notify the process throttler clients that the assertion is near expiration. 43 * UIProcess/ProcessThrottler.h: 44 * UIProcess/ProcessThrottlerClient.h: Added 45 * UIProcess/WebProcessProxy.cpp: 46 (WebKit::WebProcessProxy::sendProcessWillSuspendImminently): Added. Sends the message 47 ProcessWillSuspendImminently to the WebProcess. 48 * UIProcess/WebProcessProxy.h: 49 * UIProcess/ios/ProcessAssertionIOS.mm: 50 (-[WKProcessAssertionBackgroundTaskManager addClient:]): Added. 51 (-[WKProcessAssertionBackgroundTaskManager removeClient:]): Added. 52 (-[WKProcessAssertionBackgroundTaskManager _updateBackgroundTask]): Modified expiration handler 53 to notify ProcessAssertionClient clients that the assertion is near expiration. 54 (WebKit::ProcessAssertion::~ProcessAssertion): Remove the client on destruction. 55 (WebKit::ProcessAndUIAssertion::setClient): Added. 56 * WebProcess/WebCoreSupport/WebDatabaseManager.cpp: 57 (WebKit::WebDatabaseManager::closeAllDatabases): Added; turns around and calls DatabaseManager::closeAllDatabases(). 58 * WebProcess/WebCoreSupport/WebDatabaseManager.h: 59 * WebProcess/WebProcess.cpp: 60 (WebKit::WebProcess::didReceiveSyncMessage): Call WebProcess::didReceiveSyncWebProcessMessage() to process 61 the synchronous ProcessWillSuspendImminently message. Removed logging for an unhandled synchronous message 62 since WebProcess::didReceiveSyncWebProcessMessage() will ASSERT_NOT_REACHED() for such a message. 63 (WebKit::WebProcess::prepareToSuspend): Extracted code from WebProcess::processWillSuspend() so that it can 64 be used from both WebProcess::processWillSuspend() and WebProcess::processWillSuspendImminently(). And modified 65 it to conditionally dispatch a ProcessReadyToSuspend message to the WebProcessProxy. We only want to dispatch 66 such a message as part of a coordinated suspension by the ProcessThrottler. That is, we do not want to dispatch 67 the ProcessReadyToSuspend message when the background assertion is near expiration (i.e. WebProcess::processWillSuspendImminently() 68 is called). 69 (WebKit::WebProcess::processWillSuspendImminently): Added. Suspend all open databases among other tasks. 70 (WebKit::WebProcess::processWillSuspend): Implemented in terms of WebProcess::prepareToSuspend(). 71 (WebKit::WebProcess::processSuspensionCleanupTimerFired): Modified to conditionally dispatch a ProcessReadyToSuspend 72 message to the WebProcessProxy. 73 (WebKit::WebProcess::processDidResume): Stop the suspension cleanup timer, which may be active if the WebProcess 74 did not mark all its graphics layers as volatile before process suspension. 75 * WebProcess/WebProcess.h: 76 * WebProcess/WebProcess.messages.in: Added synchronous message ProcessWillSuspendImminently. 77 1 78 2015-05-10 Gyuyoung Kim <gyuyoung.kim@webkit.org> 2 79 -
trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp
r183737 r184105 133 133 void NetworkProcess::didReceiveSyncMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder, std::unique_ptr<IPC::MessageEncoder>& replyEncoder) 134 134 { 135 messageReceiverMap().dispatchSyncMessage(connection, decoder, replyEncoder); 135 if (messageReceiverMap().dispatchSyncMessage(connection, decoder, replyEncoder)) 136 return; 137 138 didReceiveSyncNetworkProcessMessage(connection, decoder, replyEncoder); 136 139 } 137 140 … … 506 509 } 507 510 511 void NetworkProcess::processWillSuspendImminently(bool& handled) 512 { 513 lowMemoryHandler(true); 514 handled = true; 515 } 516 508 517 void NetworkProcess::processWillSuspend() 509 518 { -
trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h
r183737 r184105 79 79 bool canHandleHTTPSServerTrustEvaluation() const { return m_canHandleHTTPSServerTrustEvaluation; } 80 80 81 void processWillSuspendImminently(bool& handled); 81 82 void processWillSuspend(); 82 83 void cancelProcessWillSuspend(); … … 123 124 // Message Handlers 124 125 void didReceiveNetworkProcessMessage(IPC::Connection&, IPC::MessageDecoder&); 126 void didReceiveSyncNetworkProcessMessage(IPC::Connection&, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&); 125 127 void initializeNetworkProcess(const NetworkProcessCreationParameters&); 126 128 void createNetworkConnectionToWebProcess(); -
trunk/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in
r182194 r184105 59 59 SetCacheModel(uint32_t cacheModel); 60 60 61 ProcessWillSuspendImminently() -> (bool handled) 61 62 ProcessWillSuspend() 62 63 CancelProcessWillSuspend() -
trunk/Source/WebKit2/Shared/ChildProcessProxy.h
r178598 r184105 49 49 50 50 template<typename T> bool send(T&& message, uint64_t destinationID, unsigned messageSendFlags = 0); 51 template<typename T> bool sendSync(T&& message, typename T::Reply&&, uint64_t destinationID, std::chrono::milliseconds timeout = std::chrono::seconds(1) );51 template<typename T> bool sendSync(T&& message, typename T::Reply&&, uint64_t destinationID, std::chrono::milliseconds timeout = std::chrono::seconds(1), unsigned sendSyncFlags = 0); 52 52 53 53 IPC::Connection* connection() const … … 106 106 107 107 template<typename U> 108 bool ChildProcessProxy::sendSync(U&& message, typename U::Reply&& reply, uint64_t destinationID, std::chrono::milliseconds timeout )108 bool ChildProcessProxy::sendSync(U&& message, typename U::Reply&& reply, uint64_t destinationID, std::chrono::milliseconds timeout, unsigned sendSyncFlags) 109 109 { 110 110 COMPILE_ASSERT(U::isSync, SyncMessageExpected); … … 113 113 return false; 114 114 115 return connection()->sendSync(std::forward<U>(message), WTF::move(reply), destinationID, timeout );115 return connection()->sendSync(std::forward<U>(message), WTF::move(reply), destinationID, timeout, sendSyncFlags); 116 116 } 117 117 -
trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp
r182323 r184105 314 314 } 315 315 316 void NetworkProcessProxy::sendProcessWillSuspendImminently() 317 { 318 if (!canSendMessage()) 319 return; 320 321 bool handled = false; 322 sendSync(Messages::NetworkProcess::ProcessWillSuspendImminently(), Messages::NetworkProcess::ProcessWillSuspendImminently::Reply(handled), 323 0, std::chrono::seconds(1), IPC::InterruptWaitingIfSyncMessageArrives); 324 } 325 316 326 void NetworkProcessProxy::sendProcessWillSuspend() 317 327 { -
trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h
r182323 r184105 70 70 #endif 71 71 72 void sendProcessWillSuspendImminently() override; 72 73 void sendProcessWillSuspend() override; 73 74 void sendCancelProcessWillSuspend() override; -
trunk/Source/WebKit2/UIProcess/ProcessAssertion.cpp
r173623 r184105 47 47 m_assertionState = assertionState; 48 48 } 49 49 50 50 ProcessAndUIAssertion::ProcessAndUIAssertion(pid_t pid, AssertionState assertionState) 51 51 : ProcessAssertion(pid, assertionState) … … 61 61 ProcessAssertion::setState(assertionState); 62 62 } 63 63 64 void ProcessAndUIAssertion::setClient(ProcessAssertionClient& client) 65 { 66 ProcessAssertion::setClient(client); 67 } 68 64 69 } 65 70 -
trunk/Source/WebKit2/UIProcess/ProcessAssertion.h
r173623 r184105 40 40 }; 41 41 42 class ProcessAssertionClient { 43 public: 44 virtual ~ProcessAssertionClient() { }; 45 virtual void assertionWillExpireImminently() = 0; 46 }; 47 42 48 class ProcessAssertion { 43 49 public: … … 45 51 ~ProcessAssertion(); 46 52 53 void setClient(ProcessAssertionClient& client) { m_client = &client; } 54 ProcessAssertionClient* client() { return m_client; } 55 47 56 AssertionState state() const { return m_assertionState; } 48 49 57 void setState(AssertionState); 50 58 51 59 private: 52 60 #if PLATFORM(IOS) && !PLATFORM(IOS_SIMULATOR) … … 54 62 #endif 55 63 AssertionState m_assertionState; 64 ProcessAssertionClient* m_client { nullptr }; 56 65 }; 57 66 … … 60 69 ProcessAndUIAssertion(pid_t, AssertionState); 61 70 ~ProcessAndUIAssertion(); 62 71 72 void setClient(ProcessAssertionClient&); 73 63 74 void setState(AssertionState); 64 75 }; -
trunk/Source/WebKit2/UIProcess/ProcessThrottler.cpp
r182194 r184105 89 89 m_suspendTimer.stop(); 90 90 m_assertion = std::make_unique<ProcessAndUIAssertion>(pid, assertionState()); 91 m_assertion->setClient(*this); 91 92 } 92 93 … … 110 111 } 111 112 113 void ProcessThrottler::assertionWillExpireImminently() 114 { 115 m_process->sendProcessWillSuspendImminently(); 112 116 } 117 118 } -
trunk/Source/WebKit2/UIProcess/ProcessThrottler.h
r182194 r184105 42 42 class ProcessThrottlerClient; 43 43 44 class ProcessThrottler {44 class ProcessThrottler : private ProcessAssertionClient { 45 45 public: 46 46 enum ForegroundActivityTokenType { }; … … 57 57 void processReadyToSuspend(); 58 58 void didCancelProcessSuspension(); 59 59 60 60 private: 61 61 AssertionState assertionState(); … … 63 63 void updateAssertionNow(); 64 64 void suspendTimerFired(); 65 65 66 // ProcessAssertionClient 67 void assertionWillExpireImminently() override; 68 66 69 ProcessThrottlerClient* m_process; 67 70 std::unique_ptr<ProcessAndUIAssertion> m_assertion; -
trunk/Source/WebKit2/UIProcess/ProcessThrottlerClient.h
r182194 r184105 33 33 virtual ~ProcessThrottlerClient() { } 34 34 35 virtual void sendProcessWillSuspendImminently() = 0; 35 36 virtual void sendProcessWillSuspend() = 0; 36 37 virtual void sendCancelProcessWillSuspend() = 0; -
trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp
r184054 r184105 890 890 } 891 891 892 void WebProcessProxy::sendProcessWillSuspendImminently() 893 { 894 if (!canSendMessage()) 895 return; 896 897 bool handled = false; 898 sendSync(Messages::WebProcess::ProcessWillSuspendImminently(), Messages::WebProcess::ProcessWillSuspendImminently::Reply(handled), 899 0, std::chrono::seconds(1), IPC::InterruptWaitingIfSyncMessageArrives); 900 } 901 892 902 void WebProcessProxy::sendProcessWillSuspend() 893 903 { -
trunk/Source/WebKit2/UIProcess/WebProcessProxy.h
r182610 r184105 144 144 void windowServerConnectionStateChanged(); 145 145 146 void sendProcessWillSuspendImminently() override; 146 147 void sendProcessWillSuspend() override; 147 148 void processReadyToSuspend(); -
trunk/Source/WebKit2/UIProcess/ios/ProcessAssertionIOS.mm
r178080 r184105 31 31 #import "BKSProcessAssertionSPI.h" 32 32 #import <UIKit/UIApplication.h> 33 #import <wtf/HashSet.h> 34 #import <wtf/Vector.h> 33 35 34 36 #if !PLATFORM(IOS_SIMULATOR) 37 38 using WebKit::ProcessAssertionClient; 35 39 36 40 @interface WKProcessAssertionBackgroundTaskManager : NSObject … … 40 44 - (void)incrementNeedsToRunInBackgroundCount; 41 45 - (void)decrementNeedsToRunInBackgroundCount; 46 47 - (void)addClient:(ProcessAssertionClient&)client; 48 - (void)removeClient:(ProcessAssertionClient&)client; 42 49 43 50 @end … … 48 55 BOOL _appIsBackground; 49 56 UIBackgroundTaskIdentifier _backgroundTask; 57 HashSet<ProcessAssertionClient*> _clients; 50 58 } 51 59 … … 84 92 } 85 93 94 - (void)addClient:(ProcessAssertionClient&)client 95 { 96 _clients.add(&client); 97 } 98 99 - (void)removeClient:(ProcessAssertionClient&)client 100 { 101 _clients.remove(&client); 102 } 103 86 104 - (void)_updateBackgroundTask 87 105 { … … 91 109 _backgroundTask = [[UIApplication sharedApplication] beginBackgroundTaskWithName:@"com.apple.WebKit.ProcessAssertion" expirationHandler:^{ 92 110 NSLog(@"Background task expired while holding WebKit ProcessAssertion."); 111 Vector<ProcessAssertionClient*> clientsToNotify; 112 copyToVector(_clients, clientsToNotify); 113 for (auto* client : clientsToNotify) 114 client->assertionWillExpireImminently(); 93 115 [[UIApplication sharedApplication] endBackgroundTask:_backgroundTask]; 94 116 _backgroundTask = UIBackgroundTaskInvalid; … … 161 183 ProcessAssertion::~ProcessAssertion() 162 184 { 185 if (ProcessAssertionClient* client = this->client()) 186 [[WKProcessAssertionBackgroundTaskManager shared] removeClient:*client]; 163 187 [m_assertion invalidate]; 164 188 } … … 196 220 } 197 221 222 void ProcessAndUIAssertion::setClient(ProcessAssertionClient& newClient) 223 { 224 [[WKProcessAssertionBackgroundTaskManager shared] addClient:newClient]; 225 if (ProcessAssertionClient* oldClient = this->client()) 226 [[WKProcessAssertionBackgroundTaskManager shared] removeClient:*oldClient]; 227 ProcessAssertion::setClient(newClient); 228 } 229 198 230 } // namespace WebKit 199 231 … … 230 262 } 231 263 264 void ProcessAndUIAssertion::setClient(ProcessAssertionClient& newClient) 265 { 266 ProcessAssertion::setClient(newClient); 267 } 268 232 269 } // namespace WebKit 233 270 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp
r183909 r184105 143 143 } 144 144 145 void WebDatabaseManager::closeAllDatabases() const 146 { 147 DatabaseManager::singleton().closeAllDatabases(); 148 } 149 145 150 void WebDatabaseManager::setQuotaForOrigin(const String& originIdentifier, unsigned long long quota) const 146 151 { -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.h
r183909 r184105 49 49 void setPauseAllDatabases(bool); 50 50 51 void closeAllDatabases() const; 52 51 53 private: 52 54 // WebProcessSupplement -
trunk/Source/WebKit2/WebProcess/WebProcess.cpp
r182626 r184105 609 609 return; 610 610 611 LOG_ERROR("Unhandled synchronous web process message '%s:%s'", decoder.messageReceiverName().toString().data(), decoder.messageName().toString().data());611 didReceiveSyncWebProcessMessage(connection, decoder, replyEncoder); 612 612 } 613 613 … … 1218 1218 } 1219 1219 #endif 1220 1221 void WebProcess::pr ocessWillSuspend()1220 1221 void WebProcess::prepareToSuspend(ShouldAcknowledgeWhenReadyToSuspend shouldAcknowledgeWhenReadyToSuspend) 1222 1222 { 1223 1223 MemoryPressureHandler::singleton().releaseMemory(true); 1224 1224 setAllLayerTreeStatesFrozen(true); 1225 1225 1226 if (!markAllLayersVolatileIfPossible()) 1227 m_processSuspensionCleanupTimer.startRepeating(std::chrono::milliseconds(20)); 1228 else 1229 parentProcessConnection()->send(Messages::WebProcessProxy::ProcessReadyToSuspend(), 0); 1226 if (markAllLayersVolatileIfPossible()) { 1227 if (shouldAcknowledgeWhenReadyToSuspend == ShouldAcknowledgeWhenReadyToSuspend::Yes) 1228 parentProcessConnection()->send(Messages::WebProcessProxy::ProcessReadyToSuspend(), 0); 1229 return; 1230 } 1231 m_shouldAcknowledgeWhenReadyToSuspend = shouldAcknowledgeWhenReadyToSuspend; 1232 m_processSuspensionCleanupTimer.startRepeating(std::chrono::milliseconds(20)); 1233 } 1234 1235 void WebProcess::processWillSuspendImminently(bool& handled) 1236 { 1237 supplement<WebDatabaseManager>()->closeAllDatabases(); 1238 prepareToSuspend(ShouldAcknowledgeWhenReadyToSuspend::No); 1239 handled = true; 1240 } 1241 1242 void WebProcess::processWillSuspend() 1243 { 1244 prepareToSuspend(ShouldAcknowledgeWhenReadyToSuspend::Yes); 1230 1245 } 1231 1246 … … 1264 1279 void WebProcess::processSuspensionCleanupTimerFired() 1265 1280 { 1266 if (markAllLayersVolatileIfPossible()) { 1267 m_processSuspensionCleanupTimer.stop(); 1281 if (!markAllLayersVolatileIfPossible()) 1282 return; 1283 m_processSuspensionCleanupTimer.stop(); 1284 if (m_shouldAcknowledgeWhenReadyToSuspend == ShouldAcknowledgeWhenReadyToSuspend::Yes) 1268 1285 parentProcessConnection()->send(Messages::WebProcessProxy::ProcessReadyToSuspend(), 0); 1269 }1270 1286 } 1271 1287 1272 1288 void WebProcess::processDidResume() 1273 1289 { 1290 m_processSuspensionCleanupTimer.stop(); 1274 1291 setAllLayerTreeStatesFrozen(false); 1275 1292 } -
trunk/Source/WebKit2/WebProcess/WebProcess.h
r182437 r184105 185 185 #endif 186 186 187 void processWillSuspendImminently(bool& handled); 187 188 void processWillSuspend(); 188 189 void cancelProcessWillSuspend(); … … 283 284 void setInjectedBundleParameter(const String& key, const IPC::DataReference&); 284 285 286 enum class ShouldAcknowledgeWhenReadyToSuspend { No, Yes }; 287 void prepareToSuspend(ShouldAcknowledgeWhenReadyToSuspend); 288 285 289 // ChildProcess 286 290 virtual void initializeProcess(const ChildProcessInitializationParameters&) override; … … 308 312 // Implemented in generated WebProcessMessageReceiver.cpp 309 313 void didReceiveWebProcessMessage(IPC::Connection&, IPC::MessageDecoder&); 314 void didReceiveSyncWebProcessMessage(IPC::Connection&, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&); 310 315 311 316 // WebOriginDataManagerSupplement … … 382 387 WebSQLiteDatabaseTracker m_webSQLiteDatabaseTracker; 383 388 #endif 389 390 ShouldAcknowledgeWhenReadyToSuspend m_shouldAcknowledgeWhenReadyToSuspend; 384 391 }; 385 392 -
trunk/Source/WebKit2/WebProcess/WebProcess.messages.in
r181562 r184105 101 101 #endif 102 102 103 ProcessWillSuspendImminently() -> (bool handled) 103 104 ProcessWillSuspend() 104 105 CancelProcessWillSuspend()
Note:
See TracChangeset
for help on using the changeset viewer.