Bug 695843 part 9 - Use FileLocations in the component manager. r=bsmedberg

This commit is contained in:
Mike Hommey
2011-11-08 18:10:51 +01:00
parent 9e54006ebd
commit 20838ba061
13 changed files with 181 additions and 638 deletions

View File

@@ -174,7 +174,7 @@ void LogMessage(const char* aMsg, ...)
console->LogMessage(error);
}
void LogMessageWithContext(nsILocalFile* aFile, const char* aPath,
void LogMessageWithContext(FileLocation &aFile,
PRUint32 aLineNumber, const char* aMsg, ...)
{
va_list args;
@@ -184,20 +184,15 @@ void LogMessageWithContext(nsILocalFile* aFile, const char* aPath,
if (!formatted)
return;
nsString file;
aFile->GetPath(file);
if (aPath) {
file.Append(':');
file.Append(NS_ConvertUTF8toUTF16(aPath));
}
nsCString file;
aFile.GetURIString(file);
nsCOMPtr<nsIScriptError> error =
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
if (!error) {
// This can happen early in component registration. Fall back to a
// generic console message.
LogMessage("Warning: in file '%s', line %i: %s",
NS_ConvertUTF16toUTF8(file).get(),
LogMessage("Warning: in '%s', line %i: %s", file.get(),
aLineNumber, (char*) formatted);
return;
}
@@ -208,7 +203,7 @@ void LogMessageWithContext(nsILocalFile* aFile, const char* aPath,
return;
nsresult rv = error->Init(NS_ConvertUTF8toUTF16(formatted).get(),
file.get(), NULL,
NS_ConvertUTF8toUTF16(file).get(), NULL,
aLineNumber, 0, nsIScriptError::warningFlag,
"chrome registration");
if (NS_FAILED(rv))
@@ -423,12 +418,12 @@ struct CachedDirective
} // anonymous namespace
static void
ParseManifestCommon(NSLocationType aType, nsILocalFile* aFile,
nsComponentManagerImpl::ManifestProcessingContext& mgrcx,
nsChromeRegistry::ManifestProcessingContext& chromecx,
const char* aPath, char* buf, bool aChromeOnly)
void
ParseManifest(NSLocationType type, FileLocation &file, char* buf, bool aChromeOnly)
{
nsComponentManagerImpl::ManifestProcessingContext mgrcx(type, file, aChromeOnly);
nsChromeRegistry::ManifestProcessingContext chromecx(type, file);
nsresult rv;
NS_NAMED_LITERAL_STRING(kPlatform, "platform");
@@ -553,21 +548,21 @@ ParseManifestCommon(NSLocationType aType, nsILocalFile* aFile,
}
if (!directive) {
LogMessageWithContext(aFile, aPath, line,
LogMessageWithContext(file, line,
"Ignoring unrecognized chrome manifest directive '%s'.",
token);
continue;
}
if (!directive->allowbootstrap && NS_BOOTSTRAPPED_LOCATION == aType) {
LogMessageWithContext(aFile, aPath, line,
if (!directive->allowbootstrap && NS_BOOTSTRAPPED_LOCATION == type) {
LogMessageWithContext(file, line,
"Bootstrapped manifest not allowed to use '%s' directive.",
token);
continue;
}
if (directive->componentonly && NS_SKIN_LOCATION == aType) {
LogMessageWithContext(aFile, aPath, line,
if (directive->componentonly && NS_SKIN_LOCATION == type) {
LogMessageWithContext(file, line,
"Skin manifest not allowed to use '%s' directive.",
token);
continue;
@@ -579,7 +574,7 @@ ParseManifestCommon(NSLocationType aType, nsILocalFile* aFile,
argv[i] = nsCRT::strtok(whitespace, kWhitespace, &whitespace);
if (!argv[directive->argc - 1]) {
LogMessageWithContext(aFile, aPath, line,
LogMessageWithContext(file, line,
"Not enough arguments for chrome manifest directive '%s', expected %i.",
token, directive->argc);
continue;
@@ -614,13 +609,13 @@ ParseManifestCommon(NSLocationType aType, nsILocalFile* aFile,
bool xpcNativeWrappers = true; // Dummy for CheckFlag.
if (CheckFlag(kXPCNativeWrappers, wtoken, xpcNativeWrappers)) {
LogMessageWithContext(aFile, aPath, line,
LogMessageWithContext(file, line,
"Warning: Ignoring obsolete chrome registration modifier '%s'.",
token);
continue;
}
LogMessageWithContext(aFile, aPath, line,
LogMessageWithContext(file, line,
"Unrecognized chrome manifest modifier '%s'.",
token);
ok = false;
@@ -643,7 +638,7 @@ ParseManifestCommon(NSLocationType aType, nsILocalFile* aFile,
nsCOMPtr<nsIChromeRegistry> cr =
mozilla::services::GetChromeRegistryService();
if (!nsChromeRegistry::gChromeRegistry) {
LogMessageWithContext(aFile, aPath, line,
LogMessageWithContext(file, line,
"Chrome registry isn't available yet.");
continue;
}
@@ -671,22 +666,3 @@ ParseManifestCommon(NSLocationType aType, nsILocalFile* aFile,
(mgrcx, d.lineno, d.argv);
}
}
void
ParseManifest(NSLocationType type, nsILocalFile* file,
char* buf, bool aChromeOnly)
{
nsComponentManagerImpl::ManifestProcessingContext mgrcx(type, file, aChromeOnly);
nsChromeRegistry::ManifestProcessingContext chromecx(type, file);
ParseManifestCommon(type, file, mgrcx, chromecx, NULL, buf, aChromeOnly);
}
void
ParseManifest(NSLocationType type, nsIZipReader* reader, const char* jarPath,
char* buf, bool aChromeOnly)
{
nsComponentManagerImpl::ManifestProcessingContext mgrcx(type, reader, jarPath, aChromeOnly);
nsChromeRegistry::ManifestProcessingContext chromecx(type, mgrcx.mFile, jarPath);
ParseManifestCommon(type, mgrcx.mFile, mgrcx, chromecx, jarPath,
buf, aChromeOnly);
}