mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1170837 - Add static GetPackageURI method to PackagedAppService r=honzab
This commit is contained in:
parent
922ebfe6d5
commit
3cc3aa4723
@ -518,6 +518,41 @@ PackagedAppService::~PackagedAppService()
|
||||
gPackagedAppService = nullptr;
|
||||
}
|
||||
|
||||
/* static */ nsresult
|
||||
PackagedAppService::GetPackageURI(nsIURI *aURI, nsIURI **aPackageURI)
|
||||
{
|
||||
nsCOMPtr<nsIURL> url = do_QueryInterface(aURI);
|
||||
if (!url) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsAutoCString path;
|
||||
nsresult rv = url->GetFilePath(path);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
int32_t pos = path.Find(PACKAGED_APP_TOKEN);
|
||||
if (pos == kNotFound) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> packageURI;
|
||||
rv = aURI->CloneIgnoringRef(getter_AddRefs(packageURI));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = packageURI->SetPath(Substring(path, 0, pos));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
packageURI.forget(aPackageURI);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PackagedAppService::RequestURI(nsIURI *aURI,
|
||||
nsILoadContextInfo *aInfo,
|
||||
|
@ -61,6 +61,9 @@ private:
|
||||
// Should be called on the main thread.
|
||||
nsresult NotifyPackageDownloaded(nsCString aKey);
|
||||
|
||||
// Extract the URI of a package from the given packaged resource URI.
|
||||
static nsresult GetPackageURI(nsIURI *aUri, nsIURI **aPackageURI);
|
||||
|
||||
// This class is used to write data into the cache entry corresponding to the
|
||||
// packaged resource being downloaded.
|
||||
// The PackagedAppDownloader will hold a ref to a CacheEntryWriter that
|
||||
|
Loading…
Reference in New Issue
Block a user