summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/ui/webui/discards/discards.mojom
blob: 5fe64a8b3ca34d8f4b0b091bdaff818cfde1c1c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// 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;

// 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;
  // If the tab is currently using media functionality (casting, WebRTC, playing
  // audio, etc) this is true.
  bool is_media;
  // If the tab is currently discarded, this is true.
  bool is_discarded;
  // If the tab is currently frozen, this is true.
  // TODO(fmeawad): is_discarded and is_frozen are mutually exclusive, instead
  // of representing each individually, we should add a "lifecycle_state" field
  // instead.
  bool is_frozen;
  // 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;
};

// 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);

  // 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) => ();
};