Commit fac0ab04 authored by Pavel Feldman's avatar Pavel Feldman Committed by Commit Bot

DevTools: expose network idle times in the detector.

Change-Id: Ife445be39e0c6be0cec0abfc154c700b275b7433
Reviewed-on: https://chromium-review.googlesource.com/721802Reviewed-by: default avatarAndrey Lushnikov <lushnikov@chromium.org>
Commit-Queue: Pavel Feldman <pfeldman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#509410}
parent 837569dd
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include "core/inspector/MainThreadDebugger.h" #include "core/inspector/MainThreadDebugger.h"
#include "core/loader/FrameFetchContext.h" #include "core/loader/FrameFetchContext.h"
#include "core/loader/FrameLoader.h" #include "core/loader/FrameLoader.h"
#include "core/loader/IdlenessDetector.h"
#include "core/loader/LinkLoader.h" #include "core/loader/LinkLoader.h"
#include "core/loader/NetworkHintsInterface.h" #include "core/loader/NetworkHintsInterface.h"
#include "core/loader/ProgressTracker.h" #include "core/loader/ProgressTracker.h"
...@@ -941,6 +942,7 @@ void DocumentLoader::WillCommitNavigation() { ...@@ -941,6 +942,7 @@ void DocumentLoader::WillCommitNavigation() {
if (GetFrameLoader().StateMachine()->CreatingInitialEmptyDocument()) if (GetFrameLoader().StateMachine()->CreatingInitialEmptyDocument())
return; return;
probe::willCommitLoad(frame_, this); probe::willCommitLoad(frame_, this);
frame_->GetIdlenessDetector()->WillCommitLoad();
} }
void DocumentLoader::DidCommitNavigation() { void DocumentLoader::DidCommitNavigation() {
......
...@@ -19,6 +19,11 @@ void IdlenessDetector::Shutdown() { ...@@ -19,6 +19,11 @@ void IdlenessDetector::Shutdown() {
local_frame_ = nullptr; local_frame_ = nullptr;
} }
void IdlenessDetector::WillCommitLoad() {
network_2_quiet_start_time_ = 0;
network_0_quiet_start_time_ = 0;
}
void IdlenessDetector::DomContentLoadedEventFired() { void IdlenessDetector::DomContentLoadedEventFired() {
if (!local_frame_) if (!local_frame_)
return; return;
...@@ -100,6 +105,14 @@ void IdlenessDetector::OnDidLoadResource() { ...@@ -100,6 +105,14 @@ void IdlenessDetector::OnDidLoadResource() {
} }
} }
double IdlenessDetector::GetNetworkAlmostIdleTime() {
return network_2_quiet_start_time_;
}
double IdlenessDetector::GetNetworkIdleTime() {
return network_0_quiet_start_time_;
}
void IdlenessDetector::WillProcessTask(double start_time) { void IdlenessDetector::WillProcessTask(double start_time) {
// If we have idle time and we are kNetworkQuietWindowSeconds seconds past it, // If we have idle time and we are kNetworkQuietWindowSeconds seconds past it,
// emit idle signals. // emit idle signals.
......
...@@ -30,12 +30,16 @@ class CORE_EXPORT IdlenessDetector ...@@ -30,12 +30,16 @@ class CORE_EXPORT IdlenessDetector
explicit IdlenessDetector(LocalFrame*); explicit IdlenessDetector(LocalFrame*);
void Shutdown(); void Shutdown();
void WillCommitLoad();
void DomContentLoadedEventFired(); void DomContentLoadedEventFired();
// TODO(lpy) Don't need to pass in fetcher once the command line of disabling // TODO(lpy) Don't need to pass in fetcher once the command line of disabling
// PlzNavigate is removed. // PlzNavigate is removed.
void OnWillSendRequest(ResourceFetcher*); void OnWillSendRequest(ResourceFetcher*);
void OnDidLoadResource(); void OnDidLoadResource();
double GetNetworkAlmostIdleTime();
double GetNetworkIdleTime();
DECLARE_TRACE(); DECLARE_TRACE();
private: private:
...@@ -60,8 +64,8 @@ class CORE_EXPORT IdlenessDetector ...@@ -60,8 +64,8 @@ class CORE_EXPORT IdlenessDetector
double network_0_quiet_ = 0; double network_0_quiet_ = 0;
double network_2_quiet_ = 0; double network_2_quiet_ = 0;
// Record the actual start time of network quiet. // Record the actual start time of network quiet.
double network_0_quiet_start_time_; double network_0_quiet_start_time_ = 0;
double network_2_quiet_start_time_; double network_2_quiet_start_time_ = 0;
TaskRunnerTimer<IdlenessDetector> network_quiet_timer_; TaskRunnerTimer<IdlenessDetector> network_quiet_timer_;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment