Bug 1210517 - Create nsVariant directly rather than via do_CreateInstance(). r=froydnj

The goal here is to leave creation stuff mostly for JS, so we can
convert it entirely over to a non-threadsafe cycle-collected version
without breaking any existing C++ users.

I didn't do this for a remaining use in nsGlobalWindow.h to avoid
including nsVariant.h all over the place.
This commit is contained in:
Andrew McCreight
2015-10-07 08:17:42 -07:00
parent 7ebda44a7d
commit 222ce9e7f0
20 changed files with 60 additions and 107 deletions

View File

@@ -63,6 +63,7 @@
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
#include "nsLayoutUtils.h"
#include "nsVariant.h"
#include "nsIDOMMutationEvent.h"
#include "mozilla/ContentEvents.h"
@@ -807,9 +808,7 @@ UploadLastDir::StoreLastUsedDirectory(nsIDocument* aDoc, nsIFile* aDir)
aDir->GetPath(unicodePath);
if (unicodePath.IsEmpty()) // nothing to do
return NS_OK;
nsCOMPtr<nsIWritableVariant> prefValue = do_CreateInstance(NS_VARIANT_CONTRACTID);
if (!prefValue)
return NS_ERROR_OUT_OF_MEMORY;
nsRefPtr<nsVariant> prefValue = new nsVariant();
prefValue->SetAsAString(unicodePath);
// Use the document's current load context to ensure that the content pref