OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 //------------------------------------------------------------------------------ | 5 //------------------------------------------------------------------------------ |
6 // Description of the life cycle of a instance of MetricsService. | 6 // Description of the life cycle of a instance of MetricsService. |
7 // | 7 // |
8 // OVERVIEW | 8 // OVERVIEW |
9 // | 9 // |
10 // A MetricsService instance is typically created at application startup. It | 10 // A MetricsService instance is typically created at application startup. It |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 // static | 225 // static |
226 MetricsService::ShutdownCleanliness MetricsService::clean_shutdown_status_ = | 226 MetricsService::ShutdownCleanliness MetricsService::clean_shutdown_status_ = |
227 MetricsService::CLEANLY_SHUTDOWN; | 227 MetricsService::CLEANLY_SHUTDOWN; |
228 | 228 |
229 // This is used to quickly log stats from child process related notifications in | 229 // This is used to quickly log stats from child process related notifications in |
230 // MetricsService::child_stats_buffer_. The buffer's contents are transferred | 230 // MetricsService::child_stats_buffer_. The buffer's contents are transferred |
231 // out when Local State is periodically saved. The information is then | 231 // out when Local State is periodically saved. The information is then |
232 // reported to the UMA server on next launch. | 232 // reported to the UMA server on next launch. |
233 struct MetricsService::ChildProcessStats { | 233 struct MetricsService::ChildProcessStats { |
234 public: | 234 public: |
235 explicit ChildProcessStats(ChildProcessInfo::ProcessType type) | 235 explicit ChildProcessStats(content::ProcessType type) |
236 : process_launches(0), | 236 : process_launches(0), |
237 process_crashes(0), | 237 process_crashes(0), |
238 instances(0), | 238 instances(0), |
239 process_type(type) {} | 239 process_type(type) {} |
240 | 240 |
241 // This constructor is only used by the map to return some default value for | 241 // This constructor is only used by the map to return some default value for |
242 // an index for which no value has been assigned. | 242 // an index for which no value has been assigned. |
243 ChildProcessStats() | 243 ChildProcessStats() |
244 : process_launches(0), | 244 : process_launches(0), |
245 process_crashes(0), | 245 process_crashes(0), |
246 instances(0), | 246 instances(0), |
247 process_type(ChildProcessInfo::UNKNOWN_PROCESS) {} | 247 process_type(content::PROCESS_TYPE_UNKNOWN) {} |
248 | 248 |
249 // The number of times that the given child process has been launched | 249 // The number of times that the given child process has been launched |
250 int process_launches; | 250 int process_launches; |
251 | 251 |
252 // The number of times that the given child process has crashed | 252 // The number of times that the given child process has crashed |
253 int process_crashes; | 253 int process_crashes; |
254 | 254 |
255 // The number of instances of this child process that have been created. | 255 // The number of instances of this child process that have been created. |
256 // An instance is a DOM object rendered by this child process during a page | 256 // An instance is a DOM object rendered by this child process during a page |
257 // load. | 257 // load. |
258 int instances; | 258 int instances; |
259 | 259 |
260 ChildProcessInfo::ProcessType process_type; | 260 content::ProcessType process_type; |
261 }; | 261 }; |
262 | 262 |
263 // Handles asynchronous fetching of memory details. | 263 // Handles asynchronous fetching of memory details. |
264 // Will run the provided task after finished. | 264 // Will run the provided task after finished. |
265 class MetricsMemoryDetails : public MemoryDetails { | 265 class MetricsMemoryDetails : public MemoryDetails { |
266 public: | 266 public: |
267 explicit MetricsMemoryDetails(const base::Closure& callback) | 267 explicit MetricsMemoryDetails(const base::Closure& callback) |
268 : callback_(callback) {} | 268 : callback_(callback) {} |
269 | 269 |
270 virtual void OnDetailsAvailable() { | 270 virtual void OnDetailsAvailable() { |
(...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1519 RecordCurrentState(pref); | 1519 RecordCurrentState(pref); |
1520 } | 1520 } |
1521 | 1521 |
1522 void MetricsService::RecordCurrentState(PrefService* pref) { | 1522 void MetricsService::RecordCurrentState(PrefService* pref) { |
1523 pref->SetInt64(prefs::kStabilityLastTimestampSec, Time::Now().ToTimeT()); | 1523 pref->SetInt64(prefs::kStabilityLastTimestampSec, Time::Now().ToTimeT()); |
1524 | 1524 |
1525 RecordPluginChanges(pref); | 1525 RecordPluginChanges(pref); |
1526 } | 1526 } |
1527 | 1527 |
1528 // static | 1528 // static |
1529 bool MetricsService::IsPluginProcess(ChildProcessInfo::ProcessType type) { | 1529 bool MetricsService::IsPluginProcess(content::ProcessType type) { |
1530 return (type == ChildProcessInfo::PLUGIN_PROCESS || | 1530 return (type == content::PROCESS_TYPE_PLUGIN|| |
1531 type == ChildProcessInfo::PPAPI_PLUGIN_PROCESS); | 1531 type == content::PROCESS_TYPE_PPAPI_PLUGIN); |
1532 } | 1532 } |
1533 | 1533 |
1534 static bool IsSingleThreaded() { | 1534 static bool IsSingleThreaded() { |
1535 static base::PlatformThreadId thread_id = 0; | 1535 static base::PlatformThreadId thread_id = 0; |
1536 if (!thread_id) | 1536 if (!thread_id) |
1537 thread_id = base::PlatformThread::CurrentId(); | 1537 thread_id = base::PlatformThread::CurrentId(); |
1538 return base::PlatformThread::CurrentId() == thread_id; | 1538 return base::PlatformThread::CurrentId() == thread_id; |
1539 } | 1539 } |
1540 | 1540 |
1541 #if defined(OS_CHROMEOS) | 1541 #if defined(OS_CHROMEOS) |
(...skipping 10 matching lines...) Expand all Loading... |
1552 if (local_state) { | 1552 if (local_state) { |
1553 const PrefService::Preference* uma_pref = | 1553 const PrefService::Preference* uma_pref = |
1554 local_state->FindPreference(prefs::kMetricsReportingEnabled); | 1554 local_state->FindPreference(prefs::kMetricsReportingEnabled); |
1555 if (uma_pref) { | 1555 if (uma_pref) { |
1556 bool success = uma_pref->GetValue()->GetAsBoolean(&result); | 1556 bool success = uma_pref->GetValue()->GetAsBoolean(&result); |
1557 DCHECK(success); | 1557 DCHECK(success); |
1558 } | 1558 } |
1559 } | 1559 } |
1560 return result; | 1560 return result; |
1561 } | 1561 } |
OLD | NEW |