Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(684)

Unified Diff: content/browser/service_worker/service_worker_url_request_job.cc

Issue 1229733003: Add net logging for ServiceWorkerURLRequestJob. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/log/net_log_event_type_list.h » ('j') | net/log/net_log_event_type_list.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/service_worker/service_worker_url_request_job.cc
diff --git a/content/browser/service_worker/service_worker_url_request_job.cc b/content/browser/service_worker/service_worker_url_request_job.cc
index 8e3f35263c895ee3e18f7e609d6483961375c78d..73f66e26d7f3f05f711e57d308bb99350a50e60d 100644
--- a/content/browser/service_worker/service_worker_url_request_job.cc
+++ b/content/browser/service_worker/service_worker_url_request_job.cc
@@ -34,6 +34,7 @@
#include "net/http/http_response_headers.h"
#include "net/http/http_response_info.h"
#include "net/http/http_util.h"
+#include "net/log/net_log.h"
#include "storage/browser/blob/blob_data_builder.h"
#include "storage/browser/blob/blob_data_handle.h"
#include "storage/browser/blob/blob_storage_context.h"
@@ -42,6 +43,59 @@
namespace content {
+namespace {
+
+net::NetLog::EventType RequestJobResultToNetEventType(
+ ServiceWorkerMetrics::URLRequestJobResult result) {
+ using n = net::NetLog;
+ using m = ServiceWorkerMetrics;
+ switch (result) {
+ case m::REQUEST_JOB_FALLBACK_RESPONSE:
+ return n::TYPE_SERVICE_WORKER_FALLBACK_RESPONSE;
+ case m::REQUEST_JOB_FALLBACK_FOR_CORS:
+ return n::TYPE_SERVICE_WORKER_FALLBACK_FOR_CORS;
+ case m::REQUEST_JOB_HEADERS_ONLY_RESPONSE:
+ return n::TYPE_SERVICE_WORKER_HEADERS_ONLY_RESPONSE;
+ case m::REQUEST_JOB_STREAM_RESPONSE:
+ return n::TYPE_SERVICE_WORKER_STREAM_RESPONSE;
+ case m::REQUEST_JOB_BLOB_RESPONSE:
+ return n::TYPE_SERVICE_WORKER_BLOB_RESPONSE;
+ case m::REQUEST_JOB_ERROR_RESPONSE_STATUS_ZERO:
+ return n::TYPE_SERVICE_WORKER_ERROR_RESPONSE_STATUS_ZERO;
+ case m::REQUEST_JOB_ERROR_BAD_BLOB:
+ return n::TYPE_SERVICE_WORKER_ERROR_BAD_BLOB;
+ case m::REQUEST_JOB_ERROR_NO_PROVIDER_HOST:
+ return n::TYPE_SERVICE_WORKER_ERROR_NO_PROVIDER_HOST;
+ case m::REQUEST_JOB_ERROR_NO_ACTIVE_VERSION:
+ return n::TYPE_SERVICE_WORKER_ERROR_NO_ACTIVE_VERSION;
+ case m::REQUEST_JOB_ERROR_FETCH_EVENT_DISPATCH:
+ return n::TYPE_SERVICE_WORKER_ERROR_FETCH_EVENT_DISPATCH;
+ case m::REQUEST_JOB_ERROR_BLOB_READ:
+ return n::TYPE_SERVICE_WORKER_ERROR_BLOB_READ;
+ case m::REQUEST_JOB_ERROR_STREAM_ABORTED:
+ return n::TYPE_SERVICE_WORKER_ERROR_STREAM_ABORTED;
+ case m::REQUEST_JOB_ERROR_KILLED:
+ return n::TYPE_SERVICE_WORKER_ERROR_KILLED;
+ case m::REQUEST_JOB_ERROR_KILLED_WITH_BLOB:
+ return n::TYPE_SERVICE_WORKER_ERROR_KILLED_WITH_BLOB;
+ case m::REQUEST_JOB_ERROR_KILLED_WITH_STREAM:
+ return n::TYPE_SERVICE_WORKER_ERROR_KILLED_WITH_STREAM;
+ case m::REQUEST_JOB_ERROR_NO_REQUEST:
+ // Fallthrough: we can't log if there's no request.
+ case m::REQUEST_JOB_ERROR_DESTROYED:
+ case m::REQUEST_JOB_ERROR_DESTROYED_WITH_BLOB:
+ case m::REQUEST_JOB_ERROR_DESTROYED_WITH_STREAM:
+ // Fallthrough: obsolete types.
+ case m::NUM_REQUEST_JOB_RESULT_TYPES:
+ // Invalid type.
+ NOTREACHED() << result;
+ }
+ NOTREACHED() << result;
+ return n::TYPE_FAILED;
+}
+
+} // namespace
+
ServiceWorkerURLRequestJob::ServiceWorkerURLRequestJob(
net::URLRequest* request,
net::NetworkDelegate* network_delegate,
@@ -90,16 +144,6 @@ void ServiceWorkerURLRequestJob::Start() {
}
void ServiceWorkerURLRequestJob::Kill() {
- if (ShouldRecordResult()) {
- ServiceWorkerMetrics::URLRequestJobResult result =
- ServiceWorkerMetrics::REQUEST_JOB_ERROR_KILLED;
- if (response_body_type_ == STREAM)
- result = ServiceWorkerMetrics::REQUEST_JOB_ERROR_KILLED_WITH_STREAM;
- else if (response_body_type_ == BLOB)
- result = ServiceWorkerMetrics::REQUEST_JOB_ERROR_KILLED_WITH_BLOB;
- RecordResult(result);
- }
-
net::URLRequestJob::Kill();
ClearStream();
fetch_dispatcher_.reset();
@@ -351,14 +395,12 @@ ServiceWorkerURLRequestJob::~ServiceWorkerURLRequestJob() {
if (!ShouldRecordResult())
return;
- // TODO(falken): If we don't see many of these, we might merge KILLED and
- // DESTROYED results together.
kinuko 2015/07/09 13:52:41 So we didn't see many of these?
falken 2015/07/09 14:26:29 Right, there were zero of these.
ServiceWorkerMetrics::URLRequestJobResult result =
- ServiceWorkerMetrics::REQUEST_JOB_ERROR_DESTROYED;
+ ServiceWorkerMetrics::REQUEST_JOB_ERROR_KILLED;
if (response_body_type_ == STREAM)
- result = ServiceWorkerMetrics::REQUEST_JOB_ERROR_DESTROYED_WITH_STREAM;
+ result = ServiceWorkerMetrics::REQUEST_JOB_ERROR_KILLED_WITH_STREAM;
else if (response_body_type_ == BLOB)
- result = ServiceWorkerMetrics::REQUEST_JOB_ERROR_DESTROYED_WITH_BLOB;
+ result = ServiceWorkerMetrics::REQUEST_JOB_ERROR_KILLED_WITH_BLOB;
RecordResult(result);
}
@@ -372,6 +414,7 @@ void ServiceWorkerURLRequestJob::MaybeStartRequest() {
}
void ServiceWorkerURLRequestJob::StartRequest() {
+ request()->net_log().AddEvent(net::NetLog::TYPE_SERVICE_WORKER_START_REQUEST);
switch (response_type_) {
case NOT_DETERMINED:
NOTREACHED();
@@ -722,6 +765,8 @@ void ServiceWorkerURLRequestJob::RecordResult(
did_record_result_ = true;
ServiceWorkerMetrics::RecordURLRequestJobResult(is_main_resource_load_,
result);
+ if (request())
+ request()->net_log().AddEvent(RequestJobResultToNetEventType(result));
}
void ServiceWorkerURLRequestJob::RecordStatusZeroResponseError(
« no previous file with comments | « no previous file | net/log/net_log_event_type_list.h » ('j') | net/log/net_log_event_type_list.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698