| 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/metrics/metrics_service.h" | 5 #include "chrome/browser/metrics/metrics_service.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
| 11 #include "chrome/browser/metrics/metrics_state_manager.h" | 11 #include "chrome/browser/metrics/metrics_state_manager.h" |
| 12 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
| 13 #include "chrome/test/base/scoped_testing_local_state.h" | 13 #include "chrome/test/base/scoped_testing_local_state.h" |
| 14 #include "chrome/test/base/testing_browser_process.h" | 14 #include "chrome/test/base/testing_browser_process.h" |
| 15 #include "components/metrics/metrics_service_observer.h" | 15 #include "components/metrics/metrics_service_observer.h" |
| 16 #include "components/metrics/test_metrics_service_client.h" | 16 #include "components/metrics/test_metrics_service_client.h" |
| 17 #include "components/variations/metrics_util.h" | 17 #include "components/variations/metrics_util.h" |
| 18 #include "content/public/common/process_type.h" | 18 #include "content/public/common/process_type.h" |
| 19 #include "content/public/common/webplugininfo.h" | |
| 20 #include "content/public/test/test_browser_thread_bundle.h" | 19 #include "content/public/test/test_browser_thread_bundle.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 22 #include "ui/gfx/size.h" | 21 #include "ui/gfx/size.h" |
| 23 | 22 |
| 24 #if defined(OS_CHROMEOS) | 23 #if defined(OS_CHROMEOS) |
| 25 #include "chrome/browser/metrics/metrics_log_chromeos.h" | 24 #include "chrome/browser/metrics/metrics_log_chromeos.h" |
| 26 #endif // OS_CHROMEOS | 25 #endif // OS_CHROMEOS |
| 27 | 26 |
| 28 namespace { | 27 namespace { |
| 29 | 28 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 TEST_F(MetricsServiceTest, InitialStabilityLogAfterCrash) { | 195 TEST_F(MetricsServiceTest, InitialStabilityLogAfterCrash) { |
| 197 EnableMetricsReporting(); | 196 EnableMetricsReporting(); |
| 198 GetLocalState()->ClearPref(prefs::kStabilityExitedCleanly); | 197 GetLocalState()->ClearPref(prefs::kStabilityExitedCleanly); |
| 199 | 198 |
| 200 // Set up prefs to simulate restarting after a crash. | 199 // Set up prefs to simulate restarting after a crash. |
| 201 | 200 |
| 202 // Save an existing system profile to prefs, to correspond to what would be | 201 // Save an existing system profile to prefs, to correspond to what would be |
| 203 // saved from a previous session. | 202 // saved from a previous session. |
| 204 TestMetricsLog log("client", 1); | 203 TestMetricsLog log("client", 1); |
| 205 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), | 204 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), |
| 206 std::vector<content::WebPluginInfo>(), | |
| 207 std::vector<variations::ActiveGroupId>()); | 205 std::vector<variations::ActiveGroupId>()); |
| 208 | 206 |
| 209 // Record stability build time and version from previous session, so that | 207 // Record stability build time and version from previous session, so that |
| 210 // stability metrics (including exited cleanly flag) won't be cleared. | 208 // stability metrics (including exited cleanly flag) won't be cleared. |
| 211 GetLocalState()->SetInt64(prefs::kStabilityStatsBuildTime, | 209 GetLocalState()->SetInt64(prefs::kStabilityStatsBuildTime, |
| 212 MetricsLog::GetBuildTime()); | 210 MetricsLog::GetBuildTime()); |
| 213 GetLocalState()->SetString(prefs::kStabilityStatsVersion, | 211 GetLocalState()->SetString(prefs::kStabilityStatsVersion, |
| 214 MetricsLog::GetVersionString()); | 212 MetricsLog::GetVersionString()); |
| 215 | 213 |
| 216 GetLocalState()->SetBoolean(prefs::kStabilityExitedCleanly, false); | 214 GetLocalState()->SetBoolean(prefs::kStabilityExitedCleanly, false); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 | 364 |
| 367 service.RemoveObserver(&observer1); | 365 service.RemoveObserver(&observer1); |
| 368 | 366 |
| 369 service.OpenNewLog(); | 367 service.OpenNewLog(); |
| 370 EXPECT_EQ(2, observer1.observed()); | 368 EXPECT_EQ(2, observer1.observed()); |
| 371 EXPECT_EQ(2, observer2.observed()); | 369 EXPECT_EQ(2, observer2.observed()); |
| 372 service.log_manager_.FinishCurrentLog(); | 370 service.log_manager_.FinishCurrentLog(); |
| 373 | 371 |
| 374 service.RemoveObserver(&observer2); | 372 service.RemoveObserver(&observer2); |
| 375 } | 373 } |
| OLD | NEW |