Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(632)

Side by Side Diff: chrome/browser/metrics/plugin_metrics_provider.cc

Issue 1114823002: [chrome/browser/metrices] Replace MessageLoopProxy usage with ThreadTaskRunnerHandle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/metrics/thread_watcher.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <string> 7 #include <string>
8 8
9 #include "base/prefs/pref_registry_simple.h" 9 #include "base/prefs/pref_registry_simple.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/prefs/scoped_user_pref_update.h" 11 #include "base/prefs/scoped_user_pref_update.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "base/thread_task_runner_handle.h"
14 #include "base/time/time.h" 15 #include "base/time/time.h"
15 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/plugins/plugin_prefs.h" 17 #include "chrome/browser/plugins/plugin_prefs.h"
17 #include "chrome/browser/profiles/profile_manager.h" 18 #include "chrome/browser/profiles/profile_manager.h"
18 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
19 #include "components/metrics/proto/system_profile.pb.h" 20 #include "components/metrics/proto/system_profile.pb.h"
20 #include "content/public/browser/child_process_data.h" 21 #include "content/public/browser/child_process_data.h"
21 #include "content/public/browser/plugin_service.h" 22 #include "content/public/browser/plugin_service.h"
22 #include "content/public/common/process_type.h" 23 #include "content/public/common/process_type.h"
23 #include "content/public/common/webplugininfo.h" 24 #include "content/public/common/webplugininfo.h"
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 void PluginMetricsProvider::BrowserChildProcessInstanceCreated( 363 void PluginMetricsProvider::BrowserChildProcessInstanceCreated(
363 const content::ChildProcessData& data) { 364 const content::ChildProcessData& data) {
364 GetChildProcessStats(data).instances++; 365 GetChildProcessStats(data).instances++;
365 RecordCurrentStateWithDelay(kRecordStateDelayMs); 366 RecordCurrentStateWithDelay(kRecordStateDelayMs);
366 } 367 }
367 368
368 bool PluginMetricsProvider::RecordCurrentStateWithDelay(int delay_sec) { 369 bool PluginMetricsProvider::RecordCurrentStateWithDelay(int delay_sec) {
369 if (weak_ptr_factory_.HasWeakPtrs()) 370 if (weak_ptr_factory_.HasWeakPtrs())
370 return false; 371 return false;
371 372
372 base::MessageLoopProxy::current()->PostDelayedTask( 373 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
373 FROM_HERE, 374 FROM_HERE,
374 base::Bind(&PluginMetricsProvider::RecordCurrentState, 375 base::Bind(&PluginMetricsProvider::RecordCurrentState,
375 weak_ptr_factory_.GetWeakPtr()), 376 weak_ptr_factory_.GetWeakPtr()),
376 base::TimeDelta::FromMilliseconds(delay_sec)); 377 base::TimeDelta::FromMilliseconds(delay_sec));
377 return true; 378 return true;
378 } 379 }
379 380
380 bool PluginMetricsProvider::RecordCurrentStateIfPending() { 381 bool PluginMetricsProvider::RecordCurrentStateIfPending() {
381 if (!weak_ptr_factory_.HasWeakPtrs()) 382 if (!weak_ptr_factory_.HasWeakPtrs())
382 return false; 383 return false;
383 384
384 weak_ptr_factory_.InvalidateWeakPtrs(); 385 weak_ptr_factory_.InvalidateWeakPtrs();
385 RecordCurrentState(); 386 RecordCurrentState();
386 return true; 387 return true;
387 } 388 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/metrics/thread_watcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698