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

Side by Side Diff: Source/core/timing/PerformanceTiming.cpp

Issue 1171893004: bindings: Supports serializer for PerformanceTiming. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added a test for PerformanceTiming's serializer. Created 5 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/timing/PerformanceTiming.h ('k') | Source/core/timing/PerformanceTiming.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/timing/PerformanceTiming.h" 32 #include "core/timing/PerformanceTiming.h"
33 33
34 #include "bindings/core/v8/ScriptValue.h"
35 #include "bindings/core/v8/V8ObjectBuilder.h"
34 #include "core/dom/Document.h" 36 #include "core/dom/Document.h"
35 #include "core/dom/DocumentTiming.h" 37 #include "core/dom/DocumentTiming.h"
36 #include "core/frame/LocalFrame.h" 38 #include "core/frame/LocalFrame.h"
37 #include "core/loader/DocumentLoadTiming.h" 39 #include "core/loader/DocumentLoadTiming.h"
38 #include "core/loader/DocumentLoader.h" 40 #include "core/loader/DocumentLoader.h"
39 #include "core/loader/FrameLoader.h" 41 #include "core/loader/FrameLoader.h"
40 #include "platform/network/ResourceLoadTiming.h" 42 #include "platform/network/ResourceLoadTiming.h"
41 #include "platform/network/ResourceResponse.h" 43 #include "platform/network/ResourceResponse.h"
42 44
43 namespace blink { 45 namespace blink {
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 344
343 ResourceLoadTiming* PerformanceTiming::resourceLoadTiming() const 345 ResourceLoadTiming* PerformanceTiming::resourceLoadTiming() const
344 { 346 {
345 DocumentLoader* loader = documentLoader(); 347 DocumentLoader* loader = documentLoader();
346 if (!loader) 348 if (!loader)
347 return nullptr; 349 return nullptr;
348 350
349 return loader->response().resourceLoadTiming(); 351 return loader->response().resourceLoadTiming();
350 } 352 }
351 353
354 ScriptValue PerformanceTiming::toJSONForBinding(ScriptState* scriptState)
355 {
356 V8ObjectBuilder result(scriptState);
357 result.addNumber("navigationStart", navigationStart());
358 result.addNumber("unloadEventStart", unloadEventStart());
359 result.addNumber("unloadEventEnd", unloadEventEnd());
360 result.addNumber("redirectStart", redirectStart());
361 result.addNumber("redirectEnd", redirectEnd());
362 result.addNumber("fetchStart", fetchStart());
363 result.addNumber("domainLookupStart", domainLookupStart());
364 result.addNumber("domainLookupEnd", domainLookupEnd());
365 result.addNumber("connectStart", connectStart());
366 result.addNumber("connectEnd", connectEnd());
367 result.addNumber("secureConnectionStart", secureConnectionStart());
368 result.addNumber("requestStart", requestStart());
369 result.addNumber("responseStart", responseStart());
370 result.addNumber("responseEnd", responseEnd());
371 result.addNumber("domLoading", domLoading());
372 result.addNumber("domInteractive", domInteractive());
373 result.addNumber("domContentLoadedEventStart", domContentLoadedEventStart()) ;
374 result.addNumber("domContentLoadedEventEnd", domContentLoadedEventEnd());
375 result.addNumber("domComplete", domComplete());
376 result.addNumber("loadEventStart", loadEventStart());
377 result.addNumber("loadEventEnd", loadEventEnd());
378 return result.scriptValue();
379 }
380
352 unsigned long long PerformanceTiming::monotonicTimeToIntegerMilliseconds(double monotonicSeconds) const 381 unsigned long long PerformanceTiming::monotonicTimeToIntegerMilliseconds(double monotonicSeconds) const
353 { 382 {
354 ASSERT(monotonicSeconds >= 0); 383 ASSERT(monotonicSeconds >= 0);
355 const DocumentLoadTiming* timing = documentLoadTiming(); 384 const DocumentLoadTiming* timing = documentLoadTiming();
356 if (!timing) 385 if (!timing)
357 return 0; 386 return 0;
358 387
359 return toIntegerMilliseconds(timing->monotonicTimeToPseudoWallTime(monotonic Seconds)); 388 return toIntegerMilliseconds(timing->monotonicTimeToPseudoWallTime(monotonic Seconds));
360 } 389 }
361 390
362 double PerformanceTiming::integerMillisecondsToMonotonicTime(unsigned long long integerMilliseconds) const 391 double PerformanceTiming::integerMillisecondsToMonotonicTime(unsigned long long integerMilliseconds) const
363 { 392 {
364 const DocumentLoadTiming* timing = documentLoadTiming(); 393 const DocumentLoadTiming* timing = documentLoadTiming();
365 if (!timing) 394 if (!timing)
366 return 0; 395 return 0;
367 396
368 return timing->pseudoWallTimeToMonotonicTime(toDoubleSeconds(integerMillisec onds)); 397 return timing->pseudoWallTimeToMonotonicTime(toDoubleSeconds(integerMillisec onds));
369 } 398 }
370 399
371 DEFINE_TRACE(PerformanceTiming) 400 DEFINE_TRACE(PerformanceTiming)
372 { 401 {
373 DOMWindowProperty::trace(visitor); 402 DOMWindowProperty::trace(visitor);
374 } 403 }
375 404
376 } // namespace blink 405 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/timing/PerformanceTiming.h ('k') | Source/core/timing/PerformanceTiming.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698