本文整理汇总了C++中NS_SUCCEEDED函数的典型用法代码示例。如果您正苦于以下问题:C++ NS_SUCCEEDED函数的具体用法?C++ NS_SUCCEEDED怎么用?C++ NS_SUCCEEDED使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NS_SUCCEEDED函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: NewURIFromString
void
HTMLTrackElement::LoadResource()
{
// Find our 'src' url
nsAutoString src;
if (!GetAttr(kNameSpaceID_None, nsGkAtoms::src, src)) {
return;
}
nsCOMPtr<nsIURI> uri;
nsresult rv = NewURIFromString(src, getter_AddRefs(uri));
NS_ENSURE_TRUE_VOID(NS_SUCCEEDED(rv));
LOG(PR_LOG_ALWAYS, ("%p Trying to load from src=%s", this,
NS_ConvertUTF16toUTF8(src).get()));
if (mChannel) {
mChannel->Cancel(NS_BINDING_ABORTED);
mChannel = nullptr;
}
rv = nsContentUtils::GetSecurityManager()->
CheckLoadURIWithPrincipal(NodePrincipal(), uri,
nsIScriptSecurityManager::STANDARD);
NS_ENSURE_TRUE_VOID(NS_SUCCEEDED(rv));
int16_t shouldLoad = nsIContentPolicy::ACCEPT;
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_MEDIA,
uri,
NodePrincipal(),
static_cast<Element*>(this),
NS_LITERAL_CSTRING("text/vtt"), // mime type
nullptr, // extra
&shouldLoad,
nsContentUtils::GetContentPolicy(),
nsContentUtils::GetSecurityManager());
NS_ENSURE_TRUE_VOID(NS_SUCCEEDED(rv));
if (NS_CP_REJECTED(shouldLoad)) {
return;
}
CreateTextTrack();
// Check for a Content Security Policy to pass down to the channel
// created to load the media content.
nsCOMPtr<nsIChannelPolicy> channelPolicy;
nsCOMPtr<nsIContentSecurityPolicy> csp;
rv = NodePrincipal()->GetCsp(getter_AddRefs(csp));
NS_ENSURE_TRUE_VOID(NS_SUCCEEDED(rv));
if (csp) {
channelPolicy = do_CreateInstance("@mozilla.org/nschannelpolicy;1");
if (!channelPolicy) {
return;
}
channelPolicy->SetContentSecurityPolicy(csp);
channelPolicy->SetLoadType(nsIContentPolicy::TYPE_MEDIA);
}
nsCOMPtr<nsIChannel> channel;
nsCOMPtr<nsILoadGroup> loadGroup = OwnerDoc()->GetDocumentLoadGroup();
rv = NS_NewChannel(getter_AddRefs(channel),
uri,
nullptr,
loadGroup,
nullptr,
nsIRequest::LOAD_NORMAL,
channelPolicy);
NS_ENSURE_TRUE_VOID(NS_SUCCEEDED(rv));
mListener = new WebVTTListener(this);
rv = mListener->LoadResource();
NS_ENSURE_TRUE_VOID(NS_SUCCEEDED(rv));
channel->SetNotificationCallbacks(mListener);
LOG(PR_LOG_DEBUG, ("opening webvtt channel"));
rv = channel->AsyncOpen(mListener, nullptr);
NS_ENSURE_TRUE_VOID(NS_SUCCEEDED(rv));
mChannel = channel;
}
开发者ID:MYSHLIFE,项目名称:gecko-dev,代码行数:78,代码来源:HTMLTrackElement.cpp
示例2: rect
// this is identical to nsHTMLContainerFrame::Paint except for the background and border.
NS_IMETHODIMP
nsFieldSetFrame::Paint(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer,
PRUint32 aFlags)
{
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {
// Paint our background and border
PRBool isVisible;
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) &&
isVisible && mRect.width && mRect.height) {
PRIntn skipSides = GetSkipSides();
const nsStyleBorder* borderStyle = GetStyleBorder();
const nsStylePadding* paddingStyle = GetStylePadding();
nscoord topBorder = borderStyle->GetBorderWidth(NS_SIDE_TOP);
nscoord yoff = 0;
// if the border is smaller than the legend. Move the border down
// to be centered on the legend.
if (topBorder < mLegendRect.height)
yoff = (mLegendRect.height - topBorder)/2;
nsRect rect(0, yoff, mRect.width, mRect.height - yoff);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *borderStyle,
*paddingStyle, PR_TRUE);
if (mLegendFrame) {
// Use the rect of the legend frame, not mLegendRect, so we draw our
// border under the legend's left and right margins.
const nsRect & legendRect = mLegendFrame->GetRect();
// we should probably use PaintBorderEdges to do this but for now just use clipping
// to achieve the same effect.
// draw left side
nsRect clipRect(rect);
clipRect.width = legendRect.x - rect.x;
clipRect.height = topBorder;
aRenderingContext.PushState();
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *borderStyle, mStyleContext, skipSides);
aRenderingContext.PopState();
// draw right side
clipRect = rect;
clipRect.x = legendRect.x + legendRect.width;
clipRect.width -= (legendRect.x + legendRect.width);
clipRect.height = topBorder;
aRenderingContext.PushState();
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *borderStyle, mStyleContext, skipSides);
aRenderingContext.PopState();
// draw bottom
clipRect = rect;
clipRect.y += topBorder;
clipRect.height = mRect.height - (yoff + topBorder);
aRenderingContext.PushState();
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *borderStyle, mStyleContext, skipSides);
aRenderingContext.PopState();
} else {
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect,
nsRect(0,0,mRect.width, mRect.height),
*borderStyle, mStyleContext, skipSides);
}
}
}
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
#ifdef DEBUG
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) && GetShowFrameBorders()) {
if (HasView()) {
aRenderingContext.SetColor(NS_RGB(0,0,255));
}
else {
aRenderingContext.SetColor(NS_RGB(255,0,0));
}
aRenderingContext.DrawRect(0, 0, mRect.width, mRect.height);
//.........这里部分代码省略.........
开发者ID:rn10950,项目名称:RetroZilla,代码行数:101,代码来源:nsFieldSetFrame.cpp
示例3: Reset
NS_IMETHODIMP
nsAuthSASL::GetNextToken(const void *inToken,
uint32_t inTokenLen,
void **outToken,
uint32_t *outTokenLen)
{
nsresult rv;
void *unwrappedToken;
char *message;
uint32_t unwrappedTokenLen, messageLen;
nsAutoCString userbuf;
if (!mInnerModule)
return NS_ERROR_NOT_INITIALIZED;
if (mSASLReady) {
// If the server COMPLETEs with an empty token, Cyrus sends us that token.
// I don't think this is correct, but we need to handle that behaviour.
// Cyrus ignores the contents of our reply token.
if (inTokenLen == 0) {
*outToken = nullptr;
*outTokenLen = 0;
return NS_OK;
}
// We've completed the GSSAPI portion of the handshake, and are
// now ready to do the SASL security layer and authzid negotiation
// Input packet from the server needs to be unwrapped.
rv = mInnerModule->Unwrap(inToken, inTokenLen, &unwrappedToken,
&unwrappedTokenLen);
if (NS_FAILED(rv)) {
Reset();
return rv;
}
// If we were doing security layers then we'd care what the
// server had sent us. We're not, so all we had to do was make
// sure that the signature was correct with the above unwrap()
nsMemory::Free(unwrappedToken);
NS_CopyUnicodeToNative(mUsername, userbuf);
messageLen = userbuf.Length() + 4 + 1;
message = (char *)nsMemory::Alloc(messageLen);
if (!message) {
Reset();
return NS_ERROR_OUT_OF_MEMORY;
}
message[0] = 0x01; // No security layer
message[1] = 0x00;
message[2] = 0x00;
message[3] = 0x00; // Maxbuf must be zero if we've got no sec layer
strcpy(message+4, userbuf.get());
// Userbuf should not be nullptr terminated, so trim the trailing nullptr
// when wrapping the message
rv = mInnerModule->Wrap((void *) message, messageLen-1, false,
outToken, outTokenLen);
nsMemory::Free(message);
Reset(); // All done
return NS_SUCCEEDED(rv) ? NS_SUCCESS_AUTH_FINISHED : rv;
}
rv = mInnerModule->GetNextToken(inToken, inTokenLen, outToken,
outTokenLen);
if (rv == NS_SUCCESS_AUTH_FINISHED) {
mSASLReady = true;
rv = NS_OK;
}
return rv;
}
开发者ID:AOSC-Dev,项目名称:Pale-Moon,代码行数:68,代码来源:nsAuthSASL.cpp
示例4: InitOperators
static nsresult
InitOperators(void)
{
// Load the property file containing the Operator Dictionary
nsresult rv;
nsCOMPtr<nsIPersistentProperties> mathfontProp;
rv = NS_LoadPersistentPropertiesFromURISpec(
getter_AddRefs(mathfontProp),
NS_LITERAL_CSTRING("resource://gre/res/fonts/mathfont.properties"),
nsContentUtils::GetSystemPrincipal(),
nsIContentPolicy::TYPE_OTHER);
if (NS_FAILED(rv)) return rv;
// Parse the Operator Dictionary in two passes.
// The first pass is to count the number of operators; the second pass is to
// allocate the necessary space for them and to add them in the hash table.
for (int32_t pass = 1; pass <= 2; pass++) {
OperatorData dummyData;
OperatorData* operatorData = &dummyData;
nsCOMPtr<nsISimpleEnumerator> iterator;
if (NS_SUCCEEDED(mathfontProp->Enumerate(getter_AddRefs(iterator)))) {
bool more;
uint32_t index = 0;
nsAutoCString name;
nsAutoString attributes;
while ((NS_SUCCEEDED(iterator->HasMoreElements(&more))) && more) {
nsCOMPtr<nsISupports> supports;
nsCOMPtr<nsIPropertyElement> element;
if (NS_SUCCEEDED(iterator->GetNext(getter_AddRefs(supports)))) {
element = do_QueryInterface(supports);
if (NS_SUCCEEDED(element->GetKey(name)) &&
NS_SUCCEEDED(element->GetValue(attributes))) {
// expected key: operator.\uNNNN.{infix,postfix,prefix}
if ((21 <= name.Length()) && (0 == name.Find("operator.\\u"))) {
name.Cut(0, 9); // 9 is the length of "operator.";
int32_t len = name.Length();
nsOperatorFlags form = 0;
if (kNotFound != name.RFind(".infix")) {
form = NS_MATHML_OPERATOR_FORM_INFIX;
len -= 6; // 6 is the length of ".infix";
}
else if (kNotFound != name.RFind(".postfix")) {
form = NS_MATHML_OPERATOR_FORM_POSTFIX;
len -= 8; // 8 is the length of ".postfix";
}
else if (kNotFound != name.RFind(".prefix")) {
form = NS_MATHML_OPERATOR_FORM_PREFIX;
len -= 7; // 7 is the length of ".prefix";
}
else continue; // input is not applicable
name.SetLength(len);
if (2 == pass) { // allocate space and start the storage
if (!gOperatorArray) {
if (0 == gOperatorCount) return NS_ERROR_UNEXPECTED;
gOperatorArray = new OperatorData[gOperatorCount];
if (!gOperatorArray) return NS_ERROR_OUT_OF_MEMORY;
}
operatorData = &gOperatorArray[index];
}
else {
form = 0; // to quickly return from SetOperator() at pass 1
}
// See if the operator should be retained
if (SetOperator(operatorData, form, name, attributes)) {
index++;
if (1 == pass) gOperatorCount = index;
}
}
}
}
}
}
}
return NS_OK;
}
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:76,代码来源:nsMathMLOperators.cpp
示例5: NS_ENSURE_ARG
NS_IMETHODIMP
nsParserUtils::ParseFragment(const nsAString& aFragment,
PRUint32 aFlags,
bool aIsXML,
nsIURI* aBaseURI,
nsIDOMElement* aContextElement,
nsIDOMDocumentFragment** aReturn)
{
NS_ENSURE_ARG(aContextElement);
*aReturn = nsnull;
nsresult rv;
nsCOMPtr<nsIParser> parser = do_CreateInstance(kCParserCID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> document;
nsCOMPtr<nsIDOMDocument> domDocument;
nsCOMPtr<nsIDOMNode> contextNode;
contextNode = do_QueryInterface(aContextElement);
contextNode->GetOwnerDocument(getter_AddRefs(domDocument));
document = do_QueryInterface(domDocument);
NS_ENSURE_TRUE(document, NS_ERROR_NOT_AVAILABLE);
nsAutoScriptBlockerSuppressNodeRemoved autoBlocker;
// stop scripts
nsRefPtr<nsScriptLoader> loader;
bool scripts_enabled = false;
if (document) {
loader = document->ScriptLoader();
scripts_enabled = loader->GetEnabled();
}
if (scripts_enabled) {
loader->SetEnabled(false);
}
// Wrap things in a div or body for parsing, but it won't show up in
// the fragment.
nsAutoTArray<nsString, 2> tagStack;
nsCAutoString base, spec;
if (aIsXML) {
// XHTML
if (aBaseURI) {
base.Append(NS_LITERAL_CSTRING(XHTML_DIV_TAG));
base.Append(NS_LITERAL_CSTRING(" xml:base=\""));
aBaseURI->GetSpec(spec);
// nsEscapeHTML is good enough, because we only need to get
// quotes, ampersands, and angle brackets
char* escapedSpec = nsEscapeHTML(spec.get());
if (escapedSpec)
base += escapedSpec;
NS_Free(escapedSpec);
base.Append(NS_LITERAL_CSTRING("\""));
tagStack.AppendElement(NS_ConvertUTF8toUTF16(base));
} else {
tagStack.AppendElement(NS_LITERAL_STRING(XHTML_DIV_TAG));
}
}
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIContent> fragment;
if (aIsXML) {
rv = nsContentUtils::ParseFragmentXML(aFragment,
document,
tagStack,
true,
aReturn);
fragment = do_QueryInterface(*aReturn);
} else {
NS_NewDocumentFragment(aReturn,
document->NodeInfoManager());
fragment = do_QueryInterface(*aReturn);
rv = nsContentUtils::ParseFragmentHTML(aFragment,
fragment,
nsGkAtoms::body,
kNameSpaceID_XHTML,
false,
true);
// Now, set the base URI on all subtree roots.
if (aBaseURI) {
aBaseURI->GetSpec(spec);
nsAutoString spec16;
CopyUTF8toUTF16(spec, spec16);
nsIContent* node = fragment->GetFirstChild();
while (node) {
if (node->IsElement()) {
node->SetAttr(kNameSpaceID_XML,
nsGkAtoms::base,
nsGkAtoms::xml,
spec16,
false);
}
node = node->GetNextSibling();
}
}
}
if (fragment) {
nsTreeSanitizer sanitizer(aFlags);
sanitizer.Sanitize(fragment);
}
//.........这里部分代码省略.........
开发者ID:msliu,项目名称:mozilla-central,代码行数:101,代码来源:nsParserUtils.cpp
示例6: MOZ_ASSERT
// static
nsresult
IDBFactory::AllowedForWindowInternal(nsPIDOMWindow* aWindow,
nsIPrincipal** aPrincipal)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aWindow);
MOZ_ASSERT(aWindow->IsInnerWindow());
if (NS_WARN_IF(!IndexedDatabaseManager::GetOrCreate())) {
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
nsIDocument* document = aWindow->GetExtantDoc();
if (document->GetSandboxFlags() & SANDBOXED_ORIGIN) {
return NS_ERROR_DOM_SECURITY_ERR;
}
nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(aWindow);
MOZ_ASSERT(sop);
nsCOMPtr<nsIPrincipal> principal = sop->GetPrincipal();
if (NS_WARN_IF(!principal)) {
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
if (nsContentUtils::IsSystemPrincipal(principal)) {
principal.forget(aPrincipal);
return NS_OK;
}
bool isNullPrincipal;
if (NS_WARN_IF(NS_FAILED(principal->GetIsNullPrincipal(&isNullPrincipal))) ||
isNullPrincipal) {
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
// Whitelist about:home, since it doesn't have a base domain it would not
// pass the ThirdPartyUtil check, though it should be able to use indexedDB.
bool skipThirdPartyCheck = false;
nsCOMPtr<nsIURI> uri;
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(principal->GetURI(getter_AddRefs(uri))));
bool isAbout;
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(uri->SchemeIs("about", &isAbout)));
if (isAbout) {
nsCOMPtr<nsIAboutModule> module;
if (NS_SUCCEEDED(NS_GetAboutModule(uri, getter_AddRefs(module)))) {
uint32_t flags;
if (NS_SUCCEEDED(module->GetURIFlags(uri, &flags))) {
skipThirdPartyCheck = flags & nsIAboutModule::ENABLE_INDEXED_DB;
} else {
NS_WARNING("GetURIFlags failed!");
}
} else {
NS_WARNING("NS_GetAboutModule failed!");
}
}
if (!skipThirdPartyCheck) {
nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil =
do_GetService(THIRDPARTYUTIL_CONTRACTID);
MOZ_ASSERT(thirdPartyUtil);
bool isThirdParty;
if (NS_WARN_IF(NS_FAILED(
thirdPartyUtil->IsThirdPartyWindow(aWindow,
nullptr,
&isThirdParty)))) {
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
if (isThirdParty) {
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
}
}
principal.forget(aPrincipal);
return NS_OK;
}
开发者ID:Acidburn0zzz,项目名称:tor-browser,代码行数:82,代码来源:IDBFactory.cpp
示例7:
~ScopedXPCOM()
{
if (NS_SUCCEEDED(rv))
NS_ShutdownXPCOM(nsnull);
}
开发者ID:LittleForker,项目名称:mozilla-central,代码行数:5,代码来源:TestCookie.cpp
示例8: main
//.........这里部分代码省略.........
GetACookieNoHttp(cookieService, "http://httponly.test/", getter_Copies(cookie));
rv[4] = CheckResult(cookie.get(), MUST_BE_NULL);
// Non-Http cookies should not delete HttpOnly cookies
SetACookie(cookieService, "http://httponly.test/", nsnull, "test=httponly; httponly", nsnull);
SetACookieNoHttp(cookieService, "http://httponly.test/", "test=httponly; max-age=-1");
GetACookie(cookieService, "http://httponly.test/", nsnull, getter_Copies(cookie));
rv[5] = CheckResult(cookie.get(), MUST_EQUAL, "test=httponly");
// ... but HttpOnly cookies should
SetACookie(cookieService, "http://httponly.test/", nsnull, "test=httponly; httponly; max-age=-1", nsnull);
GetACookie(cookieService, "http://httponly.test/", nsnull, getter_Copies(cookie));
rv[6] = CheckResult(cookie.get(), MUST_BE_NULL);
// Non-Httponly cookies can replace HttpOnly cookies when set over http
SetACookie(cookieService, "http://httponly.test/", nsnull, "test=httponly; httponly", nsnull);
SetACookie(cookieService, "http://httponly.test/", nsnull, "test=not-httponly", nsnull);
GetACookieNoHttp(cookieService, "http://httponly.test/", getter_Copies(cookie));
rv[7] = CheckResult(cookie.get(), MUST_EQUAL, "test=not-httponly");
// scripts should not be able to set httponly cookies by replacing an existing non-httponly cookie
SetACookie(cookieService, "http://httponly.test/", nsnull, "test=not-httponly", nsnull);
SetACookieNoHttp(cookieService, "http://httponly.test/", "test=httponly; httponly");
GetACookieNoHttp(cookieService, "http://httponly.test/", getter_Copies(cookie));
rv[8] = CheckResult(cookie.get(), MUST_EQUAL, "test=not-httponly");
allTestsPassed = PrintResult(rv, 9) && allTestsPassed;
// *** nsICookieManager{2} interface tests
sBuffer = PR_sprintf_append(sBuffer, "*** Beginning nsICookieManager{2} interface tests...\n");
nsCOMPtr<nsICookieManager> cookieMgr = do_GetService(NS_COOKIEMANAGER_CONTRACTID, &rv0);
if (NS_FAILED(rv0)) return -1;
nsCOMPtr<nsICookieManager2> cookieMgr2 = do_QueryInterface(cookieMgr);
if (!cookieMgr2) return -1;
// first, ensure a clean slate
rv[0] = NS_SUCCEEDED(cookieMgr->RemoveAll());
// add some cookies
rv[1] = NS_SUCCEEDED(cookieMgr2->Add(NS_LITERAL_CSTRING("cookiemgr.test"), // domain
NS_LITERAL_CSTRING("/foo"), // path
NS_LITERAL_CSTRING("test1"), // name
NS_LITERAL_CSTRING("yes"), // value
PR_FALSE, // is secure
PR_FALSE, // is httponly
PR_TRUE, // is session
LL_MAXINT)); // expiry time
rv[2] = NS_SUCCEEDED(cookieMgr2->Add(NS_LITERAL_CSTRING("cookiemgr.test"), // domain
NS_LITERAL_CSTRING("/foo"), // path
NS_LITERAL_CSTRING("test2"), // name
NS_LITERAL_CSTRING("yes"), // value
PR_FALSE, // is secure
PR_TRUE, // is httponly
PR_TRUE, // is session
PR_Now() / PR_USEC_PER_SEC + 2)); // expiry time
rv[3] = NS_SUCCEEDED(cookieMgr2->Add(NS_LITERAL_CSTRING("new.domain"), // domain
NS_LITERAL_CSTRING("/rabbit"), // path
NS_LITERAL_CSTRING("test3"), // name
NS_LITERAL_CSTRING("yes"), // value
PR_FALSE, // is secure
PR_FALSE, // is httponly
PR_TRUE, // is session
LL_MAXINT)); // expiry time
// confirm using enumerator
nsCOMPtr<nsISimpleEnumerator> enumerator;
rv[4] = NS_SUCCEEDED(cookieMgr->GetEnumerator(getter_AddRefs(enumerator)));
PRInt32 i = 0;
PRBool more;
nsCOMPtr<nsICookie2> expiredCookie, newDomainCookie;
while (NS_SUCCEEDED(enumerator->HasMoreElements(&more)) && more) {
开发者ID:LittleForker,项目名称:mozilla-central,代码行数:67,代码来源:TestCookie.cpp
示例9: AuthCertificateHook
// Extracts whatever information we need out of fd (using SSL_*) and passes it
// to SSLServerCertVerificationJob::Dispatch. SSLServerCertVerificationJob should
// never do anything with fd except logging.
SECStatus
AuthCertificateHook(void *arg, PRFileDesc *fd, PRBool checkSig, PRBool isServer)
{
// Runs on the socket transport thread
PR_LOG(gPIPNSSLog, PR_LOG_DEBUG,
("[%p] starting AuthCertificateHook\n", fd));
// Modern libssl always passes PR_TRUE for checkSig, and we have no means of
// doing verification without checking signatures.
NS_ASSERTION(checkSig, "AuthCertificateHook: checkSig unexpectedly false");
// PSM never causes libssl to call this function with PR_TRUE for isServer,
// and many things in PSM assume that we are a client.
NS_ASSERTION(!isServer, "AuthCertificateHook: isServer unexpectedly true");
nsNSSSocketInfo *socketInfo = static_cast<nsNSSSocketInfo*>(arg);
if (socketInfo) {
// This is the first callback during full handshakes.
socketInfo->SetFirstServerHelloReceived();
}
CERTCertificate *serverCert = SSL_PeerCertificate(fd);
CERTCertificateCleaner serverCertCleaner(serverCert);
if (!checkSig || isServer || !socketInfo || !serverCert) {
PR_SetError(PR_INVALID_STATE_ERROR, 0);
return SECFailure;
}
if (BlockServerCertChangeForSpdy(socketInfo, serverCert) != SECSuccess)
return SECFailure;
bool onSTSThread;
nsresult nrv;
nsCOMPtr<nsIEventTarget> sts
= do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &nrv);
if (NS_SUCCEEDED(nrv)) {
nrv = sts->IsOnCurrentThread(&onSTSThread);
}
if (NS_FAILED(nrv)) {
NS_ERROR("Could not get STS service or IsOnCurrentThread failed");
PR_SetError(PR_UNKNOWN_ERROR, 0);
return SECFailure;
}
if (onSTSThread) {
// We *must* do certificate verification on a background thread because
// we need the socket transport thread to be free for our OCSP requests,
// and we *want* to do certificate verification on a background thread
// because of the performance benefits of doing so.
socketInfo->SetCertVerificationWaiting();
SECStatus rv = SSLServerCertVerificationJob::Dispatch(
static_cast<const void *>(fd), socketInfo, serverCert);
return rv;
}
// We can't do certificate verification on a background thread, because the
// thread doing the network I/O may not interrupt its network I/O on receipt
// of our SSLServerCertVerificationResult event, and/or it might not even be
// a non-blocking socket.
SECStatus rv = AuthCertificate(socketInfo, serverCert);
if (rv == SECSuccess) {
return SECSuccess;
}
PRErrorCode error = PR_GetError();
if (error != 0) {
nsRefPtr<CertErrorRunnable> runnable = CreateCertErrorRunnable(
error, socketInfo, serverCert,
static_cast<const void *>(fd));
if (!runnable) {
// CreateCertErrorRunnable sets a new error code when it fails
error = PR_GetError();
} else {
// We have to return SECSuccess or SECFailure based on the result of the
// override processing, so we must block this thread waiting for it. The
// CertErrorRunnable will NOT dispatch the result at all, since we passed
// false for CreateCertErrorRunnable's async parameter
nrv = runnable->DispatchToMainThreadAndWait();
if (NS_FAILED(nrv)) {
NS_ERROR("Failed to dispatch CertErrorRunnable");
PR_SetError(PR_INVALID_STATE_ERROR, 0);
return SECFailure;
}
if (!runnable->mResult) {
NS_ERROR("CertErrorRunnable did not set result");
PR_SetError(PR_INVALID_STATE_ERROR, 0);
return SECFailure;
}
if (runnable->mResult->mErrorCode == 0) {
return SECSuccess; // cert error override occurred.
}
//.........这里部分代码省略.........
开发者ID:vdt,项目名称:mozilla-central,代码行数:101,代码来源:SSLServerCertVerification.cpp
示例10: NS_ENSURE_ARG_POINTER
//.........这里部分代码省略.........
ulResponse = WinMessageBox(HWND_DESKTOP, mWnd, pszFullText,
gpszFDSaveCaption, 0,
MB_YESNO | MB_MOVEABLE | MB_WARNING);
}
if (ulResponse == MBID_YES) {
fileExists = false;
}
}
}
} while (mMode == modeSave && fileExists && filedlg.lReturn == DID_OK);
if (filedlg.lReturn == DID_OK) {
result = true;
if (mMode == modeOpenMultiple) {
nsresult rv;
if (filedlg.papszFQFilename) {
for (ULONG i=0;i<filedlg.ulFQFCount;i++) {
nsCOMPtr<nsIFile> file = do_CreateInstance("@mozilla.org/file/local;1", &rv);
NS_ENSURE_SUCCESS(rv,rv);
rv = file->InitWithNativePath(nsDependentCString(*(filedlg.papszFQFilename)[i]));
NS_ENSURE_SUCCESS(rv,rv);
rv = mFiles.AppendObject(file);
NS_ENSURE_SUCCESS(rv,rv);
}
WinFreeFileDlgList(filedlg.papszFQFilename);
} else {
nsCOMPtr<nsIFile> file = do_CreateInstance("@mozilla.org/file/local;1", &rv);
NS_ENSURE_SUCCESS(rv,rv);
rv = file->InitWithNativePath(nsDependentCString(filedlg.szFullFile));
NS_ENSURE_SUCCESS(rv,rv);
rv = mFiles.AppendObject(file);
NS_ENSURE_SUCCESS(rv,rv);
}
} else {
mFile.Assign(filedlg.szFullFile);
}
mSelectedType = (int16_t)pmydata->ulCurExt;
}
for (i = 0; i < mTitles.Length(); i++)
{
nsMemory::Free(*(filedlg.papszITypeList[i]));
}
free(filedlg.papszITypeList);
for (i = 0; i < mFilters.Length(); i++)
{
nsMemory::Free(*(pmydata->papszIFilterList[i]));
}
free(pmydata->papszIFilterList);
free(pmydata);
}
if (title)
nsMemory::Free( title );
if (result) {
int16_t returnOKorReplace = returnOK;
nsresult rv;
// Remember last used directory.
nsCOMPtr<nsIFile> file(do_CreateInstance("@mozilla.org/file/local;1", &rv));
NS_ENSURE_SUCCESS(rv, rv);
file->InitWithNativePath(mFile);
nsCOMPtr<nsIFile> dir;
if (NS_SUCCEEDED(file->GetParent(getter_AddRefs(dir)))) {
nsAutoCString newDir;
dir->GetNativePath(newDir);
if(!newDir.IsEmpty())
PL_strncpyz(mLastUsedDirectory, newDir.get(), MAX_PATH+1);
// Update mDisplayDirectory with this directory, also.
// Some callers rely on this.
if (!mDisplayDirectory)
mDisplayDirectory = do_CreateInstance("@mozilla.org/file/local;1");
if (mDisplayDirectory)
mDisplayDirectory->InitWithNativePath( nsDependentCString(mLastUsedDirectory) );
}
if (mMode == modeSave) {
// Windows does not return resultReplace,
// we must check if file already exists
bool exists = false;
file->Exists(&exists);
if (exists)
returnOKorReplace = returnReplace;
}
*retval = returnOKorReplace;
}
else {
*retval = returnCancel;
}
return NS_OK;
}
开发者ID:drexler,项目名称:releases-mozilla-aurora,代码行数:101,代码来源:nsFilePicker.cpp
示例11: main
int
main(int argc, char* argv[])
{
if (test_common_init(&argc, &argv) != 0)
return -1;
nsresult rv;
if (argc < 2) {
printf("usage: %s <file-to-read>\n", argv[0]);
return -1;
}
char* fileName = argv[1];
{
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
if (registrar)
registrar->AutoRegister(nsnull);
#if defined(PR_LOGGING)
gTestLog = PR_NewLogModule("Test");
#endif
nsCOMPtr<nsILocalFile> srcFile;
rv = NS_NewNativeLocalFile(nsDependentCString(fileName), false, getter_AddRefs(srcFile));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIFile> destFile;
rv = srcFile->Clone(getter_AddRefs(destFile));
if (NS_FAILED(rv)) return rv;
nsCAutoString leafName;
rv = destFile->GetNativeLeafName(leafName);
if (NS_FAILED(rv)) return rv;
nsCAutoString newName(leafName);
newName.Append(NS_LITERAL_CSTRING(".1"));
rv = destFile->SetNativeLeafName(newName);
if (NS_FAILED(rv)) return rv;
rv = RunTest(srcFile, destFile);
NS_ASSERTION(NS_SUCCEEDED(rv), "RunTest failed");
newName = leafName;
newName.Append(NS_LITERAL_CSTRING(".2"));
rv = destFile->SetNativeLeafName(newName);
if (NS_FAILED(rv)) return rv;
rv = RunBlockingTest(srcFile, destFile);
NS_ASSERTION(NS_SUCCEEDED(rv), "RunBlockingTest failed");
// give background threads a chance to finish whatever work they may
// be doing.
PR_Sleep(PR_SecondsToInterval(1));
} // this scopes the nsCOMPtrs
// no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
rv = NS_ShutdownXPCOM(nsnull);
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
return NS_OK;
}
开发者ID:Anachid,项目名称:mozilla-central,代码行数:62,代码来源:TestStreamTransport.cpp
示例12: SplitExpatName
nsresult
RDFContentSinkImpl::OpenProperty(const PRUnichar* aName, const PRUnichar** aAttributes)
{
nsresult rv;
// an "object" non-terminal is either a "description", a "typed
// node", or a "container", so this change the content sink's
// state appropriately.
nsCOMPtr<nsIAtom> localName;
const nsDependentSubstring& nameSpaceURI =
SplitExpatName(aName, getter_AddRefs(localName));
const char* attrName;
localName->GetUTF8String(&attrName);
NS_ConvertUTF16toUTF8 propertyStr(nameSpaceURI);
propertyStr.Append(attrName);
nsCOMPtr<nsIRDFResource> property;
rv = gRDFService->GetResource(propertyStr, getter_AddRefs(property));
if (NS_FAILED(rv)) return rv;
// See if they've specified a 'resource' attribute, in which case
// they mean *that* to be the object of this property.
nsCOMPtr<nsIRDFResource> target;
GetResourceAttribute(aAttributes, getter_AddRefs(target));
PRBool isAnonymous = PR_FALSE;
if (! target) {
// See if an 'ID' attribute has been specified, in which case
// this corresponds to the fourth form of [6.12].
// XXX strictly speaking, we should reject the RDF/XML as
// invalid if they've specified both an 'ID' and a 'resource'
// attribute. Bah.
// XXX strictly speaking, 'about=' isn't allowed here, but
// what the hell.
GetIdAboutAttribute(aAttributes, getter_AddRefs(target), &isAnonymous);
}
if (target) {
// They specified an inline resource for the value of this
// property. Create an RDF resource for the inline resource
// URI, add the properties to it, and attach the inline
// resource to its parent.
PRInt32 count;
rv = AddProperties(aAttributes, target, &count);
NS_ASSERTION(NS_SUCCEEDED(rv), "problem adding properties");
if (NS_FAILED(rv)) return rv;
if (count || !isAnonymous) {
// If the resource was "anonymous" (i.e., they hadn't
// explicitly set an ID or resource attribute), then we'll
// only assert this property from the context element *if*
// there were properties specified on the anonymous
// resource.
rv = mDataSource->Assert(GetContextElement(0), property, target, PR_TRUE);
if (NS_FAILED(rv)) return rv;
}
// XXX Technically, we should _not_ fall through here and push
// the element onto the stack: this is supposed to be a closed
// node. But right now I'm lazy and the code will just Do The
// Right Thing so long as the RDF is well-formed.
}
// Push the element onto the context stack and change state.
PushContext(property, mState, mParseMode);
mState = eRDFContentSinkState_InPropertyElement;
SetParseMode(aAttributes);
return NS_OK;
}
开发者ID:MozillaOnline,项目名称:gecko-dev,代码行数:75,代码来源:nsRDFContentSink.cpp
示例13: NS_NewURI
//.........这里部分代码省略.........
return SucceedWithResponse();
}
return FailWithNetworkError();
}
if (scheme.LowerCaseEqualsLiteral("blob")) {
nsRefPtr<FileImpl> blobImpl;
rv = NS_GetBlobForBlobURI(uri, getter_AddRefs(blobImpl));
FileImpl* blob = static_cast<FileImpl*>(blobImpl.get());
if (NS_WARN_IF(NS_FAILED(rv))) {
FailWithNetworkError();
return rv;
}
nsRefPtr<InternalResponse> response = new InternalResponse(200, NS_LITERAL_CSTRING("OK"));
{
ErrorResult result;
uint64_t size = blob->GetSize(result);
if (NS_WARN_IF(result.Failed())) {
FailWithNetworkError();
return result.ErrorCode();
}
nsAutoString sizeStr;
sizeStr.AppendInt(size);
response->Headers()->Append(NS_LITERAL_CSTRING("Content-Length"), NS_ConvertUTF16toUTF8(sizeStr), result);
if (NS_WARN_IF(result.Failed())) {
FailWithNetworkError();
return result.ErrorCode();
}
nsAutoString type;
blob->GetType(type);
response->Headers()->Append(NS_LITERAL_CSTRING("Content-Type"), NS_ConvertUTF16toUTF8(type), result);
if (NS_WARN_IF(result.Failed())) {
FailWithNetworkError();
return result.ErrorCode();
}
}
nsCOMPtr<nsIInputStream> stream;
rv = blob->GetInternalStream(getter_AddRefs(stream));
if (NS_WARN_IF(NS_FAILED(rv))) {
FailWithNetworkError();
return rv;
}
response->SetBody(stream);
BeginResponse(response);
return SucceedWithResponse();
}
if (scheme.LowerCaseEqualsLiteral("data")) {
nsAutoCString method;
mRequest->GetMethod(method);
if (method.LowerCaseEqualsASCII("get")) {
// Use nsDataHandler directly so that we can extract the content type.
// XXX(nsm): Is there a way to acquire the charset without such tight
// coupling with the DataHandler? nsIProtocolHandler does not provide
// anything similar.
nsAutoCString contentType, contentCharset, dataBuffer, hashRef;
bool isBase64;
rv = nsDataHandler::ParseURI(url,
contentType,
contentCharset,
isBase64,
dataBuffer,
hashRef);
if (NS_SUCCEEDED(rv)) {
ErrorResult result;
nsRefPtr<InternalResponse> response = new InternalResponse(200, NS_LITERAL_CSTRING("OK"));
if (!contentCharset.IsEmpty()) {
contentType.Append(";charset=");
contentType.Append(contentCharset);
}
response->Headers()->Append(NS_LITERAL_CSTRING("Content-Type"), contentType, result);
if (!result.Failed()) {
nsCOMPtr<nsIInputStream> stream;
rv = NS_NewCStringInputStream(getter_AddRefs(stream), dataBuffer);
if (NS_SUCCEEDED(rv)) {
response->SetBody(stream);
BeginResponse(response);
return SucceedWithResponse();
}
}
}
}
return FailWithNetworkError();
}
if (scheme.LowerCaseEqualsLiteral("file")) {
} else if (scheme.LowerCaseEqualsLiteral("http") ||
scheme.LowerCaseEqualsLiteral("https")) {
return HttpFetch();
}
return FailWithNetworkError();
}
开发者ID:RobertJGabriel,项目名称:Waterfox,代码行数:101,代码来源:FetchDriver.cpp
示例14: theHandler
//.........这里部分代码省略.........
(numProfiles > 1) ? deleteButton->Enable() : deleteButton->Disable();
table->SelectCell(selectedCell);
// Handle the "Ask At StartUp" checkbox
LCheckBox *showAtStartCheck = (LCheckBox*) theDialog->FindPaneByID('Show');
ThrowIfNil_(showAtStartCheck);
PRBool showIt;
rv = GetShowDialogOnStart(&showIt);
if (NS_FAILED(rv))
showIt = PR_TRUE;
showAtStartCheck->SetValue(showIt);
theDialog->Show();
theDialog->Select();
while (true) // This is our modal dialog event loop
{
MessageT hitMessage = theHandler.DoDialog();
if (hitMessage == msg_OK)
{
theDialog->Hide();
SetShowDialogOnStart(showAtStartCheck->GetValue());
selectedCell = table->GetFirstSelectedCell();
if (selectedCell.row > 0)
{
dataSize = sizeof(dataBuf) - 1;
table->GetCellData(selectedCell, dataBuf, dataSize);
dataBuf[dataSize] = '\0';
CPlatformUCSConversion::GetInstance()->PlatformToUCS(nsDependentCString(dataBuf), unicodeStr);
rv = profileService->SetCurrentProfile(unicodeStr.get());
}
break;
}
else if (hitMessage == msg_Cancel)
{
break;
}
else if (hitMessage == msg_OnNewProfile)
{
if (DoNewProfileDialog(dataBuf, sizeof(dataBuf)))
{
CPlatformUCSConversion::GetInstance()->PlatformToUCS(nsDependentCString(dataBuf), unicodeStr);
rv = profileService->CreateNewProfile(unicodeStr.get(), nsnull, nsnull, PR_FALSE);
if (NS_FAILED(rv))
break;
table->InsertRows(1, LONG_MAX, dataBuf, strlen(dataBuf), true);
table->GetTableSize(rows, cols);
table->SelectCell(STableCell(rows, cols));
rv = profileService->GetProfileCount(&numProfiles);
(NS_SUCCEEDED(rv) && numProfiles > 1) ? deleteButton->Enable() : deleteButton->Disable();
}
}
else if (hitMessage == msg_OnDeleteProfile)
{
selectedCell = table->GetFirstSelectedCell();
if (selectedCell.row > 0)
{
dataSize = sizeof(dataBuf) - 1;
table->GetCellData(selectedCell, dataBuf, dataSize);
dataBuf[dataSize] = '\0';
CPlatformUCSConversion::GetInstance()->PlatformToUCS(nsDependentCString(dataBuf), unicodeStr);
rv = profileService->DeleteProfile(unicodeStr.get(), PR_TRUE);
if (NS_FAILED(rv))
break;
table->RemoveRows(1, selectedCell.row, true);
table->GetTableSize(rows, cols);
if (selectedCell.row >= rows)
selectedCell.row = rows - 1;
table->SelectCell(selectedCell);
rv = profileService->GetProfileCount(&numProfiles);
(NS_SUCCEEDED(rv) && numProfiles > 1) ? deleteButton->Enable() : deleteButton->Disable();
}
}
else if (hitMessage == msg_OnRenameProfile)
{
nsAutoString oldName;
selectedCell = table->GetFirstSelectedCell();
dataSize = sizeof(dataBuf) - 1;
table->GetCellData(selectedCell, dataBuf, dataSize);
dataBuf[dataSize] = '\0';
CPlatformUCSConversion::GetInstance()->PlatformToUCS(nsDependentCString(dataBuf), oldName);
if (DoNewProfileDialog(dataBuf, sizeof(dataBuf)))
{
CPlatformUCSConversion::GetInstance()->PlatformToUCS(nsDependentCString(dataBuf), unicodeStr);
profileService->RenameProfile(oldName.get(), unicodeStr.get());
table->SetCellData(selectedCell, dataBuf, strlen(dataBuf));
}
}
}
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:101,代码来源:CProfileManager.cpp
|
请发表评论