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

Unified Diff: components/html_viewer/html_document.cc

Issue 1278673002: Add stats collection for telemetry startup.warm.blank_page test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cache and reuse a single mojo:tracing connection in mojo:html_viewer. Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: components/html_viewer/html_document.cc
diff --git a/components/html_viewer/html_document.cc b/components/html_viewer/html_document.cc
index 3d3a30312f8d2bcd0d25fe810d12bdd4513cd578..0c8d9beb03c5d37a0abe30e679aa74b525d8bcf3 100644
--- a/components/html_viewer/html_document.cc
+++ b/components/html_viewer/html_document.cc
@@ -19,6 +19,7 @@
#include "components/html_viewer/geolocation_client_impl.h"
#include "components/html_viewer/global_state.h"
#include "components/html_viewer/media_factory.h"
+#include "components/html_viewer/stats_collection_controller.h"
#include "components/html_viewer/web_layer_tree_view_impl.h"
#include "components/html_viewer/web_storage_namespace_impl.h"
#include "components/html_viewer/web_url_loader_impl.h"
@@ -159,6 +160,15 @@ HTMLDocument::CreateParams::CreateParams(
HTMLDocument::CreateParams::~CreateParams() {
}
+HTMLDocument::Observer::Observer(HTMLDocument* html_document)
+ : html_document_(html_document) {
sky 2015/08/12 23:54:36 nit: make sure you run git cl format.
msw 2015/08/14 23:20:34 Done.
+ html_document_->AddObserver(this);
+}
+
+HTMLDocument::Observer::~Observer() {
+ html_document_->RemoveObserver(this);
+}
+
HTMLDocument::HTMLDocument(HTMLDocument::CreateParams* params)
: app_refcount_(params->html_document_app->app_lifetime_helper()
->CreateAppRefCount()),
@@ -169,7 +179,8 @@ HTMLDocument::HTMLDocument(HTMLDocument::CreateParams* params)
root_(nullptr),
view_manager_client_factory_(params->html_document_app->shell(), this),
global_state_(params->global_state),
- delete_callback_(params->delete_callback) {
+ delete_callback_(params->delete_callback),
+ stats_collection_controller_(nullptr) {
params->connection->AddService(
static_cast<InterfaceFactory<mojo::AxProvider>*>(this));
params->connection->AddService(&view_manager_client_factory_);
@@ -189,6 +200,14 @@ void HTMLDocument::Destroy() {
}
}
+void HTMLDocument::AddObserver(HTMLDocument::Observer* observer) {
+ observers_.AddObserver(observer);
+}
+
+void HTMLDocument::RemoveObserver(HTMLDocument::Observer* observer) {
+ observers_.RemoveObserver(observer);
+}
+
HTMLDocument::~HTMLDocument() {
delete_callback_.Run(this);
@@ -247,6 +266,9 @@ void HTMLDocument::Load(URLResponsePtr response) {
new DevToolsAgentImpl(main_frame, html_document_app_->shell()));
}
+ stats_collection_controller_ =
+ StatsCollectionController::Install(this, html_document_app_);
+
GURL url(response->url);
WebURLRequestExtraData* extra_data = new WebURLRequestExtraData;
@@ -398,6 +420,21 @@ void HTMLDocument::didAddMessageToConsole(
<< message.text.utf8();
}
+void HTMLDocument::didStartLoading(bool toDifferentDocument) {
+ // TODO(msw): Nix observer pattern, use stats_collection_controller_ directly?
+ FOR_EACH_OBSERVER(HTMLDocument::Observer, observers_, DidStartLoading());
+}
+
+void HTMLDocument::didStopLoading() {
+ // TODO(msw): Nix observer pattern, use stats_collection_controller_ directly?
+ FOR_EACH_OBSERVER(HTMLDocument::Observer, observers_, DidStopLoading());
+}
+
+void HTMLDocument::didHandleOnloadEvents(blink::WebLocalFrame* frame) {
+ if (stats_collection_controller_)
+ stats_collection_controller_->DidHandleOnloadEvents(base::Time::Now());
+}
+
void HTMLDocument::didFinishLoad(blink::WebLocalFrame* frame) {
// TODO(msw): Notify AxProvider clients of updates on child frame loads.
did_finish_load_ = true;
@@ -415,6 +452,13 @@ void HTMLDocument::didNavigateWithinPage(
navigator_host_->DidNavigateLocally(history_item.urlString().utf8());
}
+void HTMLDocument::didFirstVisuallyNonEmptyLayout(blink::WebLocalFrame* frame) {
+ if (stats_collection_controller_) {
+ stats_collection_controller_->DidFirstVisuallyNonEmptyLayout(
+ base::Time::Now());
+ }
+}
+
blink::WebEncryptedMediaClient* HTMLDocument::encryptedMediaClient() {
return global_state_->media_factory()->GetEncryptedMediaClient();
}

Powered by Google App Engine
This is Rietveld 408576698