Commit 12465ec0 authored by groby@chromium.org's avatar groby@chromium.org

base::Bind fixes


BUG=none
TEST=none


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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110554 0039d316-1c4b-4281-b951-d872f2087c98
parent e3210f6f
......@@ -4,6 +4,7 @@
#include "chrome/browser/net/chrome_url_request_context.h"
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/message_loop.h"
#include "base/message_loop_proxy.h"
......@@ -161,8 +162,8 @@ net::CookieStore* ChromeURLRequestContextGetter::DONTUSEME_GetCookieStore() {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
NewRunnableMethod(this,
&ChromeURLRequestContextGetter::GetCookieStoreAsyncHelper,
base::Bind(&ChromeURLRequestContextGetter::GetCookieStoreAsyncHelper,
this,
&completion,
&result));
......@@ -275,27 +276,27 @@ void ChromeURLRequestContextGetter::Observe(
prefs->GetString(prefs::kAcceptLanguages);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
NewRunnableMethod(
this,
base::Bind(
&ChromeURLRequestContextGetter::OnAcceptLanguageChange,
this,
accept_language));
} else if (*pref_name_in == prefs::kDefaultCharset) {
std::string default_charset =
prefs->GetString(prefs::kDefaultCharset);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
NewRunnableMethod(
this,
base::Bind(
&ChromeURLRequestContextGetter::OnDefaultCharsetChange,
this,
default_charset));
} else if (*pref_name_in == prefs::kClearSiteDataOnExit) {
bool clear_site_data =
prefs->GetBoolean(prefs::kClearSiteDataOnExit);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
NewRunnableMethod(
this,
base::Bind(
&ChromeURLRequestContextGetter::OnClearSiteDataOnExitChange,
this,
clear_site_data));
}
} else {
......
......@@ -4,6 +4,7 @@
#include "chrome/browser/net/connection_tester.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/logging.h"
......@@ -262,7 +263,7 @@ class ConnectionTester::TestRunner : public net::URLRequest::Delegate {
// |tester| will be notified of completion.
explicit TestRunner(ConnectionTester* tester)
: tester_(tester),
ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {}
ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {}
// Starts running |experiment|. Notifies tester->OnExperimentCompleted() when
// it is done.
......@@ -288,7 +289,7 @@ class ConnectionTester::TestRunner : public net::URLRequest::Delegate {
ConnectionTester* tester_;
scoped_ptr<net::URLRequest> request_;
ScopedRunnableMethodFactory<TestRunner> method_factory_;
base::WeakPtrFactory<TestRunner> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(TestRunner);
};
......@@ -340,8 +341,8 @@ void ConnectionTester::TestRunner::OnResponseCompleted(
// to end up deleting the URLRequest while in the middle of processing).
MessageLoop::current()->PostTask(
FROM_HERE,
method_factory_.NewRunnableMethod(
&TestRunner::OnExperimentCompletedWithResult, result));
base::Bind(&TestRunner::OnExperimentCompletedWithResult,
weak_factory_.GetWeakPtr(), result));
}
void ConnectionTester::TestRunner::OnExperimentCompletedWithResult(int result) {
......
......@@ -4,6 +4,7 @@
#include "chrome/browser/net/network_stats.h"
#include "base/bind.h"
#include "base/callback_old.h"
#include "base/logging.h"
#include "base/message_loop.h"
......@@ -87,7 +88,7 @@ NetworkStats::NetworkStats()
write_callback_(this, &NetworkStats::OnWriteComplete)),
finished_callback_(NULL),
start_time_(base::TimeTicks::Now()),
ALLOW_THIS_IN_INITIALIZER_LIST(timers_factory_(this)) {
ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
}
NetworkStats::~NetworkStats() {
......@@ -205,7 +206,7 @@ void NetworkStats::OnReadComplete(int result) {
const int kReadDataDelayMs = 1;
MessageLoop::current()->PostDelayedTask(
FROM_HERE,
timers_factory_.NewRunnableMethod(&NetworkStats::ReadData),
base::Bind(&NetworkStats::ReadData, weak_factory_.GetWeakPtr()),
kReadDataDelayMs);
}
}
......@@ -281,7 +282,7 @@ int NetworkStats::SendData() {
void NetworkStats::StartReadDataTimer(int milliseconds) {
MessageLoop::current()->PostDelayedTask(
FROM_HERE,
timers_factory_.NewRunnableMethod(&NetworkStats::OnReadDataTimeout),
base::Bind(&NetworkStats::OnReadDataTimeout, weak_factory_.GetWeakPtr()),
milliseconds);
}
......@@ -528,7 +529,7 @@ void CollectNetworkStats(const std::string& network_stats_server,
BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
NewRunnableFunction(
base::Bind(
&CollectNetworkStats, network_stats_server, io_thread));
return;
}
......
......@@ -9,6 +9,7 @@
#include <string>
#include "base/basictypes.h"
#include "base/bind.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/string_util.h"
......@@ -191,7 +192,7 @@ class NetworkStats {
base::TimeTicks start_time_;
// We use this factory to create timeout tasks for socket's ReadData.
ScopedRunnableMethodFactory<NetworkStats> timers_factory_;
base::WeakPtrFactory<NetworkStats> weak_factory_;
};
class UDPStatsClient : public NetworkStats {
......
......@@ -701,7 +701,8 @@ void Predictor::FinalizeInitializationOnIOThread(
// on the same thread. The predictor lives on the IO thread and will die
// from there so now that we're on the IO thread we need to properly
// initialize the ScopedrunnableMethodFactory.
trim_task_factory_.reset(new ScopedRunnableMethodFactory<Predictor>(this));
// TODO(groby): Check if WeakPtrFactory has the same constraint.
weak_factory_.reset(new base::WeakPtrFactory<Predictor>(this));
// Prefetch these hostnames on startup.
DnsPrefetchMotivatedList(startup_urls, UrlInfo::STARTUP_LIST_MOTIVATED);
......@@ -1054,8 +1055,8 @@ void Predictor::PostIncrementalTrimTask() {
return;
MessageLoop::current()->PostDelayedTask(
FROM_HERE,
trim_task_factory_->NewRunnableMethod(
&Predictor::IncrementalTrimReferrers, false),
base::Bind(&Predictor::IncrementalTrimReferrers,
weak_factory_->GetWeakPtr(), false),
kDurationBetweenTrimmingIncrements.InMilliseconds());
}
......
......@@ -492,7 +492,7 @@ class Predictor {
// A time after which we need to do more trimming of referrers.
base::TimeTicks next_trim_time_;
scoped_ptr<ScopedRunnableMethodFactory<Predictor> > trim_task_factory_;
scoped_ptr<base::WeakPtrFactory<Predictor> > weak_factory_;
DISALLOW_COPY_AND_ASSIGN(Predictor);
};
......
......@@ -4,6 +4,7 @@
#include "chrome/browser/net/sdch_dictionary_fetcher.h"
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/message_loop.h"
#include "chrome/browser/profiles/profile.h"
......@@ -11,7 +12,7 @@
#include "net/url_request/url_request_status.h"
SdchDictionaryFetcher::SdchDictionaryFetcher()
: ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)),
: ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
task_is_pending_(false) {
}
......@@ -46,7 +47,8 @@ void SdchDictionaryFetcher::ScheduleDelayedRun() {
if (fetch_queue_.empty() || current_fetch_.get() || task_is_pending_)
return;
MessageLoop::current()->PostDelayedTask(FROM_HERE,
method_factory_.NewRunnableMethod(&SdchDictionaryFetcher::StartFetching),
base::Bind(&SdchDictionaryFetcher::StartFetching,
weak_factory_.GetWeakPtr()),
kMsDelayFromRequestTillDownload);
task_is_pending_ = true;
}
......
......@@ -61,7 +61,7 @@ class SdchDictionaryFetcher : public content::URLFetcherDelegate,
// Always spread out the dictionary fetches, so that they don't steal
// bandwidth from the actual page load. Create delayed tasks to spread out
// the download.
ScopedRunnableMethodFactory<SdchDictionaryFetcher> method_factory_;
base::WeakPtrFactory<SdchDictionaryFetcher> weak_factory_;
bool task_is_pending_;
// Althought the SDCH spec does not preclude a server from using a single URL
......
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