本文整理汇总了C++中protector函数的典型用法代码示例。如果您正苦于以下问题:C++ protector函数的具体用法?C++ protector怎么用?C++ protector使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了protector函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: logMessage
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();
}
示例2: ASSERT
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());
}
}
示例3: VOID_TO_NPVARIANT
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);
}
示例4: myProtector
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();
}
示例5: protector
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;
}
示例6: protector
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
}
示例7: ASSERT
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();
}
示例8: ASSERT
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();
}
示例9: LOG
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);
}
示例10: protector
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;
}
示例11: ASSERT
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());
}
}
示例12: protector
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);
}
示例13: throw
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();
}
示例14: gtk_file_chooser_dialog_new
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);
}
示例15: ASSERT
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;
}