summaryrefslogtreecommitdiffstats
path: root/jingle/notifier/base
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-12 21:18:16 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-12 21:18:16 +0000
commit31a7eef76caaaa50d57166c26ebe2f9625000642 (patch)
tree53320dce2e28eef75c0b72fd0c31c2565b5e7b98 /jingle/notifier/base
parent72b6f8e29c17e3752847dd318821f18968b23dc8 (diff)
downloadchromium_src-31a7eef76caaaa50d57166c26ebe2f9625000642.zip
chromium_src-31a7eef76caaaa50d57166c26ebe2f9625000642.tar.gz
chromium_src-31a7eef76caaaa50d57166c26ebe2f9625000642.tar.bz2
base::Bind: Convert jingle/.
BUG=none TEST=none R=csilv@chromium.org Review URL: http://codereview.chromium.org/8551004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109811 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'jingle/notifier/base')
-rw-r--r--jingle/notifier/base/chrome_async_socket.cc31
-rw-r--r--jingle/notifier/base/chrome_async_socket.h5
-rw-r--r--jingle/notifier/base/proxy_resolving_client_socket.cc12
-rw-r--r--jingle/notifier/base/proxy_resolving_client_socket.h4
-rw-r--r--jingle/notifier/base/task_pump.cc7
-rw-r--r--jingle/notifier/base/task_pump.h3
6 files changed, 28 insertions, 34 deletions
diff --git a/jingle/notifier/base/chrome_async_socket.cc b/jingle/notifier/base/chrome_async_socket.cc
index 27f13a5..131f733 100644
--- a/jingle/notifier/base/chrome_async_socket.cc
+++ b/jingle/notifier/base/chrome_async_socket.cc
@@ -9,6 +9,7 @@
#include <cstdlib>
#include "base/basictypes.h"
+#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/message_loop.h"
@@ -43,8 +44,7 @@ ChromeAsyncSocket::ChromeAsyncSocket(
state_(STATE_CLOSED),
error_(ERROR_NONE),
net_error_(net::OK),
- scoped_runnable_method_factory_(
- ALLOW_THIS_IN_INITIALIZER_LIST(this)),
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
read_state_(IDLE),
read_buf_(new net::IOBufferWithSize(read_buf_size)),
read_start_(0U),
@@ -112,8 +112,7 @@ bool ChromeAsyncSocket::Connect(const talk_base::SocketAddress& address) {
state_ = STATE_CONNECTING;
- DCHECK(scoped_runnable_method_factory_.empty());
- scoped_runnable_method_factory_.RevokeAll();
+ DCHECK_EQ(false, weak_factory_.HasWeakPtrs());
net::HostPortPair dest_host_port_pair(address.IPAsString(), address.port());
@@ -128,10 +127,9 @@ bool ChromeAsyncSocket::Connect(const talk_base::SocketAddress& address) {
// the connect always happens asynchronously.
MessageLoop* message_loop = MessageLoop::current();
CHECK(message_loop);
- message_loop->PostTask(
- FROM_HERE,
- scoped_runnable_method_factory_.NewRunnableMethod(
- &ChromeAsyncSocket::ProcessConnectDone, status));
+ message_loop->PostTask(FROM_HERE,
+ base::Bind(&ChromeAsyncSocket::ProcessConnectDone,
+ weak_factory_.GetWeakPtr(), status));
}
return true;
}
@@ -167,8 +165,7 @@ void ChromeAsyncSocket::PostDoRead() {
CHECK(message_loop);
message_loop->PostTask(
FROM_HERE,
- scoped_runnable_method_factory_.NewRunnableMethod(
- &ChromeAsyncSocket::DoRead));
+ base::Bind(&ChromeAsyncSocket::DoRead, weak_factory_.GetWeakPtr()));
read_state_ = POSTED;
}
@@ -299,8 +296,7 @@ void ChromeAsyncSocket::PostDoWrite() {
CHECK(message_loop);
message_loop->PostTask(
FROM_HERE,
- scoped_runnable_method_factory_.NewRunnableMethod(
- &ChromeAsyncSocket::DoWrite));
+ base::Bind(&ChromeAsyncSocket::DoWrite, weak_factory_.GetWeakPtr()));
write_state_ = POSTED;
}
@@ -367,7 +363,7 @@ bool ChromeAsyncSocket::Close() {
// (not STATE_CLOSED) -> STATE_CLOSED
void ChromeAsyncSocket::DoClose() {
- scoped_runnable_method_factory_.RevokeAll();
+ weak_factory_.InvalidateWeakPtrs();
if (transport_socket_.get()) {
transport_socket_->Disconnect();
}
@@ -404,7 +400,7 @@ bool ChromeAsyncSocket::StartTls(const std::string& domain_name) {
DCHECK_EQ(write_end_, 0U);
// Clear out any posted DoRead() tasks.
- scoped_runnable_method_factory_.RevokeAll();
+ weak_factory_.InvalidateWeakPtrs();
DCHECK(transport_socket_.get());
net::ClientSocketHandle* socket_handle = new net::ClientSocketHandle();
@@ -416,10 +412,9 @@ bool ChromeAsyncSocket::StartTls(const std::string& domain_name) {
if (status != net::ERR_IO_PENDING) {
MessageLoop* message_loop = MessageLoop::current();
CHECK(message_loop);
- message_loop->PostTask(
- FROM_HERE,
- scoped_runnable_method_factory_.NewRunnableMethod(
- &ChromeAsyncSocket::ProcessSSLConnectDone, status));
+ message_loop->PostTask(FROM_HERE,
+ base::Bind(&ChromeAsyncSocket::ProcessSSLConnectDone,
+ weak_factory_.GetWeakPtr(), status));
}
return true;
}
diff --git a/jingle/notifier/base/chrome_async_socket.h b/jingle/notifier/base/chrome_async_socket.h
index 2960b6d..75c8873 100644
--- a/jingle/notifier/base/chrome_async_socket.h
+++ b/jingle/notifier/base/chrome_async_socket.h
@@ -17,7 +17,7 @@
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
-#include "base/task.h"
+#include "base/memory/weak_ptr.h"
#include "net/base/completion_callback.h"
#include "net/base/net_errors.h"
#include "talk/xmpp/asyncsocket.h"
@@ -189,8 +189,7 @@ class ChromeAsyncSocket : public buzz::AsyncSocket {
net::Error net_error_;
// Used by read/write loops.
- ScopedRunnableMethodFactory<ChromeAsyncSocket>
- scoped_runnable_method_factory_;
+ base::WeakPtrFactory<ChromeAsyncSocket> weak_factory_;
// NULL iff state() == STATE_CLOSED.
//
diff --git a/jingle/notifier/base/proxy_resolving_client_socket.cc b/jingle/notifier/base/proxy_resolving_client_socket.cc
index b4cc70c..cc5bcbe 100644
--- a/jingle/notifier/base/proxy_resolving_client_socket.cc
+++ b/jingle/notifier/base/proxy_resolving_client_socket.cc
@@ -5,6 +5,7 @@
#include "jingle/notifier/base/proxy_resolving_client_socket.h"
#include "base/basictypes.h"
+#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "googleurl/src/gurl.h"
@@ -35,8 +36,7 @@ ProxyResolvingClientSocket::ProxyResolvingClientSocket(
net::BoundNetLog::Make(
request_context_getter->GetURLRequestContext()->net_log(),
net::NetLog::SOURCE_SOCKET)),
- scoped_runnable_method_factory_(
- ALLOW_THIS_IN_INITIALIZER_LIST(this)),
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
user_connect_callback_(NULL) {
DCHECK(request_context_getter);
net::URLRequestContext* request_context =
@@ -117,8 +117,8 @@ int ProxyResolvingClientSocket::Connect(net::OldCompletionCallback* callback) {
CHECK(message_loop);
message_loop->PostTask(
FROM_HERE,
- scoped_runnable_method_factory_.NewRunnableMethod(
- &ProxyResolvingClientSocket::ProcessProxyResolveDone, status));
+ base::Bind(&ProxyResolvingClientSocket::ProcessProxyResolveDone,
+ weak_factory_.GetWeakPtr(), status));
}
user_connect_callback_ = callback;
return net::ERR_IO_PENDING;
@@ -270,8 +270,8 @@ int ProxyResolvingClientSocket::ReconsiderProxyAfterError(int error) {
CHECK(message_loop);
message_loop->PostTask(
FROM_HERE,
- scoped_runnable_method_factory_.NewRunnableMethod(
- &ProxyResolvingClientSocket::ProcessProxyResolveDone, rv));
+ base::Bind(&ProxyResolvingClientSocket::ProcessProxyResolveDone,
+ weak_factory_.GetWeakPtr(), rv));
// Since we potentially have another try to go (trying the direct connect)
// set the return code code to ERR_IO_PENDING.
rv = net::ERR_IO_PENDING;
diff --git a/jingle/notifier/base/proxy_resolving_client_socket.h b/jingle/notifier/base/proxy_resolving_client_socket.h
index 0cdd533..5ed2216 100644
--- a/jingle/notifier/base/proxy_resolving_client_socket.h
+++ b/jingle/notifier/base/proxy_resolving_client_socket.h
@@ -11,6 +11,7 @@
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
#include "net/base/completion_callback.h"
#include "net/base/host_port_pair.h"
#include "net/base/net_errors.h"
@@ -90,8 +91,7 @@ class ProxyResolvingClientSocket : public net::StreamSocket {
net::HostPortPair dest_host_port_pair_;
bool tried_direct_connect_fallback_;
net::BoundNetLog bound_net_log_;
- ScopedRunnableMethodFactory<ProxyResolvingClientSocket>
- scoped_runnable_method_factory_;
+ base::WeakPtrFactory<ProxyResolvingClientSocket> weak_factory_;
// The callback passed to Connect().
net::OldCompletionCallback* user_connect_callback_;
diff --git a/jingle/notifier/base/task_pump.cc b/jingle/notifier/base/task_pump.cc
index 0395314..001f1ab 100644
--- a/jingle/notifier/base/task_pump.cc
+++ b/jingle/notifier/base/task_pump.cc
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/bind.h"
#include "base/message_loop.h"
#include "jingle/notifier/base/task_pump.h"
namespace notifier {
TaskPump::TaskPump()
- : scoped_runnable_method_factory_(
- ALLOW_THIS_IN_INITIALIZER_LIST(this)),
+ : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
posted_wake_(false),
stopped_(false) {}
@@ -25,8 +25,7 @@ void TaskPump::WakeTasks() {
// Do the requested wake up.
current_message_loop->PostTask(
FROM_HERE,
- scoped_runnable_method_factory_.NewRunnableMethod(
- &TaskPump::CheckAndRunTasks));
+ base::Bind(&TaskPump::CheckAndRunTasks, weak_factory_.GetWeakPtr()));
posted_wake_ = true;
}
}
diff --git a/jingle/notifier/base/task_pump.h b/jingle/notifier/base/task_pump.h
index 958a152..440dba4 100644
--- a/jingle/notifier/base/task_pump.h
+++ b/jingle/notifier/base/task_pump.h
@@ -5,6 +5,7 @@
#ifndef JINGLE_NOTIFIER_BASE_TASK_PUMP_H_
#define JINGLE_NOTIFIER_BASE_TASK_PUMP_H_
+#include "base/memory/weak_ptr.h"
#include "base/task.h"
#include "base/threading/non_thread_safe.h"
#include "talk/base/taskrunner.h"
@@ -29,7 +30,7 @@ class TaskPump : public talk_base::TaskRunner {
void CheckAndRunTasks();
base::NonThreadSafe non_thread_safe_;
- ScopedRunnableMethodFactory<TaskPump> scoped_runnable_method_factory_;
+ base::WeakPtrFactory<TaskPump> weak_factory_;
bool posted_wake_;
bool stopped_;