Commit c48098df authored by Makoto Shimazu's avatar Makoto Shimazu Committed by Chromium LUCI CQ

Remove RunOrPostTaskOnCoreThread() from ServiceWorkerContextWatcher

As a part of clean up code related to ServiceWorkerOnUI, this CL removes
RunOrPostTaskOnCoreThread() in ServiceWorkerContextWatcher.

Bug: 1138155
Change-Id: Icce0ab49209026e6323d79d0541840e023a30b66
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2600756
Auto-Submit: Makoto Shimazu <shimazu@chromium.org>
Commit-Queue: Asami Doi <asamidoi@chromium.org>
Reviewed-by: default avatarAsami Doi <asamidoi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#839023}
parent 385197d4
......@@ -43,33 +43,23 @@ ServiceWorkerContextWatcher::ServiceWorkerContextWatcher(
void ServiceWorkerContextWatcher::Start() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
ServiceWorkerContextWrapper::RunOrPostTaskOnCoreThread(
FROM_HERE,
base::BindOnce(
&ServiceWorkerContextWatcher::GetStoredRegistrationsOnCoreThread,
this));
if (is_stopped_)
return;
context_->GetAllRegistrations(base::BindOnce(
&ServiceWorkerContextWatcher::OnStoredRegistrations, this));
}
void ServiceWorkerContextWatcher::Stop() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
stop_called_ = true;
ServiceWorkerContextWrapper::RunOrPostTaskOnCoreThread(
FROM_HERE,
base::BindOnce(&ServiceWorkerContextWatcher::StopOnCoreThread, this));
}
void ServiceWorkerContextWatcher::GetStoredRegistrationsOnCoreThread() {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
if (is_stopped_)
return;
context_->GetAllRegistrations(base::BindOnce(
&ServiceWorkerContextWatcher::OnStoredRegistrationsOnCoreThread, this));
context_->RemoveObserver(this);
is_stopped_ = true;
}
void ServiceWorkerContextWatcher::OnStoredRegistrationsOnCoreThread(
void ServiceWorkerContextWatcher::OnStoredRegistrations(
blink::ServiceWorkerStatusCode status,
const std::vector<ServiceWorkerRegistrationInfo>& stored_registrations) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (is_stopped_)
return;
context_->AddObserver(this);
......@@ -114,20 +104,13 @@ void ServiceWorkerContextWatcher::OnStoredRegistrationsOnCoreThread(
std::move(versions)));
}
void ServiceWorkerContextWatcher::StopOnCoreThread() {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
context_->RemoveObserver(this);
is_stopped_ = true;
}
ServiceWorkerContextWatcher::~ServiceWorkerContextWatcher() {
}
ServiceWorkerContextWatcher::~ServiceWorkerContextWatcher() = default;
void ServiceWorkerContextWatcher::StoreRegistrationInfo(
const ServiceWorkerRegistrationInfo& registration_info,
std::unordered_map<int64_t, std::unique_ptr<ServiceWorkerRegistrationInfo>>*
info_map) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (registration_info.registration_id ==
blink::mojom::kInvalidServiceWorkerRegistrationId)
return;
......@@ -140,7 +123,7 @@ void ServiceWorkerContextWatcher::StoreRegistrationInfo(
void ServiceWorkerContextWatcher::StoreVersionInfo(
const ServiceWorkerVersionInfo& version_info) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (version_info.version_id == blink::mojom::kInvalidServiceWorkerVersionId)
return;
version_info_map_[version_info.version_id] =
......@@ -151,7 +134,7 @@ void ServiceWorkerContextWatcher::SendRegistrationInfo(
int64_t registration_id,
const GURL& scope,
ServiceWorkerRegistrationInfo::DeleteFlag delete_flag) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
DCHECK_CURRENTLY_ON(BrowserThread::UI);
std::unique_ptr<std::vector<ServiceWorkerRegistrationInfo>> registrations =
std::make_unique<std::vector<ServiceWorkerRegistrationInfo>>();
ServiceWorkerRegistration* registration =
......@@ -171,7 +154,7 @@ void ServiceWorkerContextWatcher::SendRegistrationInfo(
void ServiceWorkerContextWatcher::SendVersionInfo(
const ServiceWorkerVersionInfo& version_info) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
DCHECK_CURRENTLY_ON(BrowserThread::UI);
std::unique_ptr<std::vector<ServiceWorkerVersionInfo>> versions =
std::make_unique<std::vector<ServiceWorkerVersionInfo>>();
versions->push_back(version_info);
......@@ -210,14 +193,14 @@ void ServiceWorkerContextWatcher::RunWorkerErrorReportedCallback(
void ServiceWorkerContextWatcher::OnNewLiveRegistration(int64_t registration_id,
const GURL& scope) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
DCHECK_CURRENTLY_ON(BrowserThread::UI);
SendRegistrationInfo(registration_id, scope,
ServiceWorkerRegistrationInfo::IS_NOT_DELETED);
}
void ServiceWorkerContextWatcher::OnNewLiveVersion(
const ServiceWorkerVersionInfo& version_info) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
DCHECK_CURRENTLY_ON(BrowserThread::UI);
int64_t version_id = version_info.version_id;
auto it = version_info_map_.find(version_id);
if (it != version_info_map_.end()) {
......@@ -258,7 +241,7 @@ void ServiceWorkerContextWatcher::OnVersionStateChanged(
int64_t version_id,
const GURL& scope,
content::ServiceWorkerVersion::Status status) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
DCHECK_CURRENTLY_ON(BrowserThread::UI);
auto it = version_info_map_.find(version_id);
if (it == version_info_map_.end())
return;
......@@ -275,7 +258,7 @@ void ServiceWorkerContextWatcher::OnVersionDevToolsRoutingIdChanged(
int64_t version_id,
int process_id,
int devtools_agent_route_id) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
DCHECK_CURRENTLY_ON(BrowserThread::UI);
auto it = version_info_map_.find(version_id);
if (it == version_info_map_.end())
return;
......@@ -295,7 +278,7 @@ void ServiceWorkerContextWatcher::OnMainScriptResponseSet(
int64_t version_id,
base::Time script_response_time,
base::Time script_last_modified) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
DCHECK_CURRENTLY_ON(BrowserThread::UI);
auto it = version_info_map_.find(version_id);
if (it == version_info_map_.end())
return;
......@@ -309,7 +292,7 @@ void ServiceWorkerContextWatcher::OnErrorReported(
int64_t version_id,
const GURL& scope,
const ServiceWorkerContextObserver::ErrorInfo& info) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
DCHECK_CURRENTLY_ON(BrowserThread::UI);
int64_t registration_id = blink::mojom::kInvalidServiceWorkerRegistrationId;
auto it = version_info_map_.find(version_id);
if (it != version_info_map_.end())
......@@ -326,7 +309,7 @@ void ServiceWorkerContextWatcher::OnReportConsoleMessage(
int64_t version_id,
const GURL& scope,
const ConsoleMessage& message) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (message.message_level != blink::mojom::ConsoleMessageLevel::kError)
return;
int64_t registration_id = blink::mojom::kInvalidServiceWorkerRegistrationId;
......@@ -347,7 +330,7 @@ void ServiceWorkerContextWatcher::OnControlleeAdded(
int64_t version_id,
const std::string& uuid,
const ServiceWorkerClientInfo& info) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
DCHECK_CURRENTLY_ON(BrowserThread::UI);
auto it = version_info_map_.find(version_id);
if (it == version_info_map_.end())
return;
......@@ -360,7 +343,7 @@ void ServiceWorkerContextWatcher::OnControlleeAdded(
void ServiceWorkerContextWatcher::OnControlleeRemoved(int64_t version_id,
const std::string& uuid) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
DCHECK_CURRENTLY_ON(BrowserThread::UI);
auto it = version_info_map_.find(version_id);
if (it == version_info_map_.end())
return;
......@@ -372,14 +355,14 @@ void ServiceWorkerContextWatcher::OnControlleeRemoved(int64_t version_id,
void ServiceWorkerContextWatcher::OnRegistrationCompleted(
int64_t registration_id,
const GURL& scope) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
DCHECK_CURRENTLY_ON(BrowserThread::UI);
SendRegistrationInfo(registration_id, scope,
ServiceWorkerRegistrationInfo::IS_NOT_DELETED);
}
void ServiceWorkerContextWatcher::OnRegistrationDeleted(int64_t registration_id,
const GURL& scope) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
DCHECK_CURRENTLY_ON(BrowserThread::UI);
SendRegistrationInfo(registration_id, scope,
ServiceWorkerRegistrationInfo::IS_DELETED);
}
......@@ -387,7 +370,7 @@ void ServiceWorkerContextWatcher::OnRegistrationDeleted(int64_t registration_id,
void ServiceWorkerContextWatcher::OnRunningStateChanged(
int64_t version_id,
EmbeddedWorkerStatus running_status) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
DCHECK_CURRENTLY_ON(BrowserThread::UI);
auto it = version_info_map_.find(version_id);
if (it == version_info_map_.end())
return;
......
......@@ -52,11 +52,9 @@ class CONTENT_EXPORT ServiceWorkerContextWatcher
~ServiceWorkerContextWatcher() override;
void GetStoredRegistrationsOnCoreThread();
void OnStoredRegistrationsOnCoreThread(
void OnStoredRegistrations(
blink::ServiceWorkerStatusCode status,
const std::vector<ServiceWorkerRegistrationInfo>& stored_registrations);
void StopOnCoreThread();
void StoreRegistrationInfo(
const ServiceWorkerRegistrationInfo& registration,
......
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