mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-24 10:45:42 +00:00
Bug 1376496 - Part 3 - MOZ_LOG JAR cache hits/misses in DEBUG. r=mayhemer
MozReview-Commit-ID: IhiNxvt7vY --HG-- extra : rebase_source : 15f727760ab8e37dea2db5024bca6f5dde8ef81b
This commit is contained in:
parent
97420c053a
commit
13d42e4e9a
@ -71,6 +71,10 @@ namespace net {
|
||||
|
||||
using extensions::URLInfo;
|
||||
|
||||
LazyLogModule gExtProtocolLog("ExtProtocol");
|
||||
#undef LOG
|
||||
#define LOG(...) MOZ_LOG(gExtProtocolLog, LogLevel::Debug, (__VA_ARGS__))
|
||||
|
||||
StaticRefPtr<ExtensionProtocolHandler> ExtensionProtocolHandler::sSingleton;
|
||||
|
||||
static inline Result<Ok, nsresult>
|
||||
@ -769,6 +773,31 @@ ExtensionProtocolHandler::SubstituteRemoteFileChannel(nsIURI* aURI,
|
||||
NewSimpleChannel(aURI, aLoadinfo, streamGetter, aRetVal);
|
||||
}
|
||||
|
||||
static Result<Ok, nsresult>
|
||||
LogCacheCheck(const nsIJARChannel* aJarChannel,
|
||||
nsIJARURI* aJarURI,
|
||||
bool aIsCached)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIURI> innerFileURI;
|
||||
NS_TRY(aJarURI->GetJARFile(getter_AddRefs(innerFileURI)));
|
||||
|
||||
nsCOMPtr<nsIFileURL> innerFileURL = do_QueryInterface(innerFileURI, &rv);
|
||||
NS_TRY(rv);
|
||||
|
||||
nsCOMPtr<nsIFile> jarFile;
|
||||
NS_TRY(innerFileURL->GetFile(getter_AddRefs(jarFile)));
|
||||
|
||||
nsAutoCString uriSpec, jarSpec;
|
||||
Unused << aJarURI->GetSpec(uriSpec);
|
||||
Unused << innerFileURI->GetSpec(jarSpec);
|
||||
LOG("[JARChannel %p] Cache %s: %s (%s)",
|
||||
aJarChannel, aIsCached ? "hit" : "miss", uriSpec.get(), jarSpec.get());
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
Result<Ok, nsresult>
|
||||
ExtensionProtocolHandler::SubstituteRemoteJarChannel(nsIURI* aURI,
|
||||
nsILoadInfo* aLoadinfo,
|
||||
@ -778,15 +807,6 @@ ExtensionProtocolHandler::SubstituteRemoteJarChannel(nsIURI* aURI,
|
||||
MOZ_ASSERT(IsNeckoChild());
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIJARChannel> jarChannel = do_QueryInterface(*aRetVal, &rv);
|
||||
NS_TRY(rv);
|
||||
|
||||
bool isCached = false;
|
||||
NS_TRY(jarChannel->EnsureCached(&isCached));
|
||||
if (isCached) {
|
||||
return Ok();
|
||||
}
|
||||
|
||||
// Build a JAR URI for this jar:file:// URI and use it to extract the
|
||||
// inner file URI.
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
@ -795,6 +815,18 @@ ExtensionProtocolHandler::SubstituteRemoteJarChannel(nsIURI* aURI,
|
||||
nsCOMPtr<nsIJARURI> jarURI = do_QueryInterface(uri, &rv);
|
||||
NS_TRY(rv);
|
||||
|
||||
nsCOMPtr<nsIJARChannel> jarChannel = do_QueryInterface(*aRetVal, &rv);
|
||||
NS_TRY(rv);
|
||||
|
||||
bool isCached = false;
|
||||
NS_TRY(jarChannel->EnsureCached(&isCached));
|
||||
if (MOZ_LOG_TEST(gExtProtocolLog, LogLevel::Debug)) {
|
||||
Unused << LogCacheCheck(jarChannel, jarURI, isCached);
|
||||
}
|
||||
if (isCached) {
|
||||
return Ok();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> innerFileURI;
|
||||
NS_TRY(jarURI->GetJARFile(getter_AddRefs(innerFileURI)));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user