Commit 5592d099 authored by shimazu's avatar shimazu Committed by Commit bot

ServiceWorker: Convert status code to string for logging

BUG=N/A
TEST=N/A

Review URL: https://codereview.chromium.org/654823002

Cr-Commit-Position: refs/heads/master@{#300061}
parent 45796dc8
...@@ -265,7 +265,10 @@ ServiceWorkerDatabase::Status LevelDBStatusToStatus( ...@@ -265,7 +265,10 @@ ServiceWorkerDatabase::Status LevelDBStatusToStatus(
return ServiceWorkerDatabase::STATUS_ERROR_FAILED; return ServiceWorkerDatabase::STATUS_ERROR_FAILED;
} }
const char* StatusToString(ServiceWorkerDatabase::Status status) { } // namespace
const char* ServiceWorkerDatabase::StatusToString(
ServiceWorkerDatabase::Status status) {
switch (status) { switch (status) {
case ServiceWorkerDatabase::STATUS_OK: case ServiceWorkerDatabase::STATUS_OK:
return "Database OK"; return "Database OK";
...@@ -285,8 +288,6 @@ const char* StatusToString(ServiceWorkerDatabase::Status status) { ...@@ -285,8 +288,6 @@ const char* StatusToString(ServiceWorkerDatabase::Status status) {
return "Database unknown error"; return "Database unknown error";
} }
} // namespace
ServiceWorkerDatabase::RegistrationData::RegistrationData() ServiceWorkerDatabase::RegistrationData::RegistrationData()
: registration_id(kInvalidServiceWorkerRegistrationId), : registration_id(kInvalidServiceWorkerRegistrationId),
version_id(kInvalidServiceWorkerVersionId), version_id(kInvalidServiceWorkerVersionId),
......
...@@ -48,6 +48,7 @@ class CONTENT_EXPORT ServiceWorkerDatabase { ...@@ -48,6 +48,7 @@ class CONTENT_EXPORT ServiceWorkerDatabase {
STATUS_ERROR_FAILED, STATUS_ERROR_FAILED,
STATUS_ERROR_MAX, STATUS_ERROR_MAX,
}; };
static const char* StatusToString(Status status);
struct CONTENT_EXPORT RegistrationData { struct CONTENT_EXPORT RegistrationData {
// These values are immutable for the life of a registration. // These values are immutable for the life of a registration.
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/debug/trace_event.h" #include "base/debug/trace_event.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/hash.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
...@@ -286,7 +285,7 @@ void ServiceWorkerStorage::FindRegistrationForDocument( ...@@ -286,7 +285,7 @@ void ServiceWorkerStorage::FindRegistrationForDocument(
"ServiceWorkerStorage::FindRegistrationForDocument:CheckInstalling", "ServiceWorkerStorage::FindRegistrationForDocument:CheckInstalling",
TRACE_EVENT_SCOPE_THREAD, TRACE_EVENT_SCOPE_THREAD,
"URL", document_url.spec(), "URL", document_url.spec(),
"Status", (status == SERVICE_WORKER_OK) ? "Found" : "Not Found"); "Status", ServiceWorkerStatusToString(status));
CompleteFindNow(installing_registration, CompleteFindNow(installing_registration,
status, status,
callback); callback);
...@@ -788,9 +787,8 @@ void ServiceWorkerStorage::DidReadInitialData( ...@@ -788,9 +787,8 @@ void ServiceWorkerStorage::DidReadInitialData(
registered_origins_.swap(data->origins); registered_origins_.swap(data->origins);
state_ = INITIALIZED; state_ = INITIALIZED;
} else { } else {
// TODO(nhiroki): Stringify |status| using StatusToString() defined in DVLOG(2) << "Failed to initialize: "
// service_worker_database.cc. << ServiceWorkerDatabase::StatusToString(status);
DVLOG(2) << "Failed to initialize: " << status;
ScheduleDeleteAndStartOver(); ScheduleDeleteAndStartOver();
} }
...@@ -814,7 +812,7 @@ void ServiceWorkerStorage::DidFindRegistrationForDocument( ...@@ -814,7 +812,7 @@ void ServiceWorkerStorage::DidFindRegistrationForDocument(
"ServiceWorker", "ServiceWorker",
"ServiceWorkerStorage::FindRegistrationForDocument", "ServiceWorkerStorage::FindRegistrationForDocument",
callback_id, callback_id,
"Status", "OK"); "Status", ServiceWorkerDatabase::StatusToString(status));
return; return;
} }
...@@ -822,14 +820,18 @@ void ServiceWorkerStorage::DidFindRegistrationForDocument( ...@@ -822,14 +820,18 @@ void ServiceWorkerStorage::DidFindRegistrationForDocument(
// Look for something currently being installed. // Look for something currently being installed.
scoped_refptr<ServiceWorkerRegistration> installing_registration = scoped_refptr<ServiceWorkerRegistration> installing_registration =
FindInstallingRegistrationForDocument(document_url); FindInstallingRegistrationForDocument(document_url);
callback.Run(installing_registration.get() ? SERVICE_WORKER_OK ServiceWorkerStatusCode installing_status = installing_registration.get() ?
: SERVICE_WORKER_ERROR_NOT_FOUND, SERVICE_WORKER_OK : SERVICE_WORKER_ERROR_NOT_FOUND;
installing_registration); callback.Run(installing_status, installing_registration);
TRACE_EVENT_ASYNC_END1( TRACE_EVENT_ASYNC_END2(
"ServiceWorker", "ServiceWorker",
"ServiceWorkerStorage::FindRegistrationForDocument", "ServiceWorkerStorage::FindRegistrationForDocument",
callback_id, callback_id,
"Status", status); "Status", ServiceWorkerDatabase::StatusToString(status),
"Info",
(installing_status == SERVICE_WORKER_OK) ?
"Installing registration is found" :
"Any registrations are not found");
return; return;
} }
...@@ -840,7 +842,7 @@ void ServiceWorkerStorage::DidFindRegistrationForDocument( ...@@ -840,7 +842,7 @@ void ServiceWorkerStorage::DidFindRegistrationForDocument(
"ServiceWorker", "ServiceWorker",
"ServiceWorkerStorage::FindRegistrationForDocument", "ServiceWorkerStorage::FindRegistrationForDocument",
callback_id, callback_id,
"Status", status); "Status", ServiceWorkerDatabase::StatusToString(status));
} }
void ServiceWorkerStorage::DidFindRegistrationForPattern( void ServiceWorkerStorage::DidFindRegistrationForPattern(
...@@ -1460,7 +1462,8 @@ void ServiceWorkerStorage::DidDeleteDatabase( ...@@ -1460,7 +1462,8 @@ void ServiceWorkerStorage::DidDeleteDatabase(
DCHECK_EQ(DISABLED, state_); DCHECK_EQ(DISABLED, state_);
if (status != ServiceWorkerDatabase::STATUS_OK) { if (status != ServiceWorkerDatabase::STATUS_OK) {
// Give up the corruption recovery until the browser restarts. // Give up the corruption recovery until the browser restarts.
LOG(ERROR) << "Failed to delete the database: " << status; LOG(ERROR) << "Failed to delete the database: "
<< ServiceWorkerDatabase::StatusToString(status);
callback.Run(DatabaseStatusToStatusCode(status)); callback.Run(DatabaseStatusToStatusCode(status));
return; return;
} }
......
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