diff options
author | yutak@chromium.org <yutak@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-29 12:09:00 +0000 |
---|---|---|
committer | yutak@chromium.org <yutak@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-29 12:09:00 +0000 |
commit | d1bf3d33beae2f1fe90b549bd68aa561b5bb8caa (patch) | |
tree | 38f1cb2481c9dd790baf9abc81873ca0ad474665 /net/websockets | |
parent | 4c1bd635cf5de020499655d545e543583e3f7e21 (diff) | |
download | chromium_src-d1bf3d33beae2f1fe90b549bd68aa561b5bb8caa.zip chromium_src-d1bf3d33beae2f1fe90b549bd68aa561b5bb8caa.tar.gz chromium_src-d1bf3d33beae2f1fe90b549bd68aa561b5bb8caa.tar.bz2 |
Replace Callback0::Type and NewCallback() in WebSocketJobTest.
BUG=105683
TEST=none
Review URL: http://codereview.chromium.org/8729021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111918 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/websockets')
-rw-r--r-- | net/websockets/websocket_job_unittest.cc | 69 |
1 files changed, 36 insertions, 33 deletions
diff --git a/net/websockets/websocket_job_unittest.cc b/net/websockets/websocket_job_unittest.cc index efbebf3..db3add1 100644 --- a/net/websockets/websocket_job_unittest.cc +++ b/net/websockets/websocket_job_unittest.cc @@ -7,6 +7,9 @@ #include <string> #include <vector> +#include "base/bind.h" +#include "base/bind_helpers.h" +#include "base/callback.h" #include "base/memory/ref_counted.h" #include "base/string_split.h" #include "base/string_util.h" @@ -73,47 +76,47 @@ class MockSocketStreamDelegate : public net::SocketStream::Delegate { } virtual ~MockSocketStreamDelegate() {} - void SetOnStartOpenConnection(Callback0::Type* callback) { - on_start_open_connection_.reset(callback); + void SetOnStartOpenConnection(const base::Closure& callback) { + on_start_open_connection_ = callback; } - void SetOnConnected(Callback0::Type* callback) { - on_connected_.reset(callback); + void SetOnConnected(const base::Closure& callback) { + on_connected_ = callback; } - void SetOnSentData(Callback0::Type* callback) { - on_sent_data_.reset(callback); + void SetOnSentData(const base::Closure& callback) { + on_sent_data_ = callback; } - void SetOnReceivedData(Callback0::Type* callback) { - on_received_data_.reset(callback); + void SetOnReceivedData(const base::Closure& callback) { + on_received_data_ = callback; } - void SetOnClose(Callback0::Type* callback) { - on_close_.reset(callback); + void SetOnClose(const base::Closure& callback) { + on_close_ = callback; } virtual int OnStartOpenConnection(net::SocketStream* socket, net::OldCompletionCallback* callback) { - if (on_start_open_connection_.get()) - on_start_open_connection_->Run(); + if (!on_start_open_connection_.is_null()) + on_start_open_connection_.Run(); return net::OK; } virtual void OnConnected(net::SocketStream* socket, int max_pending_send_allowed) { - if (on_connected_.get()) - on_connected_->Run(); + if (!on_connected_.is_null()) + on_connected_.Run(); } virtual void OnSentData(net::SocketStream* socket, int amount_sent) { amount_sent_ += amount_sent; - if (on_sent_data_.get()) - on_sent_data_->Run(); + if (!on_sent_data_.is_null()) + on_sent_data_.Run(); } virtual void OnReceivedData(net::SocketStream* socket, const char* data, int len) { received_data_ += std::string(data, len); - if (on_received_data_.get()) - on_received_data_->Run(); + if (!on_received_data_.is_null()) + on_received_data_.Run(); } virtual void OnClose(net::SocketStream* socket) { - if (on_close_.get()) - on_close_->Run(); + if (!on_close_.is_null()) + on_close_.Run(); } virtual bool CanGetCookies(net::SocketStream* socket, const GURL& url) { return allow_all_cookies_; @@ -132,11 +135,11 @@ class MockSocketStreamDelegate : public net::SocketStream::Delegate { int amount_sent_; bool allow_all_cookies_; std::string received_data_; - scoped_ptr<Callback0::Type> on_start_open_connection_; - scoped_ptr<Callback0::Type> on_connected_; - scoped_ptr<Callback0::Type> on_sent_data_; - scoped_ptr<Callback0::Type> on_received_data_; - scoped_ptr<Callback0::Type> on_close_; + base::Closure on_start_open_connection_; + base::Closure on_connected_; + base::Closure on_sent_data_; + base::Closure on_received_data_; + base::Closure on_close_; }; class MockCookieStore : public net::CookieStore { @@ -828,13 +831,13 @@ void WebSocketJobTest::TestConnectByWebSocket(ThrottlingOption throttling) { WebSocketJobTest* test = this; if (throttling == THROTTLING_ON) delegate.SetOnStartOpenConnection( - NewCallback(test, &WebSocketJobTest::DoSync)); + base::Bind(&WebSocketJobTest::DoSync, base::Unretained(test))); delegate.SetOnConnected( - NewCallback(test, &WebSocketJobTest::DoSendRequest)); + base::Bind(&WebSocketJobTest::DoSendRequest, base::Unretained(test))); delegate.SetOnReceivedData( - NewCallback(test, &WebSocketJobTest::DoSendData)); + base::Bind(&WebSocketJobTest::DoSendData, base::Unretained(test))); delegate.SetOnClose( - NewCallback(test, &WebSocketJobTest::DoSync)); + base::Bind(&WebSocketJobTest::DoSync, base::Unretained(test))); InitWebSocketJob(url, &delegate, STREAM_SOCKET); scoped_refptr<WebSocketJob> block_websocket; @@ -943,13 +946,13 @@ void WebSocketJobTest::TestConnectBySpdy( WebSocketJobTest* test = this; if (throttling == THROTTLING_ON) delegate.SetOnStartOpenConnection( - NewCallback(test, &WebSocketJobTest::DoSync)); + base::Bind(&WebSocketJobTest::DoSync, base::Unretained(test))); delegate.SetOnConnected( - NewCallback(test, &WebSocketJobTest::DoSendRequest)); + base::Bind(&WebSocketJobTest::DoSendRequest, base::Unretained(test))); delegate.SetOnReceivedData( - NewCallback(test, &WebSocketJobTest::DoSendData)); + base::Bind(&WebSocketJobTest::DoSendData, base::Unretained(test))); delegate.SetOnClose( - NewCallback(test, &WebSocketJobTest::DoSync)); + base::Bind(&WebSocketJobTest::DoSync, base::Unretained(test))); InitWebSocketJob(url, &delegate, STREAM_SPDY_WEBSOCKET); scoped_refptr<WebSocketJob> block_websocket; |