Commit 8454aeb8 authored by isherman@chromium.org's avatar isherman@chromium.org

Migrate several instances of NewRunnableMethod to base::Bind in browser/metrics

BUG=none
TEST=none


Review URL: http://codereview.chromium.org/8536054

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110848 0039d316-1c4b-4281-b951-d872f2087c98
parent b3cc0544
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "chrome/browser/metrics/field_trial_synchronizer.h" #include "chrome/browser/metrics/field_trial_synchronizer.h"
#include "base/bind.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_constants.h"
...@@ -44,10 +45,10 @@ void FieldTrialSynchronizer::OnFieldTrialGroupFinalized( ...@@ -44,10 +45,10 @@ void FieldTrialSynchronizer::OnFieldTrialGroupFinalized(
const std::string& group_name) { const std::string& group_name) {
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE, BrowserThread::UI, FROM_HERE,
NewRunnableMethod(this, base::Bind(&FieldTrialSynchronizer::NotifyAllRenderers,
&FieldTrialSynchronizer::NotifyAllRenderers, this,
field_trial_name, field_trial_name,
group_name)); group_name));
} }
// static // static
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "chrome/browser/metrics/histogram_synchronizer.h" #include "chrome/browser/metrics/histogram_synchronizer.h"
#include "base/bind.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
#include "base/threading/thread.h" #include "base/threading/thread.h"
...@@ -101,9 +102,9 @@ void HistogramSynchronizer::FetchRendererHistogramsAsynchronously( ...@@ -101,9 +102,9 @@ void HistogramSynchronizer::FetchRendererHistogramsAsynchronously(
// making the callback. // making the callback.
BrowserThread::PostDelayedTask( BrowserThread::PostDelayedTask(
BrowserThread::UI, FROM_HERE, BrowserThread::UI, FROM_HERE,
NewRunnableMethod( base::Bind(
current_synchronizer,
&HistogramSynchronizer::ForceHistogramSynchronizationDoneCallback, &HistogramSynchronizer::ForceHistogramSynchronizationDoneCallback,
current_synchronizer,
sequence_number), sequence_number),
wait_time); wait_time);
} }
......
...@@ -33,7 +33,7 @@ static const int kMaxBackoffMultiplier = 10; ...@@ -33,7 +33,7 @@ static const int kMaxBackoffMultiplier = 10;
MetricsReportingScheduler::MetricsReportingScheduler( MetricsReportingScheduler::MetricsReportingScheduler(
const base::Closure& upload_callback) const base::Closure& upload_callback)
: upload_callback_(upload_callback), : upload_callback_(upload_callback),
ALLOW_THIS_IN_INITIALIZER_LIST(upload_timer_factory_(this)), ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)),
upload_interval_(TimeDelta::FromSeconds(kInitialUploadIntervalSeconds)), upload_interval_(TimeDelta::FromSeconds(kInitialUploadIntervalSeconds)),
running_(false), running_(false),
timer_pending_(false), timer_pending_(false),
...@@ -92,8 +92,8 @@ void MetricsReportingScheduler::ScheduleNextCallback() { ...@@ -92,8 +92,8 @@ void MetricsReportingScheduler::ScheduleNextCallback() {
MessageLoop::current()->PostDelayedTask( MessageLoop::current()->PostDelayedTask(
FROM_HERE, FROM_HERE,
upload_timer_factory_.NewRunnableMethod( base::Bind(&MetricsReportingScheduler::TriggerUpload,
&MetricsReportingScheduler::TriggerUpload), weak_ptr_factory_.GetWeakPtr()),
upload_interval_.InMilliseconds()); upload_interval_.InMilliseconds());
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/task.h" #include "base/memory/weak_ptr.h"
#include "base/time.h" #include "base/time.h"
// Scheduler task to drive a MetricsService object's uploading. // Scheduler task to drive a MetricsService object's uploading.
...@@ -46,7 +46,7 @@ class MetricsReportingScheduler { ...@@ -46,7 +46,7 @@ class MetricsReportingScheduler {
// The MetricsService method to call when uploading should happen. // The MetricsService method to call when uploading should happen.
base::Closure upload_callback_; base::Closure upload_callback_;
ScopedRunnableMethodFactory<MetricsReportingScheduler> upload_timer_factory_; base::WeakPtrFactory<MetricsReportingScheduler> weak_ptr_factory_;
// The interval between being told an upload is done and starting the next // The interval between being told an upload is done and starting the next
// upload. // upload.
......
...@@ -760,10 +760,11 @@ std::string MetricsService::GenerateClientID() { ...@@ -760,10 +760,11 @@ std::string MetricsService::GenerateClientID() {
// State save methods // State save methods
void MetricsService::ScheduleNextStateSave() { void MetricsService::ScheduleNextStateSave() {
state_saver_factory_.RevokeAll(); state_saver_factory_.InvalidateWeakPtrs();
MessageLoop::current()->PostDelayedTask(FROM_HERE, MessageLoop::current()->PostDelayedTask(FROM_HERE,
state_saver_factory_.NewRunnableMethod(&MetricsService::SaveLocalState), base::Bind(&MetricsService::SaveLocalState,
state_saver_factory_.GetWeakPtr()),
kSaveStateInterval * 1000); kSaveStateInterval * 1000);
} }
...@@ -1304,7 +1305,7 @@ void MetricsService::LogCleanShutdown() { ...@@ -1304,7 +1305,7 @@ void MetricsService::LogCleanShutdown() {
// completed. // completed.
base::WaitableEvent done_writing(false, false); base::WaitableEvent done_writing(false, false);
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
NewRunnableFunction(Signal, &done_writing)); base::Bind(Signal, &done_writing));
done_writing.TimedWait(base::TimeDelta::FromHours(1)); done_writing.TimedWait(base::TimeDelta::FromHours(1));
// Redundant setting to assure that we always reset this value at shutdown // Redundant setting to assure that we always reset this value at shutdown
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/memory/weak_ptr.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/process_util.h" #include "base/process_util.h"
#include "chrome/browser/io_thread.h" #include "chrome/browser/io_thread.h"
...@@ -369,7 +370,7 @@ class MetricsService : public content::NotificationObserver, ...@@ -369,7 +370,7 @@ class MetricsService : public content::NotificationObserver,
std::map<string16, ChildProcessStats> child_process_stats_buffer_; std::map<string16, ChildProcessStats> child_process_stats_buffer_;
ScopedRunnableMethodFactory<MetricsService> log_sender_factory_; ScopedRunnableMethodFactory<MetricsService> log_sender_factory_;
ScopedRunnableMethodFactory<MetricsService> state_saver_factory_; base::WeakPtrFactory<MetricsService> state_saver_factory_;
// Dictionary containing all the profile specific metrics. This is set // Dictionary containing all the profile specific metrics. This is set
// at creation time from the prefs. // at creation time from the prefs.
......
...@@ -590,7 +590,7 @@ void ThreadWatcherList::InitializeAndStartWatching( ...@@ -590,7 +590,7 @@ void ThreadWatcherList::InitializeAndStartWatching(
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::UI, BrowserThread::UI,
FROM_HERE, FROM_HERE,
NewRunnableFunction(StartupTimeBomb::Disarm)); base::Bind(StartupTimeBomb::Disarm));
} }
// static // static
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment