Skip to content

Commit

Permalink
Update Mandoline didFirstVisuallyNonEmptyLayout observation.
Browse files Browse the repository at this point in the history
Broken by https://codereview.chromium.org/1318283003 etc.
(callback moved from WebFrameClient to Web[View|Widget]Client)

Report the first paint startup metric from HTMLWidgetRootLocal.
Make a new connection (sharing HTMLFrame's is awkward, but possible.)

BUG=513779
TEST=First paint metrics collected on http://build.chromium.org/p/chromium.mojo/builders/Chromium%20Mojo%20Linux%20Perf
R=sky@chromium.org

Review URL: https://codereview.chromium.org/1347433002

Cr-Commit-Position: refs/heads/master@{#348948}
  • Loading branch information
msw authored and Commit bot committed Sep 15, 2015
1 parent 3b42944 commit d24a029
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 11 deletions.
9 changes: 0 additions & 9 deletions components/html_viewer/html_frame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -396,15 +396,6 @@ void HTMLFrame::didNavigateWithinPage(blink::WebLocalFrame* frame,
history_item.urlString().utf8());
}

void HTMLFrame::didFirstVisuallyNonEmptyLayout(blink::WebLocalFrame* frame) {
static bool recorded = false;
if (!recorded && startup_performance_data_collector_) {
startup_performance_data_collector_->SetFirstVisuallyNonEmptyLayoutTime(
base::Time::Now().ToInternalValue());
recorded = true;
}
}

blink::WebGeolocationClient* HTMLFrame::geolocationClient() {
if (!geolocation_client_impl_)
geolocation_client_impl_.reset(new GeolocationClientImpl);
Expand Down
1 change: 0 additions & 1 deletion components/html_viewer/html_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ class HTMLFrame : public blink::WebFrameClient,
virtual void didNavigateWithinPage(blink::WebLocalFrame* frame,
const blink::WebHistoryItem& history_item,
blink::WebHistoryCommitType commit_type);
virtual void didFirstVisuallyNonEmptyLayout(blink::WebLocalFrame* frame);
virtual blink::WebGeolocationClient* geolocationClient();
virtual blink::WebEncryptedMediaClient* encryptedMediaClient();
virtual void didStartLoading(bool to_different_document);
Expand Down
14 changes: 14 additions & 0 deletions components/html_viewer/html_widget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@

#include "components/html_viewer/global_state.h"
#include "components/html_viewer/ime_controller.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/mus/public/cpp/view.h"
#include "mojo/application/public/cpp/application_impl.h"
#include "mojo/services/tracing/public/interfaces/tracing.mojom.h"
#include "third_party/WebKit/public/web/WebFrameWidget.h"
#include "third_party/WebKit/public/web/WebSettings.h"
#include "third_party/WebKit/public/web/WebView.h"
Expand Down Expand Up @@ -117,6 +119,18 @@ blink::WebLayerTreeView* HTMLWidgetRootLocal::layerTreeView() {
return web_layer_tree_view_impl_.get();
}

void HTMLWidgetRootLocal::didFirstVisuallyNonEmptyLayout() {
static bool called = false;
if (!called) {
const int64 time = base::Time::Now().ToInternalValue();
tracing::StartupPerformanceDataCollectorPtr collector =
StatsCollectionController::ConnectToDataCollector(app_);
if (collector)
collector->SetFirstVisuallyNonEmptyLayoutTime(time);
called = true;
}
}

void HTMLWidgetRootLocal::resetInputMethod() {
ime_controller_->ResetInputMethod();
}
Expand Down
1 change: 1 addition & 0 deletions components/html_viewer/html_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class HTMLWidgetRootLocal : public HTMLWidget, public blink::WebViewClient {
virtual blink::WebStorageNamespace* createSessionStorageNamespace();
virtual void initializeLayerTreeView();
virtual blink::WebLayerTreeView* layerTreeView();
virtual void didFirstVisuallyNonEmptyLayout();
virtual void resetInputMethod();
virtual void didHandleGestureEvent(const blink::WebGestureEvent& event,
bool event_cancelled);
Expand Down
17 changes: 17 additions & 0 deletions components/html_viewer/stats_collection_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,23 @@ tracing::StartupPerformanceDataCollectorPtr StatsCollectionController::Install(
return collector_for_caller.Pass();
}

// static
tracing::StartupPerformanceDataCollectorPtr
StatsCollectionController::ConnectToDataCollector(mojo::ApplicationImpl* app) {
// Only make startup tracing available when running in the context of a test.
if (!app ||
!base::CommandLine::ForCurrentProcess()->HasSwitch(
tracing::kEnableStatsCollectionBindings)) {
return nullptr;
}

mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = mojo::String::From("mojo:tracing");
tracing::StartupPerformanceDataCollectorPtr collector;
app->ConnectToService(request.Pass(), &collector);
return collector.Pass();
}

StatsCollectionController::StatsCollectionController(
tracing::StartupPerformanceDataCollectorPtr collector)
: startup_performance_data_collector_(collector.Pass()) {}
Expand Down
7 changes: 6 additions & 1 deletion components/html_viewer/stats_collection_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@ class StatsCollectionController
static gin::WrapperInfo kWrapperInfo;

// Install the JS and return a mojo:tracing InterfacePtr for stats reporting.
// This bails and returns a null pointer without the command line flag.
// This bails and returns a null pointer without the stats command line flag.
static tracing::StartupPerformanceDataCollectorPtr Install(
blink::WebFrame* frame,
mojo::ApplicationImpl* app);

// Return a mojo:metrics InterfacePtr for stats reporting.
// This bails and returns a null pointer without the stats command line flag.
static tracing::StartupPerformanceDataCollectorPtr ConnectToDataCollector(
mojo::ApplicationImpl* app);

private:
explicit StatsCollectionController(
tracing::StartupPerformanceDataCollectorPtr collector);
Expand Down

0 comments on commit d24a029

Please sign in to comment.