本文整理汇总了C++中PRInt64函数的典型用法代码示例。如果您正苦于以下问题:C++ PRInt64函数的具体用法?C++ PRInt64怎么用?C++ PRInt64使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PRInt64函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PRInt64
void nsIndexedToHTML::FormatSizeString(PRInt64 inSize, nsString& outSizeString)
{
outSizeString.Truncate();
if (inSize > PRInt64(0)) {
// round up to the nearest Kilobyte
PRInt64 upperSize = (inSize + PRInt64(1023)) / PRInt64(1024);
outSizeString.AppendInt(upperSize);
outSizeString.AppendLiteral(" KB");
}
}
示例2: PR_Now
void
nsIncrementalDownload::UpdateProgress()
{
mLastProgressUpdate = PR_Now();
if (mProgressSink)
mProgressSink->OnProgress(this, mObserverContext,
PRUint64(PRInt64(mCurrentSize) + mChunkLen),
PRUint64(PRInt64(mTotalSize)));
}
示例3: NS_ASSERTION
nsresult
nsIncrementalDownload::ProcessTimeout()
{
NS_ASSERTION(!mChannel, "how can we have a channel?");
// Handle existing error conditions
if (NS_FAILED(mStatus)) {
CallOnStopRequest();
return NS_OK;
}
// Fetch next chunk
nsCOMPtr<nsIChannel> channel;
nsresult rv = NS_NewChannel(getter_AddRefs(channel), mFinalURI, nsnull,
nsnull, this, mLoadFlags);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIHttpChannel> http = do_QueryInterface(channel, &rv);
if (NS_FAILED(rv))
return rv;
NS_ASSERTION(mCurrentSize != PRInt64(-1),
"we should know the current file size by now");
rv = ClearRequestHeader(http);
if (NS_FAILED(rv))
return rv;
// Don't bother making a range request if we are just going to fetch the
// entire document.
if (mInterval || mCurrentSize != PRInt64(0)) {
nsCAutoString range;
MakeRangeSpec(mCurrentSize, mTotalSize, mChunkSize, mInterval == 0, range);
rv = http->SetRequestHeader(NS_LITERAL_CSTRING("Range"), range, PR_FALSE);
if (NS_FAILED(rv))
return rv;
}
rv = channel->AsyncOpen(this, nsnull);
if (NS_FAILED(rv))
return rv;
// Wait to assign mChannel when we know we are going to succeed. This is
// important because we don't want to introduce a reference cycle between
// mChannel and this until we know for a fact that AsyncOpen has succeeded,
// thus ensuring that our stream listener methods will be invoked.
mChannel = channel;
return NS_OK;
}
示例4: SynthesizeDomain
nsresult
nsOperaCookieMigrator::AddCookie(nsICookieManager2* aManager)
{
// This is where we use the information gathered in all the other
// states to add a cookie to the Firebird/Firefox Cookie Manager.
nsCString domain;
SynthesizeDomain(getter_Copies(domain));
nsCString path;
SynthesizePath(getter_Copies(path));
mCookieOpen = PR_FALSE;
nsresult rv = aManager->Add(domain,
path,
mCurrCookie.id,
mCurrCookie.data,
mCurrCookie.isSecure,
PR_FALSE, // isHttpOnly
PR_FALSE, // isSession
PRInt64(mCurrCookie.expiryTime));
mCurrCookie.isSecure = 0;
mCurrCookie.expiryTime = 0;
return rv;
}
示例5: FromTicks
TimeDuration
TimeDuration::Resolution()
{
// This is grossly nonrepresentative of actual system capabilities
// on some platforms
return TimeDuration::FromTicks(PRInt64(1));
}
示例6: lock
TimeDuration
TimeDuration::Resolution()
{
AutoCriticalSection lock(&sTimeStampLock);
return TimeDuration::FromTicks(PRInt64(sResolution));
}
示例7: NS_ABORT_IF_FALSE
/*static*/ void
SharedMemory::Destroyed()
{
NS_ABORT_IF_FALSE(gShmemAllocated >= PRInt64(mAllocSize),
"Can't destroy more than allocated");
gShmemAllocated -= mAllocSize;
mAllocSize = 0;
}
示例8: MakeRangeSpec
// maxSize may be -1 if unknown
static void
MakeRangeSpec(const PRInt64 &size, const PRInt64 &maxSize, PRInt32 chunkSize,
PRBool fetchRemaining, nsCString &rangeSpec)
{
rangeSpec.AssignLiteral("bytes=");
rangeSpec.AppendInt(PRInt64(size));
rangeSpec.Append('-');
if (fetchRemaining)
return;
PRInt64 end = size + PRInt64(chunkSize);
if (maxSize != PRInt64(-1) && end > maxSize)
end = maxSize;
end -= 1;
rangeSpec.AppendInt(PRInt64(end));
}
示例9: NS_ENSURE_TRUE
NS_IMETHODIMP
nsInputStreamPump::Init(nsIInputStream *stream,
PRInt64 streamPos, PRInt64 streamLen,
PRUint32 segsize, PRUint32 segcount,
bool closeWhenDone)
{
NS_ENSURE_TRUE(mState == STATE_IDLE, NS_ERROR_IN_PROGRESS);
mStreamOffset = PRUint64(streamPos);
if (PRInt64(streamLen) >= PRInt64(0))
mStreamLength = PRUint64(streamLen);
mStream = stream;
mSegSize = segsize;
mSegCount = segcount;
mCloseWhenDone = closeWhenDone;
return NS_OK;
}
示例10: GetSoftPageFaults
static PRInt64 GetSoftPageFaults()
{
struct rusage usage;
int err = getrusage(RUSAGE_SELF, &usage);
if (err != 0) {
return PRInt64(-1);
}
return usage.ru_minflt;
}
示例11: InitThresholds
static void
InitThresholds()
{
DWORD timeAdjustment = 0, timeIncrement = 0;
BOOL timeAdjustmentDisabled;
GetSystemTimeAdjustment(&timeAdjustment,
&timeIncrement,
&timeAdjustmentDisabled);
if (!timeIncrement)
timeIncrement = kDefaultTimeIncrement;
// Ceiling to a millisecond
// Example values: 156001, 210000
DWORD timeIncrementCeil = timeIncrement;
// Don't want to round up if already rounded, values will be: 156000, 209999
timeIncrementCeil -= 1;
// Convert to ms, values will be: 15, 20
timeIncrementCeil /= 10000;
// Round up, values will be: 16, 21
timeIncrementCeil += 1;
// Convert back to 100ns, values will be: 160000, 210000
timeIncrementCeil *= 10000;
// How many milli-ticks has the interval
LONGLONG ticksPerGetTickCountResolution =
(PRInt64(timeIncrement) * sFrequencyPerSec) / 10000LL;
// How many milli-ticks has the interval rounded up
LONGLONG ticksPerGetTickCountResolutionCeiling =
(PRInt64(timeIncrementCeil) * sFrequencyPerSec) / 10000LL;
// I observed differences about 2 times of the GTC resolution. GTC may
// jump by 32 ms in two steps, therefor use the ceiling value.
sUnderrunThreshold =
LONGLONG((-2) * ticksPerGetTickCountResolutionCeiling);
// QPC should go no further then 2 * GTC resolution
sOverrunThreshold =
LONGLONG((+2) * ticksPerGetTickCountResolution);
}
示例12: RunTest
/**
* asynchronously copy file.
*/
static nsresult
RunTest(nsIFile *srcFile, nsIFile *destFile)
{
nsresult rv;
LOG(("RunTest\n"));
nsCOMPtr<nsIStreamTransportService> sts =
do_GetService(kStreamTransportServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIInputStream> srcStr;
rv = NS_NewLocalFileInputStream(getter_AddRefs(srcStr), srcFile);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIOutputStream> destStr;
rv = NS_NewLocalFileOutputStream(getter_AddRefs(destStr), destFile);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsITransport> srcTransport;
rv = sts->CreateInputTransport(srcStr, PRInt64(-1), PRInt64(-1), PR_TRUE,
getter_AddRefs(srcTransport));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsITransport> destTransport;
rv = sts->CreateOutputTransport(destStr, PRInt64(-1), PRInt64(-1), PR_TRUE,
getter_AddRefs(destTransport));
if (NS_FAILED(rv)) return rv;
MyCopier *copier = new MyCopier();
if (copier == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(copier);
rv = copier->AsyncCopy(srcTransport, destTransport);
if (NS_FAILED(rv)) return rv;
PumpEvents();
NS_RELEASE(copier);
return NS_OK;
}
示例13: NS_ASSERTION
nsresult
nsIncrementalDownload::FlushChunk()
{
NS_ASSERTION(mTotalSize != nsInt64(-1), "total size should be known");
if (mChunkLen == 0)
return NS_OK;
nsresult rv = AppendToFile(mDest, mChunk, mChunkLen);
if (NS_FAILED(rv))
return rv;
mCurrentSize += nsInt64(mChunkLen);
mChunkLen = 0;
if (mProgressSink)
mProgressSink->OnProgress(this, mObserverContext,
PRUint64(PRInt64(mCurrentSize)),
PRUint64(PRInt64(mTotalSize)));
return NS_OK;
}
示例14: RunBlockingTest
static nsresult
RunBlockingTest(nsIFile *srcFile, nsIFile *destFile)
{
nsresult rv;
LOG(("RunBlockingTest\n"));
nsCOMPtr<nsIStreamTransportService> sts =
do_GetService(kStreamTransportServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIInputStream> srcIn;
rv = NS_NewLocalFileInputStream(getter_AddRefs(srcIn), srcFile);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIOutputStream> fileOut;
rv = NS_NewLocalFileOutputStream(getter_AddRefs(fileOut), destFile);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsITransport> destTransport;
rv = sts->CreateOutputTransport(fileOut, PRInt64(-1), PRInt64(-1),
PR_TRUE, getter_AddRefs(destTransport));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIOutputStream> destOut;
rv = destTransport->OpenOutputStream(nsITransport::OPEN_BLOCKING, 100, 10, getter_AddRefs(destOut));
if (NS_FAILED(rv)) return rv;
char buf[120];
PRUint32 n;
for (;;) {
rv = srcIn->Read(buf, sizeof(buf), &n);
if (NS_FAILED(rv) || (n == 0)) return rv;
rv = destOut->Write(buf, n, &n);
if (NS_FAILED(rv)) return rv;
}
return NS_OK;
}
示例15: PRInt64
void
nsSMILTimedElement::AddInstanceTimeFromCurrentTime(nsSMILTime aCurrentTime,
double aOffsetSeconds, PRBool aIsBegin)
{
double offset = aOffsetSeconds * PR_MSEC_PER_SEC;
nsSMILTime timeWithOffset = aCurrentTime + PRInt64(NS_round(offset));
nsSMILTimeValue timeVal;
timeVal.SetMillis(timeWithOffset);
nsSMILInstanceTime instanceTime(timeVal, nsnull, PR_TRUE);
AddInstanceTime(instanceTime, aIsBegin);
}