Skip to content

Commit

Permalink
Bug 1744425 - widget/windows: Use nsID::GenerateUUIDInPlace() instead…
Browse files Browse the repository at this point in the history
… of the nsUUIDGenerator service. r=tkikuchi

This change is needed to avoid toolkit/components/backgroundtasks/tests/browser/browser_xpcom_graph_wait.js test failures where the nsUUIDGenerator service was loaded during ASan test runs but not non-ASan test runs (due to differences in temp profile directory paths).

Using nsID::GenerateUUIDInPlace() also avoids the overhead of instantiating the nsUUIDGenerator service.

Depends on D132866

Differential Revision: https://phabricator.services.mozilla.com/D136992
  • Loading branch information
cpeterso committed Feb 3, 2022
1 parent 81801ff commit 9856960
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
8 changes: 3 additions & 5 deletions widget/windows/AudioSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

#include "mozilla/RefPtr.h"
#include "nsIStringBundle.h"
#include "nsIUUIDGenerator.h"

//#include "AudioSession.h"
#include "nsCOMPtr.h"
#include "nsID.h"
#include "nsServiceManagerUtils.h"
#include "nsString.h"
#include "nsThreadUtils.h"
Expand Down Expand Up @@ -193,10 +193,8 @@ nsresult AudioSession::Start() {
mIconPath.GetMutableData(&buffer, MAX_PATH);
::GetModuleFileNameW(nullptr, buffer, MAX_PATH);

nsCOMPtr<nsIUUIDGenerator> uuidgen =
do_GetService("@mozilla.org/uuid-generator;1");
NS_ENSURE_TRUE(uuidgen, NS_ERROR_FAILURE);
uuidgen->GenerateUUIDInPlace(&mSessionGroupingParameter);
nsresult rv = nsID::GenerateUUIDInPlace(mSessionGroupingParameter);
NS_ENSURE_SUCCESS(rv, rv);
}

mState = FAILED;
Expand Down
9 changes: 1 addition & 8 deletions widget/windows/ToastNotificationHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "nsIDUtils.h"
#include "nsIStringBundle.h"
#include "nsIURI.h"
#include "nsIUUIDGenerator.h"
#include "nsIWidget.h"
#include "nsIWindowMediator.h"
#include "nsNetUtil.h"
Expand Down Expand Up @@ -534,14 +533,8 @@ nsresult ToastNotificationHandler::AsyncSaveImage(imgIRequest* aRequest) {
return rv;
}

nsCOMPtr<nsIUUIDGenerator> idGen =
do_GetService("@mozilla.org/uuid-generator;1", &rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}

nsID uuid;
rv = idGen->GenerateUUIDInPlace(&uuid);
rv = nsID::GenerateUUIDInPlace(uuid);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
Expand Down

0 comments on commit 9856960

Please sign in to comment.