Commit 9e78c080 authored by David Bertoni's avatar David Bertoni Committed by Commit Bot

[Extensions] Don't report a bad message if the UUID is legitimate.

Bug: 955657
Change-Id: Id5124d9651d8939b8d4e37f6cfaca5b2561233d1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1579639
Commit-Queue: David Bertoni <dbertoni@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#653659}
parent 21418305
......@@ -73,6 +73,7 @@ void ExtensionServiceWorkerMessageFilter::OnIncrementServiceWorkerActivity(
int64_t service_worker_version_id,
const std::string& request_uuid) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
active_request_uuids_.insert(request_uuid);
// The worker might have already stopped before we got here, so the increment
// below might fail legitimately. Therefore, we do not send bad_message to the
// worker even if it fails.
......@@ -86,7 +87,12 @@ void ExtensionServiceWorkerMessageFilter::OnDecrementServiceWorkerActivity(
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
bool status = service_worker_context_->FinishedExternalRequest(
service_worker_version_id, request_uuid);
if (!status) {
if (!status)
LOG(ERROR) << "ServiceWorkerContext::FinishedExternalRequest failed.";
bool erased = active_request_uuids_.erase(request_uuid) == 1;
// The worker may have already stopped before we got here, so only report
// a bad message if we didn't have an increment for the UUID.
if (!erased) {
bad_message::ReceivedBadMessage(
this, bad_message::ESWMF_INVALID_DECREMENT_ACTIVITY);
}
......
......@@ -5,6 +5,8 @@
#ifndef EXTENSIONS_BROWSER_EXTENSION_SERVICE_WORKER_MESSAGE_FILTER_H_
#define EXTENSIONS_BROWSER_EXTENSION_SERVICE_WORKER_MESSAGE_FILTER_H_
#include <unordered_set>
#include "base/macros.h"
#include "content/public/browser/browser_message_filter.h"
#include "content/public/browser/browser_thread.h"
......@@ -71,6 +73,8 @@ class ExtensionServiceWorkerMessageFilter
content::BrowserThread::DeleteOnUIThread>
dispatcher_;
std::unordered_set<std::string> active_request_uuids_;
DISALLOW_COPY_AND_ASSIGN(ExtensionServiceWorkerMessageFilter);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment