Changeset 62790 in webkit
- Timestamp:
- Jul 8, 2010 9:01:42 AM (14 years ago)
- Location:
- trunk/WebKit2
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit2/ChangeLog
r62788 r62790 1 2010-07-08 Luiz Agostini <luiz@webkit.org>, Kenneth Rohde Christiansen <kenneth@webkit.org> 2 3 Reviewed by Antti Koivisto. 4 5 [Qt] Improve QtWebkit2 secondary process launching procedure 6 https://bugs.webkit.org/show_bug.cgi?id=41853 7 8 Changing secondary process launching procedure to make sure that the method 9 ProcessLauncher::didFinishLaunchingProcess will only be called after secondary 10 process has been launched and the connection has been stablished between the 11 UIProcess and WebProcess. 12 13 This solves the timing issues ocasionaly observed when launching MiniBrowser. 14 15 QLocalServer object and related code has been removed from the class Connection. 16 Server instances of the Connection class now get the QLocalSocket via ProcessLauncher. 17 18 * Platform/CoreIPC/Connection.h: 19 * Platform/CoreIPC/qt/ConnectionQt.cpp: 20 (CoreIPC::Connection::platformInitialize): 21 (CoreIPC::Connection::platformInvalidate): 22 (CoreIPC::Connection::open): 23 24 Using QProcess* as PlatformProcessIdentifier. 25 26 * Platform/PlatformProcessIdentifier.h: 27 28 A new singleton class named ProcessLauncherHelper was created to handle the QLocalServer 29 object used to receive connections. This class launches the process and waits for it to connect 30 before calling ProcessLauncher::didFinishLaunchingProcess. 31 32 * UIProcess/Launcher/ProcessLauncher.h: 33 * UIProcess/Launcher/qt/ProcessLauncherQt.cpp: 34 (WebKit::ProcessLauncherHelper::launch): 35 (WebKit::ProcessLauncherHelper::takePendingConnection): 36 (WebKit::ProcessLauncherHelper::ProcessLauncherHelper): 37 (WebKit::ProcessLauncherHelper::instance): 38 (WebKit::ProcessLauncherHelper::newConnection): 39 (WebKit::ProcessLauncher::launchProcess): 40 (WebKit::ProcessLauncher::terminateProcess): 41 (_qt_takePendingConnection): 42 1 43 2010-07-08 Antti Koivisto <koivisto@iki.fi> 2 44 -
trunk/WebKit2/Platform/CoreIPC/Connection.h
r62430 r62790 174 174 #elif PLATFORM(QT) 175 175 // Called on the connection queue. 176 void openConnectionHandler();177 void newConnectionHandler();178 176 void readyReadHandler(); 179 177 … … 181 179 size_t m_currentMessageSize; 182 180 QLocalSocket* m_socket; 183 QLocalServer* m_server;184 181 QString m_serverName; 185 182 #endif -
trunk/WebKit2/Platform/CoreIPC/qt/ConnectionQt.cpp
r62648 r62790 28 28 29 29 #include "ArgumentEncoder.h" 30 #include "ProcessLauncher.h" 30 31 #include "WebPageProxyMessageKinds.h" 31 32 #include "WorkItem.h" … … 43 44 void Connection::platformInitialize(Identifier identifier) 44 45 { 45 m_serverName = "QtWebKit" + identifier; 46 m_server = 0; 46 m_serverName = identifier; 47 47 m_socket = 0; 48 48 m_readBuffer.resize(messageMaxSize); … … 52 52 void Connection::platformInvalidate() 53 53 { 54 delete m_server;55 54 delete m_socket; 56 }57 58 void Connection::newConnectionHandler()59 {60 m_socket = m_server->nextPendingConnection();61 m_isConnected = m_socket;62 if (m_isConnected)63 m_connectionQueue.connectSignal(m_socket, SIGNAL(readyRead()), WorkItem::create(this, &Connection::readyReadHandler));64 55 } 65 56 … … 94 85 } 95 86 96 void Connection::openConnectionHandler()87 bool Connection::open() 97 88 { 98 ASSERT(!m_server);99 89 ASSERT(!m_socket); 100 90 101 91 if (m_isServer) { 102 m_server = new QLocalServer(); 103 if (!m_server->listen(m_serverName)) { 104 qDebug() << "failed to create server " << m_serverName; 105 return; 106 } 107 m_connectionQueue.connectSignal(m_server, SIGNAL(newConnection()), WorkItem::create(this, &Connection::newConnectionHandler)); 92 m_socket = WebKit::ProcessLauncher::takePendingConnection(); 93 m_isConnected = m_socket; 94 if (m_isConnected) 95 m_connectionQueue.connectSignal(m_socket, SIGNAL(readyRead()), WorkItem::create(this, &Connection::readyReadHandler)); 108 96 } else { 109 97 m_socket = new QLocalSocket(); … … 112 100 m_isConnected = m_socket->waitForConnected(); 113 101 } 114 } 115 116 bool Connection::open() 117 { 118 m_connectionQueue.scheduleWork(WorkItem::create(this, &Connection::openConnectionHandler)); 119 return false; 102 return m_isConnected; 120 103 } 121 104 -
trunk/WebKit2/Platform/PlatformProcessIdentifier.h
r62257 r62790 28 28 #define PlatformProcessIdentifier_h 29 29 30 #if PLATFORM(QT) 31 class QProcess; 32 #endif 33 30 34 namespace WebKit { 31 35 … … 35 39 typedef HANDLE PlatformProcessIdentifier; 36 40 #elif PLATFORM(QT) 37 typedef pid_tPlatformProcessIdentifier;41 typedef QProcess* PlatformProcessIdentifier; 38 42 #endif 39 43 -
trunk/WebKit2/UIProcess/Launcher/ProcessLauncher.h
r62305 r62790 32 32 #include <wtf/Threading.h> 33 33 34 #if PLATFORM(QT) 35 class QLocalSocket; 36 #endif 37 34 38 namespace WebKit { 35 39 … … 56 60 static CoreIPC::Connection::Identifier createWebThread(); 57 61 62 #if PLATFORM(QT) 63 friend class ProcessLauncherHelper; 64 static QLocalSocket* takePendingConnection(); 65 #endif 66 58 67 private: 59 68 explicit ProcessLauncher(Client*); -
trunk/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp
r62485 r62790 40 40 #endif 41 41 42 #ifdef Q_OS_UNIX43 #include <signal.h>44 #endif45 46 42 #include <QApplication> 47 43 #include <QDebug> 44 #include <QLocalServer> 48 45 #include <QProcess> 49 46 … … 65 62 namespace WebKit { 66 63 67 void ProcessLauncher::launchProcess() 68 { 69 srandom(time(0)); 70 QString connectionIdentifier = QString::number(random()); 71 72 QString program("QtWebProcess " + connectionIdentifier); 73 74 QProcess* webProcess = new QProcess; 64 class ProcessLauncherHelper : public QObject { 65 Q_OBJECT 66 public: 67 void launch(WebKit::ProcessLauncher*); 68 QLocalSocket* takePendingConnection(); 69 static ProcessLauncherHelper* instance(); 70 private: 71 ProcessLauncherHelper(); 72 QLocalServer m_server; 73 QList<WorkItem*> m_items; 74 75 Q_SLOT void newConnection(); 76 }; 77 78 void ProcessLauncherHelper::launch(WebKit::ProcessLauncher* launcher) 79 { 80 QString program("QtWebProcess " + m_server.serverName()); 81 82 QProcess* webProcess = new QProcess(); 75 83 webProcess->start(program); 76 84 … … 78 86 qDebug() << "Failed to start" << program; 79 87 ASSERT_NOT_REACHED(); 88 delete webProcess; 89 return; 80 90 } 81 91 82 PlatformProcessIdentifier processIdentifier = webProcess->pid(); 83 setpriority(PRIO_PROCESS, processIdentifier, 10); 84 85 qDebug() << program << "nice" << getpriority(PRIO_PROCESS, processIdentifier); 86 87 // We've finished launching the process, message back to the run loop. 88 RunLoop::main()->scheduleWork(WorkItem::create(this, &ProcessLauncher::didFinishLaunchingProcess, processIdentifier, connectionIdentifier)); 92 setpriority(PRIO_PROCESS, webProcess->pid(), 10); 93 94 m_items.append(WorkItem::create(launcher, &WebKit::ProcessLauncher::didFinishLaunchingProcess, webProcess, m_server.serverName()).release()); 95 } 96 97 QLocalSocket* ProcessLauncherHelper::takePendingConnection() 98 { 99 return m_server.nextPendingConnection(); 100 } 101 102 ProcessLauncherHelper::ProcessLauncherHelper() 103 { 104 srandom(time(0)); 105 if (!m_server.listen("QtWebKit" + QString::number(random()))) { 106 qDebug() << "Failed to create server socket."; 107 ASSERT_NOT_REACHED(); 108 } 109 connect(&m_server, SIGNAL(newConnection()), this, SLOT(newConnection())); 110 } 111 112 ProcessLauncherHelper* ProcessLauncherHelper::instance() 113 { 114 static ProcessLauncherHelper* result = new ProcessLauncherHelper(); 115 return result; 116 } 117 118 void ProcessLauncherHelper::newConnection() 119 { 120 ASSERT(!m_items.isEmpty()); 121 122 m_items[0]->execute(); 123 delete m_items[0]; 124 m_items.pop_front(); 125 } 126 127 void ProcessLauncher::launchProcess() 128 { 129 ProcessLauncherHelper::instance()->launch(this); 89 130 } 90 131 … … 94 135 return; 95 136 96 #ifdef Q_OS_UNIX 97 kill(m_processIdentifier, SIGKILL); 98 #endif 137 QObject::connect(m_processIdentifier, SIGNAL(finished(int)), m_processIdentifier, SLOT(deleteLater()), Qt::QueuedConnection); 138 m_processIdentifier->kill(); 139 } 140 141 QLocalSocket* ProcessLauncher::takePendingConnection() 142 { 143 return ProcessLauncherHelper::instance()->takePendingConnection(); 99 144 } 100 145 … … 153 198 return 0; 154 199 } 200 201 #include "WebProcessLauncherQt.moc"
Note: See TracChangeset
for help on using the changeset viewer.