void ClientImpl::initiateAuthentication(PendingConnection* pc, struct bufferevent *bev)throw (voltdb::LibEventException) { logMessage(ClientLogger::DEBUG, "ClientImpl::initiateAuthentication"); FreeBEVOnFailure protector(bev); bufferevent_setwatermark( bev, EV_READ, 4, HIGH_WATERMARK); bufferevent_setwatermark( bev, EV_WRITE, 8192, 262144); if (bufferevent_enable(bev, EV_READ)) { throw voltdb::LibEventException(); } AuthenticationRequest authRequest( m_username, "database", m_passwordHash, m_hashScheme ); ScopedByteBuffer bb(authRequest.getSerializedSize()); authRequest.serializeTo(&bb); struct evbuffer *evbuf = bufferevent_get_output(bev); if (evbuffer_add( evbuf, bb.bytes(), static_cast<size_t>(bb.remaining()))) { throw voltdb::LibEventException(); } protector.success(); }
void DOMWindowEventQueue::pendingEventTimerFired() { ASSERT(!m_pendingEventTimer->isActive()); ASSERT(!m_queuedEvents.isEmpty()); // Insert a marker for where we should stop. ASSERT(!m_queuedEvents.contains(nullptr)); bool wasAdded = m_queuedEvents.add(nullptr).isNewEntry; ASSERT_UNUSED(wasAdded, wasAdded); // It should not have already been in the list. RefPtr<DOMWindowEventQueue> protector(this); while (!m_queuedEvents.isEmpty()) { ListHashSet<RefPtr<Event>, 16>::iterator iter = m_queuedEvents.begin(); RefPtr<Event> event = *iter; m_queuedEvents.remove(iter); if (!event) break; dispatchEvent(event.get()); } }
void WebProcessConnection::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageDecoder& decoder) { ConnectionStack::CurrentConnectionPusher currentConnection(ConnectionStack::shared(), connection); if (decoder.messageReceiverName() == Messages::WebProcessConnection::messageReceiverName()) { didReceiveWebProcessConnectionMessage(connection, decoder); return; } if (!decoder.destinationID()) { ASSERT_NOT_REACHED(); return; } PluginControllerProxy* pluginControllerProxy = m_pluginControllers.get(decoder.destinationID()); if (!pluginControllerProxy) return; PluginController::PluginDestructionProtector protector(pluginControllerProxy->asPluginController()); pluginControllerProxy->didReceivePluginControllerProxyMessage(connection, decoder); }
void NPObjectMessageReceiver::getProperty(const NPIdentifierData& propertyNameData, bool& returnValue, NPVariantData& resultData) { if (!m_npObject->_class->getProperty) { returnValue = false; return; } NPVariant result; VOID_TO_NPVARIANT(result); PluginController::PluginDestructionProtector protector(m_plugin->controller()); returnValue = m_npObject->_class->getProperty(m_npObject, propertyNameData.createNPIdentifier(), &result); if (!returnValue) return; resultData = m_npRemoteObjectMap->npVariantToNPVariantData(result, m_plugin); releaseNPVariantValue(&result); }
void Loader::Host::didFinishLoading(SubresourceLoader* loader) { RefPtr<Host> myProtector(this); RequestMap::iterator i = m_requestsLoading.find(loader); if (i == m_requestsLoading.end()) return; Request* request = i->second; m_requestsLoading.remove(i); DocLoader* docLoader = request->docLoader(); // Prevent the document from being destroyed before we are done with // the docLoader that it will delete when the document gets deleted. RefPtr<Document> protector(docLoader->doc()); if (!request->isMultipart()) docLoader->decrementRequestCount(); CachedResource* resource = request->cachedResource(); ASSERT(!resource->resourceToRevalidate()); // If we got a 4xx response, we're pretending to have received a network // error, so we can't send the successful data() and finish() callbacks. if (!resource->errorOccurred()) { docLoader->setLoadInProgress(true); resource->data(loader->resourceData(), true); resource->finish(); } delete request; docLoader->setLoadInProgress(false); docLoader->checkForPendingPreloads(); #if REQUEST_DEBUG KURL u(ParsedURLString, resource->url()); printf("HOST %s COUNT %d RECEIVED %s\n", u.host().latin1().data(), m_requestsLoading.size(), resource->url().latin1().data()); #endif servePendingRequests(); }
bool CoordinatedLayerTreeHost::flushPendingLayerChanges() { if (m_waitingForUIProcess) return false; TemporaryChange<bool> protector(m_isFlushingLayerChanges, true); createCompositingLayers(); initializeRootCompositingLayerIfNeeded(); m_rootLayer->flushCompositingStateForThisLayerOnly(); m_nonCompositedContentLayer->flushCompositingStateForThisLayerOnly(); if (m_pageOverlayLayer) m_pageOverlayLayer->flushCompositingStateForThisLayerOnly(); bool didSync = m_webPage->corePage()->mainFrame()->view()->flushCompositingStateIncludingSubframes(); flushPendingImageBackingChanges(); deleteCompositingLayers(); if (m_shouldSyncFrame) { didSync = true; IntSize contentsSize = roundedIntSize(m_nonCompositedContentLayer->size()); IntRect coveredRect = toCoordinatedGraphicsLayer(m_nonCompositedContentLayer.get())->coverRect(); m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::DidRenderFrame(contentsSize, coveredRect)); m_waitingForUIProcess = true; m_shouldSyncFrame = false; } else unlockAnimations(); if (m_forceRepaintAsyncCallbackID) { m_webPage->send(Messages::WebPageProxy::VoidCallback(m_forceRepaintAsyncCallbackID)); m_forceRepaintAsyncCallbackID = 0; } return didSync; }
void ResourceLoader::didReceiveAuthenticationChallenge(const AuthenticationChallenge& challenge) { ASSERT(handle()->hasAuthenticationChallenge()); // Protect this in this delegate method since the additional processing can do // anything including possibly derefing this; one example of this is Radar 3266216. RefPtr<ResourceLoader> protector(this); if (m_options.allowCredentials == AllowStoredCredentials) { if (m_options.crossOriginCredentialPolicy == AskClientForCrossOriginCredentials || m_frame->document()->securityOrigin()->canRequest(originalRequest().url())) { frameLoader()->notifier()->didReceiveAuthenticationChallenge(this, challenge); return; } } // Only these platforms provide a way to continue without credentials. // If we can't continue with credentials, we need to cancel the load altogether. #if PLATFORM(MAC) || USE(CFNETWORK) || USE(CURL) handle()->receivedRequestToContinueWithoutCredential(challenge); ASSERT(!handle()->hasAuthenticationChallenge()); #else didFail(blockedError()); #endif }
void PageAnimator::serviceScriptedAnimations(double monotonicAnimationStartTime) { RefPtrWillBeRawPtr<PageAnimator> protector(this); m_animationFramePending = false; TemporaryChange<bool> servicing(m_servicingAnimations, true); WillBeHeapVector<RefPtrWillBeMember<Document>> documents; for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traverseNext()) { if (frame->isLocalFrame()) documents.append(toLocalFrame(frame)->document()); } for (size_t i = 0; i < documents.size(); ++i) { if (documents[i]->frame()) { documents[i]->view()->serviceScrollAnimations(monotonicAnimationStartTime); if (const FrameView::ScrollableAreaSet* animatingScrollableAreas = documents[i]->view()->animatingScrollableAreas()) { // Iterate over a copy, since ScrollableAreas may deregister // themselves during the iteration. Vector<ScrollableArea*> animatingScrollableAreasCopy; copyToVector(*animatingScrollableAreas, animatingScrollableAreasCopy); for (ScrollableArea* scrollableArea : animatingScrollableAreasCopy) scrollableArea->serviceScrollAnimations(monotonicAnimationStartTime); } } } for (size_t i = 0; i < documents.size(); ++i) { DocumentAnimations::updateAnimationTimingForAnimationFrame(*documents[i], monotonicAnimationStartTime); SVGDocumentExtensions::serviceOnAnimationFrame(*documents[i], monotonicAnimationStartTime); } for (size_t i = 0; i < documents.size(); ++i) documents[i]->serviceScriptedAnimations(monotonicAnimationStartTime); #if ENABLE(OILPAN) documents.clear(); #endif }
void Loader::Host::didFail(SubresourceLoader* loader, bool cancelled) { RefPtr<Host> myProtector(this); loader->clearClient(); RequestMap::iterator i = m_requestsLoading.find(loader); if (i == m_requestsLoading.end()) return; Request* request = i->second; m_requestsLoading.remove(i); DocLoader* docLoader = request->docLoader(); // Prevent the document from being destroyed before we are done with // the docLoader that it will delete when the document gets deleted. RefPtr<Document> protector(docLoader->doc()); if (!request->isMultipart()) docLoader->decrementRequestCount(); CachedResource* resource = request->cachedResource(); if (resource->resourceToRevalidate()) cache()->revalidationFailed(resource); if (!cancelled) { docLoader->setLoadInProgress(true); resource->error(); } docLoader->setLoadInProgress(false); if (cancelled || !resource->isPreloaded()) cache()->remove(resource); delete request; docLoader->checkForPendingPreloads(); servePendingRequests(); }
void ResourceLoader::releaseResources() { ASSERT(!m_reachedTerminalState); // It's possible that when we release the handle, it will be // deallocated and release the last reference to this object. // We need to retain to avoid accessing the object after it // has been deallocated and also to avoid reentering this method. RefPtr<ResourceLoader> protector(this); m_frame = 0; // We need to set reachedTerminalState to true before we release // the resources to prevent a double dealloc of WebView <rdar://problem/4372628> m_reachedTerminalState = true; m_identifier = 0; m_handle = 0; m_resourceData = 0; m_deferredRequest = ResourceRequest(); }
JSC::JSValue JSNPObject::callObject(JSC::ExecState* exec) { ASSERT_GC_OBJECT_INHERITS(this, &s_info); if (!m_npObject) return throwInvalidAccessError(exec); size_t argumentCount = exec->argumentCount(); Vector<NPVariant, 8> arguments(argumentCount); // Convert all arguments to NPVariants. for (size_t i = 0; i < argumentCount; ++i) m_objectMap->convertJSValueToNPVariant(exec, exec->argument(i), arguments[i]); // Calling NPClass::invokeDefault will call into plug-in code, and there's no telling what the plug-in can do. // (including destroying the plug-in). Because of this, we make sure to keep the plug-in alive until // the call has finished. NPRuntimeObjectMap::PluginProtector protector(m_objectMap); bool returnValue; NPVariant result; VOID_TO_NPVARIANT(result); { JSLock::DropAllLocks dropAllLocks(SilenceAssertionsOnly); returnValue = m_npObject->_class->invokeDefault(m_npObject, arguments.data(), argumentCount, &result); NPRuntimeObjectMap::moveGlobalExceptionToExecState(exec); } // Release all arguments; for (size_t i = 0; i < argumentCount; ++i) releaseNPVariantValue(&arguments[i]); if (!returnValue) throwError(exec, createError(exec, "Error calling method on NPObject.")); JSValue propertyValue = m_objectMap->convertNPVariantToJSValue(exec, globalObject(), result); releaseNPVariantValue(&result); return propertyValue; }
void UniqueIDBDatabase::performNextDatabaseTask() { ASSERT(!isMainThread()); // It is possible that this database might be shutting down on the main thread. // In this case, immediately after releasing m_databaseTaskMutex, this database might get deleted. // We take a ref() to make sure the database is still live while this last task is performed. RefPtr<UniqueIDBDatabase> protector(this); std::unique_ptr<AsyncTask> task; { MutexLocker locker(m_databaseTaskMutex); // This database might be shutting down on the main thread, in which case the task queue might be empty. if (m_databaseTasks.isEmpty()) return; task = m_databaseTasks.takeFirst(); } task->performTask(); }
bool PluginControllerProxy::evaluate(NPObject* npObject, const String& scriptString, NPVariant* result, bool allowPopups) { PluginDestructionProtector protector(this); NPVariant npObjectAsNPVariant; OBJECT_TO_NPVARIANT(npObject, npObjectAsNPVariant); // Send the NPObject over as an NPVariantData. NPVariantData npObjectAsNPVariantData = m_connection->npRemoteObjectMap()->npVariantToNPVariantData(npObjectAsNPVariant, m_plugin.get()); bool returnValue = false; NPVariantData resultData; if (!m_connection->connection()->sendSync(Messages::PluginProxy::Evaluate(npObjectAsNPVariantData, scriptString, allowPopups), Messages::PluginProxy::Evaluate::Reply(returnValue, resultData), m_pluginInstanceID)) return false; if (!returnValue) return false; *result = m_connection->npRemoteObjectMap()->npVariantDataToNPVariant(resultData, m_plugin.get()); return true; }
void WebResourceLoader::didReceiveResource(const ShareableResource::Handle& handle, double finishTime) { LOG(Network, "(WebProcess) WebResourceLoader::didReceiveResource for '%s'", m_coreLoader->url().string().utf8().data()); RefPtr<SharedBuffer> buffer = handle.tryWrapInSharedBuffer(); if (!buffer) { LOG_ERROR("Unable to create buffer from ShareableResource sent from the network process."); m_coreLoader->didFail(internalError(m_coreLoader->request().url())); return; } RefPtr<WebResourceLoader> protector(this); // Only send data to the didReceiveData callback if it exists. if (buffer->size()) m_coreLoader->didReceiveBuffer(buffer.get(), buffer->size(), DataPayloadWholeResource); if (!m_coreLoader) return; m_coreLoader->didFinishLoading(finishTime); }
bool CompositingCoordinator::flushPendingLayerChanges() { TemporaryChange<bool> protector(m_isFlushingLayerChanges, true); initializeRootCompositingLayerIfNeeded(); bool viewportIsStable = m_page->mainFrame().view()->viewportIsStable(); m_rootLayer->flushCompositingStateForThisLayerOnly(viewportIsStable); m_client->didFlushRootLayer(m_visibleContentsRect); if (m_overlayCompositingLayer) m_overlayCompositingLayer->flushCompositingState(FloatRect(FloatPoint(), m_rootLayer->size()), viewportIsStable); bool didSync = m_page->mainFrame().view()->flushCompositingStateIncludingSubframes(); toCoordinatedGraphicsLayer(m_rootLayer.get())->updateContentBuffersIncludingSubLayers(); toCoordinatedGraphicsLayer(m_rootLayer.get())->syncPendingStateChangesIncludingSubLayers(); flushPendingImageBackingChanges(); if (m_shouldSyncFrame) { didSync = true; if (m_rootCompositingLayer) { m_state.contentsSize = roundedIntSize(m_rootCompositingLayer->size()); if (CoordinatedGraphicsLayer* contentsLayer = mainContentsLayer()) m_state.coveredRect = contentsLayer->coverRect(); } m_state.scrollPosition = m_visibleContentsRect.location(); m_client->commitSceneState(m_state); clearPendingStateChanges(); m_shouldSyncFrame = false; } return didSync; }
void JSNPObject::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot&) { JSNPObject* thisObject = JSC::jsCast<JSNPObject*>(cell); ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); if (!thisObject->m_npObject) { throwInvalidAccessError(exec); return; } NPIdentifier npIdentifier = npIdentifierFromIdentifier(propertyName); if (!thisObject->m_npObject->_class->hasProperty || !thisObject->m_npObject->_class->hasProperty(thisObject->m_npObject, npIdentifier)) { // FIXME: Should we throw an exception here? return; } if (!thisObject->m_npObject->_class->setProperty) return; NPVariant variant; thisObject->m_objectMap->convertJSValueToNPVariant(exec, value, variant); // Calling NPClass::setProperty will call into plug-in code, and there's no telling what the plug-in can do. // (including destroying the plug-in). Because of this, we make sure to keep the plug-in alive until // the call has finished. NPRuntimeObjectMap::PluginProtector protector(thisObject->m_objectMap); { JSLock::DropAllLocks dropAllLocks(SilenceAssertionsOnly); thisObject->m_npObject->_class->setProperty(thisObject->m_npObject, npIdentifier, &variant); NPRuntimeObjectMap::moveGlobalExceptionToExecState(exec); // FIXME: Should we throw an exception if setProperty returns false? } releaseNPVariantValue(&variant); }
void EventQueue::pendingEventTimerFired() { ASSERT(!m_pendingEventTimer->isActive()); ASSERT(!m_queuedEvents.isEmpty()); m_nodesWithQueuedScrollEvents.clear(); // Insert a marker for where we should stop. ASSERT(!m_queuedEvents.contains(0)); bool wasAdded = m_queuedEvents.add(0).second; ASSERT_UNUSED(wasAdded, wasAdded); // It should not have already been in the list. RefPtr<EventQueue> protector(this); while (!m_queuedEvents.isEmpty()) { ListHashSet<RefPtr<Event> >::iterator iter = m_queuedEvents.begin(); RefPtr<Event> event = *iter; m_queuedEvents.remove(iter); if (!event) break; dispatchEvent(event.get()); } }
void PluginProxy::evaluate(const NPVariantData& npObjectAsVariantData, const String& scriptString, bool allowPopups, bool& returnValue, NPVariantData& resultData) { PluginController::PluginDestructionProtector protector(controller()); NPVariant npObjectAsVariant = m_connection->npRemoteObjectMap()->npVariantDataToNPVariant(npObjectAsVariantData, this); if (!NPVARIANT_IS_OBJECT(npObjectAsVariant) || !(NPVARIANT_TO_OBJECT(npObjectAsVariant))) { returnValue = false; return; } NPVariant result; returnValue = controller()->evaluate(NPVARIANT_TO_OBJECT(npObjectAsVariant), scriptString, &result, allowPopups); if (!returnValue) return; // Convert the NPVariant to an NPVariantData. resultData = m_connection->npRemoteObjectMap()->npVariantToNPVariantData(result, this); // And release the result. releaseNPVariantValue(&result); releaseNPVariantValue(&npObjectAsVariant); }
void ClientImpl::initiateConnection(boost::shared_ptr<PendingConnection> &pc) throw (voltdb::ConnectException, voltdb::LibEventException){ std::stringstream ss; ss << "ClientImpl::initiateConnection to " << pc->m_hostname << ":" << pc->m_port; logMessage(ClientLogger::INFO, ss.str()); struct bufferevent * bev = bufferevent_socket_new(m_base, -1, BEV_OPT_CLOSE_ON_FREE | BEV_OPT_THREADSAFE); if (bev == NULL) { throw ConnectException(); } FreeBEVOnFailure protector(bev); bufferevent_setcb(bev, authenticationReadCallback, NULL, authenticationEventCallback, pc.get()); if (bufferevent_socket_connect_hostname(bev, NULL, AF_INET, pc->m_hostname.c_str(), pc->m_port) != 0) { ss.str(""); ss << "!!!! ClientImpl::initiateConnection to " << pc->m_hostname << ":" << pc->m_port << " failed"; logMessage(ClientLogger::ERROR, ss.str()); throw voltdb::LibEventException(); } protector.success(); }
void ResourceLoader::didReceiveData(const char* data, int length, long long encodedDataLength, bool allAtOnce) { if (!m_cancelled && !fastMallocSize(documentLoader()->applicationCacheHost())) CRASH(); if (!m_cancelled && !fastMallocSize(documentLoader()->frame())) CRASH(); // The following assertions are not quite valid here, since a subclass // might override didReceiveData in a way that invalidates them. This // happens with the steps listed in 3266216 // ASSERT(con == connection); // ASSERT(!m_reachedTerminalState); // Protect this in this delegate method since the additional processing can do // anything including possibly derefing this; one example of this is Radar 3266216. RefPtr<ResourceLoader> protector(this); addData(data, length, allAtOnce); // FIXME: If we get a resource with more than 2B bytes, this code won't do the right thing. // However, with today's computers and networking speeds, this won't happen in practice. // Could be an issue with a giant local file. if (m_options.sendLoadCallbacks == SendCallbacks && m_frame) frameLoader()->notifier()->didReceiveData(this, data, length, static_cast<int>(encodedDataLength)); }
void FileChooser::openFileChooser(Document* document) { FrameView* view = document->view(); if (!view) return; GtkWidget* dialog = gtk_file_chooser_dialog_new(_("Upload File"), GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(view->containingWindow()))), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); // We need this protector because otherwise we can be deleted if the file upload control is detached while // we're within the gtk_run_dialog call. RefPtr<FileChooser> protector(this); String result; const bool acceptedDialog = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT; if (acceptedDialog && stringByAdoptingFileSystemRepresentation(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)), result)) chooseFile(result); gtk_widget_destroy(dialog); }
void DocumentWriter::end() { ASSERT(m_frame->page()); ASSERT(m_frame->document()); // The parser is guaranteed to be released after this point. begin() would // have to be called again before we can start writing more data. m_state = FinishedWritingState; // http://bugs.webkit.org/show_bug.cgi?id=10854 // The frame's last ref may be removed and it can be deleted by checkCompleted(), // so we'll add a protective refcount RefPtr<Frame> protector(m_frame); if (!m_parser) return; // FIXME: m_parser->finish() should imply m_parser->flush(). m_parser->flush(this); if (!m_parser) return; m_parser->finish(); m_parser = 0; }
void WebProcessConnection::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder, OwnPtr<CoreIPC::MessageEncoder>& replyEncoder) { ConnectionStack::CurrentConnectionPusher currentConnection(ConnectionStack::shared(), connection); uint64_t destinationID = decoder.destinationID(); if (!destinationID) { didReceiveSyncWebProcessConnectionMessage(connection, messageID, decoder, replyEncoder); return; } if (messageID.is<CoreIPC::MessageClassNPObjectMessageReceiver>()) { m_npRemoteObjectMap->didReceiveSyncMessage(connection, messageID, decoder, replyEncoder); return; } PluginControllerProxy* pluginControllerProxy = m_pluginControllers.get(decoder.destinationID()); if (!pluginControllerProxy) return; PluginController::PluginDestructionProtector protector(pluginControllerProxy->asPluginController()); pluginControllerProxy->didReceiveSyncPluginControllerProxyMessage(connection, messageID, decoder, replyEncoder); }
void ResourceLoader::didReceiveData(const char* data, int length, long long encodedDataLength, bool allAtOnce) { // The following assertions are not quite valid here, since a subclass // might override didReceiveData in a way that invalidates them. This // happens with the steps listed in 3266216 // ASSERT(con == connection); // ASSERT(!m_reachedTerminalState); // Protect this in this delegate method since the additional processing can do // anything including possibly derefing this; one example of this is Radar 3266216. RefPtr<ResourceLoader> protector(this); addData(data, length, allAtOnce); // FIXME: If we get a resource with more than 2B bytes, this code won't do the right thing. // However, with today's computers and networking speeds, this won't happen in practice. // Could be an issue with a giant local file. if (m_options.sendLoadCallbacks == SendCallbacks && m_frame) { ActionLogScope log_scope( String::format("recv_data:%s", m_request.url().lastPathComponent().ascii().data()).ascii().data()); frameLoader()->notifier()->didReceiveData(this, data, length, static_cast<int>(encodedDataLength)); } }
void NetworkConnectionToWebProcess::writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, uint64_t requestIdentifier) { RefPtr<NetworkConnectionToWebProcess> protector(this); Vector<RefPtr<WebCore::BlobDataFileReference>> fileReferences; for (auto& url : blobURLs) fileReferences.appendVector(NetworkBlobRegistry::singleton().filesInBlob(*this, { ParsedURLString, url })); for (auto& file : fileReferences) file->prepareForFileAccess(); NetworkBlobRegistry::singleton().writeBlobsToTemporaryFiles(blobURLs, [this, protector, requestIdentifier, fileReferences](const Vector<String>& fileNames) { for (auto& file : fileReferences) file->revokeFileAccess(); NetworkProcess::singleton().grantSandboxExtensionsToDatabaseProcessForBlobs(fileNames, [this, protector, requestIdentifier, fileNames]() { if (!m_connection || !m_connection->isValid()) return; m_connection->send(Messages::NetworkProcessConnection::DidWriteBlobsToTemporaryFiles(requestIdentifier, fileNames), 0); }); }); }
void WebProcessConnection::didReceiveSyncMessage(IPC::Connection& connection, IPC::Decoder& decoder, std::unique_ptr<IPC::Encoder>& replyEncoder) { TemporaryChange<IPC::Connection*> currentConnectionChange(currentConnection, &connection); uint64_t destinationID = decoder.destinationID(); if (!destinationID) { didReceiveSyncWebProcessConnectionMessage(connection, decoder, replyEncoder); return; } if (decoder.messageReceiverName() == Messages::NPObjectMessageReceiver::messageReceiverName()) { m_npRemoteObjectMap->didReceiveSyncMessage(connection, decoder, replyEncoder); return; } PluginControllerProxy* pluginControllerProxy = m_pluginControllers.get(decoder.destinationID()); if (!pluginControllerProxy) return; PluginController::PluginDestructionProtector protector(pluginControllerProxy->asPluginController()); pluginControllerProxy->didReceiveSyncPluginControllerProxyMessage(connection, decoder, replyEncoder); }
void ResourceLoader::cancel(const ResourceError& error) { // If the load has already completed - succeeded, failed, or previously cancelled - do nothing. if (m_state == Terminated) return; if (m_state == Finishing) { releaseResources(); return; } ResourceError nonNullError = error.isNull() ? ResourceError::cancelledError(m_request.url()) : error; // This function calls out to clients at several points that might do // something that causes the last reference to this object to go away. RefPtr<ResourceLoader> protector(this); WTF_LOG(ResourceLoading, "Cancelled load of '%s'.\n", m_resource->url().string().latin1().data()); if (m_state == Initialized) m_state = Finishing; m_resource->setResourceError(nonNullError); if (m_loader) { m_connectionState = ConnectionStateCanceled; m_loader->cancel(); m_loader.clear(); } if (!m_notifiedLoadComplete) { m_notifiedLoadComplete = true; m_host->didFailLoading(m_resource, nonNullError); } if (m_state == Finishing) m_resource->error(Resource::LoadError); if (m_state != Terminated) releaseResources(); }
void PlaybackPipeline::removeSourceBuffer(RefPtr<SourceBufferPrivateGStreamer> sourceBufferPrivate) { GST_DEBUG_OBJECT(m_webKitMediaSrc.get(), "Element removed from MediaSource"); GST_OBJECT_LOCK(m_webKitMediaSrc.get()); WebKitMediaSrcPrivate* priv = m_webKitMediaSrc->priv; Stream* stream = 0; GList *l; for (l = priv->streams; l; l = l->next) { Stream *tmp = static_cast<Stream*>(l->data); if (tmp->sourceBuffer == sourceBufferPrivate.get()) { stream = tmp; priv->streams = g_list_remove(priv->streams, stream); break; } } GST_OBJECT_UNLOCK(m_webKitMediaSrc.get()); if (stream) { if (stream->appsrc) gst_app_src_end_of_stream(GST_APP_SRC(stream->appsrc)); if (stream->type != Invalid) { if (WTF::isMainThread()) releaseStreamTrackInfo(stream->parent, stream); else { WTF::GMutexLocker<GMutex> lock(stream->parent->priv->streamMutex); GRefPtr<WebKitMediaSrc> protector(stream->parent); stream->parent->priv->timeoutSource.schedule([protector, stream] { releaseStreamTrackInfo(protector.get(), stream); }); g_cond_wait(&stream->parent->priv->streamCondition, &stream->parent->priv->streamMutex); } } g_timeout_add(300, (GSourceFunc)freeStreamLater, stream); } }
void ResourceLoader::releaseResources() { ASSERT(!m_reachedTerminalState); // It's possible that when we release the handle, it will be // deallocated and release the last reference to this object. // We need to retain to avoid accessing the object after it // has been deallocated and also to avoid reentering this method. RefPtr<ResourceLoader> protector(this); m_frame = 0; m_documentLoader = 0; // We need to set reachedTerminalState to true before we release // the resources to prevent a double dealloc of WebView <rdar://problem/4372628> m_reachedTerminalState = true; #if USE(PLATFORM_STRATEGIES) platformStrategies()->loaderStrategy()->resourceLoadScheduler()->remove(this); #endif m_identifier = 0; #if !USE(PLATFORM_STRATEGIES) resourceLoadScheduler()->remove(this); #endif if (m_handle) { // Clear out the ResourceHandle's client so that it doesn't try to call // us back after we release it, unless it has been replaced by someone else. if (m_handle->client() == this) m_handle->setClient(0); m_handle = 0; } m_resourceData = 0; m_deferredRequest = ResourceRequest(); }
void StorageAreaSync::scheduleFinalSync() { ASSERT(isMainThread()); // FIXME: We do this to avoid races, but it'd be better to make things safe without blocking. blockUntilImportComplete(); m_storageArea = nullptr; // This is done in blockUntilImportComplete() but this is here as a form of documentation that we must be absolutely sure the ref count cycle is broken. if (m_syncTimer.isActive()) m_syncTimer.stop(); else { // The following is balanced by the call to enableSuddenTermination in the // syncTimerFired function. disableSuddenTermination(); } // FIXME: This is synchronous. We should do it on the background process, but // we should do it safely. m_finalSyncScheduled = true; syncTimerFired(); RefPtr<StorageAreaSync> protector(this); m_syncManager->dispatch([protector] { protector->deleteEmptyDatabase(); }); }