beidson@apple.com | 21dd3ed | 2012-10-12 17:13:13 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Apple Inc. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
| 14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
| 17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 23 | * THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
| 26 | #include "config.h" |
| 27 | #include "NetworkProcessProxy.h" |
| 28 | |
ap@apple.com | 9fb96e1 | 2013-01-08 17:50:51 +0000 | [diff] [blame] | 29 | #if ENABLE(NETWORK_PROCESS) |
| 30 | |
beidson@apple.com | daf9106 | 2013-01-26 00:03:48 +0000 | [diff] [blame] | 31 | #include "AuthenticationChallengeProxy.h" |
andersca@apple.com | 172fb56 | 2013-01-30 00:00:39 +0000 | [diff] [blame] | 32 | #include "CustomProtocolManagerProxyMessages.h" |
andersca@apple.com | 93b4c36 | 2012-12-16 01:26:05 +0000 | [diff] [blame] | 33 | #include "DownloadProxyMessages.h" |
beidson@apple.com | c9a08bc | 2012-10-12 23:37:30 +0000 | [diff] [blame] | 34 | #include "NetworkProcessCreationParameters.h" |
| 35 | #include "NetworkProcessMessages.h" |
beidson@apple.com | dfbdf94 | 2012-10-19 23:26:16 +0000 | [diff] [blame] | 36 | #include "WebProcessMessages.h" |
weinig@apple.com | 9c5a3ea | 2014-12-23 20:29:26 +0000 | [diff] [blame] | 37 | #include "WebProcessPool.h" |
andersca@apple.com | ce92768 | 2015-02-27 20:14:22 +0000 | [diff] [blame] | 38 | #include "WebsiteData.h" |
paroga@webkit.org | f8108ef | 2013-11-09 20:59:28 +0000 | [diff] [blame] | 39 | #include <wtf/RunLoop.h> |
beidson@apple.com | 21dd3ed | 2012-10-12 17:13:13 +0000 | [diff] [blame] | 40 | |
commit-queue@webkit.org | b48afca | 2013-12-08 18:26:15 +0000 | [diff] [blame] | 41 | #if ENABLE(SEC_ITEM_SHIM) |
| 42 | #include "SecItemShimProxy.h" |
| 43 | #endif |
| 44 | |
bdakin@apple.com | 1539c6c | 2015-01-28 22:22:16 +0000 | [diff] [blame] | 45 | #if PLATFORM(IOS) |
dbates@webkit.org | dcec383 | 2014-11-21 16:40:55 +0000 | [diff] [blame] | 46 | #include <wtf/spi/darwin/XPCSPI.h> |
| 47 | #endif |
| 48 | |
beidson@apple.com | daf9106 | 2013-01-26 00:03:48 +0000 | [diff] [blame] | 49 | #define MESSAGE_CHECK(assertion) MESSAGE_CHECK_BASE(assertion, connection()) |
| 50 | |
beidson@apple.com | 21dd3ed | 2012-10-12 17:13:13 +0000 | [diff] [blame] | 51 | using namespace WebCore; |
| 52 | |
| 53 | namespace WebKit { |
| 54 | |
andersca@apple.com | 5ebf458 | 2014-12-09 20:29:59 +0000 | [diff] [blame] | 55 | static uint64_t generateCallbackID() |
| 56 | { |
| 57 | static uint64_t callbackID; |
| 58 | |
| 59 | return ++callbackID; |
| 60 | } |
| 61 | |
weinig@apple.com | 9c5a3ea | 2014-12-23 20:29:26 +0000 | [diff] [blame] | 62 | PassRefPtr<NetworkProcessProxy> NetworkProcessProxy::create(WebProcessPool& processPool) |
beidson@apple.com | 21dd3ed | 2012-10-12 17:13:13 +0000 | [diff] [blame] | 63 | { |
weinig@apple.com | 9c5a3ea | 2014-12-23 20:29:26 +0000 | [diff] [blame] | 64 | return adoptRef(new NetworkProcessProxy(processPool)); |
beidson@apple.com | 21dd3ed | 2012-10-12 17:13:13 +0000 | [diff] [blame] | 65 | } |
| 66 | |
weinig@apple.com | 9c5a3ea | 2014-12-23 20:29:26 +0000 | [diff] [blame] | 67 | NetworkProcessProxy::NetworkProcessProxy(WebProcessPool& processPool) |
| 68 | : m_processPool(processPool) |
beidson@apple.com | dfbdf94 | 2012-10-19 23:26:16 +0000 | [diff] [blame] | 69 | , m_numPendingConnectionRequests(0) |
weinig@apple.com | 9c5a3ea | 2014-12-23 20:29:26 +0000 | [diff] [blame] | 70 | , m_customProtocolManagerProxy(this, processPool) |
beidson@apple.com | 21dd3ed | 2012-10-12 17:13:13 +0000 | [diff] [blame] | 71 | { |
ap@apple.com | 10a670e | 2012-12-05 23:28:31 +0000 | [diff] [blame] | 72 | connect(); |
| 73 | } |
| 74 | |
weinig@apple.com | 444fbd69 | 2013-01-27 05:32:53 +0000 | [diff] [blame] | 75 | NetworkProcessProxy::~NetworkProcessProxy() |
| 76 | { |
andersca@apple.com | ce92768 | 2015-02-27 20:14:22 +0000 | [diff] [blame] | 77 | ASSERT(m_pendingFetchWebsiteDataCallbacks.isEmpty()); |
andersca@apple.com | 5ebf458 | 2014-12-09 20:29:59 +0000 | [diff] [blame] | 78 | ASSERT(m_pendingDeleteWebsiteDataCallbacks.isEmpty()); |
andersca@apple.com | ce92768 | 2015-02-27 20:14:22 +0000 | [diff] [blame] | 79 | ASSERT(m_pendingDeleteWebsiteDataForOriginsCallbacks.isEmpty()); |
weinig@apple.com | 444fbd69 | 2013-01-27 05:32:53 +0000 | [diff] [blame] | 80 | } |
| 81 | |
ap@apple.com | 10a670e | 2012-12-05 23:28:31 +0000 | [diff] [blame] | 82 | void NetworkProcessProxy::getLaunchOptions(ProcessLauncher::LaunchOptions& launchOptions) |
| 83 | { |
beidson@apple.com | 21dd3ed | 2012-10-12 17:13:13 +0000 | [diff] [blame] | 84 | launchOptions.processType = ProcessLauncher::NetworkProcess; |
weinig@apple.com | 444fbd69 | 2013-01-27 05:32:53 +0000 | [diff] [blame] | 85 | platformGetLaunchOptions(launchOptions); |
beidson@apple.com | 21dd3ed | 2012-10-12 17:13:13 +0000 | [diff] [blame] | 86 | } |
| 87 | |
andersca@apple.com | 15bc086 | 2015-01-16 21:37:42 +0000 | [diff] [blame] | 88 | void NetworkProcessProxy::connectionWillOpen(IPC::Connection& connection) |
andersca@apple.com | 296139a | 2013-02-12 20:56:57 +0000 | [diff] [blame] | 89 | { |
mitz@apple.com | da402b7 | 2013-12-04 21:04:31 +0000 | [diff] [blame] | 90 | #if ENABLE(SEC_ITEM_SHIM) |
cdumez@apple.com | 4faf1ef | 2015-01-30 20:49:33 +0000 | [diff] [blame] | 91 | SecItemShimProxy::singleton().initializeConnection(connection); |
mrobinson@webkit.org | ab8540d | 2014-03-20 17:20:58 +0000 | [diff] [blame] | 92 | #else |
| 93 | UNUSED_PARAM(connection); |
andersca@apple.com | 296139a | 2013-02-12 20:56:57 +0000 | [diff] [blame] | 94 | #endif |
| 95 | } |
| 96 | |
beidson@apple.com | dfbdf94 | 2012-10-19 23:26:16 +0000 | [diff] [blame] | 97 | void NetworkProcessProxy::getNetworkProcessConnection(PassRefPtr<Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply> reply) |
beidson@apple.com | 21dd3ed | 2012-10-12 17:13:13 +0000 | [diff] [blame] | 98 | { |
beidson@apple.com | dfbdf94 | 2012-10-19 23:26:16 +0000 | [diff] [blame] | 99 | m_pendingConnectionReplies.append(reply); |
beidson@apple.com | 21dd3ed | 2012-10-12 17:13:13 +0000 | [diff] [blame] | 100 | |
andersca@apple.com | 90ab0cb | 2014-02-27 23:16:41 +0000 | [diff] [blame] | 101 | if (state() == State::Launching) { |
beidson@apple.com | dfbdf94 | 2012-10-19 23:26:16 +0000 | [diff] [blame] | 102 | m_numPendingConnectionRequests++; |
| 103 | return; |
| 104 | } |
| 105 | |
andersca@apple.com | 69388f0 | 2013-12-30 20:20:02 +0000 | [diff] [blame] | 106 | connection()->send(Messages::NetworkProcess::CreateNetworkConnectionToWebProcess(), 0, IPC::DispatchMessageEvenWhenWaitingForSyncReply); |
beidson@apple.com | dfbdf94 | 2012-10-19 23:26:16 +0000 | [diff] [blame] | 107 | } |
| 108 | |
jeffm@apple.com | 76858a1 | 2014-10-02 21:01:08 +0000 | [diff] [blame] | 109 | DownloadProxy* NetworkProcessProxy::createDownloadProxy(const ResourceRequest& resourceRequest) |
andersca@apple.com | 12e7492 | 2012-12-15 23:11:52 +0000 | [diff] [blame] | 110 | { |
| 111 | if (!m_downloadProxyMap) |
zandobersek@gmail.com | da3be5e3 | 2014-04-27 13:40:14 +0000 | [diff] [blame] | 112 | m_downloadProxyMap = std::make_unique<DownloadProxyMap>(this); |
andersca@apple.com | 12e7492 | 2012-12-15 23:11:52 +0000 | [diff] [blame] | 113 | |
weinig@apple.com | 9c5a3ea | 2014-12-23 20:29:26 +0000 | [diff] [blame] | 114 | return m_downloadProxyMap->createDownloadProxy(m_processPool, resourceRequest); |
andersca@apple.com | 12e7492 | 2012-12-15 23:11:52 +0000 | [diff] [blame] | 115 | } |
| 116 | |
andersca@apple.com | ce92768 | 2015-02-27 20:14:22 +0000 | [diff] [blame] | 117 | void NetworkProcessProxy::fetchWebsiteData(SessionID sessionID, WebsiteDataTypes dataTypes, std::function<void (WebsiteData)> completionHandler) |
| 118 | { |
| 119 | ASSERT(canSendMessage()); |
| 120 | |
| 121 | uint64_t callbackID = generateCallbackID(); |
| 122 | m_pendingFetchWebsiteDataCallbacks.add(callbackID, WTF::move(completionHandler)); |
| 123 | |
| 124 | send(Messages::WebProcess::FetchWebsiteData(sessionID, dataTypes, callbackID), 0); |
| 125 | } |
| 126 | |
andersca@apple.com | 5ebf458 | 2014-12-09 20:29:59 +0000 | [diff] [blame] | 127 | void NetworkProcessProxy::deleteWebsiteData(WebCore::SessionID sessionID, WebsiteDataTypes dataTypes, std::chrono::system_clock::time_point modifiedSince, std::function<void ()> completionHandler) |
| 128 | { |
| 129 | auto callbackID = generateCallbackID(); |
| 130 | |
| 131 | m_pendingDeleteWebsiteDataCallbacks.add(callbackID, WTF::move(completionHandler)); |
| 132 | send(Messages::NetworkProcess::DeleteWebsiteData(sessionID, dataTypes, modifiedSince, callbackID), 0); |
| 133 | } |
| 134 | |
andersca@apple.com | ce92768 | 2015-02-27 20:14:22 +0000 | [diff] [blame] | 135 | void NetworkProcessProxy::deleteWebsiteDataForOrigins(SessionID sessionID, WebsiteDataTypes dataTypes, const Vector<RefPtr<WebCore::SecurityOrigin>>& origins, std::function<void ()> completionHandler) |
| 136 | { |
| 137 | ASSERT(canSendMessage()); |
| 138 | |
| 139 | uint64_t callbackID = generateCallbackID(); |
| 140 | m_pendingDeleteWebsiteDataForOriginsCallbacks.add(callbackID, WTF::move(completionHandler)); |
| 141 | |
| 142 | Vector<SecurityOriginData> originData; |
| 143 | for (auto& origin : origins) |
| 144 | originData.append(SecurityOriginData::fromSecurityOrigin(*origin)); |
| 145 | |
| 146 | send(Messages::WebProcess::DeleteWebsiteDataForOrigins(sessionID, dataTypes, originData, callbackID), 0); |
| 147 | } |
| 148 | |
beidson@apple.com | dfbdf94 | 2012-10-19 23:26:16 +0000 | [diff] [blame] | 149 | void NetworkProcessProxy::networkProcessCrashedOrFailedToLaunch() |
| 150 | { |
| 151 | // The network process must have crashed or exited, send any pending sync replies we might have. |
| 152 | while (!m_pendingConnectionReplies.isEmpty()) { |
| 153 | RefPtr<Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply> reply = m_pendingConnectionReplies.takeFirst(); |
| 154 | |
mitz@apple.com | 1b97088 | 2014-02-15 17:06:17 +0000 | [diff] [blame] | 155 | #if OS(DARWIN) |
andersca@apple.com | 69388f0 | 2013-12-30 20:20:02 +0000 | [diff] [blame] | 156 | reply->send(IPC::Attachment(0, MACH_MSG_TYPE_MOVE_SEND)); |
svillar@igalia.com | e78749f | 2013-12-09 12:28:44 +0000 | [diff] [blame] | 157 | #elif USE(UNIX_DOMAIN_SOCKETS) |
andersca@apple.com | 69388f0 | 2013-12-30 20:20:02 +0000 | [diff] [blame] | 158 | reply->send(IPC::Attachment()); |
beidson@apple.com | dfbdf94 | 2012-10-19 23:26:16 +0000 | [diff] [blame] | 159 | #else |
| 160 | notImplemented(); |
| 161 | #endif |
| 162 | } |
| 163 | |
andersca@apple.com | ce92768 | 2015-02-27 20:14:22 +0000 | [diff] [blame] | 164 | for (const auto& callback : m_pendingFetchWebsiteDataCallbacks.values()) |
| 165 | callback(WebsiteData()); |
| 166 | m_pendingFetchWebsiteDataCallbacks.clear(); |
| 167 | |
andersca@apple.com | 5ebf458 | 2014-12-09 20:29:59 +0000 | [diff] [blame] | 168 | for (const auto& callback : m_pendingDeleteWebsiteDataCallbacks.values()) |
| 169 | callback(); |
| 170 | m_pendingDeleteWebsiteDataCallbacks.clear(); |
| 171 | |
andersca@apple.com | ce92768 | 2015-02-27 20:14:22 +0000 | [diff] [blame] | 172 | for (const auto& callback : m_pendingDeleteWebsiteDataForOriginsCallbacks.values()) |
| 173 | callback(); |
| 174 | m_pendingDeleteWebsiteDataForOriginsCallbacks.clear(); |
| 175 | |
beidson@apple.com | dfbdf94 | 2012-10-19 23:26:16 +0000 | [diff] [blame] | 176 | // Tell the network process manager to forget about this network process proxy. This may cause us to be deleted. |
weinig@apple.com | 9c5a3ea | 2014-12-23 20:29:26 +0000 | [diff] [blame] | 177 | m_processPool.networkProcessCrashed(this); |
beidson@apple.com | dfbdf94 | 2012-10-19 23:26:16 +0000 | [diff] [blame] | 178 | } |
| 179 | |
andersca@apple.com | 6a18685 | 2015-01-05 18:38:15 +0000 | [diff] [blame] | 180 | void NetworkProcessProxy::didReceiveMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder) |
beidson@apple.com | dfbdf94 | 2012-10-19 23:26:16 +0000 | [diff] [blame] | 181 | { |
weinig@apple.com | aa38204 | 2013-02-07 04:40:29 +0000 | [diff] [blame] | 182 | if (dispatchMessage(connection, decoder)) |
andersca@apple.com | 93b4c36 | 2012-12-16 01:26:05 +0000 | [diff] [blame] | 183 | return; |
| 184 | |
weinig@apple.com | 9c5a3ea | 2014-12-23 20:29:26 +0000 | [diff] [blame] | 185 | if (m_processPool.dispatchMessage(connection, decoder)) |
ap@apple.com | a6354cb | 2012-12-24 01:29:47 +0000 | [diff] [blame] | 186 | return; |
| 187 | |
andersca@apple.com | 93914d8 | 2013-01-30 22:48:09 +0000 | [diff] [blame] | 188 | didReceiveNetworkProcessProxyMessage(connection, decoder); |
beidson@apple.com | 21dd3ed | 2012-10-12 17:13:13 +0000 | [diff] [blame] | 189 | } |
| 190 | |
andersca@apple.com | 6a18685 | 2015-01-05 18:38:15 +0000 | [diff] [blame] | 191 | void NetworkProcessProxy::didReceiveSyncMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder, std::unique_ptr<IPC::MessageEncoder>& replyEncoder) |
andersca@apple.com | 93b4c36 | 2012-12-16 01:26:05 +0000 | [diff] [blame] | 192 | { |
weinig@apple.com | aa38204 | 2013-02-07 04:40:29 +0000 | [diff] [blame] | 193 | if (dispatchSyncMessage(connection, decoder, replyEncoder)) |
andersca@apple.com | 93b4c36 | 2012-12-16 01:26:05 +0000 | [diff] [blame] | 194 | return; |
| 195 | |
| 196 | ASSERT_NOT_REACHED(); |
| 197 | } |
| 198 | |
andersca@apple.com | 30e768b | 2015-01-04 20:14:45 +0000 | [diff] [blame] | 199 | void NetworkProcessProxy::didClose(IPC::Connection&) |
beidson@apple.com | 21dd3ed | 2012-10-12 17:13:13 +0000 | [diff] [blame] | 200 | { |
andersca@apple.com | 12e7492 | 2012-12-15 23:11:52 +0000 | [diff] [blame] | 201 | if (m_downloadProxyMap) |
| 202 | m_downloadProxyMap->processDidClose(); |
| 203 | |
beidson@apple.com | dfbdf94 | 2012-10-19 23:26:16 +0000 | [diff] [blame] | 204 | // This may cause us to be deleted. |
| 205 | networkProcessCrashedOrFailedToLaunch(); |
beidson@apple.com | 21dd3ed | 2012-10-12 17:13:13 +0000 | [diff] [blame] | 206 | } |
| 207 | |
andersca@apple.com | 30e768b | 2015-01-04 20:14:45 +0000 | [diff] [blame] | 208 | void NetworkProcessProxy::didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference, IPC::StringReference) |
beidson@apple.com | 21dd3ed | 2012-10-12 17:13:13 +0000 | [diff] [blame] | 209 | { |
beidson@apple.com | 21dd3ed | 2012-10-12 17:13:13 +0000 | [diff] [blame] | 210 | } |
| 211 | |
andersca@apple.com | 69388f0 | 2013-12-30 20:20:02 +0000 | [diff] [blame] | 212 | void NetworkProcessProxy::didCreateNetworkConnectionToWebProcess(const IPC::Attachment& connectionIdentifier) |
beidson@apple.com | dfbdf94 | 2012-10-19 23:26:16 +0000 | [diff] [blame] | 213 | { |
| 214 | ASSERT(!m_pendingConnectionReplies.isEmpty()); |
| 215 | |
| 216 | // Grab the first pending connection reply. |
| 217 | RefPtr<Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply> reply = m_pendingConnectionReplies.takeFirst(); |
| 218 | |
mitz@apple.com | 1b97088 | 2014-02-15 17:06:17 +0000 | [diff] [blame] | 219 | #if OS(DARWIN) |
andersca@apple.com | 69388f0 | 2013-12-30 20:20:02 +0000 | [diff] [blame] | 220 | reply->send(IPC::Attachment(connectionIdentifier.port(), MACH_MSG_TYPE_MOVE_SEND)); |
svillar@igalia.com | e78749f | 2013-12-09 12:28:44 +0000 | [diff] [blame] | 221 | #elif USE(UNIX_DOMAIN_SOCKETS) |
| 222 | reply->send(connectionIdentifier); |
beidson@apple.com | dfbdf94 | 2012-10-19 23:26:16 +0000 | [diff] [blame] | 223 | #else |
| 224 | notImplemented(); |
| 225 | #endif |
| 226 | } |
| 227 | |
beidson@apple.com | daf9106 | 2013-01-26 00:03:48 +0000 | [diff] [blame] | 228 | void NetworkProcessProxy::didReceiveAuthenticationChallenge(uint64_t pageID, uint64_t frameID, const WebCore::AuthenticationChallenge& coreChallenge, uint64_t challengeID) |
| 229 | { |
| 230 | WebPageProxy* page = WebProcessProxy::webPage(pageID); |
| 231 | MESSAGE_CHECK(page); |
| 232 | |
| 233 | RefPtr<AuthenticationChallengeProxy> authenticationChallenge = AuthenticationChallengeProxy::create(coreChallenge, challengeID, connection()); |
| 234 | page->didReceiveAuthenticationChallengeProxy(frameID, authenticationChallenge.release()); |
| 235 | } |
| 236 | |
andersca@apple.com | ce92768 | 2015-02-27 20:14:22 +0000 | [diff] [blame] | 237 | void NetworkProcessProxy::didFetchWebsiteData(uint64_t callbackID, const WebsiteData& websiteData) |
| 238 | { |
| 239 | auto callback = m_pendingFetchWebsiteDataCallbacks.take(callbackID); |
| 240 | callback(websiteData); |
| 241 | } |
| 242 | |
andersca@apple.com | 5ebf458 | 2014-12-09 20:29:59 +0000 | [diff] [blame] | 243 | void NetworkProcessProxy::didDeleteWebsiteData(uint64_t callbackID) |
| 244 | { |
| 245 | auto callback = m_pendingDeleteWebsiteDataCallbacks.take(callbackID); |
| 246 | callback(); |
| 247 | } |
| 248 | |
andersca@apple.com | ce92768 | 2015-02-27 20:14:22 +0000 | [diff] [blame] | 249 | void NetworkProcessProxy::didDeleteWebsiteDataForOrigins(uint64_t callbackID) |
| 250 | { |
| 251 | auto callback = m_pendingDeleteWebsiteDataForOriginsCallbacks.take(callbackID); |
| 252 | callback(); |
| 253 | } |
| 254 | |
andersca@apple.com | 69388f0 | 2013-12-30 20:20:02 +0000 | [diff] [blame] | 255 | void NetworkProcessProxy::didFinishLaunching(ProcessLauncher* launcher, IPC::Connection::Identifier connectionIdentifier) |
beidson@apple.com | 21dd3ed | 2012-10-12 17:13:13 +0000 | [diff] [blame] | 256 | { |
ap@apple.com | 10a670e | 2012-12-05 23:28:31 +0000 | [diff] [blame] | 257 | ChildProcessProxy::didFinishLaunching(launcher, connectionIdentifier); |
beidson@apple.com | 21dd3ed | 2012-10-12 17:13:13 +0000 | [diff] [blame] | 258 | |
andersca@apple.com | 69388f0 | 2013-12-30 20:20:02 +0000 | [diff] [blame] | 259 | if (IPC::Connection::identifierIsNull(connectionIdentifier)) { |
beidson@apple.com | 21dd3ed | 2012-10-12 17:13:13 +0000 | [diff] [blame] | 260 | // FIXME: Do better cleanup here. |
| 261 | return; |
| 262 | } |
| 263 | |
beidson@apple.com | dfbdf94 | 2012-10-19 23:26:16 +0000 | [diff] [blame] | 264 | for (unsigned i = 0; i < m_numPendingConnectionRequests; ++i) |
ap@apple.com | 10a670e | 2012-12-05 23:28:31 +0000 | [diff] [blame] | 265 | connection()->send(Messages::NetworkProcess::CreateNetworkConnectionToWebProcess(), 0); |
beidson@apple.com | dfbdf94 | 2012-10-19 23:26:16 +0000 | [diff] [blame] | 266 | |
| 267 | m_numPendingConnectionRequests = 0; |
commit-queue@webkit.org | 948d584 | 2012-11-07 01:17:53 +0000 | [diff] [blame] | 268 | |
mitz@apple.com | 1b97088 | 2014-02-15 17:06:17 +0000 | [diff] [blame] | 269 | #if PLATFORM(COCOA) |
weinig@apple.com | 9c5a3ea | 2014-12-23 20:29:26 +0000 | [diff] [blame] | 270 | if (m_processPool.processSuppressionEnabled()) |
commit-queue@webkit.org | b1ebaef | 2013-01-29 22:52:19 +0000 | [diff] [blame] | 271 | setProcessSuppressionEnabled(true); |
commit-queue@webkit.org | 948d584 | 2012-11-07 01:17:53 +0000 | [diff] [blame] | 272 | #endif |
barraclough@apple.com | d915134 | 2014-04-17 01:40:04 +0000 | [diff] [blame] | 273 | |
bdakin@apple.com | 1539c6c | 2015-01-28 22:22:16 +0000 | [diff] [blame] | 274 | #if PLATFORM(IOS) |
simon.fraser@apple.com | dd0dee1 | 2014-04-22 00:23:04 +0000 | [diff] [blame] | 275 | if (xpc_connection_t connection = this->connection()->xpcConnection()) |
| 276 | m_assertion = std::make_unique<ProcessAssertion>(xpc_connection_get_pid(connection), AssertionState::Foreground); |
barraclough@apple.com | d915134 | 2014-04-17 01:40:04 +0000 | [diff] [blame] | 277 | #endif |
beidson@apple.com | 21dd3ed | 2012-10-12 17:13:13 +0000 | [diff] [blame] | 278 | } |
| 279 | |
cdumez@apple.com | 216d257 | 2015-02-23 22:08:45 +0000 | [diff] [blame] | 280 | void NetworkProcessProxy::logDiagnosticMessage(uint64_t pageID, const String& message, const String& description, bool shouldSample) |
cdumez@apple.com | 35cab1d | 2015-02-11 23:57:31 +0000 | [diff] [blame] | 281 | { |
| 282 | WebPageProxy* page = WebProcessProxy::webPage(pageID); |
| 283 | // FIXME: We do this null-check because by the time the decision to log is made, the page may be gone. We should refactor to avoid this, |
| 284 | // but for now we simply drop the message in the rare case this happens. |
| 285 | if (!page) |
| 286 | return; |
| 287 | |
cdumez@apple.com | 216d257 | 2015-02-23 22:08:45 +0000 | [diff] [blame] | 288 | page->logDiagnosticMessage(message, description, shouldSample); |
cdumez@apple.com | 35cab1d | 2015-02-11 23:57:31 +0000 | [diff] [blame] | 289 | } |
| 290 | |
cdumez@apple.com | 216d257 | 2015-02-23 22:08:45 +0000 | [diff] [blame] | 291 | void NetworkProcessProxy::logDiagnosticMessageWithResult(uint64_t pageID, const String& message, const String& description, uint32_t result, bool shouldSample) |
cdumez@apple.com | 35cab1d | 2015-02-11 23:57:31 +0000 | [diff] [blame] | 292 | { |
| 293 | WebPageProxy* page = WebProcessProxy::webPage(pageID); |
| 294 | // FIXME: We do this null-check because by the time the decision to log is made, the page may be gone. We should refactor to avoid this, |
| 295 | // but for now we simply drop the message in the rare case this happens. |
| 296 | if (!page) |
| 297 | return; |
| 298 | |
cdumez@apple.com | 216d257 | 2015-02-23 22:08:45 +0000 | [diff] [blame] | 299 | page->logDiagnosticMessageWithResult(message, description, result, shouldSample); |
cdumez@apple.com | 35cab1d | 2015-02-11 23:57:31 +0000 | [diff] [blame] | 300 | } |
| 301 | |
cdumez@apple.com | 216d257 | 2015-02-23 22:08:45 +0000 | [diff] [blame] | 302 | void NetworkProcessProxy::logDiagnosticMessageWithValue(uint64_t pageID, const String& message, const String& description, const String& value, bool shouldSample) |
cdumez@apple.com | 35cab1d | 2015-02-11 23:57:31 +0000 | [diff] [blame] | 303 | { |
| 304 | WebPageProxy* page = WebProcessProxy::webPage(pageID); |
| 305 | // FIXME: We do this null-check because by the time the decision to log is made, the page may be gone. We should refactor to avoid this, |
| 306 | // but for now we simply drop the message in the rare case this happens. |
| 307 | if (!page) |
| 308 | return; |
| 309 | |
cdumez@apple.com | 216d257 | 2015-02-23 22:08:45 +0000 | [diff] [blame] | 310 | page->logDiagnosticMessageWithValue(message, description, value, shouldSample); |
cdumez@apple.com | 35cab1d | 2015-02-11 23:57:31 +0000 | [diff] [blame] | 311 | } |
| 312 | |
beidson@apple.com | 21dd3ed | 2012-10-12 17:13:13 +0000 | [diff] [blame] | 313 | } // namespace WebKit |
| 314 | |
| 315 | #endif // ENABLE(NETWORK_PROCESS) |