author | Andrew McCreight <continuation@gmail.com> |
Mon, 17 Mar 2014 10:21:26 -0700 | |
changeset 173904 | eb0d9222174b457bfd0d354d010a6dcc87414740 |
parent 173903 | 18944b83451149777abb22d9e103139edef81794 |
child 173905 | 409036268a8eef4600410ac1b98f6c7990b3c023 |
push id | 41132 |
push user | amccreight@mozilla.com |
push date | Mon, 17 Mar 2014 17:21:45 +0000 |
treeherder | mozilla-inbound@409036268a8e [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | ehsan |
bugs | 984008 |
milestone | 30.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp +++ b/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp @@ -510,18 +510,17 @@ nsWebBrowserPersist::StartUpload(nsIInpu // NOTE: ALL data must be available in "inputstream" nsresult rv = uploadChannel->SetUploadStream(aInputStream, aContentType, -1); NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); rv = destChannel->AsyncOpen(this, nullptr); NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); // add this to the upload list nsCOMPtr<nsISupports> keyPtr = do_QueryInterface(destChannel); - nsISupportsKey key(keyPtr); - mUploadList.Put(&key, new UploadData(aDestinationURI)); + mUploadList.Put(keyPtr, new UploadData(aDestinationURI)); return NS_OK; } nsresult nsWebBrowserPersist::SaveGatheredURIs(nsIURI *aFileAsURI) { nsresult rv = NS_OK; @@ -630,18 +629,17 @@ NS_IMETHODIMP nsWebBrowserPersist::OnSta OutputData *data = mOutputMap.Get(keyPtr); // NOTE: This code uses the channel as a hash key so it will not // recognize redirected channels because the key is not the same. // When that happens we remove and add the data entry to use the // new channel as the hash key. if (!data) { - nsISupportsKey key(keyPtr); - UploadData *upData = (UploadData *) mUploadList.Get(&key); + UploadData *upData = mUploadList.Get(keyPtr); if (!upData) { // Redirect? Try and fixup the output table nsresult rv = FixRedirectedChannelEntry(channel); NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); // Should be able to find the data after fixup unless redirects // are disabled. @@ -701,22 +699,20 @@ NS_IMETHODIMP nsWebBrowserPersist::OnSto SendErrorStatusChange(true, status, request, data->mFile); // This will automatically close the output stream mOutputMap.Remove(keyPtr); } else { // if we didn't find the data in mOutputMap, try mUploadList - nsISupportsKey key(keyPtr); - UploadData *upData = (UploadData *) mUploadList.Get(&key); + UploadData *upData = mUploadList.Get(keyPtr); if (upData) { - delete upData; - mUploadList.Remove(&key); + mUploadList.Remove(keyPtr); } } // ensure we call SaveDocuments if we: // 1) aren't canceling // 2) we haven't triggered the save (which we only want to trigger once) // 3) we aren't serializing (which will call it inside SerializeNextFile) if (mOutputMap.Count() == 0 && !mCancel && !mStartSaving && !mSerializingOutput) @@ -921,18 +917,17 @@ NS_IMETHODIMP nsWebBrowserPersist::OnPro OutputData *data = mOutputMap.Get(keyPtr); if (data) { data->mSelfProgress = int64_t(aProgress); data->mSelfProgressMax = int64_t(aProgressMax); } else { - nsISupportsKey key(keyPtr); - UploadData *upData = (UploadData *) mUploadList.Get(&key); + UploadData *upData = mUploadList.Get(keyPtr); if (upData) { upData->mSelfProgress = int64_t(aProgress); upData->mSelfProgressMax = int64_t(aProgressMax); } } // Notify listener of total progress @@ -1767,18 +1762,18 @@ nsresult nsWebBrowserPersist::SaveDocume } void nsWebBrowserPersist::Cleanup() { mURIMap.Enumerate(EnumCleanupURIMap, this); mURIMap.Reset(); mOutputMap.EnumerateRead(EnumCleanupOutputMap, this); mOutputMap.Clear(); - mUploadList.Enumerate(EnumCleanupUploadList, this); - mUploadList.Reset(); + mUploadList.EnumerateRead(EnumCleanupUploadList, this); + mUploadList.Clear(); uint32_t i; for (i = 0; i < mDocList.Length(); i++) { DocData *docData = mDocList.ElementAt(i); delete docData; } mDocList.Clear(); for (i = 0; i < mCleanupList.Length(); i++) @@ -2312,32 +2307,16 @@ nsWebBrowserPersist::EndDownload(nsresul CleanupLocalFiles(); } // Cleanup the channels mCompleted = true; Cleanup(); } -/* Hack class to get access to nsISupportsKey's protected mKey member */ -class nsMyISupportsKey : public nsISupportsKey -{ -public: - nsMyISupportsKey(nsISupports *key) : nsISupportsKey(key) - { - } - - nsresult GetISupports(nsISupports **ret) - { - *ret = mKey; - NS_IF_ADDREF(mKey); - return NS_OK; - } -}; - struct MOZ_STACK_CLASS FixRedirectData { nsCOMPtr<nsIChannel> mNewChannel; nsCOMPtr<nsIURI> mOriginalURI; nsCOMPtr<nsISupports> mMatchingKey; }; nsresult @@ -2406,17 +2385,17 @@ nsWebBrowserPersist::CalcTotalProgress() { // Total up the progress of each output stream mOutputMap.EnumerateRead(EnumCalcProgress, this); } if (mUploadList.Count() > 0) { // Total up the progress of each upload - mUploadList.Enumerate(EnumCalcUploadProgress, this); + mUploadList.EnumerateRead(EnumCalcUploadProgress, this); } // XXX this code seems pretty bogus and pointless if (mTotalCurrentProgress == 0 && mTotalMaxProgress == 0) { // No output streams so we must be complete mTotalCurrentProgress = 10000; mTotalMaxProgress = 10000; @@ -2433,27 +2412,26 @@ nsWebBrowserPersist::EnumCalcProgress(ns if (fileURL) { pthis->mTotalCurrentProgress += aData->mSelfProgress; pthis->mTotalMaxProgress += aData->mSelfProgressMax; } return PL_DHASH_NEXT; } -bool -nsWebBrowserPersist::EnumCalcUploadProgress(nsHashKey *aKey, void *aData, void* closure) +PLDHashOperator +nsWebBrowserPersist::EnumCalcUploadProgress(nsISupports *aKey, UploadData *aData, void* aClosure) { - if (aData && closure) + if (aData && aClosure) { - nsWebBrowserPersist *pthis = (nsWebBrowserPersist *) closure; - UploadData *data = (UploadData *) aData; - pthis->mTotalCurrentProgress += data->mSelfProgress; - pthis->mTotalMaxProgress += data->mSelfProgressMax; + nsWebBrowserPersist *pthis = static_cast<nsWebBrowserPersist *>(aClosure); + pthis->mTotalCurrentProgress += aData->mSelfProgress; + pthis->mTotalMaxProgress += aData->mSelfProgressMax; } - return true; + return PL_DHASH_NEXT; } bool nsWebBrowserPersist::EnumCountURIsToPersist(nsHashKey *aKey, void *aData, void* closure) { URIData *data = (URIData *) aData; uint32_t *count = (uint32_t *) closure; if (data->mNeedsPersisting && !data->mSaved) @@ -2531,29 +2509,25 @@ bool nsWebBrowserPersist::EnumCleanupURIMap(nsHashKey *aKey, void *aData, void* closure) { URIData *data = (URIData *) aData; delete data; // Delete data associated with key return true; } -bool -nsWebBrowserPersist::EnumCleanupUploadList(nsHashKey *aKey, void *aData, void* closure) +PLDHashOperator +nsWebBrowserPersist::EnumCleanupUploadList(nsISupports *aKey, UploadData *aData, void* aClosure) { - nsCOMPtr<nsISupports> keyPtr; - ((nsMyISupportsKey *) aKey)->GetISupports(getter_AddRefs(keyPtr)); - nsCOMPtr<nsIChannel> channel = do_QueryInterface(keyPtr); + nsCOMPtr<nsIChannel> channel = do_QueryInterface(aKey); if (channel) { channel->Cancel(NS_BINDING_ABORTED); } - UploadData *data = (UploadData *) aData; - delete data; // Delete data associated with key - return true; + return PL_DHASH_NEXT; } nsresult nsWebBrowserPersist::FixupXMLStyleSheetLink(nsIDOMProcessingInstruction *aPI, const nsAString &aHref) { NS_ENSURE_ARG_POINTER(aPI); nsresult rv = NS_OK; nsAutoString data;
--- a/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.h +++ b/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.h @@ -31,16 +31,17 @@ #include "nsCWebBrowserPersist.h" class nsEncoderNodeFixup; class nsIStorageStream; struct CleanupData; struct DocData; struct OutputData; +struct UploadData; struct URIData; class nsWebBrowserPersist : public nsIInterfaceRequestor, public nsIWebBrowserPersist, public nsIStreamListener, public nsIProgressEventSink, public nsSupportsWeakReference { @@ -160,20 +161,22 @@ private: static bool EnumPersistURIs( nsHashKey *aKey, void *aData, void* closure); static bool EnumCleanupURIMap( nsHashKey *aKey, void *aData, void* closure); static PLDHashOperator EnumCleanupOutputMap( nsISupports *aKey, OutputData *aData, void* aClosure); static bool EnumCleanupUploadList( nsHashKey *aKey, void *aData, void* closure); + static PLDHashOperator EnumCleanupUploadList( + nsISupports *aKey, UploadData *aData, void* aClosure); static PLDHashOperator EnumCalcProgress( nsISupports *aKey, OutputData *aData, void* aClosure); - static bool EnumCalcUploadProgress( - nsHashKey *aKey, void *aData, void* closure); + static PLDHashOperator EnumCalcUploadProgress( + nsISupports *aKey, UploadData *aData, void* aClosure); static PLDHashOperator EnumFixRedirect( nsISupports *aKey, OutputData *aData, void* aClosure); static bool EnumCountURIsToPersist( nsHashKey *aKey, void *aData, void* closure); nsCOMPtr<nsIURI> mCurrentDataPath; bool mCurrentDataPathIsRelative; nsCString mCurrentRelativePathToData; @@ -188,17 +191,17 @@ private: /** * Progress listener for 64-bit values; this is the same object as * mProgressListener, but is a member to avoid having to qi it for each * progress notification. */ nsCOMPtr<nsIWebProgressListener2> mProgressListener2; nsCOMPtr<nsIProgressEventSink> mEventSink; nsClassHashtable<nsISupportsHashKey, OutputData> mOutputMap; - nsHashtable mUploadList; + nsClassHashtable<nsISupportsHashKey, UploadData> mUploadList; nsHashtable mURIMap; nsTArray<DocData*> mDocList; nsTArray<CleanupData*> mCleanupList; nsTArray<nsCString> mFilenameList; bool mFirstAndOnlyUse; bool mCancel; bool mJustStartedLoading; bool mCompleted;