Bug 825285 - Part a: Don't pass around ArchiveReaderOptions; r=khuey

This commit is contained in:
Ms2ger 2013-03-10 08:54:42 +01:00
parent 0cfab1aff2
commit c3d2f16850
4 changed files with 16 additions and 14 deletions

View File

@ -69,8 +69,10 @@ ArchiveReader::Initialize(nsISupports* aOwner,
// Extra param is an object
if (aArgc > 1) {
nsresult rv = mOptions.Init(aCx, &aArgv[1]);
mozilla::idl::ArchiveReaderOptions options;
nsresult rv = options.Init(aCx, &aArgv[1]);
NS_ENSURE_SUCCESS(rv, rv);
mEncoding = options.encoding;
}
mWindow = do_QueryInterface(aOwner);
@ -140,7 +142,7 @@ ArchiveReader::OpenArchive()
nsRefPtr<ArchiveReaderEvent> event;
/* FIXME: If we want to support more than 1 format we should check the content type here: */
event = new ArchiveReaderZipEvent(this, mOptions);
event = new ArchiveReaderZipEvent(this, mEncoding);
rv = target->Dispatch(event, NS_DISPATCH_NORMAL);
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -97,7 +97,7 @@ protected:
nsresult status;
} mData;
mozilla::idl::ArchiveReaderOptions mOptions;
nsString mEncoding;
};
END_FILE_NAMESPACE

View File

@ -22,10 +22,10 @@ USING_FILE_NAMESPACE
ArchiveZipItem::ArchiveZipItem(const char* aFilename,
const ZipCentral& aCentralStruct,
const mozilla::idl::ArchiveReaderOptions& aOptions)
const nsAString& aEncoding)
: mFilename(aFilename),
mCentralStruct(aCentralStruct),
mOptions(aOptions)
mEncoding(aEncoding)
{
MOZ_COUNT_CTOR(ArchiveZipItem);
}
@ -38,13 +38,13 @@ ArchiveZipItem::~ArchiveZipItem()
nsresult
ArchiveZipItem::ConvertFilename()
{
if (mOptions.encoding.IsEmpty()) {
if (mEncoding.IsEmpty()) {
return NS_ERROR_FAILURE;
}
nsString filenameU;
nsresult rv = nsContentUtils::ConvertStringFromCharset(
NS_ConvertUTF16toUTF8(mOptions.encoding),
NS_ConvertUTF16toUTF8(mEncoding),
mFilename, filenameU);
NS_ENSURE_SUCCESS(rv, rv);
@ -111,9 +111,9 @@ ArchiveZipItem::StrToInt16(const uint8_t* aStr)
// ArchiveReaderZipEvent
ArchiveReaderZipEvent::ArchiveReaderZipEvent(ArchiveReader* aArchiveReader,
const mozilla::idl::ArchiveReaderOptions& aOptions)
const nsAString& aEncoding)
: ArchiveReaderEvent(aArchiveReader),
mOptions(aOptions)
mEncoding(aEncoding)
{
}
@ -201,7 +201,7 @@ ArchiveReaderZipEvent::Exec()
// We ignore the directories:
if (filename[filenameLen - 1] != '/') {
mFileList.AppendElement(new ArchiveZipItem(filename, centralStruct, mOptions));
mFileList.AppendElement(new ArchiveZipItem(filename, centralStruct, mEncoding));
}
// Ignore the rest

View File

@ -24,7 +24,7 @@ class ArchiveZipItem : public ArchiveItem
public:
ArchiveZipItem(const char* aFilename,
const ZipCentral& aCentralStruct,
const mozilla::idl::ArchiveReaderOptions& aOptions);
const nsAString& aEncoding);
virtual ~ArchiveZipItem();
nsresult GetFilename(nsString& aFilename);
@ -45,7 +45,7 @@ private: // data
nsString mFilenameU;
ZipCentral mCentralStruct;
mozilla::idl::ArchiveReaderOptions mOptions;
nsString mEncoding;
};
/**
@ -55,12 +55,12 @@ class ArchiveReaderZipEvent : public ArchiveReaderEvent
{
public:
ArchiveReaderZipEvent(ArchiveReader* aArchiveReader,
const mozilla::idl::ArchiveReaderOptions& aOptions);
const nsAString& aEncoding);
nsresult Exec();
private:
mozilla::idl::ArchiveReaderOptions mOptions;
nsString mEncoding;
};
END_FILE_NAMESPACE