OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/plugin_metrics_provider.h" | 5 #include "chrome/browser/metrics/plugin_metrics_provider.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 void PluginMetricsProvider::LogPluginLoadingError( | 291 void PluginMetricsProvider::LogPluginLoadingError( |
292 const base::FilePath& plugin_path) { | 292 const base::FilePath& plugin_path) { |
293 content::WebPluginInfo plugin; | 293 content::WebPluginInfo plugin; |
294 bool success = | 294 bool success = |
295 content::PluginService::GetInstance()->GetPluginInfoByPath(plugin_path, | 295 content::PluginService::GetInstance()->GetPluginInfoByPath(plugin_path, |
296 &plugin); | 296 &plugin); |
297 DCHECK(success); | 297 DCHECK(success); |
298 ChildProcessStats& stats = child_process_stats_buffer_[plugin.name]; | 298 ChildProcessStats& stats = child_process_stats_buffer_[plugin.name]; |
299 // Initialize the type if this entry is new. | 299 // Initialize the type if this entry is new. |
300 if (stats.process_type == content::PROCESS_TYPE_UNKNOWN) { | 300 if (stats.process_type == content::PROCESS_TYPE_UNKNOWN) { |
301 // The plugin process might not actually be of type PLUGIN (which means | 301 // The plugin process might not actually be of type PPAPI_PLUGIN, but we |
302 // NPAPI), but we only care that it is *a* plugin process. | 302 // only care that it is *a* plugin process. |
303 stats.process_type = content::PROCESS_TYPE_PLUGIN; | 303 stats.process_type = content::PROCESS_TYPE_PPAPI_PLUGIN; |
304 } else { | 304 } else { |
305 DCHECK(IsPluginProcess(stats.process_type)); | 305 DCHECK(IsPluginProcess(stats.process_type)); |
306 } | 306 } |
307 stats.loading_errors++; | 307 stats.loading_errors++; |
308 RecordCurrentStateWithDelay(kRecordStateDelayMs); | 308 RecordCurrentStateWithDelay(kRecordStateDelayMs); |
309 } | 309 } |
310 | 310 |
311 void PluginMetricsProvider::SetPluginsForTesting( | 311 void PluginMetricsProvider::SetPluginsForTesting( |
312 const std::vector<content::WebPluginInfo>& plugins) { | 312 const std::vector<content::WebPluginInfo>& plugins) { |
313 plugins_ = plugins; | 313 plugins_ = plugins; |
314 } | 314 } |
315 | 315 |
316 // static | 316 // static |
317 bool PluginMetricsProvider::IsPluginProcess(int process_type) { | 317 bool PluginMetricsProvider::IsPluginProcess(int process_type) { |
318 return (process_type == content::PROCESS_TYPE_PLUGIN || | 318 return (process_type == content::PROCESS_TYPE_PPAPI_PLUGIN || |
319 process_type == content::PROCESS_TYPE_PPAPI_PLUGIN || | |
320 process_type == content::PROCESS_TYPE_PPAPI_BROKER); | 319 process_type == content::PROCESS_TYPE_PPAPI_BROKER); |
321 } | 320 } |
322 | 321 |
323 // static | 322 // static |
324 void PluginMetricsProvider::RegisterPrefs(PrefRegistrySimple* registry) { | 323 void PluginMetricsProvider::RegisterPrefs(PrefRegistrySimple* registry) { |
325 registry->RegisterListPref(prefs::kStabilityPluginStats); | 324 registry->RegisterListPref(prefs::kStabilityPluginStats); |
326 } | 325 } |
327 | 326 |
328 void PluginMetricsProvider::OnGotPlugins( | 327 void PluginMetricsProvider::OnGotPlugins( |
329 const base::Closure& done_callback, | 328 const base::Closure& done_callback, |
(...skipping 19 matching lines...) Expand all Loading... |
349 RecordCurrentStateWithDelay(kRecordStateDelayMs); | 348 RecordCurrentStateWithDelay(kRecordStateDelayMs); |
350 } | 349 } |
351 | 350 |
352 void PluginMetricsProvider::BrowserChildProcessCrashed( | 351 void PluginMetricsProvider::BrowserChildProcessCrashed( |
353 const content::ChildProcessData& data, | 352 const content::ChildProcessData& data, |
354 int exit_code) { | 353 int exit_code) { |
355 GetChildProcessStats(data).process_crashes++; | 354 GetChildProcessStats(data).process_crashes++; |
356 RecordCurrentStateWithDelay(kRecordStateDelayMs); | 355 RecordCurrentStateWithDelay(kRecordStateDelayMs); |
357 } | 356 } |
358 | 357 |
359 void PluginMetricsProvider::BrowserChildProcessInstanceCreated( | |
360 const content::ChildProcessData& data) { | |
361 GetChildProcessStats(data).instances++; | |
362 RecordCurrentStateWithDelay(kRecordStateDelayMs); | |
363 } | |
364 | |
365 void PluginMetricsProvider::BrowserChildProcessKilled( | 358 void PluginMetricsProvider::BrowserChildProcessKilled( |
366 const content::ChildProcessData& data, | 359 const content::ChildProcessData& data, |
367 int exit_code) { | 360 int exit_code) { |
368 // Treat a kill as a crash, since Flash returns STATUS_DEBUGGER_INACTIVE for | 361 // Treat a kill as a crash, since Flash returns STATUS_DEBUGGER_INACTIVE for |
369 // actual crashes, which is treated as a kill rather than a crash by | 362 // actual crashes, which is treated as a kill rather than a crash by |
370 // base::GetTerminationStatus | 363 // base::GetTerminationStatus |
371 GetChildProcessStats(data).process_crashes++; | 364 GetChildProcessStats(data).process_crashes++; |
372 RecordCurrentStateWithDelay(kRecordStateDelayMs); | 365 RecordCurrentStateWithDelay(kRecordStateDelayMs); |
373 } | 366 } |
374 | 367 |
(...skipping 10 matching lines...) Expand all Loading... |
385 } | 378 } |
386 | 379 |
387 bool PluginMetricsProvider::RecordCurrentStateIfPending() { | 380 bool PluginMetricsProvider::RecordCurrentStateIfPending() { |
388 if (!weak_ptr_factory_.HasWeakPtrs()) | 381 if (!weak_ptr_factory_.HasWeakPtrs()) |
389 return false; | 382 return false; |
390 | 383 |
391 weak_ptr_factory_.InvalidateWeakPtrs(); | 384 weak_ptr_factory_.InvalidateWeakPtrs(); |
392 RecordCurrentState(); | 385 RecordCurrentState(); |
393 return true; | 386 return true; |
394 } | 387 } |
OLD | NEW |