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:
Haik Aftandilian 2017-07-21 16:14:16 -07:00
parent 97420c053a
commit 13d42e4e9a

View File

@ -71,6 +71,10 @@ namespace net {
using extensions::URLInfo; using extensions::URLInfo;
LazyLogModule gExtProtocolLog("ExtProtocol");
#undef LOG
#define LOG(...) MOZ_LOG(gExtProtocolLog, LogLevel::Debug, (__VA_ARGS__))
StaticRefPtr<ExtensionProtocolHandler> ExtensionProtocolHandler::sSingleton; StaticRefPtr<ExtensionProtocolHandler> ExtensionProtocolHandler::sSingleton;
static inline Result<Ok, nsresult> static inline Result<Ok, nsresult>
@ -769,6 +773,31 @@ ExtensionProtocolHandler::SubstituteRemoteFileChannel(nsIURI* aURI,
NewSimpleChannel(aURI, aLoadinfo, streamGetter, aRetVal); 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> Result<Ok, nsresult>
ExtensionProtocolHandler::SubstituteRemoteJarChannel(nsIURI* aURI, ExtensionProtocolHandler::SubstituteRemoteJarChannel(nsIURI* aURI,
nsILoadInfo* aLoadinfo, nsILoadInfo* aLoadinfo,
@ -778,15 +807,6 @@ ExtensionProtocolHandler::SubstituteRemoteJarChannel(nsIURI* aURI,
MOZ_ASSERT(IsNeckoChild()); MOZ_ASSERT(IsNeckoChild());
nsresult rv; 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 // Build a JAR URI for this jar:file:// URI and use it to extract the
// inner file URI. // inner file URI.
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
@ -795,6 +815,18 @@ ExtensionProtocolHandler::SubstituteRemoteJarChannel(nsIURI* aURI,
nsCOMPtr<nsIJARURI> jarURI = do_QueryInterface(uri, &rv); nsCOMPtr<nsIJARURI> jarURI = do_QueryInterface(uri, &rv);
NS_TRY(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; nsCOMPtr<nsIURI> innerFileURI;
NS_TRY(jarURI->GetJARFile(getter_AddRefs(innerFileURI))); NS_TRY(jarURI->GetJARFile(getter_AddRefs(innerFileURI)));