Commit 81465b1d authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Remove dead code in content::ServiceWorkerVersion.

There are some CHECKs and an include leftover from debugging. Remove
them. Also remove unused SetClockForTesting(). Fix various nits along
the way.

Bug: 951571
Change-Id: Icfc7fcc75cf35697d3efaf5c271edc90ebe5af26
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2368913
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: default avatarKenichi Ishibashi <bashi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801091}
parent 97b02fd2
......@@ -89,9 +89,10 @@ const char kForceUpdateInfoMessage[] =
"checked in the DevTools Application panel.";
void RunSoon(base::OnceClosure callback) {
if (!callback.is_null())
if (callback) {
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
std::move(callback));
}
}
template <typename CallbackArray, typename Arg>
......@@ -664,7 +665,7 @@ ServiceWorkerExternalRequestResult ServiceWorkerVersion::StartExternalRequest(
return ServiceWorkerExternalRequestResult::kWorkerNotRunning;
}
if (external_request_uuid_to_request_id_.count(request_uuid) > 0u)
if (base::Contains(external_request_uuid_to_request_id_, request_uuid))
return ServiceWorkerExternalRequestResult::kBadRequestId;
int request_id =
......@@ -695,10 +696,11 @@ bool ServiceWorkerVersion::FinishRequest(int request_id, bool was_handled) {
ServiceWorkerExternalRequestResult ServiceWorkerVersion::FinishExternalRequest(
const std::string& request_uuid) {
if (running_status() == EmbeddedWorkerStatus::STARTING)
if (running_status() == EmbeddedWorkerStatus::STARTING) {
return pending_external_requests_.erase(request_uuid) > 0u
? ServiceWorkerExternalRequestResult::kOk
: ServiceWorkerExternalRequestResult::kBadRequestId;
}
// If it's STOPPED, there is no request to finish. We could just consider this
// a success, but the caller may want to know about it. (If it's STOPPING,
......@@ -757,13 +759,6 @@ void ServiceWorkerVersion::AddControllee(
// crash.
CHECK(!base::Contains(controllee_map_, uuid));
// TODO(yuzus, crbug.com/951571): Remove these CHECKs once we figure out the
// cause of crash.
CHECK_NE(status_, NEW);
CHECK_NE(status_, INSTALLING);
CHECK_NE(status_, INSTALLED);
CHECK_NE(status_, REDUNDANT);
// Set the idle timeout to the default value if there's no controllee and the
// worker is running because the worker's idle delay has been set to a shorter
// value when all controllee are gone.
......@@ -1117,10 +1112,6 @@ void ServiceWorkerVersion::SetTickClockForTesting(
tick_clock_ = tick_clock;
}
void ServiceWorkerVersion::SetClockForTesting(base::Clock* clock) {
clock_ = clock;
}
bool ServiceWorkerVersion::HasNoWork() const {
return !HasWorkInBrowser() && worker_is_idle_on_renderer_;
}
......@@ -1187,10 +1178,11 @@ void ServiceWorkerVersion::OnStarted(
mojo::ConvertTo<blink::ServiceWorkerStatusCode>(start_status);
if (status == blink::ServiceWorkerStatusCode::kOk &&
fetch_handler_existence_ == FetchHandlerExistence::UNKNOWN)
fetch_handler_existence_ == FetchHandlerExistence::UNKNOWN) {
set_fetch_handler_existence(has_fetch_handler
? FetchHandlerExistence::EXISTS
: FetchHandlerExistence::DOES_NOT_EXIST);
}
// Fire all start callbacks.
scoped_refptr<ServiceWorkerVersion> protect(this);
......
......@@ -18,7 +18,6 @@
#include "base/callback.h"
#include "base/cancelable_callback.h"
#include "base/containers/id_map.h"
#include "base/debug/stack_trace.h"
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
......@@ -496,9 +495,6 @@ class CONTENT_EXPORT ServiceWorkerVersion
// Used to allow tests to change time for testing.
void SetTickClockForTesting(const base::TickClock* tick_clock);
// Used to allow tests to change wall clock for testing.
void SetClockForTesting(base::Clock* clock);
// Returns true when the service worker isn't handling any events or stream
// responses, initiated from either the browser or the renderer.
bool HasNoWork() const;
......@@ -1052,7 +1048,7 @@ class CONTENT_EXPORT ServiceWorkerVersion
const base::TickClock* tick_clock_;
// The clock used for actual (wall clock) time
base::Clock* clock_;
base::Clock* const clock_;
ServiceWorkerPingController ping_controller_;
......@@ -1062,7 +1058,7 @@ class CONTENT_EXPORT ServiceWorkerVersion
// version completed, or used during the lifetime of |this|.
std::set<blink::mojom::WebFeature> used_features_;
std::unique_ptr<blink::TrialTokenValidator> validator_;
std::unique_ptr<blink::TrialTokenValidator> const validator_;
// Stores the result of byte-to-byte update check for each script. Used only
// when ServiceWorkerImportedScriptUpdateCheck is enabled.
......
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