本文整理汇总了C++中nsCOMPtr::AsyncWait方法的典型用法代码示例。如果您正苦于以下问题:C++ nsCOMPtr::AsyncWait方法的具体用法?C++ nsCOMPtr::AsyncWait怎么用?C++ nsCOMPtr::AsyncWait使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsCOMPtr
的用法示例。
在下文中一共展示了nsCOMPtr::AsyncWait方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OpenSocket
void
nsGopherContentStream::OnCallbackPending()
{
nsresult rv;
// We have a callback, so failure means we should close the stream.
if (!mSocket) {
rv = OpenSocket(CallbackTarget());
} else if (mSocketInput) {
rv = mSocketInput->AsyncWait(this, 0, 0, CallbackTarget());
}
if (NS_FAILED(rv))
CloseWithStatus(rv);
}
示例2:
nsresult
nsGopherContentStream::OpenSocket(nsIEventTarget *target)
{
// This function is called to get things started.
// We begin by opening a socket to the specified host and wait for the
// socket to become writable.
nsCAutoString host;
nsresult rv = mChannel->URI()->GetAsciiHost(host);
if (NS_FAILED(rv))
return rv;
if (host.IsEmpty())
return NS_ERROR_MALFORMED_URI;
// For security reasons, don't allow anything expect the default
// gopher port (70). See bug 71916 - [email protected]
PRInt32 port = GOPHER_PORT;
// Create socket tranport
nsCOMPtr<nsISocketTransportService> sts =
do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv))
return rv;
rv = sts->CreateTransport(nsnull, 0, host, port, mChannel->ProxyInfo(),
getter_AddRefs(mSocket));
if (NS_FAILED(rv))
return rv;
// Setup progress and status notifications
rv = mSocket->SetEventSink(mChannel, target);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIOutputStream> output;
rv = mSocket->OpenOutputStream(0, 0, GOPHER_MAX_WRITE_SEGMENT_COUNT,
getter_AddRefs(output));
if (NS_FAILED(rv))
return rv;
mSocketOutput = do_QueryInterface(output);
NS_ENSURE_STATE(mSocketOutput);
return mSocketOutput->AsyncWait(this, 0, 0, target);
}
示例3: SendRequest
nsresult
nsGopherContentStream::OnSocketWritable()
{
// Write to output stream (we can do this in one big chunk)
nsresult rv = SendRequest();
if (NS_FAILED(rv))
return rv;
// Open input stream
nsCOMPtr<nsIInputStream> input;
rv = mSocket->OpenInputStream(0, 0, 0, getter_AddRefs(input));
if (NS_FAILED(rv))
return rv;
mSocketInput = do_QueryInterface(input, &rv);
NS_ASSERTION(CallbackTarget(), "where is my pending callback?");
rv = mSocketInput->AsyncWait(this, 0, 0, CallbackTarget());
return rv;
}