| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/memory/tab_manager.h" | 5 #include "chrome/browser/memory/tab_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include "components/variations/variations_associated_data.h" | 49 #include "components/variations/variations_associated_data.h" |
| 50 #include "content/public/browser/browser_thread.h" | 50 #include "content/public/browser/browser_thread.h" |
| 51 #include "content/public/browser/memory_pressure_controller.h" | 51 #include "content/public/browser/memory_pressure_controller.h" |
| 52 #include "content/public/browser/navigation_controller.h" | 52 #include "content/public/browser/navigation_controller.h" |
| 53 #include "content/public/browser/render_process_host.h" | 53 #include "content/public/browser/render_process_host.h" |
| 54 #include "content/public/browser/web_contents.h" | 54 #include "content/public/browser/web_contents.h" |
| 55 #include "content/public/common/page_importance_signals.h" | 55 #include "content/public/common/page_importance_signals.h" |
| 56 | 56 |
| 57 #if defined(OS_CHROMEOS) | 57 #if defined(OS_CHROMEOS) |
| 58 #include "ash/common/multi_profile_uma.h" | 58 #include "ash/common/multi_profile_uma.h" |
| 59 #include "ash/common/session/session_state_delegate.h" | |
| 60 #include "ash/common/wm_shell.h" | 59 #include "ash/common/wm_shell.h" |
| 61 #include "chrome/browser/memory/tab_manager_delegate_chromeos.h" | 60 #include "chrome/browser/memory/tab_manager_delegate_chromeos.h" |
| 61 #include "components/user_manager/user_manager.h" |
| 62 #endif | 62 #endif |
| 63 | 63 |
| 64 using base::TimeDelta; | 64 using base::TimeDelta; |
| 65 using base::TimeTicks; | 65 using base::TimeTicks; |
| 66 using content::BrowserThread; | 66 using content::BrowserThread; |
| 67 using content::WebContents; | 67 using content::WebContents; |
| 68 | 68 |
| 69 namespace memory { | 69 namespace memory { |
| 70 namespace { | 70 namespace { |
| 71 | 71 |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 void TabManager::RecordDiscardStatistics() { | 560 void TabManager::RecordDiscardStatistics() { |
| 561 discard_count_++; | 561 discard_count_++; |
| 562 | 562 |
| 563 // TODO(jamescook): Maybe incorporate extension count? | 563 // TODO(jamescook): Maybe incorporate extension count? |
| 564 UMA_HISTOGRAM_CUSTOM_COUNTS("Tabs.Discard.TabCount", GetTabCount(), 1, 100, | 564 UMA_HISTOGRAM_CUSTOM_COUNTS("Tabs.Discard.TabCount", GetTabCount(), 1, 100, |
| 565 50); | 565 50); |
| 566 #if defined(OS_CHROMEOS) | 566 #if defined(OS_CHROMEOS) |
| 567 // Record the discarded tab in relation to the amount of simultaneously | 567 // Record the discarded tab in relation to the amount of simultaneously |
| 568 // logged in users. | 568 // logged in users. |
| 569 if (ash::WmShell::HasInstance()) { | 569 if (ash::WmShell::HasInstance()) { |
| 570 ash::MultiProfileUMA::RecordDiscardedTab(ash::WmShell::Get() | 570 ash::MultiProfileUMA::RecordDiscardedTab( |
| 571 ->GetSessionStateDelegate() | 571 user_manager::UserManager::Get()->GetLoggedInUsers().size()); |
| 572 ->NumberOfLoggedInUsers()); | |
| 573 } | 572 } |
| 574 #endif | 573 #endif |
| 575 // TODO(jamescook): If the time stats prove too noisy, then divide up users | 574 // TODO(jamescook): If the time stats prove too noisy, then divide up users |
| 576 // based on how heavily they use Chrome using tab count as a proxy. | 575 // based on how heavily they use Chrome using tab count as a proxy. |
| 577 // Bin into <= 1, <= 2, <= 4, <= 8, etc. | 576 // Bin into <= 1, <= 2, <= 4, <= 8, etc. |
| 578 if (last_discard_time_.is_null()) { | 577 if (last_discard_time_.is_null()) { |
| 579 // This is the first discard this session. | 578 // This is the first discard this session. |
| 580 TimeDelta interval = NowTicks() - start_time_; | 579 TimeDelta interval = NowTicks() - start_time_; |
| 581 int interval_seconds = static_cast<int>(interval.InSeconds()); | 580 int interval_seconds = static_cast<int>(interval.InSeconds()); |
| 582 // Record time in seconds over an interval of approximately 1 day. | 581 // Record time in seconds over an interval of approximately 1 day. |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 // platform. | 1031 // platform. |
| 1033 std::string allow_multiple_discards = variations::GetVariationParamValue( | 1032 std::string allow_multiple_discards = variations::GetVariationParamValue( |
| 1034 features::kAutomaticTabDiscarding.name, "AllowMultipleDiscards"); | 1033 features::kAutomaticTabDiscarding.name, "AllowMultipleDiscards"); |
| 1035 return (allow_multiple_discards != "true"); | 1034 return (allow_multiple_discards != "true"); |
| 1036 #else | 1035 #else |
| 1037 return false; | 1036 return false; |
| 1038 #endif | 1037 #endif |
| 1039 } | 1038 } |
| 1040 | 1039 |
| 1041 } // namespace memory | 1040 } // namespace memory |
| OLD | NEW |