Changeset 83767 in webkit
- Timestamp:
- Apr 13, 2011 2:29:36 PM (13 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r83766 r83767 1 2011-04-13 Anders Carlsson <andersca@apple.com> 2 3 Reviewed by Adam Roben. 4 5 Add support for disabling/enabling termination to ChildProcess 6 https://bugs.webkit.org/show_bug.cgi?id=58476 7 8 Add ChildProcess::disableTermination and ChildProcess::enableTermination and convert 9 the PluginProcess class over to using them. 10 11 * PluginProcess/PluginProcess.cpp: 12 (WebKit::PluginProcess::PluginProcess): 13 The child process now takes a terminationTimeout argument. Get rid of the shutdown timer. 14 15 (WebKit::PluginProcess::removeWebProcessConnection): 16 Call enableTermination(). 17 18 (WebKit::PluginProcess::shouldTerminate): 19 Always return true. 20 21 (WebKit::PluginProcess::createWebProcessConnection): 22 Call disableTermination(). 23 24 (WebKit::PluginProcess::getSitesWithData): 25 Call disableTermination()/enableTermination(). 26 27 (WebKit::PluginProcess::clearSiteData): 28 Ditto. 29 30 * Shared/ChildProcess.cpp: 31 (WebKit::ChildProcess::disableTermination): 32 Increment the counter and stop the timer. 33 34 (WebKit::ChildProcess::enableTermination): 35 Decrement the counter; if it's zero, start the timer. 36 37 (WebKit::ChildProcess::terminationTimerFired): 38 Call shouldTerminate(). If it returns true, call terminate(). 39 40 (WebKit::ChildProcess::terminate): 41 Call RunLoop::quit(). 42 43 * WebProcess/WebProcess.cpp: 44 (WebKit::WebProcess::WebProcess): 45 Just initialize the termination timeout to 0 for now. 46 47 (WebKit::WebProcess::shouldTerminate): 48 Always return true; this isn't used yet. 49 50 * WebProcess/WebProcess.h: 51 1 52 2011-04-13 Enrica Casucci <enrica@apple.com> 2 53 -
trunk/Source/WebKit2/PluginProcess/PluginProcess.cpp
r82460 r83767 47 47 48 48 PluginProcess::PluginProcess() 49 : m_shutdownTimer(RunLoop::main(), this, &PluginProcess::shutdownTimerFired)50 #if USE(ACCELERATED_COMPOSITING) &&PLATFORM(MAC)49 : ChildProcess(shutdownTimeout) 50 #if PLATFORM(MAC) 51 51 , m_compositingRenderServerPort(MACH_PORT_NULL) 52 52 #endif … … 79 79 } 80 80 81 startShutdownTimerIfNecessary();81 enableTermination(); 82 82 } 83 83 … … 99 99 } 100 100 101 bool PluginProcess::shouldTerminate() 102 { 103 ASSERT(m_webProcessConnections.isEmpty()); 104 105 return true; 106 } 107 101 108 void PluginProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments) 102 109 { … … 156 163 } 157 164 158 // Stop the shutdown timer. 159 m_shutdownTimer.stop(); 165 disableTermination(); 160 166 } 161 167 162 168 void PluginProcess::getSitesWithData(uint64_t callbackID) 163 169 { 170 disableTermination(); 171 164 172 Vector<String> sites; 165 173 if (NetscapePluginModule* module = netscapePluginModule()) … … 168 176 m_connection->send(Messages::PluginProcessProxy::DidGetSitesWithData(sites, callbackID), 0); 169 177 170 startShutdownTimerIfNecessary();178 enableTermination(); 171 179 } 172 180 173 181 void PluginProcess::clearSiteData(const Vector<String>& sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID) 174 182 { 183 disableTermination(); 184 175 185 if (NetscapePluginModule* module = netscapePluginModule()) { 176 186 if (sites.isEmpty()) { … … 185 195 m_connection->send(Messages::PluginProcessProxy::DidClearSiteData(callbackID), 0); 186 196 187 startShutdownTimerIfNecessary(); 188 } 189 190 void PluginProcess::startShutdownTimerIfNecessary() 191 { 192 if (!m_webProcessConnections.isEmpty()) 193 return; 194 195 // Start the shutdown timer. 196 m_shutdownTimer.startOneShot(shutdownTimeout); 197 } 198 199 void PluginProcess::shutdownTimerFired() 200 { 201 RunLoop::current()->stop(); 197 enableTermination(); 202 198 } 203 199 -
trunk/Source/WebKit2/PluginProcess/PluginProcess.h
r81412 r83767 65 65 ~PluginProcess(); 66 66 67 // ChildProcess 68 virtual bool shouldTerminate(); 69 67 70 // CoreIPC::Connection::Client 68 71 virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); … … 77 80 void getSitesWithData(uint64_t callbackID); 78 81 void clearSiteData(const Vector<String>& sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID); 79 80 void startShutdownTimerIfNecessary();81 void shutdownTimerFired();82 82 83 83 void platformInitialize(const PluginProcessCreationParameters&); … … 95 95 RefPtr<NetscapePluginModule> m_pluginModule; 96 96 97 // A timer used for the shutdown timeout.98 RunLoop::Timer<PluginProcess> m_shutdownTimer;99 100 97 #if USE(ACCELERATED_COMPOSITING) && PLATFORM(MAC) 101 98 // The Mach port used for accelerated compositing. -
trunk/Source/WebKit2/Shared/ChildProcess.cpp
r77874 r83767 33 33 namespace WebKit { 34 34 35 ChildProcess::ChildProcess()35 void ChildProcess::disableTermination() 36 36 { 37 m_terminationCounter++; 38 m_terminationTimer.stop(); 39 } 40 41 void ChildProcess::enableTermination() 42 { 43 ASSERT(m_terminationCounter > 0); 44 m_terminationCounter--; 45 46 if (m_terminationCounter) 47 return; 48 49 if (!m_terminationTimeout) { 50 terminationTimerFired(); 51 return; 52 } 53 54 m_terminationTimer.startOneShot(m_terminationTimeout); 55 } 56 57 ChildProcess::ChildProcess(double terminationTimeout) 58 : m_terminationTimeout(terminationTimeout) 59 , m_terminationCounter(0) 60 , m_terminationTimer(RunLoop::main(), this, &ChildProcess::terminationTimerFired) 61 { 62 // FIXME: The termination timer should not be scheduled on the main run loop. 63 // It won't work with the threaded mode, but it's not really useful anyway as is. 37 64 } 38 65 39 66 ChildProcess::~ChildProcess() 40 67 { 68 } 69 70 void ChildProcess::terminationTimerFired() 71 { 72 if (!shouldTerminate()) 73 return; 74 75 terminate(); 76 } 77 78 void ChildProcess::terminate() 79 { 80 RunLoop::main()->stop(); 41 81 } 42 82 -
trunk/Source/WebKit2/Shared/ChildProcess.h
r77874 r83767 28 28 29 29 #include "Connection.h" 30 #include "RunLoop.h" 30 31 31 32 namespace WebKit { … … 33 34 class ChildProcess : protected CoreIPC::Connection::Client { 34 35 WTF_MAKE_NONCOPYABLE(ChildProcess); 36 37 public: 38 // disable and enable termination of the process. when disableTermination is called, the 39 // process won't terminate unless a corresponding disableTermination call is made. 40 void disableTermination(); 41 void enableTermination(); 42 35 43 protected: 36 ChildProcess();44 explicit ChildProcess(double terminationTimeout); 37 45 ~ChildProcess(); 38 46 39 47 static void didCloseOnConnectionWorkQueue(WorkQueue&, CoreIPC::Connection*); 48 49 private: 50 void terminationTimerFired(); 51 52 virtual bool shouldTerminate() = 0; 53 virtual void terminate(); 54 55 // The timeout, in seconds, before this process will be terminated if termination 56 // has been enabled. If the timeout is 0 seconds, the process will be terminated immediately. 57 double m_terminationTimeout; 58 59 // A termination counter; when the counter reaches zero, the process will be terminated 60 // after a given period of time. 61 unsigned m_terminationCounter; 62 63 RunLoop::Timer<ChildProcess> m_terminationTimer; 40 64 }; 41 65 -
trunk/Source/WebKit2/WebProcess/WebProcess.cpp
r83627 r83767 119 119 120 120 WebProcess::WebProcess() 121 : m_inDidClose(false) 121 : ChildProcess(0) 122 , m_inDidClose(false) 122 123 , m_hasSetCacheModel(false) 123 124 , m_cacheModel(CacheModelDocumentViewer) … … 543 544 } 544 545 546 bool WebProcess::shouldTerminate() 547 { 548 // FIXME: Implement. 549 ASSERT_NOT_REACHED(); 550 return false; 551 } 552 545 553 CoreIPC::SyncReplyMode WebProcess::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, CoreIPC::ArgumentEncoder* reply) 546 554 { -
trunk/Source/WebKit2/WebProcess/WebProcess.h
r83498 r83767 167 167 void setTextCheckerState(const TextCheckerState&); 168 168 169 // ChildProcess 170 virtual bool shouldTerminate(); 171 169 172 // CoreIPC::Connection::Client 170 173 void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
Note: See TracChangeset
for help on using the changeset viewer.