Files
palemoon27/netwerk/cache/nsCache.cpp
T
roytam1 9938fac30a import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1212279 - Fix uninitialized boolean in Fprinter. r=h4writer (105d3c6507)
- Bug 1223007 - Fix eval redeclaration check for Debugger.Frame.eval. (r=efaust) (a3fddcc2b8)
- cleanup, rearrange (88d8fc8ced)
- Bug 1211956: Check result of EmptyShape::getInitialShape; r=h4writer (41aee681c0)
- Bug 1193102 - Deal with OOM in NewObjectCache::invalidateEntriesForShape. r=bhackett (4c2b2a3bb9)
- Bug 1208747 - Fix self-comparison compiler warnings. r=Yoric over IRC (d64cc9500c)
- Bug 1208747 - Fix include files for the stopwatch. r=jandem (a146b10267)
- Bug 1207843 - Part 1/3 - Clean up ma_b(void* target). r=h4writer (238615768e)
- Bug 1207843 - Part 2/3 - Clean up MacroAssemblerARM spacing. r=h4writer (a316b5bdac)
- Bug 1207843 - Part 3/3 - Clean up ARM Imm8::EncodeImm(). r=h4writer (c24cda23ef)
- Bug 939157 - RotateLeft with shift of zero gives undefined behavior. r=Waldo (36e1324c16)
- Bug 1224041 - Use stable hashing for CloneMemory r=terrence (9c2f5db9e3)
- Bug 1177122 - handle OOM in JSStructuredCloneWriter destructor. r=evilpie (d4fd3d8fd9)
- Bug 1225298 - Use GC policy mechanism for sweeping hashtable-based collections. r=terrence (5369de6951)
- Bug 1200642 - Add OOM simulation to Vector r=Waldo (325c17a5c4)
- Bug 1221680 - Avoid hard errors when testing convertibility using the IsConvertible type trait. r=froydnj (c4220f1a1c)
- Bug 1108017: Loosen third-party restrictions for tracking protection checks (r=sworkman) (2997474d59)
- Bug 1205138 - Cleanup tracking protection warnings and logs. r=gcp (fb61d17b01)
- Bug 1197000 - Better debugging output for Safe Browsing list updates. r=gcp (727005eb8f)
- Bug 1208285 - Improve TP debug logging. r=gcp (72d7561c76)
- Bug 1214122 - Check if addon ProtocolHandler actually provide nsHttpChannel. r=sicking r=mayhemer (07bf8afb12)
- Bug 1214786 - Channelwrapper: Fix up maybeWrapChannel to wrap if not gecko internal channel (r=mayhemer,sicking) (8adb832a11)
- Bug 1158404 - part 1 - DataChannelShutdown should instead observe xpcom-will-shutdown. r=jesup (ad4be087ea)
- Bug 1158404 - Part 2 - Don't hold alive DataChannelShutdown with a global. r=jesup (4b9a0e9b5c)
- bug 1219466 - convert netwerk to LazyLogModule r=valentin.gosu (2a85aa4068)
- Bug 1125947 - Fix clang warnings in netwerk/sctp/datachannel. r=jesup (247ab6dc09)
2023-01-03 10:06:19 +08:00

96 lines
2.3 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsCache.h"
#include "nsReadableUtils.h"
#include "nsDependentSubstring.h"
#include "nsString.h"
/**
* Cache Service Utility Functions
*/
mozilla::LazyLogModule gCacheLog("cache");
void
CacheLogPrintPath(mozilla::LogLevel level, const char * format, nsIFile * item)
{
nsAutoCString path;
nsresult rv = item->GetNativePath(path);
if (NS_SUCCEEDED(rv)) {
MOZ_LOG(gCacheLog, level, (format, path.get()));
} else {
MOZ_LOG(gCacheLog, level, ("GetNativePath failed: %x", rv));
}
}
uint32_t
SecondsFromPRTime(PRTime prTime)
{
int64_t microSecondsPerSecond = PR_USEC_PER_SEC;
return uint32_t(prTime / microSecondsPerSecond);
}
PRTime
PRTimeFromSeconds(uint32_t seconds)
{
int64_t intermediateResult = seconds;
PRTime prTime = intermediateResult * PR_USEC_PER_SEC;
return prTime;
}
nsresult
ClientIDFromCacheKey(const nsACString& key, char ** result)
{
nsresult rv = NS_OK;
*result = nullptr;
nsReadingIterator<char> colon;
key.BeginReading(colon);
nsReadingIterator<char> start;
key.BeginReading(start);
nsReadingIterator<char> end;
key.EndReading(end);
if (FindCharInReadable(':', colon, end)) {
*result = ToNewCString( Substring(start, colon));
if (!*result) rv = NS_ERROR_OUT_OF_MEMORY;
} else {
NS_ASSERTION(false, "FindCharInRead failed to find ':'");
rv = NS_ERROR_UNEXPECTED;
}
return rv;
}
nsresult
ClientKeyFromCacheKey(const nsCString& key, nsACString &result)
{
nsresult rv = NS_OK;
nsReadingIterator<char> start;
key.BeginReading(start);
nsReadingIterator<char> end;
key.EndReading(end);
if (FindCharInReadable(':', start, end)) {
++start; // advance past clientID ':' delimiter
result.Assign(Substring(start, end));
} else {
NS_ASSERTION(false, "FindCharInRead failed to find ':'");
rv = NS_ERROR_UNEXPECTED;
result.Truncate(0);
}
return rv;
}