summaryrefslogtreecommitdiffstats
path: root/chrome/browser/task_manager.cc
diff options
context:
space:
mode:
authordarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-03 18:18:14 +0000
committerdarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-03 18:18:14 +0000
commit2d31666a58e746b7a1d415c99e5f68ad9256d236 (patch)
tree144c99d4b80df0f0f9a3ded83f9d21a8b36f17cc /chrome/browser/task_manager.cc
parent90d6958fe2374a00d3c8583cf4d3b8a509ae8e90 (diff)
downloadchromium_src-2d31666a58e746b7a1d415c99e5f68ad9256d236.zip
chromium_src-2d31666a58e746b7a1d415c99e5f68ad9256d236.tar.gz
chromium_src-2d31666a58e746b7a1d415c99e5f68ad9256d236.tar.bz2
Minor cleanup to OneShotTimer and RepeatingTimer: moves more of the member variables into the Task subclass.
Also included in this change: deprecate MessageLoop::timer_manager(), and change consumers over to use OneShotTimer or RepeatingTimer. R=beng BUG=1346553 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1684 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/task_manager.cc')
-rw-r--r--chrome/browser/task_manager.cc33
1 files changed, 3 insertions, 30 deletions
diff --git a/chrome/browser/task_manager.cc b/chrome/browser/task_manager.cc
index 06c7bbc..7cb75ff 100644
--- a/chrome/browser/task_manager.cc
+++ b/chrome/browser/task_manager.cc
@@ -7,7 +7,6 @@
#include "base/process_util.h"
#include "base/stats_table.h"
#include "base/string_util.h"
-#include "base/timer.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/render_process_host.h"
@@ -44,26 +43,6 @@ static const int kGoatsTeleportedColumn =
(94024 * kNuthMagicNumber) & kBitMask;
////////////////////////////////////////////////////////////////////////////////
-// TaskManagerUpdateTask class.
-//
-// Used to periodically updates the task manager contents.
-//
-////////////////////////////////////////////////////////////////////////////////
-
-class TaskManagerUpdateTask : public Task {
- public:
- explicit TaskManagerUpdateTask(TaskManagerTableModel* model) : model_(model) {
- }
- void Run() {
- if (model_) model_->Refresh();
- }
-
- private:
- TaskManagerTableModel* model_;
- DISALLOW_EVIL_CONSTRUCTORS(TaskManagerUpdateTask);
-};
-
-////////////////////////////////////////////////////////////////////////////////
// TaskManagerTableModel class
////////////////////////////////////////////////////////////////////////////////
@@ -72,7 +51,6 @@ int TaskManagerTableModel::goats_teleported_ = 0;
TaskManagerTableModel::TaskManagerTableModel(TaskManager* task_manager)
: observer_(NULL),
- timer_(NULL),
ui_loop_(MessageLoop::current()),
is_updating_(false) {
@@ -88,11 +66,9 @@ TaskManagerTableModel::TaskManagerTableModel(TaskManager* task_manager)
new TaskManagerPluginProcessResourceProvider(task_manager);
plugin_provider->AddRef();
providers_.push_back(plugin_provider);
- update_task_.reset(new TaskManagerUpdateTask(this));
}
TaskManagerTableModel::~TaskManagerTableModel() {
- DCHECK(timer_ == NULL);
for (ResourceProviderList::iterator iter = providers_.begin();
iter != providers_.end(); ++iter) {
(*iter)->Release();
@@ -229,9 +205,8 @@ HANDLE TaskManagerTableModel::GetProcessAt(int index) {
void TaskManagerTableModel::StartUpdating() {
DCHECK(!is_updating_);
is_updating_ = true;
- DCHECK(timer_ == NULL);
- TimerManager* tm = MessageLoop::current()->timer_manager();
- timer_ = tm->StartTimer(kUpdateTimeMs, update_task_.get(), true);
+ update_timer_.Start(TimeDelta::FromMilliseconds(kUpdateTimeMs), this,
+ &TaskManagerTableModel::Refresh);
// Register jobs notifications so we can compute network usage (it must be
// done from the IO thread).
@@ -250,9 +225,7 @@ void TaskManagerTableModel::StartUpdating() {
void TaskManagerTableModel::StopUpdating() {
DCHECK(is_updating_);
is_updating_ = false;
- MessageLoop::current()->timer_manager()->StopTimer(timer_);
- delete timer_;
- timer_ = NULL;
+ update_timer_.Stop();
// Notify resource providers that we are done updating.
for (ResourceProviderList::const_iterator iter = providers_.begin();