blob: ecb2c2c29b74f612f0b7585adf175bfa462085f3 [file] [log] [blame]
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module resource_coordinator.mojom;
import "services/resource_coordinator/public/mojom/coordination_unit.mojom";
import "services/resource_coordinator/public/mojom/lifecycle.mojom";
import "mojo/public/mojom/base/time.mojom";
// This structure has the identity of the page and navigation that the
// notifications below relate to. When a notification is received, it may be
// necessary to know whether the WebContents associated to the
// CoordinationUnitID has been re-navigated. When maintaining per-navigation
// state, an event pertaining to an earlier navigation should typically be
// discarded.
// If data pertaining to the notification is to be persisted, then on a
// re-navigated WebContents, either the event can be dropped, leading to loss of
// data, or else the url can be used to associate the data to its origin.
struct PageNavigationIdentity {
// The coordination ID of the page this event relates to.
CoordinationUnitID page_cu_id;
// The unique ID of the NavigationHandle of the page at the time the event
// relates to.
int64 navigation_id;
// The URL of the last navigation.
string url;
};
// A PageSignalReceiver implementation receives page-scoped signal from
// PageSignalGenerator.
// Any interested party that needs to receive page-scoped signal from GRC must
// implement this interface, construct mojo channel to the implementation, and
// pass the interface pointer of mojo channel to PageSignalGenerator through
// PageSignalGenerator::AddReceiver.
interface PageSignalReceiver {
NotifyPageAlmostIdle(PageNavigationIdentity page_navigation_id);
NotifyRendererIsBloated(PageNavigationIdentity page_navigation_id);
SetExpectedTaskQueueingDuration(PageNavigationIdentity page_navigation_id,
mojo_base.mojom.TimeDelta duration);
SetLifecycleState(PageNavigationIdentity page_navigation_id,
LifecycleState state);
// Indicates that the page has created a non-persistent web notification, i.e.
// a notification created by a particular page (in opposition to persistent
// web notifications, who require a service worker).
//
// |page_cu_id| is the coordination ID of the page that created this
// notification.
NotifyNonPersistentNotificationCreated(
PageNavigationIdentity page_navigation_id);
// This notification needs the url that was loaded, as by the time the
// notification comes back around, the WebContents may have navigated to
// another site altogether.
// |load_duration| is the wall-clock duration from navigation commit, until
// the page is considered loaded (currently almost idle).
// |cpu_usage_estimate| is an estimate of how much CPU time was consumed by
// this page load across all the the processes involved. This is approximate
// primarily because it's impossible to accurately approportion the cost
// of shared processes to individual pages. Other considerations involve
// the timing of measurement, as well as the fact that there's no accounting
// for processes that contributed to a page in the past, but no longer do
// so at the time of measurement.
OnLoadTimePerformanceEstimate(PageNavigationIdentity page_navigation_id,
mojo_base.mojom.TimeDelta load_duration,
mojo_base.mojom.TimeDelta cpu_usage_estimate,
uint64 private_footprint_kb_estimate);
};
// A PageSignalGenerator implementation will be implemented inside GRC to receive
// signals from Coordination Units, generate page-scoped signals, sends signals
// to PageSignalReceiver implementations.
// There will be only one PageSignalGenerator implementation.
interface PageSignalGenerator {
AddReceiver(PageSignalReceiver receiver);
};