Commit 6e67d953 authored by Makoto Shimazu's avatar Makoto Shimazu Committed by Commit Bot

ServiceWorker: More traces for events dispatched to service workers

Bug: 852202, 669772, 806658
Change-Id: Ife9c41fbe08c1f414bb5459cba29d98d7e1fb892
Reviewed-on: https://chromium-review.googlesource.com/1098650
Commit-Queue: Makoto Shimazu <shimazu@chromium.org>
Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567205}
parent b3102f62
...@@ -4,9 +4,6 @@ ...@@ -4,9 +4,6 @@
#include "content/common/service_worker/service_worker_utils.h" #include "content/common/service_worker/service_worker_utils.h"
#include <sstream>
#include <string>
#include "base/command_line.h" #include "base/command_line.h"
#include "base/feature_list.h" #include "base/feature_list.h"
#include "base/logging.h" #include "base/logging.h"
...@@ -147,22 +144,6 @@ bool ServiceWorkerUtils::IsServicificationEnabled() { ...@@ -147,22 +144,6 @@ bool ServiceWorkerUtils::IsServicificationEnabled() {
base::FeatureList::IsEnabled(features::kServiceWorkerServicification); base::FeatureList::IsEnabled(features::kServiceWorkerServicification);
} }
// static
std::string ServiceWorkerUtils::ErrorTypeToString(
blink::mojom::ServiceWorkerErrorType error) {
std::ostringstream oss;
oss << error;
return oss.str();
}
// static
std::string ServiceWorkerUtils::ClientTypeToString(
blink::mojom::ServiceWorkerClientType type) {
std::ostringstream oss;
oss << type;
return oss.str();
}
bool ServiceWorkerUtils::ExtractSinglePartHttpRange( bool ServiceWorkerUtils::ExtractSinglePartHttpRange(
const net::HttpRequestHeaders& headers, const net::HttpRequestHeaders& headers,
bool* has_range_out, bool* has_range_out,
......
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
#ifndef CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_UTILS_H_ #ifndef CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_UTILS_H_
#define CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_UTILS_H_ #define CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_UTILS_H_
#include <sstream>
#include <string>
#include "base/command_line.h" #include "base/command_line.h"
#include "base/macros.h" #include "base/macros.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
...@@ -13,7 +16,6 @@ ...@@ -13,7 +16,6 @@
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "content/public/common/resource_type.h" #include "content/public/common/resource_type.h"
#include "net/http/http_request_headers.h" #include "net/http/http_request_headers.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_error_type.mojom.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace content { namespace content {
...@@ -56,11 +58,12 @@ class ServiceWorkerUtils { ...@@ -56,11 +58,12 @@ class ServiceWorkerUtils {
return provider_id < kInvalidServiceWorkerProviderId; return provider_id < kInvalidServiceWorkerProviderId;
} }
static std::string ErrorTypeToString( template <typename T>
blink::mojom::ServiceWorkerErrorType error); static std::string MojoEnumToString(T mojo_enum) {
std::ostringstream oss;
static std::string ClientTypeToString( oss << mojo_enum;
blink::mojom::ServiceWorkerClientType type); return oss.str();
}
// Sets |has_range| to true if |headers| specify a single range request, and // Sets |has_range| to true if |headers| specify a single range request, and
// |offset| and |size| to the range. Returns true on valid input (regardless // |offset| and |size| to the range. Returns true on valid input (regardless
......
...@@ -230,7 +230,7 @@ void WebServiceWorkerProviderImpl::OnRegistered( ...@@ -230,7 +230,7 @@ void WebServiceWorkerProviderImpl::OnRegistered(
blink::mojom::ServiceWorkerRegistrationObjectInfoPtr registration) { blink::mojom::ServiceWorkerRegistrationObjectInfoPtr registration) {
TRACE_EVENT_ASYNC_END2( TRACE_EVENT_ASYNC_END2(
"ServiceWorker", "WebServiceWorkerProviderImpl::RegisterServiceWorker", "ServiceWorker", "WebServiceWorkerProviderImpl::RegisterServiceWorker",
this, "Error", ServiceWorkerUtils::ErrorTypeToString(error), "Message", this, "Error", ServiceWorkerUtils::MojoEnumToString(error), "Message",
error_msg ? *error_msg : "Success"); error_msg ? *error_msg : "Success");
if (error != blink::mojom::ServiceWorkerErrorType::kNone) { if (error != blink::mojom::ServiceWorkerErrorType::kNone) {
DCHECK(error_msg); DCHECK(error_msg);
...@@ -256,7 +256,7 @@ void WebServiceWorkerProviderImpl::OnDidGetRegistration( ...@@ -256,7 +256,7 @@ void WebServiceWorkerProviderImpl::OnDidGetRegistration(
blink::mojom::ServiceWorkerRegistrationObjectInfoPtr registration) { blink::mojom::ServiceWorkerRegistrationObjectInfoPtr registration) {
TRACE_EVENT_ASYNC_END2("ServiceWorker", TRACE_EVENT_ASYNC_END2("ServiceWorker",
"WebServiceWorkerProviderImpl::GetRegistration", this, "WebServiceWorkerProviderImpl::GetRegistration", this,
"Error", ServiceWorkerUtils::ErrorTypeToString(error), "Error", ServiceWorkerUtils::MojoEnumToString(error),
"Message", error_msg ? *error_msg : "Success"); "Message", error_msg ? *error_msg : "Success");
if (error != blink::mojom::ServiceWorkerErrorType::kNone) { if (error != blink::mojom::ServiceWorkerErrorType::kNone) {
DCHECK(error_msg); DCHECK(error_msg);
...@@ -292,7 +292,7 @@ void WebServiceWorkerProviderImpl::OnDidGetRegistrations( ...@@ -292,7 +292,7 @@ void WebServiceWorkerProviderImpl::OnDidGetRegistrations(
infos) { infos) {
TRACE_EVENT_ASYNC_END2("ServiceWorker", TRACE_EVENT_ASYNC_END2("ServiceWorker",
"WebServiceWorkerProviderImpl::GetRegistrations", this, "WebServiceWorkerProviderImpl::GetRegistrations", this,
"Error", ServiceWorkerUtils::ErrorTypeToString(error), "Error", ServiceWorkerUtils::MojoEnumToString(error),
"Message", error_msg ? *error_msg : "Success"); "Message", error_msg ? *error_msg : "Success");
if (error != blink::mojom::ServiceWorkerErrorType::kNone) { if (error != blink::mojom::ServiceWorkerErrorType::kNone) {
DCHECK(error_msg); DCHECK(error_msg);
......
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