| OLD | NEW |
| 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 21 matching lines...) Expand all Loading... |
| 32 #include "core/timing/PerformanceTiming.h" | 32 #include "core/timing/PerformanceTiming.h" |
| 33 | 33 |
| 34 #include "bindings/core/v8/ScriptValue.h" | 34 #include "bindings/core/v8/ScriptValue.h" |
| 35 #include "bindings/core/v8/V8ObjectBuilder.h" | 35 #include "bindings/core/v8/V8ObjectBuilder.h" |
| 36 #include "core/dom/Document.h" | 36 #include "core/dom/Document.h" |
| 37 #include "core/dom/DocumentTiming.h" | 37 #include "core/dom/DocumentTiming.h" |
| 38 #include "core/frame/LocalFrame.h" | 38 #include "core/frame/LocalFrame.h" |
| 39 #include "core/loader/DocumentLoadTiming.h" | 39 #include "core/loader/DocumentLoadTiming.h" |
| 40 #include "core/loader/DocumentLoader.h" | 40 #include "core/loader/DocumentLoader.h" |
| 41 #include "core/loader/FrameLoader.h" | 41 #include "core/loader/FrameLoader.h" |
| 42 #include "core/paint/PaintTiming.h" |
| 42 #include "core/timing/PerformanceBase.h" | 43 #include "core/timing/PerformanceBase.h" |
| 43 #include "platform/network/ResourceLoadTiming.h" | 44 #include "platform/network/ResourceLoadTiming.h" |
| 44 #include "platform/network/ResourceResponse.h" | 45 #include "platform/network/ResourceResponse.h" |
| 45 | 46 |
| 46 namespace blink { | 47 namespace blink { |
| 47 | 48 |
| 48 static unsigned long long toIntegerMilliseconds(double seconds) | 49 static unsigned long long toIntegerMilliseconds(double seconds) |
| 49 { | 50 { |
| 50 ASSERT(seconds >= 0); | 51 ASSERT(seconds >= 0); |
| 51 double clampedSeconds = PerformanceBase::clampTimeResolution(seconds); | 52 double clampedSeconds = PerformanceBase::clampTimeResolution(seconds); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 { | 320 { |
| 320 const DocumentTiming* timing = documentTiming(); | 321 const DocumentTiming* timing = documentTiming(); |
| 321 if (!timing) | 322 if (!timing) |
| 322 return 0; | 323 return 0; |
| 323 | 324 |
| 324 return monotonicTimeToIntegerMilliseconds(timing->firstLayout()); | 325 return monotonicTimeToIntegerMilliseconds(timing->firstLayout()); |
| 325 } | 326 } |
| 326 | 327 |
| 327 unsigned long long PerformanceTiming::firstPaint() const | 328 unsigned long long PerformanceTiming::firstPaint() const |
| 328 { | 329 { |
| 329 const DocumentTiming* timing = documentTiming(); | 330 const PaintTiming* timing = paintTiming(); |
| 330 if (!timing) | 331 if (!timing) |
| 331 return 0; | 332 return 0; |
| 332 | 333 |
| 333 return monotonicTimeToIntegerMilliseconds(timing->firstPaint()); | 334 return monotonicTimeToIntegerMilliseconds(timing->firstPaint()); |
| 334 } | 335 } |
| 335 | 336 |
| 336 unsigned long long PerformanceTiming::firstTextPaint() const | 337 unsigned long long PerformanceTiming::firstTextPaint() const |
| 337 { | 338 { |
| 338 const DocumentTiming* timing = documentTiming(); | 339 const PaintTiming* timing = paintTiming(); |
| 339 if (!timing) | 340 if (!timing) |
| 340 return 0; | 341 return 0; |
| 341 | 342 |
| 342 return monotonicTimeToIntegerMilliseconds(timing->firstTextPaint()); | 343 return monotonicTimeToIntegerMilliseconds(timing->firstTextPaint()); |
| 343 } | 344 } |
| 344 | 345 |
| 345 unsigned long long PerformanceTiming::firstImagePaint() const | 346 unsigned long long PerformanceTiming::firstImagePaint() const |
| 346 { | 347 { |
| 347 const DocumentTiming* timing = documentTiming(); | 348 const PaintTiming* timing = paintTiming(); |
| 348 if (!timing) | 349 if (!timing) |
| 349 return 0; | 350 return 0; |
| 350 | 351 |
| 351 return monotonicTimeToIntegerMilliseconds(timing->firstImagePaint()); | 352 return monotonicTimeToIntegerMilliseconds(timing->firstImagePaint()); |
| 352 } | 353 } |
| 353 | 354 |
| 354 DocumentLoader* PerformanceTiming::documentLoader() const | 355 DocumentLoader* PerformanceTiming::documentLoader() const |
| 355 { | 356 { |
| 356 if (!m_frame) | 357 if (!m_frame) |
| 357 return nullptr; | 358 return nullptr; |
| 358 | 359 |
| 359 return m_frame->loader().documentLoader(); | 360 return m_frame->loader().documentLoader(); |
| 360 } | 361 } |
| 361 | 362 |
| 362 const DocumentTiming* PerformanceTiming::documentTiming() const | 363 const DocumentTiming* PerformanceTiming::documentTiming() const |
| 363 { | 364 { |
| 364 if (!m_frame) | 365 if (!m_frame) |
| 365 return nullptr; | 366 return nullptr; |
| 366 | 367 |
| 367 Document* document = m_frame->document(); | 368 Document* document = m_frame->document(); |
| 368 if (!document) | 369 if (!document) |
| 369 return nullptr; | 370 return nullptr; |
| 370 | 371 |
| 371 return &document->timing(); | 372 return &document->timing(); |
| 372 } | 373 } |
| 373 | 374 |
| 375 const PaintTiming* PerformanceTiming::paintTiming() const |
| 376 { |
| 377 if (!m_frame) |
| 378 return nullptr; |
| 379 |
| 380 Document* document = m_frame->document(); |
| 381 if (!document) |
| 382 return nullptr; |
| 383 |
| 384 return &PaintTiming::from(*document); |
| 385 } |
| 386 |
| 374 DocumentLoadTiming* PerformanceTiming::documentLoadTiming() const | 387 DocumentLoadTiming* PerformanceTiming::documentLoadTiming() const |
| 375 { | 388 { |
| 376 DocumentLoader* loader = documentLoader(); | 389 DocumentLoader* loader = documentLoader(); |
| 377 if (!loader) | 390 if (!loader) |
| 378 return nullptr; | 391 return nullptr; |
| 379 | 392 |
| 380 return &loader->timing(); | 393 return &loader->timing(); |
| 381 } | 394 } |
| 382 | 395 |
| 383 ResourceLoadTiming* PerformanceTiming::resourceLoadTiming() const | 396 ResourceLoadTiming* PerformanceTiming::resourceLoadTiming() const |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 | 447 |
| 435 return timing->pseudoWallTimeToMonotonicTime(toDoubleSeconds(integerMillisec
onds)); | 448 return timing->pseudoWallTimeToMonotonicTime(toDoubleSeconds(integerMillisec
onds)); |
| 436 } | 449 } |
| 437 | 450 |
| 438 DEFINE_TRACE(PerformanceTiming) | 451 DEFINE_TRACE(PerformanceTiming) |
| 439 { | 452 { |
| 440 DOMWindowProperty::trace(visitor); | 453 DOMWindowProperty::trace(visitor); |
| 441 } | 454 } |
| 442 | 455 |
| 443 } // namespace blink | 456 } // namespace blink |
| OLD | NEW |