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

Side by Side Diff: chrome/browser/chromeos/web_socket_proxy.cc

Issue 8801005: base::Bind: Convert Socket::Read. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/web_socket_proxy.h" 5 #include "chrome/browser/chromeos/web_socket_proxy.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <string.h> 9 #include <string.h>
10 10
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 const net::HostPortPair host_port_pair, 548 const net::HostPortPair host_port_pair,
549 int read_pipe, 549 int read_pipe,
550 int write_pipe) 550 int write_pipe)
551 : phase_(PHASE_CONNECTING), 551 : phase_(PHASE_CONNECTING),
552 host_port_pair_(host_port_pair), 552 host_port_pair_(host_port_pair),
553 inbound_stream_(WebSocketProxy::kBufferLimit), 553 inbound_stream_(WebSocketProxy::kBufferLimit),
554 outbound_stream_(WebSocketProxy::kBufferLimit), 554 outbound_stream_(WebSocketProxy::kBufferLimit),
555 read_pipe_(read_pipe), 555 read_pipe_(read_pipe),
556 write_pipe_(write_pipe), 556 write_pipe_(write_pipe),
557 method_factory_(this), 557 method_factory_(this),
558 socket_connect_callback_( 558 ALLOW_THIS_IN_INITIALIZER_LIST(socket_connect_callback_(
559 base::Bind(&SSLChan::OnSocketConnect, base::Unretained(this))), 559 base::Bind(&SSLChan::OnSocketConnect, base::Unretained(this)))),
560 ssl_handshake_callback_( 560 ALLOW_THIS_IN_INITIALIZER_LIST(ssl_handshake_callback_(
561 base::Bind(&SSLChan::OnSSLHandshakeCompleted, 561 base::Bind(&SSLChan::OnSSLHandshakeCompleted,
562 base::Unretained(this))), 562 base::Unretained(this)))),
563 socket_read_callback_(NewCallback(this, &SSLChan::OnSocketRead)), 563 ALLOW_THIS_IN_INITIALIZER_LIST(socket_read_callback_(
564 base::Bind(&SSLChan::OnSocketRead, base::Unretained(this)))),
564 socket_write_callback_(NewCallback(this, &SSLChan::OnSocketWrite)) { 565 socket_write_callback_(NewCallback(this, &SSLChan::OnSocketWrite)) {
565 if (!SetNonBlock(read_pipe_) || !SetNonBlock(write_pipe_)) { 566 if (!SetNonBlock(read_pipe_) || !SetNonBlock(write_pipe_)) {
566 Shut(net::ERR_UNEXPECTED); 567 Shut(net::ERR_UNEXPECTED);
567 return; 568 return;
568 } 569 }
569 net::ClientSocketFactory* factory = 570 net::ClientSocketFactory* factory =
570 net::ClientSocketFactory::GetDefaultFactory(); 571 net::ClientSocketFactory::GetDefaultFactory();
571 socket_.reset(factory->CreateTransportClientSocket( 572 socket_.reset(factory->CreateTransportClientSocket(
572 address_list, NULL, net::NetLog::Source())); 573 address_list, NULL, net::NetLog::Source()));
573 if (socket_ == NULL) { 574 if (socket_ == NULL) {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 DCHECK_LT(rv, 0); 726 DCHECK_LT(rv, 0);
726 Shut(net::ERR_UNEXPECTED); 727 Shut(net::ERR_UNEXPECTED);
727 return; 728 return;
728 } 729 }
729 } 730 }
730 } 731 }
731 if (!is_socket_read_pending_ && phase_ == PHASE_RUNNING) { 732 if (!is_socket_read_pending_ && phase_ == PHASE_RUNNING) {
732 scoped_refptr<net::IOBufferWithSize> buf = 733 scoped_refptr<net::IOBufferWithSize> buf =
733 inbound_stream_.GetIOBufferToFill(); 734 inbound_stream_.GetIOBufferToFill();
734 if (buf && buf->size() > 0) { 735 if (buf && buf->size() > 0) {
735 int rv = socket_->Read(buf, buf->size(), socket_read_callback_.get()); 736 int rv = socket_->Read(buf, buf->size(), socket_read_callback_);
736 is_socket_read_pending_ = true; 737 is_socket_read_pending_ = true;
737 if (rv != net::ERR_IO_PENDING) { 738 if (rv != net::ERR_IO_PENDING) {
738 MessageLoop::current()->PostTask(FROM_HERE, 739 MessageLoop::current()->PostTask(FROM_HERE,
739 method_factory_.NewRunnableMethod(&SSLChan::OnSocketRead, rv)); 740 method_factory_.NewRunnableMethod(&SSLChan::OnSocketRead, rv));
740 } 741 }
741 } 742 }
742 } 743 }
743 if (!is_socket_write_pending_) { 744 if (!is_socket_write_pending_) {
744 scoped_refptr<net::IOBufferWithSize> buf = 745 scoped_refptr<net::IOBufferWithSize> buf =
745 outbound_stream_.GetIOBufferToProcess(); 746 outbound_stream_.GetIOBufferToProcess();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 net::SSLConfig ssl_config_; 789 net::SSLConfig ssl_config_;
789 IOBufferQueue inbound_stream_; 790 IOBufferQueue inbound_stream_;
790 IOBufferQueue outbound_stream_; 791 IOBufferQueue outbound_stream_;
791 int read_pipe_; 792 int read_pipe_;
792 int write_pipe_; 793 int write_pipe_;
793 bool is_socket_read_pending_; 794 bool is_socket_read_pending_;
794 bool is_socket_write_pending_; 795 bool is_socket_write_pending_;
795 bool is_read_pipe_blocked_; 796 bool is_read_pipe_blocked_;
796 bool is_write_pipe_blocked_; 797 bool is_write_pipe_blocked_;
797 ScopedRunnableMethodFactory<SSLChan> method_factory_; 798 ScopedRunnableMethodFactory<SSLChan> method_factory_;
798 net::CompletionCallback socket_connect_callback_; 799 net::CompletionCallback socket_connect_callback_;
James Hawkins 2011/12/07 00:01:57 #include "net/base/completion_callback.h"
James Hawkins 2011/12/07 00:08:11 Done.
799 net::CompletionCallback ssl_handshake_callback_; 800 net::CompletionCallback ssl_handshake_callback_;
800 scoped_ptr<net::OldCompletionCallback> socket_read_callback_; 801 net::CompletionCallback socket_read_callback_;
801 scoped_ptr<net::OldCompletionCallback> socket_write_callback_; 802 scoped_ptr<net::OldCompletionCallback> socket_write_callback_;
802 MessageLoopForIO::FileDescriptorWatcher read_pipe_controller_; 803 MessageLoopForIO::FileDescriptorWatcher read_pipe_controller_;
803 MessageLoopForIO::FileDescriptorWatcher write_pipe_controller_; 804 MessageLoopForIO::FileDescriptorWatcher write_pipe_controller_;
804 805
805 friend class DeleteTask<SSLChan>; 806 friend class DeleteTask<SSLChan>;
806 DISALLOW_COPY_AND_ASSIGN(SSLChan); 807 DISALLOW_COPY_AND_ASSIGN(SSLChan);
807 }; 808 };
808 809
809 Serv::Serv(const std::vector<std::string>& allowed_origins) 810 Serv::Serv(const std::vector<std::string>& allowed_origins)
810 : allowed_origins_(allowed_origins), 811 : allowed_origins_(allowed_origins),
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1917 1918
1918 void WebSocketProxy::Shutdown() { 1919 void WebSocketProxy::Shutdown() {
1919 static_cast<Serv*>(impl_)->Shutdown(); 1920 static_cast<Serv*>(impl_)->Shutdown();
1920 } 1921 }
1921 1922
1922 void WebSocketProxy::OnNetworkChange() { 1923 void WebSocketProxy::OnNetworkChange() {
1923 static_cast<Serv*>(impl_)->OnNetworkChange(); 1924 static_cast<Serv*>(impl_)->OnNetworkChange();
1924 } 1925 }
1925 1926
1926 } // namespace chromeos 1927 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/p2p/socket_host_test_utils.h » ('j') | jingle/glue/channel_socket_adapter.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698