Bug 1539539 - Add main thread assertion and fix a clang warning r=mayhemer

The resultCallback at [1] should be always executed on main thread, so adding an assertion to enforce this.
This patch also fixes a warning at [2]. This is about moving a const captured variable.


[1] https://searchfox.org/mozilla-central/rev/3d469329a42644b41e66944d8da22d78d8c0f5ec/netwerk/protocol/http/nsHttpChannel.cpp#551-558
[2] https://searchfox.org/mozilla-central/rev/3d469329a42644b41e66944d8da22d78d8c0f5ec/netwerk/base/nsNetUtil.cpp#2808

Differential Revision: https://phabricator.services.mozilla.com/D25219

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kershaw Chang 2019-03-28 15:03:46 +00:00
Родитель bd12eaff99
Коммит c711763836
2 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -2790,7 +2790,7 @@ nsresult NS_ShouldSecureUpgrade(
[service{std::move(service)}, uri{std::move(uri)}, flags(flags),
originAttributes(aOriginAttributes),
handleResultFunc{std::move(handleResultFunc)},
resultCallback{std::move(aResultCallback)}]() {
resultCallback{std::move(aResultCallback)}]() mutable {
uint32_t hstsSource = 0;
bool isStsHost = false;
nsresult rv = service->IsSecureURI(

Просмотреть файл

@ -553,6 +553,8 @@ nsresult nsHttpChannel::OnBeforeConnect() {
new nsMainThreadPtrHolder<nsHttpChannel>(
"nsHttpChannel::OnBeforeConnect::self", this));
auto resultCallback = [self(self)](bool aResult, nsresult aStatus) {
MOZ_ASSERT(NS_IsMainThread());
nsresult rv = self->ContinueOnBeforeConnect(aResult, aStatus);
if (NS_FAILED(rv)) {
self->CloseCacheEntry(false);