Changeset 237294 in webkit
- Timestamp:
- Oct 19, 2018, 10:40:20 AM (7 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r237283 r237294 1 2018-10-19 Alex Christensen <achristensen@webkit.org> 2 3 Introduce CompletionHandler-based Async IPC messages with replies 4 https://bugs.webkit.org/show_bug.cgi?id=190746 5 6 Reviewed by Tim Horton. 7 8 Before this patch, to make an asynchronous IPC message with a reply you had to find two objects that 9 can talk to each other, make two new message types, send a generated identifier, keep track of that 10 identifier, make a HashMap somewhere to store the object waiting for the response, and hook it all up. 11 What a mess. No wonder people take shortcuts and make strange design decisions. 12 13 Now, you can just use a CompletionHandler and mark the reply as Async in *.messages.in. 14 I've adopted this with a message whose behavior is covered by the storage/indexeddb/modern/blob-cursor.html 15 layout test and many others. I intent to refine and further adopt this incrementally. 16 17 * NetworkProcess/NetworkProcess.cpp: 18 (WebKit::NetworkProcess::getSandboxExtensionsForBlobFiles): 19 (WebKit::NetworkProcess::didGetSandboxExtensionsForBlobFiles): Deleted. 20 * NetworkProcess/NetworkProcess.h: 21 * NetworkProcess/NetworkProcess.messages.in: 22 This is representative of how code will be simplified with greater adoption. 23 * NetworkProcess/NetworkResourceLoadParameters.cpp: 24 (WebKit::NetworkResourceLoadParameters::decode): 25 Modernize HandleArray decoding. 26 * Platform/IPC/Connection.cpp: 27 (IPC::Connection::dispatchMessage): 28 (IPC::nextAsyncReplyHandlerID): 29 (IPC::asyncReplyHandlerMap): 30 Handle async replies when looking at incoming messages from the sending process. 31 * Platform/IPC/Connection.h: 32 (IPC::Connection::sendWithAsyncReply): 33 Send a message with an async reply and prepare the reply receiver. 34 * Platform/IPC/Encoder.h: 35 Make the uint64_t encoder public so we can use it when encoding the listenerID. 36 * Platform/IPC/HandleMessage.h: 37 (IPC::handleMessageAsync): 38 Handle an asynchronous message with a reply from the receiving process. 39 This is similar to how DelayedReply messages are handled, but the listenerID is automatically captured and sent back. 40 * Scripts/webkit/messages.py: 41 Generate code for async message replies. 42 * Shared/Databases/IndexedDB/WebIDBResult.cpp: 43 (WebKit::WebIDBResult::decode): 44 * Shared/SandboxExtension.h: 45 (WebKit::SandboxExtension::HandleArray::at): 46 (WebKit::SandboxExtension::HandleArray::decode): 47 * Shared/WebProcessCreationParameters.cpp: 48 (WebKit::WebProcessCreationParameters::decode): 49 * Shared/mac/SandboxExtensionMac.mm: 50 (WebKit::SandboxExtension::HandleArray::decode): 51 Modernize the decoding of HandleArray to work with generated decoding. 52 * UIProcess/Network/NetworkProcessProxy.cpp: 53 (WebKit::NetworkProcessProxy::getSandboxExtensionsForBlobFiles): 54 * UIProcess/Network/NetworkProcessProxy.h: 55 * UIProcess/Network/NetworkProcessProxy.messages.in: 56 This is also representative of how code will be simplified with greater adoption. 57 * WebProcess/MediaStream/MediaDeviceSandboxExtensions.cpp: 58 (WebKit::MediaDeviceSandboxExtensions::decode): 59 Modernize HandleArray decoding. 60 1 61 2018-10-19 Chris Dumez <cdumez@apple.com> 2 62 -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp
r236988 r237294 1191 1191 1192 1192 #if ENABLE(SANDBOX_EXTENSIONS) 1193 void NetworkProcess::getSandboxExtensionsForBlobFiles(const Vector<String>& filenames, Function<void(SandboxExtension::HandleArray&&)>&& completionHandler) 1194 { 1195 static uint64_t lastRequestID; 1196 1197 uint64_t requestID = ++lastRequestID; 1198 m_sandboxExtensionForBlobsCompletionHandlersStorageForNetworkProcess.set(requestID, WTFMove(completionHandler)); 1199 parentProcessConnection()->send(Messages::NetworkProcessProxy::GetSandboxExtensionsForBlobFiles(requestID, filenames), 0); 1200 } 1201 1202 void NetworkProcess::didGetSandboxExtensionsForBlobFiles(uint64_t requestID, SandboxExtension::HandleArray&& handles) 1203 { 1204 if (auto handler = m_sandboxExtensionForBlobsCompletionHandlersStorageForNetworkProcess.take(requestID)) 1205 handler(WTFMove(handles)); 1206 } 1207 1193 void NetworkProcess::getSandboxExtensionsForBlobFiles(const Vector<String>& filenames, CompletionHandler<void(SandboxExtension::HandleArray&&)>&& completionHandler) 1194 { 1195 parentProcessConnection()->sendWithAsyncReply(Messages::NetworkProcessProxy::GetSandboxExtensionsForBlobFiles(filenames), WTFMove(completionHandler)); 1196 } 1197 1208 1198 void NetworkProcess::updateTemporaryFileSandboxExtensions(const Vector<String>& paths, SandboxExtension::HandleArray& handles) 1209 1199 { -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.h
r237266 r237294 194 194 195 195 #if ENABLE(SANDBOX_EXTENSIONS) 196 void getSandboxExtensionsForBlobFiles(const Vector<String>& filenames, WTF::Function<void(SandboxExtension::HandleArray&&)>&& completionHandler);196 void getSandboxExtensionsForBlobFiles(const Vector<String>& filenames, CompletionHandler<void(SandboxExtension::HandleArray&&)>&&); 197 197 void updateTemporaryFileSandboxExtensions(const Vector<String>& paths, SandboxExtension::HandleArray&); 198 198 #endif … … 314 314 void registerURLSchemeAsCORSEnabled(const String&) const; 315 315 void registerURLSchemeAsCanDisplayOnlyIfCanRequest(const String&) const; 316 317 #if ENABLE(SANDBOX_EXTENSIONS)318 void didGetSandboxExtensionsForBlobFiles(uint64_t requestID, SandboxExtension::HandleArray&&);319 #endif320 316 321 317 #if ENABLE(INDEXED_DATABASE) … … 399 395 400 396 HashMap<String, RefPtr<SandboxExtension>> m_blobTemporaryFileSandboxExtensions; 401 HashMap<uint64_t, WTF::Function<void(SandboxExtension::HandleArray&&)>> m_sandboxExtensionForBlobsCompletionHandlersStorageForNetworkProcess;402 397 403 398 Deque<CrossThreadTask> m_storageTasks; -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in
r237264 r237294 74 74 ProcessDidResume() 75 75 76 #if ENABLE(SANDBOX_EXTENSIONS)77 DidGetSandboxExtensionsForBlobFiles(uint64_t requestID, WebKit::SandboxExtension::HandleArray extensions)78 #endif79 80 76 WriteBlobToFilePath(WebCore::URL blobURL, String path, WebKit::SandboxExtension::Handle handle, uint64_t callbackID) 81 77 -
trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp
r236365 r237294 134 134 result.request.setHTTPBody(WTFMove(formData)); 135 135 136 SandboxExtension::HandleArray requestBodySandboxExtensionHandles; 137 if (!decoder.decode(requestBodySandboxExtensionHandles)) 138 return false; 139 for (size_t i = 0; i < requestBodySandboxExtensionHandles.size(); ++i) { 140 if (auto extension = SandboxExtension::create(WTFMove(requestBodySandboxExtensionHandles[i]))) 136 std::optional<SandboxExtension::HandleArray> requestBodySandboxExtensionHandles; 137 decoder >> requestBodySandboxExtensionHandles; 138 if (!requestBodySandboxExtensionHandles) 139 return false; 140 for (size_t i = 0; i < requestBodySandboxExtensionHandles->size(); ++i) { 141 if (auto extension = SandboxExtension::create(WTFMove(requestBodySandboxExtensionHandles->at(i)))) 141 142 result.requestBodySandboxExtensions.append(WTFMove(extension)); 142 143 } -
trunk/Source/WebKit/Platform/IPC/Connection.cpp
r236680 r237294 238 238 } 239 239 240 static HashMap<uintptr_t, HashMap<uint64_t, CompletionHandler<void(Decoder*)>>>& asyncReplyHandlerMap() 241 { 242 static NeverDestroyed<HashMap<uintptr_t, HashMap<uint64_t, CompletionHandler<void(Decoder*)>>>> map; 243 return map.get(); 244 } 245 240 246 Connection::Connection(Identifier identifier, bool isServer, Client& client) 241 247 : m_client(client) … … 272 278 273 279 allConnections().remove(m_uniqueID); 280 281 auto map = asyncReplyHandlerMap().take(reinterpret_cast<uintptr_t>(this)); 282 for (auto& handler : map.values()) { 283 if (handler) 284 handler(nullptr); 285 } 274 286 } 275 287 … … 949 961 { 950 962 RELEASE_ASSERT(isValid()); 963 if (decoder.messageReceiverName() == "AsyncReply") { 964 std::optional<uint64_t> listenerID; 965 decoder >> listenerID; 966 if (!listenerID) { 967 ASSERT_NOT_REACHED(); 968 return; 969 } 970 auto handler = takeAsyncReplyHandler(*this, *listenerID); 971 if (!handler) { 972 ASSERT_NOT_REACHED(); 973 return; 974 } 975 handler(&decoder); 976 return; 977 } 951 978 m_client.didReceiveMessage(*this, decoder); 952 979 } … … 1094 1121 } 1095 1122 1123 uint64_t nextAsyncReplyHandlerID() 1124 { 1125 static uint64_t identifier { 0 }; 1126 return ++identifier; 1127 } 1128 1129 void addAsyncReplyHandler(Connection& connection, uint64_t identifier, CompletionHandler<void(Decoder*)>&& completionHandler) 1130 { 1131 auto result = asyncReplyHandlerMap().ensure(reinterpret_cast<uintptr_t>(&connection), [] { 1132 return HashMap<uint64_t, CompletionHandler<void(Decoder*)>>(); 1133 }).iterator->value.add(identifier, WTFMove(completionHandler)); 1134 ASSERT_UNUSED(result, result.isNewEntry); 1135 } 1136 1137 CompletionHandler<void(Decoder*)> takeAsyncReplyHandler(Connection& connection, uint64_t identifier) 1138 { 1139 auto iterator = asyncReplyHandlerMap().find(reinterpret_cast<uintptr_t>(&connection)); 1140 if (iterator != asyncReplyHandlerMap().end()) { 1141 if (!iterator->value.isValidKey(identifier)) { 1142 ASSERT_NOT_REACHED(); 1143 connection.markCurrentlyDispatchedMessageAsInvalid(); 1144 return nullptr; 1145 } 1146 ASSERT(iterator->value.contains(identifier)); 1147 return iterator->value.take(identifier); 1148 } 1149 ASSERT_NOT_REACHED(); 1150 return nullptr; 1151 } 1152 1096 1153 void Connection::wakeUpRunLoop() 1097 1154 { -
trunk/Source/WebKit/Platform/IPC/Connection.h
r236680 r237294 178 178 void postConnectionDidCloseOnConnectionWorkQueue(); 179 179 180 template<typename T, typename... Args> void sendWithAsyncReply(T&& message, CompletionHandler<void(Args...)>&& args, uint64_t destinationID = 0); 180 181 template<typename T> bool send(T&& message, uint64_t destinationID, OptionSet<SendOption> sendOptions = { }); 181 182 template<typename T> void sendWithReply(T&& message, uint64_t destinationID, FunctionDispatcher& replyDispatcher, Function<void(std::optional<typename CodingType<typename T::Reply>::Type>)>&& replyHandler); … … 411 412 } 412 413 414 uint64_t nextAsyncReplyHandlerID(); 415 void addAsyncReplyHandler(Connection&, uint64_t, CompletionHandler<void(Decoder*)>&&); 416 CompletionHandler<void(Decoder*)> takeAsyncReplyHandler(Connection&, uint64_t); 417 418 template<typename T, typename... Args> 419 void Connection::sendWithAsyncReply(T&& message, CompletionHandler<void(Args...)>&& completionHandler, uint64_t destinationID) 420 { 421 COMPILE_ASSERT(!T::isSync, AsyncMessageExpected); 422 423 auto encoder = std::make_unique<Encoder>(T::receiverName(), T::name(), destinationID); 424 uint64_t listenerID = nextAsyncReplyHandlerID(); 425 encoder->encode(listenerID); 426 encoder->encode(message.arguments()); 427 sendMessage(WTFMove(encoder), { }); 428 addAsyncReplyHandler(*this, listenerID, [completionHandler = WTFMove(completionHandler)] (Decoder* decoder) mutable { 429 if (decoder && !decoder->isInvalid()) 430 T::callReply(*decoder, WTFMove(completionHandler)); 431 else 432 T::cancelReply(WTFMove(completionHandler)); 433 }); 434 } 435 413 436 template<typename T> 414 437 void Connection::sendWithReply(T&& message, uint64_t destinationID, FunctionDispatcher& replyDispatcher, Function<void(std::optional<typename CodingType<typename T::Reply>::Type>)>&& replyHandler) -
trunk/Source/WebKit/Platform/IPC/Encoder.h
r222894 r237294 95 95 static const bool isIPCEncoder = true; 96 96 97 void encode(uint64_t); 98 97 99 private: 98 100 uint8_t* grow(unsigned alignment, size_t); … … 102 104 void encode(uint16_t); 103 105 void encode(uint32_t); 104 void encode(uint64_t);105 106 void encode(int16_t); 106 107 void encode(int32_t); -
trunk/Source/WebKit/Platform/IPC/HandleMessage.h
r235951 r237294 188 188 } 189 189 190 template<typename T, typename C, typename MF> 191 void handleMessageAsync(Connection& connection, Decoder& decoder, C* object, MF function) 192 { 193 std::optional<uint64_t> listenerID; 194 decoder >> listenerID; 195 if (!listenerID) { 196 ASSERT(decoder.isInvalid()); 197 return; 198 } 199 200 typename CodingType<typename T::Arguments>::Type arguments; 201 if (!decoder.decode(arguments)) { 202 ASSERT(decoder.isInvalid()); 203 return; 204 } 205 206 typename T::AsyncReply completionHandler = [listenerID = *listenerID, connection = makeRef(connection)] (auto&&... args) mutable { 207 auto encoder = std::make_unique<Encoder>("AsyncReply", T::asyncMessageReplyName(), 0); 208 *encoder << listenerID; 209 T::send(WTFMove(encoder), WTFMove(connection), args...); 210 }; 211 callMemberFunction(WTFMove(arguments), WTFMove(completionHandler), object, function); 212 } 213 190 214 } // namespace IPC -
trunk/Source/WebKit/Scripts/webkit/messages.py
r237264 r237294 30 30 LEGACY_RECEIVER_ATTRIBUTE = 'LegacyReceiver' 31 31 DELAYED_ATTRIBUTE = 'Delayed' 32 ASYNC_ATTRIBUTE = 'Async' 32 33 33 34 _license_header = """/* … … 97 98 98 99 100 def move_type(type): 101 return '%s&&' % type 102 103 99 104 def arguments_type(message): 100 105 return 'std::tuple<%s>' % ', '.join(function_parameter_type(parameter.type, parameter.kind) for parameter in message.parameters) … … 114 119 result.append(' static IPC::StringReference receiverName() { return messageReceiverName(); }\n') 115 120 result.append(' static IPC::StringReference name() { return IPC::StringReference("%s"); }\n' % message.name) 116 result.append(' static const bool isSync = %s;\n' % ('false', 'true')[message.reply_parameters != None ])121 result.append(' static const bool isSync = %s;\n' % ('false', 'true')[message.reply_parameters != None and not message.has_attribute(ASYNC_ATTRIBUTE)]) 117 122 result.append('\n') 118 123 if message.reply_parameters != None: 119 if message.has_attribute(DELAYED_ATTRIBUTE): 120 send_parameters = [(function_parameter_type(x.type, x.kind), x.name) for x in message.reply_parameters] 121 result.append(' using DelayedReply = CompletionHandler<void(') 122 if len(send_parameters): 123 result.append('%s' % ', '.join([' '.join(x) for x in send_parameters])) 124 result.append(')>;\n') 124 send_parameters = [(function_parameter_type(x.type, x.kind), x.name) for x in message.reply_parameters] 125 if message.has_attribute(DELAYED_ATTRIBUTE) or message.has_attribute(ASYNC_ATTRIBUTE): 126 completion_handler_parameters = '%s' % ', '.join([' '.join(x) for x in send_parameters]) 127 if message.has_attribute(ASYNC_ATTRIBUTE): 128 move_parameters = ', '.join([move_type(x.type) for x in message.reply_parameters]) 129 result.append(' static void callReply(IPC::Decoder&, CompletionHandler<void(%s)>&&);\n' % move_parameters) 130 result.append(' static void cancelReply(CompletionHandler<void(%s)>&&);\n' % move_parameters) 131 result.append(' static IPC::StringReference asyncMessageReplyName() { return { "%sReply" }; }\n' % message.name) 132 result.append(' using AsyncReply') 133 else: 134 result.append(' using DelayedReply') 135 result.append(' = CompletionHandler<void(%s)>;\n' % completion_handler_parameters) 125 136 result.append(' static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&') 126 137 if len(send_parameters): 127 result.append(', %s' % ', '.join([' '.join(x) for x in send_parameters]))138 result.append(', %s' % completion_handler_parameters) 128 139 result.append(');\n') 129 130 140 result.append(' typedef %s Reply;\n' % reply_type(message)) 131 141 … … 277 287 278 288 dispatch_function = 'handleMessage' 289 if message.has_attribute(ASYNC_ATTRIBUTE): 290 dispatch_function += 'Async' 291 dispatch_function_args.insert(0, 'connection') 279 292 280 293 if message.has_attribute(WANTS_CONNECTION_ATTRIBUTE): … … 293 306 if message.has_attribute(DELAYED_ATTRIBUTE): 294 307 dispatch_function += 'Delayed' 308 if message.has_attribute(ASYNC_ATTRIBUTE): 309 dispatch_function += 'Async' 295 310 296 311 wants_connection = message.has_attribute(DELAYED_ATTRIBUTE) or message.has_attribute(WANTS_CONNECTION_ATTRIBUTE) … … 298 313 result = [] 299 314 result.append(' if (decoder.messageName() == Messages::%s::%s::name()) {\n' % (receiver.name, message.name)) 300 result.append(' IPC::%s<Messages::%s::%s>(%sdecoder, %sreplyEncoder, this, &%s);\n' % (dispatch_function, receiver.name, message.name, 'connection, ' if wants_connection else '', '' if message.has_attribute(DELAYED_ATTRIBUTE) else '*', handler_function(receiver, message)))315 result.append(' IPC::%s<Messages::%s::%s>(%sdecoder, %sreplyEncoder, this, &%s);\n' % (dispatch_function, receiver.name, message.name, 'connection, ' if wants_connection else '', '' if message.has_attribute(DELAYED_ATTRIBUTE) or message.has_attribute(ASYNC_ATTRIBUTE) else '*', handler_function(receiver, message))) 301 316 result.append(' return;\n') 302 317 result.append(' }\n') … … 526 541 result.append('\n') 527 542 528 sync_delayed_messages = []543 delayed_or_async_messages = [] 529 544 for message in receiver.messages: 530 if message.reply_parameters != None and message.has_attribute(DELAYED_ATTRIBUTE):531 sync_delayed_messages.append(message)532 533 if sync_delayed_messages:545 if message.reply_parameters != None and (message.has_attribute(DELAYED_ATTRIBUTE) or message.has_attribute(ASYNC_ATTRIBUTE)): 546 delayed_or_async_messages.append(message) 547 548 if delayed_or_async_messages: 534 549 result.append('namespace Messages {\n\nnamespace %s {\n\n' % receiver.name) 535 550 536 for message in sync_delayed_messages:551 for message in delayed_or_async_messages: 537 552 send_parameters = [(function_parameter_type(x.type, x.kind), x.name) for x in message.reply_parameters] 538 553 539 554 if message.condition: 540 555 result.append('#if %s\n\n' % message.condition) 556 557 if message.has_attribute(ASYNC_ATTRIBUTE): 558 move_parameters = message.name, ', '.join([move_type(x.type) for x in message.reply_parameters]) 559 result.append('void %s::callReply(IPC::Decoder& decoder, CompletionHandler<void(%s)>&& completionHandler)\n{\n' % move_parameters) 560 for x in message.reply_parameters: 561 result.append(' std::optional<%s> %s;\n' % (x.type, x.name)) 562 result.append(' decoder >> %s;\n' % x.name) 563 result.append(' if (!%s) {\n ASSERT_NOT_REACHED();\n return;\n }\n' % x.name) 564 result.append(' completionHandler(WTFMove(*%s));\n}\n\n' % (', *'.join(x.name for x in message.reply_parameters))) 565 result.append('void %s::cancelReply(CompletionHandler<void(%s)>&& completionHandler)\n{\n completionHandler(' % move_parameters) 566 result.append(', '.join(['{ }' for x in message.reply_parameters])) 567 result.append(');\n}\n\n') 541 568 542 569 result.append('void %s::send(std::unique_ptr<IPC::Encoder>&& encoder, IPC::Connection& connection' % (message.name)) … … 559 586 sync_messages = [] 560 587 for message in receiver.messages: 561 if message.reply_parameters is not None :588 if message.reply_parameters is not None and not message.has_attribute(ASYNC_ATTRIBUTE): 562 589 sync_messages.append(message) 563 590 else: … … 587 614 result.append('}\n') 588 615 589 result.append('\n} // namespace WebKit\n ')616 result.append('\n} // namespace WebKit\n\n') 590 617 591 618 if receiver.condition: -
trunk/Source/WebKit/Shared/Databases/IndexedDB/WebIDBResult.cpp
r222233 r237294 47 47 result.m_resultData = WTFMove(*resultData); 48 48 49 if (!SandboxExtension::HandleArray::decode(decoder, result.m_handles)) 49 std::optional<SandboxExtension::HandleArray> handles; 50 decoder >> handles; 51 if (!handles) 50 52 return false; 53 result.m_handles = WTFMove(*handles); 51 54 52 55 return true; -
trunk/Source/WebKit/Shared/SandboxExtension.h
r231342 r237294 78 78 HandleArray(); 79 79 HandleArray(HandleArray&&) = default; 80 HandleArray& operator=(HandleArray&&) = default; 80 81 ~HandleArray(); 81 82 void allocate(size_t); 82 83 Handle& operator[](size_t i); 84 Handle& at(size_t i) { return operator[](i); } 83 85 const Handle& operator[](size_t i) const; 84 86 size_t size() const; 85 87 void encode(IPC::Encoder&) const; 86 static bool decode(IPC::Decoder&, HandleArray&);87 88 static std::optional<HandleArray> decode(IPC::Decoder&); 89 88 90 private: 89 91 #if ENABLE(SANDBOX_EXTENSIONS) … … 129 131 inline SandboxExtension::Handle& SandboxExtension::HandleArray::operator[](size_t) { return m_emptyHandle; } 130 132 inline void SandboxExtension::HandleArray::encode(IPC::Encoder&) const { } 131 inline bool SandboxExtension::HandleArray::decode(IPC::Decoder&, HandleArray&) { return true; }133 inline auto SandboxExtension::HandleArray::decode(IPC::Decoder&) -> std::optional<HandleArray> { return {{ }}; } 132 134 inline RefPtr<SandboxExtension> SandboxExtension::create(Handle&&) { return nullptr; } 133 135 inline bool SandboxExtension::createHandle(const String&, Type, Handle&) { return true; } -
trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp
r237281 r237294 176 176 parameters.injectedBundlePathExtensionHandle = WTFMove(*injectedBundlePathExtensionHandle); 177 177 178 if (!decoder.decode(parameters.additionalSandboxExtensionHandles)) 179 return false; 178 std::optional<SandboxExtension::HandleArray> additionalSandboxExtensionHandles; 179 decoder >> additionalSandboxExtensionHandles; 180 if (!additionalSandboxExtensionHandles) 181 return false; 182 parameters.additionalSandboxExtensionHandles = WTFMove(*additionalSandboxExtensionHandles); 180 183 if (!decoder.decode(parameters.initializationUserData)) 181 184 return false; -
trunk/Source/WebKit/Shared/mac/SandboxExtensionMac.mm
r237266 r237294 191 191 } 192 192 193 bool SandboxExtension::HandleArray::decode(IPC::Decoder& decoder, SandboxExtension::HandleArray& handles) 194 { 195 uint64_t size; 196 if (!decoder.decode(size)) 197 return false; 198 handles.allocate(size); 199 for (size_t i = 0; i < size; i++) { 193 std::optional<SandboxExtension::HandleArray> SandboxExtension::HandleArray::decode(IPC::Decoder& decoder) 194 { 195 std::optional<uint64_t> size; 196 decoder >> size; 197 if (!size) 198 return std::nullopt; 199 SandboxExtension::HandleArray handles; 200 handles.allocate(*size); 201 for (size_t i = 0; i < *size; ++i) { 200 202 std::optional<SandboxExtension::Handle> handle; 201 203 decoder >> handle; 202 204 if (!handle) 203 return false;205 return std::nullopt; 204 206 handles[i] = WTFMove(*handle); 205 207 } 206 return true;208 return WTFMove(handles); 207 209 } 208 210 -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
r237266 r237294 693 693 694 694 #if ENABLE(SANDBOX_EXTENSIONS) 695 void NetworkProcessProxy::getSandboxExtensionsForBlobFiles( uint64_t requestID, const Vector<String>& paths)695 void NetworkProcessProxy::getSandboxExtensionsForBlobFiles(const Vector<String>& paths, Messages::NetworkProcessProxy::GetSandboxExtensionsForBlobFiles::AsyncReply&& reply) 696 696 { 697 697 SandboxExtension::HandleArray extensions; … … 701 701 SandboxExtension::createHandle(paths[i], SandboxExtension::Type::ReadWrite, extensions[i]); 702 702 } 703 704 send(Messages::NetworkProcess::DidGetSandboxExtensionsForBlobFiles(requestID, extensions), 0); 703 reply(WTFMove(extensions)); 705 704 } 706 705 #endif -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h
r237110 r237294 31 31 #include "LegacyCustomProtocolManagerProxy.h" 32 32 #endif 33 #include "NetworkProcessProxyMessages.h" 33 34 #include "ProcessLauncher.h" 34 35 #include "ProcessThrottler.h" … … 157 158 158 159 #if ENABLE(SANDBOX_EXTENSIONS) 159 void getSandboxExtensionsForBlobFiles( uint64_t requestID, const Vector<String>& paths);160 void getSandboxExtensionsForBlobFiles(const Vector<String>& paths, Messages::NetworkProcessProxy::GetSandboxExtensionsForBlobFiles::AsyncReply&&); 160 161 #endif 161 162 -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in
r237110 r237294 57 57 58 58 #if ENABLE(SANDBOX_EXTENSIONS) 59 GetSandboxExtensionsForBlobFiles( uint64_t requestID, Vector<String> paths)59 GetSandboxExtensionsForBlobFiles(Vector<String> paths) -> (WebKit::SandboxExtension::HandleArray extensions) Async 60 60 #endif 61 61 -
trunk/Source/WebKit/WebProcess/MediaStream/MediaDeviceSandboxExtensions.cpp
r225926 r237294 51 51 return false; 52 52 53 if (!SandboxExtension::HandleArray::decode(decoder, result.m_handles)) 53 std::optional<SandboxExtension::HandleArray> handles; 54 decoder >> handles; 55 if (!handles) 54 56 return false; 57 result.m_handles = WTFMove(*handles); 55 58 56 59 return true;
Note:
See TracChangeset
for help on using the changeset viewer.