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

Unified Diff: chrome/browser/chromeos/web_socket_proxy.cc

Issue 8960010: base::Bind: Convert NewRunnableMethod in chrome/browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Build fix 55. Created 9 years 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/chromeos/version_loader.cc ('k') | chrome/browser/download/download_prefs.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/web_socket_proxy.cc
diff --git a/chrome/browser/chromeos/web_socket_proxy.cc b/chrome/browser/chromeos/web_socket_proxy.cc
index 85d7d2ffc52d2355cf17a100724865aff30dde37..1a8f320765f98bb57b59ca22b1d260e35a803836 100644
--- a/chrome/browser/chromeos/web_socket_proxy.cc
+++ b/chrome/browser/chromeos/web_socket_proxy.cc
@@ -31,6 +31,7 @@
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "base/message_loop.h"
#include "base/sha1.h"
#include "base/stl_util.h"
@@ -554,7 +555,7 @@ class SSLChan : public MessageLoopForIO::Watcher {
outbound_stream_(WebSocketProxy::kBufferLimit),
read_pipe_(read_pipe),
write_pipe_(write_pipe),
- method_factory_(this) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
if (!SetNonBlock(read_pipe_) || !SetNonBlock(write_pipe_)) {
Shut(net::ERR_UNEXPECTED);
return;
@@ -590,8 +591,9 @@ class SSLChan : public MessageLoopForIO::Watcher {
};
for (int i = arraysize(buf); i--;) {
if (buf[i] && buf[i]->size() > 0) {
- MessageLoop::current()->PostTask(FROM_HERE,
- method_factory_.NewRunnableMethod(&SSLChan::Proceed));
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&SSLChan::Proceed, weak_factory_.GetWeakPtr()));
return;
}
}
@@ -732,8 +734,9 @@ class SSLChan : public MessageLoopForIO::Watcher {
base::Bind(&SSLChan::OnSocketRead, base::Unretained(this)));
is_socket_read_pending_ = true;
if (rv != net::ERR_IO_PENDING) {
- MessageLoop::current()->PostTask(FROM_HERE,
- method_factory_.NewRunnableMethod(&SSLChan::OnSocketRead, rv));
+ MessageLoop::current()->PostTask(
+ FROM_HERE, base::Bind(&SSLChan::OnSocketRead,
+ weak_factory_.GetWeakPtr(), rv));
}
}
}
@@ -746,8 +749,9 @@ class SSLChan : public MessageLoopForIO::Watcher {
base::Bind(&SSLChan::OnSocketWrite, base::Unretained(this)));
is_socket_write_pending_ = true;
if (rv != net::ERR_IO_PENDING) {
- MessageLoop::current()->PostTask(FROM_HERE,
- method_factory_.NewRunnableMethod(&SSLChan::OnSocketWrite, rv));
+ MessageLoop::current()->PostTask(
+ FROM_HERE, base::Bind(&SSLChan::OnSocketWrite,
+ weak_factory_.GetWeakPtr(), rv));
}
} else if (phase_ == PHASE_CLOSING) {
Shut(0);
@@ -792,7 +796,7 @@ class SSLChan : public MessageLoopForIO::Watcher {
bool is_socket_write_pending_;
bool is_read_pipe_blocked_;
bool is_write_pipe_blocked_;
- ScopedRunnableMethodFactory<SSLChan> method_factory_;
+ base::WeakPtrFactory<SSLChan> weak_factory_;
MessageLoopForIO::FileDescriptorWatcher read_pipe_controller_;
MessageLoopForIO::FileDescriptorWatcher write_pipe_controller_;
« no previous file with comments | « chrome/browser/chromeos/version_loader.cc ('k') | chrome/browser/download/download_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698