diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-15 22:25:21 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-15 22:25:21 +0000 |
commit | 32876aeb6bbb36b4c0cb928fa578f10d306337b0 (patch) | |
tree | fe42b86df7c9e71ac7fd9d0804e103e4e12111a0 /content/renderer/load_progress_tracker.cc | |
parent | 360e7a03b7265826324fe5727636f5e83490e8ab (diff) | |
download | chromium_src-32876aeb6bbb36b4c0cb928fa578f10d306337b0.zip chromium_src-32876aeb6bbb36b4c0cb928fa578f10d306337b0.tar.gz chromium_src-32876aeb6bbb36b4c0cb928fa578f10d306337b0.tar.bz2 |
base::Bind: Convert content/renderer.
BUG=none
TEST=none
R=csilv@chromium.org
Review URL: http://codereview.chromium.org/8554001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110189 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer/load_progress_tracker.cc')
-rw-r--r-- | content/renderer/load_progress_tracker.cc | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/content/renderer/load_progress_tracker.cc b/content/renderer/load_progress_tracker.cc index c4ceb5e..cc153f6 100644 --- a/content/renderer/load_progress_tracker.cc +++ b/content/renderer/load_progress_tracker.cc @@ -1,9 +1,10 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "content/renderer/load_progress_tracker.h" +#include "base/bind.h" #include "base/message_loop.h" #include "content/common/view_messages.h" #include "content/renderer/render_view_impl.h" @@ -18,7 +19,7 @@ LoadProgressTracker::LoadProgressTracker(RenderViewImpl* render_view) : render_view_(render_view), tracked_frame_(NULL), progress_(0.0), - ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { + ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { } LoadProgressTracker::~LoadProgressTracker() { @@ -28,7 +29,7 @@ void LoadProgressTracker::DidStopLoading() { if (!tracked_frame_) return; - // Load stoped while we were still tracking load. Make sure we notify the + // Load stopped while we were still tracking load. Make sure we notify the // browser that load is complete. progress_ = 1.0; SendChangeLoadProgress(); @@ -54,20 +55,20 @@ void LoadProgressTracker::DidChangeLoadProgress(WebKit::WebFrame* frame, (base::TimeTicks::Now() - last_time_progress_sent_).InMilliseconds() > kMinimumDelayBetweenUpdatesMS) { // If there is a pending task to send progress, it is now obsolete. - method_factory_.RevokeAll(); + weak_factory_.InvalidateWeakPtrs(); SendChangeLoadProgress(); if (progress == 1.0) ResetStates(); return; } - if (!method_factory_.empty()) + if (weak_factory_.HasWeakPtrs()) return; MessageLoop::current()->PostDelayedTask( FROM_HERE, - method_factory_.NewRunnableMethod( - &LoadProgressTracker::SendChangeLoadProgress), + base::Bind(&LoadProgressTracker::SendChangeLoadProgress, + weak_factory_.GetWeakPtr()), kMinimumDelayBetweenUpdatesMS); } @@ -81,6 +82,6 @@ void LoadProgressTracker::SendChangeLoadProgress() { void LoadProgressTracker::ResetStates() { tracked_frame_ = NULL; progress_ = 0.0; - method_factory_.RevokeAll(); + weak_factory_.InvalidateWeakPtrs(); last_time_progress_sent_ = base::TimeTicks(); } |