| Index: chrome/browser/sessions/tab_loader.cc
|
| diff --git a/chrome/browser/sessions/tab_loader.cc b/chrome/browser/sessions/tab_loader.cc
|
| index df77a8c906ede3d188c1aad804953c1fb78ba162..ce0c0a4b466b5addb46e071bcd966d8b23c9a146 100644
|
| --- a/chrome/browser/sessions/tab_loader.cc
|
| +++ b/chrome/browser/sessions/tab_loader.cc
|
| @@ -7,6 +7,7 @@
|
| #include <algorithm>
|
| #include <string>
|
|
|
| +#include "base/metrics/field_trial.h"
|
| #include "base/metrics/histogram.h"
|
| #include "base/strings/stringprintf.h"
|
| #include "chrome/browser/ui/browser.h"
|
| @@ -17,6 +18,7 @@
|
| #include "content/public/browser/notification_types.h"
|
| #include "content/public/browser/render_widget_host.h"
|
| #include "content/public/browser/render_widget_host_view.h"
|
| +#include "content/public/browser/session_restore_uma.h"
|
| #include "content/public/browser/web_contents.h"
|
|
|
| using content::NavigationController;
|
| @@ -117,6 +119,17 @@ void TabLoader::LoadNextTab() {
|
| DCHECK(controller);
|
| tabs_loading_.insert(controller);
|
| tabs_to_load_.pop_front();
|
| +
|
| + // Keep track of tabs that have been automatically loaded by session
|
| + // restore. This is the complement to SessionRestore.DeferredTabLoadedByUser
|
| + // recorded in NavigationControllerImpl::SetActive.
|
| + if (controller->NeedsReload()) {
|
| + UMA_HISTOGRAM_ENUMERATION(
|
| + content::kSessionRestoreTabActions,
|
| + content::kSessionRestoreTabActionsUma_BackgroundTabLoaded,
|
| + content::kSessionRestoreTabActionsUma_Max);
|
| + }
|
| +
|
| controller->LoadIfNecessary();
|
| content::WebContents* contents = controller->GetWebContents();
|
| if (contents) {
|
| @@ -183,6 +196,21 @@ void TabLoader::HandleTabClosedOrLoaded(NavigationController* controller) {
|
|
|
| void TabLoader::OnMemoryPressure(
|
| base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) {
|
| + // On Windows and Mac this mechanism is only experimentally enabled.
|
| +#if defined(OS_WIN) or (defined(OS_MACOSX) and !defined(OS_IOS))
|
| + // If memory pressure isn't explicitly turned on then ignore these calls.
|
| + std::string react_to_memory_pressure = variations::GetVariationParamValue(
|
| + kSessionRestoreBackgroundLoading, "ReactToMemoryPressure"));
|
| + if (react_to_memory_pressure != "1")
|
| + return;
|
| +#endif
|
| +
|
| + // Note that the session restore was interrupted by memory pressure.
|
| + UMA_HISTOGRAM_ENUMERATION(
|
| + content::kSessionRestoreActions,
|
| + content::kSessionRestoreActionsUma_InterruptedByMemoryPressure,
|
| + content::kSessionRestoreActionsUma_Max);
|
| +
|
| // When receiving a resource pressure level warning, we stop pre-loading more
|
| // tabs since we are running in danger of loading more tabs by throwing out
|
| // old ones.
|
| @@ -191,6 +219,12 @@ void TabLoader::OnMemoryPressure(
|
| // Stop the timer and suppress any tab loads while we clean the list.
|
| SetTabLoadingEnabled(false);
|
| while (!tabs_to_load_.empty()) {
|
| + // Count the number of tabs that have had their loading deferred.
|
| + UMA_HISTOGRAM_ENUMERATION(
|
| + content::kSessionRestoreTabActions,
|
| + content::kSessionRestoreTabActionsUma_TabLoadingDeferred,
|
| + content::kSessionRestoreTabActionsUma_Max);
|
| +
|
| NavigationController* controller = tabs_to_load_.front();
|
| tabs_to_load_.pop_front();
|
| RemoveTab(controller);
|
|
|