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

Unified Diff: chrome/browser/io_thread.cc

Issue 8473009: base::Bind() conversion for IOThread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/io_thread.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/io_thread.cc
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc
index c86f21ec0c45ba51671c5f54c8bc78edae5c968f..0769a208d0c5a9b8d9094f86eb6d2d2085bb249c 100644
--- a/chrome/browser/io_thread.cc
+++ b/chrome/browser/io_thread.cc
@@ -7,6 +7,8 @@
#include <vector>
#include "base/command_line.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/debug/leak_tracker.h"
#include "base/logging.h"
#include "base/metrics/field_trial.h"
@@ -68,6 +70,9 @@
using content::BrowserThread;
+// The IOThread object must outlive any tasks posted to the IO thread before the
+// Quit task, so base::Bind() calls are not refcounted.
+
namespace {
// Custom URLRequestContext used by requests which aren't associated with a
@@ -328,10 +333,6 @@ SystemURLRequestContextGetter::GetIOMessageLoopProxy() const {
return io_message_loop_proxy_;
}
-// The IOThread object must outlive any tasks posted to the IO thread before the
-// Quit task.
-DISABLE_RUNNABLE_METHOD_REFCOUNT(IOThread);
-
IOThread::Globals::Globals() {}
IOThread::Globals::~Globals() {}
@@ -351,7 +352,7 @@ IOThread::IOThread(
extension_event_router_forwarder_(extension_event_router_forwarder),
globals_(NULL),
sdch_manager_(NULL),
- ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
// We call RegisterPrefs() here (instead of inside browser_prefs.cc) to make
// sure that everything is initialized in the right order.
RegisterPrefs(local_state);
@@ -371,8 +372,9 @@ IOThread::IOThread(
ssl_config_service_manager_.reset(
SSLConfigServiceManager::CreateDefaultManager(local_state));
MessageLoop::current()->PostTask(FROM_HERE,
James Hawkins 2011/11/20 20:23:55 You could save a line by shifting this: PostTask(
dcheng 2011/11/20 23:09:24 Done.
- method_factory_.NewRunnableMethod(
- &IOThread::InitSystemRequestContext));
+ base::Bind(
+ &IOThread::InitSystemRequestContext,
+ weak_factory_.GetWeakPtr()));
}
IOThread::~IOThread() {
@@ -594,9 +596,9 @@ void IOThread::InitSystemRequestContext() {
new SystemURLRequestContextGetter(this);
message_loop()->PostTask(
FROM_HERE,
- NewRunnableMethod(
- this,
- &IOThread::InitSystemRequestContextOnIOThread));
+ base::Bind(
+ &IOThread::InitSystemRequestContextOnIOThread,
James Hawkins 2011/11/20 20:23:55 Can this not fit on the line above?
dcheng 2011/11/20 23:09:24 Done. Not quite, but I rearranged it a bit to fit
+ base::Unretained(this)));
}
void IOThread::InitSystemRequestContextOnIOThread() {
« no previous file with comments | « chrome/browser/io_thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698