| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/gpu/gpu_mode_manager.h" | 5 #include "chrome/browser/gpu/gpu_mode_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "base/metrics/user_metrics.h" |
| 9 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/common/pref_names.h" | 11 #include "chrome/common/pref_names.h" |
| 11 #include "components/prefs/pref_registry_simple.h" | 12 #include "components/prefs/pref_registry_simple.h" |
| 12 #include "components/prefs/pref_service.h" | 13 #include "components/prefs/pref_service.h" |
| 13 #include "content/public/browser/gpu_data_manager.h" | 14 #include "content/public/browser/gpu_data_manager.h" |
| 14 #include "content/public/browser/user_metrics.h" | |
| 15 | 15 |
| 16 using base::UserMetricsAction; | 16 using base::UserMetricsAction; |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 bool GetPreviousGpuModePref() { | 20 bool GetPreviousGpuModePref() { |
| 21 PrefService* service = g_browser_process->local_state(); | 21 PrefService* service = g_browser_process->local_state(); |
| 22 DCHECK(service); | 22 DCHECK(service); |
| 23 return service->GetBoolean(prefs::kHardwareAccelerationModePrevious); | 23 return service->GetBoolean(prefs::kHardwareAccelerationModePrevious); |
| 24 } | 24 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 49 prefs::kHardwareAccelerationModeEnabled, | 49 prefs::kHardwareAccelerationModeEnabled, |
| 50 base::Bind(&base::DoNothing)); | 50 base::Bind(&base::DoNothing)); |
| 51 | 51 |
| 52 initial_gpu_mode_pref_ = IsGpuModePrefEnabled(); | 52 initial_gpu_mode_pref_ = IsGpuModePrefEnabled(); |
| 53 bool previous_gpu_mode_pref = GetPreviousGpuModePref(); | 53 bool previous_gpu_mode_pref = GetPreviousGpuModePref(); |
| 54 SetPreviousGpuModePref(initial_gpu_mode_pref_); | 54 SetPreviousGpuModePref(initial_gpu_mode_pref_); |
| 55 | 55 |
| 56 UMA_HISTOGRAM_BOOLEAN("GPU.HardwareAccelerationModeEnabled", | 56 UMA_HISTOGRAM_BOOLEAN("GPU.HardwareAccelerationModeEnabled", |
| 57 initial_gpu_mode_pref_); | 57 initial_gpu_mode_pref_); |
| 58 if (previous_gpu_mode_pref && !initial_gpu_mode_pref_) | 58 if (previous_gpu_mode_pref && !initial_gpu_mode_pref_) |
| 59 content::RecordAction(UserMetricsAction("GpuAccelerationDisabled")); | 59 base::RecordAction(UserMetricsAction("GpuAccelerationDisabled")); |
| 60 if (!previous_gpu_mode_pref && initial_gpu_mode_pref_) | 60 if (!previous_gpu_mode_pref && initial_gpu_mode_pref_) |
| 61 content::RecordAction(UserMetricsAction("GpuAccelerationEnabled")); | 61 base::RecordAction(UserMetricsAction("GpuAccelerationEnabled")); |
| 62 | 62 |
| 63 if (!initial_gpu_mode_pref_) { | 63 if (!initial_gpu_mode_pref_) { |
| 64 content::GpuDataManager* gpu_data_manager = | 64 content::GpuDataManager* gpu_data_manager = |
| 65 content::GpuDataManager::GetInstance(); | 65 content::GpuDataManager::GetInstance(); |
| 66 DCHECK(gpu_data_manager); | 66 DCHECK(gpu_data_manager); |
| 67 gpu_data_manager->DisableHardwareAcceleration(); | 67 gpu_data_manager->DisableHardwareAcceleration(); |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 GpuModeManager::~GpuModeManager() { | 72 GpuModeManager::~GpuModeManager() { |
| 73 } | 73 } |
| 74 | 74 |
| 75 bool GpuModeManager::initial_gpu_mode_pref() const { | 75 bool GpuModeManager::initial_gpu_mode_pref() const { |
| 76 return initial_gpu_mode_pref_; | 76 return initial_gpu_mode_pref_; |
| 77 } | 77 } |
| 78 | 78 |
| 79 // static | 79 // static |
| 80 bool GpuModeManager::IsGpuModePrefEnabled() { | 80 bool GpuModeManager::IsGpuModePrefEnabled() { |
| 81 PrefService* service = g_browser_process->local_state(); | 81 PrefService* service = g_browser_process->local_state(); |
| 82 DCHECK(service); | 82 DCHECK(service); |
| 83 return service->GetBoolean( | 83 return service->GetBoolean( |
| 84 prefs::kHardwareAccelerationModeEnabled); | 84 prefs::kHardwareAccelerationModeEnabled); |
| 85 } | 85 } |
| 86 | 86 |
| OLD | NEW |