Commit 21ee224e authored by dcheng@chromium.org's avatar dcheng@chromium.org

base::Bind() conversion for IOThread.

BUG=none
TEST=trybots


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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110874 0039d316-1c4b-4281-b951-d872f2087c98
parent 40d347ea
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include <vector> #include <vector>
#include "base/command_line.h" #include "base/command_line.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/debug/leak_tracker.h" #include "base/debug/leak_tracker.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/metrics/field_trial.h" #include "base/metrics/field_trial.h"
...@@ -68,6 +70,9 @@ ...@@ -68,6 +70,9 @@
using content::BrowserThread; 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 { namespace {
// Custom URLRequestContext used by requests which aren't associated with a // Custom URLRequestContext used by requests which aren't associated with a
...@@ -328,10 +333,6 @@ SystemURLRequestContextGetter::GetIOMessageLoopProxy() const { ...@@ -328,10 +333,6 @@ SystemURLRequestContextGetter::GetIOMessageLoopProxy() const {
return io_message_loop_proxy_; 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() {}
IOThread::Globals::~Globals() {} IOThread::Globals::~Globals() {}
...@@ -351,7 +352,7 @@ IOThread::IOThread( ...@@ -351,7 +352,7 @@ IOThread::IOThread(
extension_event_router_forwarder_(extension_event_router_forwarder), extension_event_router_forwarder_(extension_event_router_forwarder),
globals_(NULL), globals_(NULL),
sdch_manager_(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 // We call RegisterPrefs() here (instead of inside browser_prefs.cc) to make
// sure that everything is initialized in the right order. // sure that everything is initialized in the right order.
RegisterPrefs(local_state); RegisterPrefs(local_state);
...@@ -370,9 +371,9 @@ IOThread::IOThread( ...@@ -370,9 +371,9 @@ IOThread::IOThread(
local_state); local_state);
ssl_config_service_manager_.reset( ssl_config_service_manager_.reset(
SSLConfigServiceManager::CreateDefaultManager(local_state)); SSLConfigServiceManager::CreateDefaultManager(local_state));
MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::current()->PostTask(
method_factory_.NewRunnableMethod( FROM_HERE, base::Bind(&IOThread::InitSystemRequestContext,
&IOThread::InitSystemRequestContext)); weak_factory_.GetWeakPtr()));
} }
IOThread::~IOThread() { IOThread::~IOThread() {
...@@ -593,10 +594,8 @@ void IOThread::InitSystemRequestContext() { ...@@ -593,10 +594,8 @@ void IOThread::InitSystemRequestContext() {
system_url_request_context_getter_ = system_url_request_context_getter_ =
new SystemURLRequestContextGetter(this); new SystemURLRequestContextGetter(this);
message_loop()->PostTask( message_loop()->PostTask(
FROM_HERE, FROM_HERE, base::Bind(&IOThread::InitSystemRequestContextOnIOThread,
NewRunnableMethod( base::Unretained(this)));
this,
&IOThread::InitSystemRequestContextOnIOThread));
} }
void IOThread::InitSystemRequestContextOnIOThread() { void IOThread::InitSystemRequestContextOnIOThread() {
......
...@@ -9,9 +9,8 @@ ...@@ -9,9 +9,8 @@
#include <string> #include <string>
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/task.h" #include "base/memory/weak_ptr.h"
#include "chrome/browser/net/ssl_config_service_manager.h" #include "chrome/browser/net/ssl_config_service_manager.h"
#include "chrome/browser/prefs/pref_member.h" #include "chrome/browser/prefs/pref_member.h"
#include "content/browser/browser_process_sub_thread.h" #include "content/browser/browser_process_sub_thread.h"
...@@ -180,7 +179,7 @@ class IOThread : public content::BrowserProcessSubThread { ...@@ -180,7 +179,7 @@ class IOThread : public content::BrowserProcessSubThread {
net::SdchManager* sdch_manager_; net::SdchManager* sdch_manager_;
ScopedRunnableMethodFactory<IOThread> method_factory_; base::WeakPtrFactory<IOThread> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(IOThread); DISALLOW_COPY_AND_ASSIGN(IOThread);
}; };
......
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