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

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

Issue 2444783002: Add trace event for complete network request (Closed)
Patch Set: Address review comments 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 #include "wtf/text/CString.h"
9
10 namespace network_instrumentation {
11
12 using network_instrumentation::RequestOutcome;
13
14 const char kBlinkResourceID[] = "BlinkResourceID";
15 const char kResourceLoadTitle[] = "ResourceLoad";
16 const char kNetInstrumentationCategory[] = TRACE_DISABLED_BY_DEFAULT("net.v2");
17
18 const char* RequestOutcomeToString(RequestOutcome outcome) {
19 switch (outcome) {
20 case RequestOutcome::Success:
21 return "Success";
22 case RequestOutcome::Fail:
23 return "Fail";
24 default:
25 NOTREACHED();
26 }
27 }
28
29 ScopedResourceLoadTracker::ScopedResourceLoadTracker(
30 unsigned long resourceID,
31 const blink::ResourceRequest& request)
32 : closeSliceAtEndOfScope(true), resourceID(resourceID), request(request) {
33 beginResourceLoad(resourceID, request);
34 }
35
36 ScopedResourceLoadTracker::~ScopedResourceLoadTracker() {
37 if (this->closeSliceAtEndOfScope)
38 endResourceLoad(this->resourceID, RequestOutcome::Fail);
39 }
40
41 void ScopedResourceLoadTracker::doNotCloseSliceAtEndOfScope() {
42 this->closeSliceAtEndOfScope = false;
43 }
44
45 void beginResourceLoad(unsigned long resourceID,
chiniforooshan 2016/11/03 15:50:36 Is it necessary to have this function? I would mov
dproy 2016/11/03 16:27:19 I moved it inside.
46 const blink::ResourceRequest& request) {
47 const String urlString = request.url().getString();
48 TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(
49 kNetInstrumentationCategory, kResourceLoadTitle,
50 TRACE_ID_WITH_SCOPE(kBlinkResourceID, TRACE_ID_LOCAL(resourceID)), "url",
51 TRACE_STR_COPY(urlString.utf8().data()));
chiniforooshan 2016/11/03 15:50:36 is TRACE_STR_COPY(request.url().getString().utf8()
dproy 2016/11/03 16:27:19 Done.
52 }
53
54 void endResourceLoad(unsigned long resourceID, RequestOutcome outcome) {
55 TRACE_EVENT_NESTABLE_ASYNC_END1(
56 kNetInstrumentationCategory, kResourceLoadTitle,
57 TRACE_ID_WITH_SCOPE(kBlinkResourceID, TRACE_ID_LOCAL(resourceID)),
58 "outcome", TRACE_STR_COPY(RequestOutcomeToString(outcome)));
59 }
60
61 } // namespace network_instrumentation
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698