naiveproxy/chrome/browser/ui/webui/discards/discards.mojom

92 lines
3.7 KiB
Plaintext
Raw Normal View History

2018-08-15 01:19:20 +03:00
// 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 mojom;
import "chrome/browser/resource_coordinator/lifecycle_unit_state.mojom";
// Identical to content::Visibility.
enum LifecycleUnitVisibility {
HIDDEN = 0,
OCCLUDED = 1,
VISIBLE = 2,
};
// Discard related information about a single tab in a browser.
struct TabDiscardsInfo {
// The URL associated with the tab. This corresponds to GetLastCommittedURL,
// and is also what is visible in the Omnibox for a given tab.
string tab_url;
// The title of the tab, as displayed on the tab itself.
string title;
// The visibility of the LifecycleUnit.
LifecycleUnitVisibility visibility;
// The loading state of the LifecycleUnit.
LifecycleUnitLoadingState loading_state;
// The state of the LifecycleUnit.
LifecycleUnitState state;
// Whether the tab can be frozen.
bool can_freeze;
// List of human-readable reasons why a tab can't be frozen.
array<string> cannot_freeze_reasons;
// Whether the tab can be discarded.
bool can_discard;
// List of human-readable reasons why a tab can't be discarded.
array<string> cannot_discard_reasons;
// The number of times this tab has been discarded in the current browser
// session.
int32 discard_count;
// The rank of the tab in the "importance to user" list. The tab with 1 is the
// most important, the tab with N is the least important.
int32 utility_rank;
// The time the tab was last active (foreground in a window), in seconds.
int32 last_active_seconds;
// A unique ID for the tab. This is unique for a browser session and follows a
// tab across tab strip operations, reloads and discards.
int32 id;
// Whether or not the tab is eligible for auto-discarding by the browser.
// This can be manipulated by the chrome://discards UI, or via the discards
// extension API.
bool is_auto_discardable;
// True if a reactivation score is calculated for the tab. Reactivation score
// can be predicted only for background tabs.
bool has_reactivation_score;
// Tab Ranker reactivation score, if |has_reactivation_score| is true.
double reactivation_score;
// Site engagement score.
double site_engagement_score;
};
// Interface for providing information about discards. Lives in the browser
// process and is invoked in the renderer process via Javascript code running in
// the chrome://discards WebUI.
interface DiscardsDetailsProvider {
// Returns an array of TabDiscardsInfo containing discard information about
// each tab currently open in the browser, across all profiles.
GetTabDiscardsInfo() => (array<TabDiscardsInfo> infos);
// Sets the auto-discardable state of a tab, as specified by its stable
// |tab_id|, earlier returned by GetTabDiscardsInfo. Invokes a callback when
// the change has been made.
SetAutoDiscardable(int32 tab_id, bool is_auto_discardable) => ();
// Discards a tab given its |tab_id|. If |urgent| is specified the unload
// handlers will not be run, and the tab will be unloaded with prejudice.
// Invokes a callback when the discard is complete.
DiscardById(int32 tab_id, bool urgent) => ();
// Freezes a tab given its |tab_id|.
FreezeById(int32 tab_id);
// Loads a tab given its |tab_id|.
LoadById(int32 tab_id);
// Discards the least important tab. If |urgent| is specified the unload
// handlers will not be run, and the tab will be unloaded with prejudice.
// This can fail to discard a tab if no tabs are currently considered
// eligible for discard. Invokes a callback when the discard is complete, or
// if the decision was made not to discard.
Discard(bool urgent) => ();
};