本文整理汇总了C++中protect函数的典型用法代码示例。如果您正苦于以下问题:C++ protect函数的具体用法?C++ protect怎么用?C++ protect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了protect函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: protect
SCM Scm::loadFile(const QString& filename) {
return protect(_load_file,(void*)filename.ascii());
}
开发者ID:sigma,项目名称:qnet,代码行数:3,代码来源:scm.cpp
示例2: protect
v8::Local<v8::Value> ScriptController::callFunction(v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[])
{
// Keep Frame (and therefore ScriptController) alive.
RefPtr<Frame> protect(m_frame);
return ScriptController::callFunctionWithInstrumentation(m_frame ? m_frame->document() : 0, function, receiver, argc, args);
}
开发者ID:windyuuy,项目名称:opera,代码行数:6,代码来源:ScriptController.cpp
示例3: protect
QString QsCodeMarker::markedUpCode( const QString& code,
const Node * /* relative */,
const QString& /* dirPath */ )
{
return protect( code );
}
开发者ID:Fale,项目名称:qtmoko,代码行数:6,代码来源:qscodemarker.cpp
示例4: GetAndSet
/**
* Determine the value of the flag, and set it before returning.
*/
bool GetAndSet(bool new_value=true) {
ScopeLock protect(mutex);
bool old_value = value;
value = new_value;
return old_value;
}
开发者ID:joachimwieland,项目名称:xcsoar-jwieland,代码行数:9,代码来源:Flag.hpp
示例5: ASSERT
// In this method, we can clear |request| to tell content::WebURLLoaderImpl of
// Chromium not to follow the redirect. This works only when this method is
// called by RawResource::willSendRequest(). If called by
// RawResource::didAddClient(), clearing |request| won't be propagated
// to content::WebURLLoaderImpl. So, this loader must also get detached from
// the resource by calling clearResource().
void DocumentThreadableLoader::redirectReceived(Resource* resource, ResourceRequest& request, const ResourceResponse& redirectResponse)
{
ASSERT(m_client);
ASSERT_UNUSED(resource, resource == this->resource());
ASSERT(m_async);
if (!m_actualRequest.isNull()) {
reportResponseReceived(resource->identifier(), redirectResponse);
handlePreflightFailure(redirectResponse.url().string(), "Response for preflight is invalid (redirect)");
// |this| may be dead here.
request = ResourceRequest();
return;
}
if (m_redirectMode == WebURLRequest::FetchRedirectModeManual) {
// Keep |this| alive even if the client release a reference in
// responseReceived().
RefPtr<DocumentThreadableLoader> protect(this);
// We use |m_redirectMode| to check the original redirect mode.
// |request| is a new request for redirect. So we don't set the redirect
// mode of it in WebURLLoaderImpl::Context::OnReceivedRedirect().
ASSERT(request.useStreamOnResponse());
// There is no need to read the body of redirect response because there
// is no way to read the body of opaque-redirect filtered response's
// internal response.
// TODO(horo): If we support any API which expose the internal body, we
// will have to read the body. And also HTTPCache changes will be needed
// because it doesn't store the body of redirect responses.
responseReceived(resource, redirectResponse, adoptPtr(new EmptyDataHandle()));
if (m_client) {
ASSERT(m_actualRequest.isNull());
notifyFinished(resource);
}
request = ResourceRequest();
return;
}
if (m_redirectMode == WebURLRequest::FetchRedirectModeError || !isAllowedByContentSecurityPolicy(request.url(), ContentSecurityPolicy::DidRedirect)) {
ThreadableLoaderClient* client = m_client;
clear();
client->didFailRedirectCheck();
// |this| may be dead here.
request = ResourceRequest();
return;
}
// Allow same origin requests to continue after allowing clients to audit the redirect.
if (isAllowedRedirect(request.url())) {
if (m_client->isDocumentThreadableLoaderClient())
static_cast<DocumentThreadableLoaderClient*>(m_client)->willFollowRedirect(request, redirectResponse);
return;
}
if (m_corsRedirectLimit <= 0) {
ThreadableLoaderClient* client = m_client;
clear();
client->didFailRedirectCheck();
// |this| may be dead here.
} else if (m_options.crossOriginRequestPolicy == UseAccessControl) {
--m_corsRedirectLimit;
InspectorInstrumentation::didReceiveCORSRedirectResponse(document().frame(), resource->identifier(), document().frame()->loader().documentLoader(), redirectResponse, 0);
bool allowRedirect = false;
String accessControlErrorDescription;
// Non-simple cross origin requests (both preflight and actual one) are
// not allowed to follow redirect.
if (m_crossOriginNonSimpleRequest) {
accessControlErrorDescription = "The request was redirected to '"+ request.url().string() + "', which is disallowed for cross-origin requests that require preflight.";
} else {
// The redirect response must pass the access control check if the
// original request was not same-origin.
allowRedirect = CrossOriginAccessControl::isLegalRedirectLocation(request.url(), accessControlErrorDescription)
&& (m_sameOriginRequest || passesAccessControlCheck(redirectResponse, effectiveAllowCredentials(), securityOrigin(), accessControlErrorDescription, m_requestContext));
}
if (allowRedirect) {
// FIXME: consider combining this with CORS redirect handling performed by
// CrossOriginAccessControl::handleRedirect().
clearResource();
RefPtr<SecurityOrigin> originalOrigin = SecurityOrigin::create(redirectResponse.url());
RefPtr<SecurityOrigin> requestOrigin = SecurityOrigin::create(request.url());
// If the original request wasn't same-origin, then if the request URL origin is not same origin with the original URL origin,
//.........这里部分代码省略.........
开发者ID:joone,项目名称:chromium-crosswalk,代码行数:101,代码来源:DocumentThreadableLoader.cpp
示例6: protect
void ResourceLoader::willSendRequestInternal(ResourceRequest& request, const ResourceResponse& redirectResponse)
{
// Protect this in this delegate method since the additional processing can do
// anything including possibly derefing this; one example of this is Radar 3266216.
Ref<ResourceLoader> protect(*this);
ASSERT(!m_reachedTerminalState);
#if ENABLE(CONTENT_EXTENSIONS)
ASSERT(m_resourceType != ResourceType::Invalid);
#endif
// We need a resource identifier for all requests, even if FrameLoader is never going to see it (such as with CORS preflight requests).
bool createdResourceIdentifier = false;
if (!m_identifier) {
m_identifier = m_frame->page()->progress().createUniqueIdentifier();
createdResourceIdentifier = true;
}
#if ENABLE(CONTENT_EXTENSIONS)
if (frameLoader()) {
Page* page = frameLoader()->frame().page();
if (page && m_documentLoader) {
auto* userContentController = page->userContentController();
if (userContentController)
userContentController->processContentExtensionRulesForLoad(*page, request, m_resourceType, *m_documentLoader);
}
}
#endif
if (request.isNull()) {
didFail(cannotShowURLError());
return;
}
if (m_options.sendLoadCallbacks() == SendCallbacks) {
if (createdResourceIdentifier)
frameLoader()->notifier().assignIdentifierToInitialRequest(m_identifier, documentLoader(), request);
#if PLATFORM(IOS)
// If this ResourceLoader was stopped as a result of assignIdentifierToInitialRequest, bail out
if (m_reachedTerminalState)
return;
#endif
frameLoader()->notifier().willSendRequest(this, request, redirectResponse);
}
else
InspectorInstrumentation::willSendRequest(m_frame.get(), m_identifier, m_frame->loader().documentLoader(), request, redirectResponse);
bool isRedirect = !redirectResponse.isNull();
if (isRedirect)
platformStrategies()->loaderStrategy()->resourceLoadScheduler()->crossOriginRedirectReceived(this, request.url());
m_request = request;
if (isRedirect) {
auto& redirectURL = request.url();
if (!m_documentLoader->isCommitted())
frameLoader()->client().dispatchDidReceiveServerRedirectForProvisionalLoad();
if (redirectURL.protocolIsData()) {
// Handle data URL decoding locally.
finishNetworkLoad();
loadDataURL();
}
}
}
开发者ID:home201448,项目名称:webkit,代码行数:67,代码来源:ResourceLoader.cpp
示例7: protect
void
TrackingGlue::WaitStopped()
{
ScopeLock protect(mutex);
StandbyThread::WaitStopped();
}
开发者ID:piermariamattioli,项目名称:XCSoar,代码行数:6,代码来源:TrackingGlue.cpp
示例8: f
bool MetaTranslator::save( const QString& filename ) const
{
QFile f( filename );
if ( !f.open(IO_WriteOnly) )
return FALSE;
QTextStream t( &f );
t.setCodec( QTextCodec::codecForName("ISO-8859-1") );
t << "<!DOCTYPE TS><TS>\n";
if ( codecName != "ISO-8859-1" )
t << "<defaultcodec>" << codecName << "</defaultcodec>\n";
TMM::ConstIterator m = mm.begin();
while ( m != mm.end() ) {
TMMInv inv;
TMMInv::Iterator i;
bool contextIsUtf8 = m.key().utf8();
QCString context = m.key().context();
QCString comment = "";
do {
if ( QCString(m.key().sourceText()) == ContextComment ) {
if ( m.key().type() != MetaTranslatorMessage::Obsolete ) {
contextIsUtf8 = m.key().utf8();
comment = QCString( m.key().comment() );
}
} else {
inv.insert( *m, m.key() );
}
} while ( ++m != mm.end() && QCString(m.key().context()) == context );
t << "<context";
if ( contextIsUtf8 )
t << " encoding=\"UTF-8\"";
t << ">\n";
t << " <name>" << evilBytes( context, contextIsUtf8 )
<< "</name>\n";
if ( !comment.isEmpty() )
t << " <comment>" << evilBytes( comment, contextIsUtf8 )
<< "</comment>\n";
for ( i = inv.begin(); i != inv.end(); ++i ) {
// no need for such noise
if ( (*i).type() == MetaTranslatorMessage::Obsolete &&
(*i).translation().isEmpty() )
continue;
t << " <message";
if ( (*i).utf8() )
t << " encoding=\"UTF-8\"";
t << ">\n"
<< " <source>" << evilBytes( (*i).sourceText(),
(*i).utf8() )
<< "</source>\n";
if ( !QCString((*i).comment()).isEmpty() )
t << " <comment>" << evilBytes( (*i).comment(),
(*i).utf8() )
<< "</comment>\n";
t << " <translation";
if ( (*i).type() == MetaTranslatorMessage::Unfinished )
t << " type=\"unfinished\"";
else if ( (*i).type() == MetaTranslatorMessage::Obsolete )
t << " type=\"obsolete\"";
t << ">" << protect( (*i).translation().utf8() )
<< "</translation>\n";
t << " </message>\n";
}
t << "</context>\n";
}
t << "</TS>\n";
f.close();
return TRUE;
}
开发者ID:OS2World,项目名称:LIB-QT3_Toolkit_Vbox,代码行数:73,代码来源:metatranslator.cpp
示例9: protect
void Notification::stopLoading()
{
m_iconData = 0;
RefPtr<ThreadableLoader> protect(m_loader);
m_loader->cancel();
}
开发者ID:studiomobile,项目名称:webcore,代码行数:6,代码来源:Notification.cpp
示例10: protect
void
Logger::ClearBuffer()
{
Poco::ScopedRWLock protect(lock, true);
logger.ClearBuffer();
}
开发者ID:damianob,项目名称:xcsoar,代码行数:6,代码来源:Logger.cpp
示例11: envfs_save
/**
* Make the current environment persistent
* @param[in] filename where to store
* @param[in] dirname what to store (all files in this dir)
* @param[in] flags superblock flags (refer ENVFS_FLAGS_* macros)
* @return 0 on success, anything else in case of failure
*
* Note: This function will also be used on the host! See note in the header
* of this file.
*/
int envfs_save(const char *filename, const char *dirname, unsigned flags)
{
struct envfs_super *super;
int envfd, size, ret;
struct action_data data = {};
void *buf = NULL, *wbuf;
struct envfs_entry *env;
if (!filename)
filename = default_environment_path_get();
if (!dirname)
dirname = "/env";
data.writep = NULL;
data.base = dirname;
#ifdef __BAREBOX__
defaultenv_load(TMPDIR, 0);
#endif
if (flags & ENVFS_FLAGS_FORCE_BUILT_IN) {
size = 0; /* force no content */
} else {
/* first pass: calculate size */
recursive_action(dirname, ACTION_RECURSE, file_action,
NULL, &data, 0);
recursive_action("/.defaultenv", ACTION_RECURSE,
file_remove_action, NULL, &data, 0);
size = 0;
for (env = data.env; env; env = env->next) {
size += PAD4(env->size);
size += sizeof(struct envfs_inode);
size += PAD4(strlen(env->name) + 1);
size += sizeof(struct envfs_inode_end);
}
}
buf = xzalloc(size + sizeof(struct envfs_super));
data.writep = buf + sizeof(struct envfs_super);
super = buf;
super->magic = ENVFS_32(ENVFS_MAGIC);
super->major = ENVFS_MAJOR;
super->minor = ENVFS_MINOR;
super->size = ENVFS_32(size);
super->flags = ENVFS_32(flags);
if (!(flags & ENVFS_FLAGS_FORCE_BUILT_IN)) {
/* second pass: copy files to buffer */
env = data.env;
while (env) {
struct envfs_entry *next = env->next;
envfs_save_inode(&data, env);
free(env->buf);
free(env->name);
free(env);
env = next;
}
}
super->crc = ENVFS_32(crc32(0, buf + sizeof(struct envfs_super), size));
super->sb_crc = ENVFS_32(crc32(0, buf, sizeof(struct envfs_super) - 4));
envfd = open(filename, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
if (envfd < 0) {
printf("could not open %s: %s\n", filename, errno_str());
ret = -errno;
goto out1;
}
ret = protect(envfd, ~0, 0, 0);
/* ENOSYS and EOPNOTSUPP aren't errors here, many devices don't need it */
if (ret && errno != ENOSYS && errno != EOPNOTSUPP) {
printf("could not unprotect %s: %s\n", filename, errno_str());
goto out;
}
ret = erase(envfd, ~0, 0);
/* ENOSYS and EOPNOTSUPP aren't errors here, many devices don't need it */
if (ret && errno != ENOSYS && errno != EOPNOTSUPP) {
printf("could not erase %s: %s\n", filename, errno_str());
goto out;
}
//.........这里部分代码省略.........
开发者ID:shesselba,项目名称:barebox-dove,代码行数:101,代码来源:environment.c
示例12: protect
bool
DeviceDescriptor::IsAlive() const
{
ScopeLock protect(device_blackboard->mutex);
return device_blackboard->RealState(index).alive;
}
开发者ID:kwtskran,项目名称:XCSoar,代码行数:6,代码来源:Descriptor.cpp
示例13: ASSERT
void PluginStream::destroyStream()
{
if (m_streamState == StreamStopped)
return;
ASSERT(m_reason != WebReasonNone);
ASSERT(!m_deliveryData || m_deliveryData->size() == 0);
closeFile(m_tempFileHandle);
bool newStreamCalled = m_stream.ndata;
// Protect from destruction if:
// NPN_DestroyStream is called from NPP_NewStream or
// PluginStreamClient::streamDidFinishLoading() removes the last reference
RefPtr<PluginStream> protect(this);
if (newStreamCalled) {
if (m_reason == NPRES_DONE && (m_transferMode == NP_ASFILE || m_transferMode == NP_ASFILEONLY)) {
ASSERT(!m_path.isNull());
if (m_loader)
m_loader->setDefersLoading(true);
m_pluginFuncs->asfile(m_instance, &m_stream, m_path.utf8().data());
if (m_loader)
m_loader->setDefersLoading(false);
}
if (m_streamState != StreamBeforeStarted) {
if (m_loader)
m_loader->setDefersLoading(true);
NPError npErr = m_pluginFuncs->destroystream(m_instance, &m_stream, m_reason);
if (m_loader)
m_loader->setDefersLoading(false);
LOG_NPERROR(npErr);
}
m_stream.ndata = 0;
}
if (m_sendNotification) {
// Flash 9 can dereference null if we call NPP_URLNotify without first calling NPP_NewStream
// for requests made with NPN_PostURLNotify; see <rdar://5588807>
if (m_loader)
m_loader->setDefersLoading(true);
if (!newStreamCalled && m_quirks.contains(PluginQuirkFlashURLNotifyBug) &&
equalIgnoringCase(m_resourceRequest.httpMethod(), "POST")) {
m_transferMode = NP_NORMAL;
m_stream.url = "";
m_stream.notifyData = m_notifyData;
static char emptyMimeType[] = "";
m_pluginFuncs->newstream(m_instance, emptyMimeType, &m_stream, false, &m_transferMode);
m_pluginFuncs->destroystream(m_instance, &m_stream, m_reason);
// in successful requests, the URL is dynamically allocated and freed in our
// destructor, so reset it to 0
m_stream.url = 0;
}
m_pluginFuncs->urlnotify(m_instance, m_resourceRequest.url().string().utf8().data(), m_reason, m_notifyData);
if (m_loader)
m_loader->setDefersLoading(false);
}
m_streamState = StreamStopped;
if (!m_loadManually && m_client)
m_client->streamDidFinishLoading(this);
if (!m_path.isNull())
deleteFile(m_path);
}
开发者ID:AtlantisCD9,项目名称:Qt,代码行数:75,代码来源:PluginStream.cpp
示例14: protect
unsigned
RasterWeather::GetParameter() const
{
Poco::ScopedRWLock protect(lock, false);
return _parameter;
}
开发者ID:galippi,项目名称:xcsoar,代码行数:6,代码来源:RasterWeather.cpp
示例15: protect
QString JavaCodeMarker::markedUpEnumValue(const QString &enumValue,
const Node * /* relative */)
{
return protect(enumValue);
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:5,代码来源:javacodemarker.cpp
示例16: Get
/**
* Returns the current value of the flag.
*/
gcc_pure
bool Get() const {
ScopeLock protect(mutex);
return value;
}
开发者ID:joachimwieland,项目名称:xcsoar-jwieland,代码行数:8,代码来源:Flag.hpp
示例17: ASSERT
void ResourceLoader::didSendData(blink::WebURLLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent)
{
ASSERT(m_state == Initialized);
RefPtr<ResourceLoader> protect(this);
m_resource->didSendData(bytesSent, totalBytesToBeSent);
}
开发者ID:glenkim-dev,项目名称:blink-crosswalk,代码行数:6,代码来源:ResourceLoader.cpp
示例18: Set
/**
* Set a new value for the flag.
*/
void Set(bool _value=true) {
ScopeLock protect(mutex);
value = _value;
}
开发者ID:joachimwieland,项目名称:xcsoar-jwieland,代码行数:7,代码来源:Flag.hpp
示例19: protect
bool ResourceLoader::canAuthenticateAgainstProtectionSpace(const ProtectionSpace& protectionSpace)
{
Ref<ResourceLoader> protect(*this);
return frameLoader()->client().canAuthenticateAgainstProtectionSpace(documentLoader(), identifier(), protectionSpace);
}
开发者ID:Wrichik1999,项目名称:webkit,代码行数:5,代码来源:ResourceLoader.cpp
示例20: protect
void
DoubleBufferWindow::OnPaint(Canvas &canvas)
{
ScopeLock protect(mutex);
canvas.Copy(GetVisibleCanvas());
}
开发者ID:DRIZO,项目名称:xcsoar,代码行数:6,代码来源:DoubleBufferWindow.cpp
注:本文中的protect函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论