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

Side by Side Diff: third_party/WebKit/Source/platform/network/NetworkInstrumentation.cpp

Issue 2444783002: Add trace event for complete network request (Closed)
Patch Set: Remove empty beginResourceLoad function Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "platform/network/NetworkInstrumentation.h"
6
7 #include "base/trace_event/trace_event.h"
8
9 namespace network_instrumentation {
10
11 using network_instrumentation::RequestOutcome;
12
13 const char kBlinkResourceID[] = "BlinkResourceID";
14 const char kResourceLoadTitle[] = "ResourceLoad";
15 const char kNetInstrumentationCategory[] = TRACE_DISABLED_BY_DEFAULT("net.v2");
fmeawad 2016/11/03 22:18:58 Can you use a category name that does not include
dproy 2016/11/04 20:41:55 Done.
16
17 const char* RequestOutcomeToString(RequestOutcome outcome) {
18 switch (outcome) {
19 case RequestOutcome::Success:
20 return "Success";
21 case RequestOutcome::Fail:
22 return "Fail";
23 default:
24 NOTREACHED();
25 }
26 }
27
28 ScopedResourceLoadTracker::ScopedResourceLoadTracker(
29 unsigned long resourceID,
30 const blink::ResourceRequest& request)
31 : closeSliceAtEndOfScope(true), resourceID(resourceID) {
32 TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(
33 kNetInstrumentationCategory, kResourceLoadTitle,
34 TRACE_ID_WITH_SCOPE(kBlinkResourceID, TRACE_ID_LOCAL(resourceID)), "url",
35 TRACE_STR_COPY(request.url().getString().utf8().data()));
36 }
37
38 ScopedResourceLoadTracker::~ScopedResourceLoadTracker() {
39 if (this->closeSliceAtEndOfScope)
40 endResourceLoad(this->resourceID, RequestOutcome::Fail);
41 }
42
43 void ScopedResourceLoadTracker::doNotCloseSliceAtEndOfScope() {
44 this->closeSliceAtEndOfScope = false;
45 }
46
47 void endResourceLoad(unsigned long resourceID, RequestOutcome outcome) {
48 TRACE_EVENT_NESTABLE_ASYNC_END1(
49 kNetInstrumentationCategory, kResourceLoadTitle,
50 TRACE_ID_WITH_SCOPE(kBlinkResourceID, TRACE_ID_LOCAL(resourceID)),
51 "outcome", TRACE_STR_COPY(RequestOutcomeToString(outcome)));
52 }
53
54 } // namespace network_instrumentation
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698