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

Side by Side Diff: third_party/WebKit/Source/core/timing/Performance.cpp

Issue 2668753006: Special-case LocalDOMWindow for same-origin access in bindings. (Closed)
Patch Set: . Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Intel Inc. All rights reserved. 3 * Copyright (C) 2012 Intel Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 } 179 }
180 180
181 /** 181 /**
182 * Report sanitized name based on cross-origin policy. 182 * Report sanitized name based on cross-origin policy.
183 * See detailed Security doc here: http://bit.ly/2duD3F7 183 * See detailed Security doc here: http://bit.ly/2duD3F7
184 */ 184 */
185 // static 185 // static
186 std::pair<String, DOMWindow*> Performance::sanitizedAttribution( 186 std::pair<String, DOMWindow*> Performance::sanitizedAttribution(
187 ExecutionContext* taskContext, 187 ExecutionContext* taskContext,
188 bool hasMultipleContexts, 188 bool hasMultipleContexts,
189 Frame* observerFrame) { 189 LocalFrame* observerFrame) {
190 if (hasMultipleContexts) { 190 if (hasMultipleContexts) {
191 // Unable to attribute, multiple script execution contents were involved. 191 // Unable to attribute, multiple script execution contents were involved.
192 return std::make_pair(kAmbiguousAttribution, nullptr); 192 return std::make_pair(kAmbiguousAttribution, nullptr);
193 } 193 }
194 194
195 if (!taskContext || !taskContext->isDocument() || 195 if (!taskContext || !taskContext->isDocument() ||
196 !toDocument(taskContext)->frame()) { 196 !toDocument(taskContext)->frame()) {
197 // Unable to attribute as no script was involved. 197 // Unable to attribute as no script was involved.
198 return std::make_pair(kUnknownAttribution, nullptr); 198 return std::make_pair(kUnknownAttribution, nullptr);
199 } 199 }
(...skipping 30 matching lines...) Expand all
230 return std::make_pair(kCrossOriginAttribution, nullptr); 230 return std::make_pair(kCrossOriginAttribution, nullptr);
231 } 231 }
232 232
233 void Performance::reportLongTask(double startTime, 233 void Performance::reportLongTask(double startTime,
234 double endTime, 234 double endTime,
235 ExecutionContext* taskContext, 235 ExecutionContext* taskContext,
236 bool hasMultipleContexts) { 236 bool hasMultipleContexts) {
237 std::pair<String, DOMWindow*> attribution = Performance::sanitizedAttribution( 237 std::pair<String, DOMWindow*> attribution = Performance::sanitizedAttribution(
238 taskContext, hasMultipleContexts, frame()); 238 taskContext, hasMultipleContexts, frame());
239 DOMWindow* culpritDomWindow = attribution.second; 239 DOMWindow* culpritDomWindow = attribution.second;
240 if (!culpritDomWindow || !culpritDomWindow->document() || 240 if (!culpritDomWindow || !culpritDomWindow->frame() ||
241 !culpritDomWindow->document()->localOwner()) { 241 !culpritDomWindow->frame()->deprecatedLocalOwner()) {
242 addLongTaskTiming(startTime, endTime, attribution.first, "", "", ""); 242 addLongTaskTiming(startTime, endTime, attribution.first, emptyString(),
243 emptyString(), emptyString());
dcheng 2017/02/01 07:22:59 To avoid constructing three new empty strings.
243 } else { 244 } else {
244 HTMLFrameOwnerElement* frameOwner = 245 HTMLFrameOwnerElement* frameOwner =
245 culpritDomWindow->document()->localOwner(); 246 culpritDomWindow->frame()->deprecatedLocalOwner();
246 addLongTaskTiming(startTime, endTime, attribution.first, 247 addLongTaskTiming(startTime, endTime, attribution.first,
247 getFrameAttribute(frameOwner, HTMLNames::srcAttr, false), 248 getFrameAttribute(frameOwner, HTMLNames::srcAttr, false),
248 getFrameAttribute(frameOwner, HTMLNames::idAttr, false), 249 getFrameAttribute(frameOwner, HTMLNames::idAttr, false),
249 getFrameAttribute(frameOwner, HTMLNames::nameAttr, true)); 250 getFrameAttribute(frameOwner, HTMLNames::nameAttr, true));
250 } 251 }
251 } 252 }
252 253
253 } // namespace blink 254 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698