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

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: Review fixes. 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
« no previous file with comments | « no previous file | content/browser/renderer_host/p2p/socket_host_test_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "chrome/common/url_constants.h" 42 #include "chrome/common/url_constants.h"
43 #include "content/public/browser/browser_thread.h" 43 #include "content/public/browser/browser_thread.h"
44 #include "content/public/browser/notification_details.h" 44 #include "content/public/browser/notification_details.h"
45 #include "content/public/browser/notification_service.h" 45 #include "content/public/browser/notification_service.h"
46 #include "content/public/browser/notification_types.h" 46 #include "content/public/browser/notification_types.h"
47 #include "content/public/common/url_constants.h" 47 #include "content/public/common/url_constants.h"
48 #include "googleurl/src/gurl.h" 48 #include "googleurl/src/gurl.h"
49 #include "googleurl/src/url_parse.h" 49 #include "googleurl/src/url_parse.h"
50 #include "net/base/address_list.h" 50 #include "net/base/address_list.h"
51 #include "net/base/cert_verifier.h" 51 #include "net/base/cert_verifier.h"
52 #include "net/base/completion_callback.h"
52 #include "net/base/host_port_pair.h" 53 #include "net/base/host_port_pair.h"
53 #include "net/base/io_buffer.h" 54 #include "net/base/io_buffer.h"
54 #include "net/base/net_errors.h" 55 #include "net/base/net_errors.h"
55 #include "net/base/ssl_config_service.h" 56 #include "net/base/ssl_config_service.h"
56 #include "net/socket/client_socket_factory.h" 57 #include "net/socket/client_socket_factory.h"
57 #include "net/socket/client_socket_handle.h" 58 #include "net/socket/client_socket_handle.h"
58 #include "net/socket/ssl_client_socket.h" 59 #include "net/socket/ssl_client_socket.h"
59 #include "net/socket/stream_socket.h" 60 #include "net/socket/stream_socket.h"
60 #include "third_party/libevent/evdns.h" 61 #include "third_party/libevent/evdns.h"
61 #include "third_party/libevent/event.h" 62 #include "third_party/libevent/event.h"
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 const net::HostPortPair host_port_pair, 549 const net::HostPortPair host_port_pair,
549 int read_pipe, 550 int read_pipe,
550 int write_pipe) 551 int write_pipe)
551 : phase_(PHASE_CONNECTING), 552 : phase_(PHASE_CONNECTING),
552 host_port_pair_(host_port_pair), 553 host_port_pair_(host_port_pair),
553 inbound_stream_(WebSocketProxy::kBufferLimit), 554 inbound_stream_(WebSocketProxy::kBufferLimit),
554 outbound_stream_(WebSocketProxy::kBufferLimit), 555 outbound_stream_(WebSocketProxy::kBufferLimit),
555 read_pipe_(read_pipe), 556 read_pipe_(read_pipe),
556 write_pipe_(write_pipe), 557 write_pipe_(write_pipe),
557 method_factory_(this), 558 method_factory_(this),
558 socket_connect_callback_( 559 ALLOW_THIS_IN_INITIALIZER_LIST(socket_connect_callback_(
559 base::Bind(&SSLChan::OnSocketConnect, base::Unretained(this))), 560 base::Bind(&SSLChan::OnSocketConnect, base::Unretained(this)))),
560 ssl_handshake_callback_( 561 ALLOW_THIS_IN_INITIALIZER_LIST(ssl_handshake_callback_(
561 base::Bind(&SSLChan::OnSSLHandshakeCompleted, 562 base::Bind(&SSLChan::OnSSLHandshakeCompleted,
562 base::Unretained(this))), 563 base::Unretained(this)))),
563 socket_read_callback_(NewCallback(this, &SSLChan::OnSocketRead)), 564 ALLOW_THIS_IN_INITIALIZER_LIST(socket_read_callback_(
565 base::Bind(&SSLChan::OnSocketRead, base::Unretained(this)))),
564 socket_write_callback_(NewCallback(this, &SSLChan::OnSocketWrite)) { 566 socket_write_callback_(NewCallback(this, &SSLChan::OnSocketWrite)) {
565 if (!SetNonBlock(read_pipe_) || !SetNonBlock(write_pipe_)) { 567 if (!SetNonBlock(read_pipe_) || !SetNonBlock(write_pipe_)) {
566 Shut(net::ERR_UNEXPECTED); 568 Shut(net::ERR_UNEXPECTED);
567 return; 569 return;
568 } 570 }
569 net::ClientSocketFactory* factory = 571 net::ClientSocketFactory* factory =
570 net::ClientSocketFactory::GetDefaultFactory(); 572 net::ClientSocketFactory::GetDefaultFactory();
571 socket_.reset(factory->CreateTransportClientSocket( 573 socket_.reset(factory->CreateTransportClientSocket(
572 address_list, NULL, net::NetLog::Source())); 574 address_list, NULL, net::NetLog::Source()));
573 if (socket_ == NULL) { 575 if (socket_ == NULL) {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 DCHECK_LT(rv, 0); 727 DCHECK_LT(rv, 0);
726 Shut(net::ERR_UNEXPECTED); 728 Shut(net::ERR_UNEXPECTED);
727 return; 729 return;
728 } 730 }
729 } 731 }
730 } 732 }
731 if (!is_socket_read_pending_ && phase_ == PHASE_RUNNING) { 733 if (!is_socket_read_pending_ && phase_ == PHASE_RUNNING) {
732 scoped_refptr<net::IOBufferWithSize> buf = 734 scoped_refptr<net::IOBufferWithSize> buf =
733 inbound_stream_.GetIOBufferToFill(); 735 inbound_stream_.GetIOBufferToFill();
734 if (buf && buf->size() > 0) { 736 if (buf && buf->size() > 0) {
735 int rv = socket_->Read(buf, buf->size(), socket_read_callback_.get()); 737 int rv = socket_->Read(buf, buf->size(), socket_read_callback_);
736 is_socket_read_pending_ = true; 738 is_socket_read_pending_ = true;
737 if (rv != net::ERR_IO_PENDING) { 739 if (rv != net::ERR_IO_PENDING) {
738 MessageLoop::current()->PostTask(FROM_HERE, 740 MessageLoop::current()->PostTask(FROM_HERE,
739 method_factory_.NewRunnableMethod(&SSLChan::OnSocketRead, rv)); 741 method_factory_.NewRunnableMethod(&SSLChan::OnSocketRead, rv));
740 } 742 }
741 } 743 }
742 } 744 }
743 if (!is_socket_write_pending_) { 745 if (!is_socket_write_pending_) {
744 scoped_refptr<net::IOBufferWithSize> buf = 746 scoped_refptr<net::IOBufferWithSize> buf =
745 outbound_stream_.GetIOBufferToProcess(); 747 outbound_stream_.GetIOBufferToProcess();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 IOBufferQueue outbound_stream_; 792 IOBufferQueue outbound_stream_;
791 int read_pipe_; 793 int read_pipe_;
792 int write_pipe_; 794 int write_pipe_;
793 bool is_socket_read_pending_; 795 bool is_socket_read_pending_;
794 bool is_socket_write_pending_; 796 bool is_socket_write_pending_;
795 bool is_read_pipe_blocked_; 797 bool is_read_pipe_blocked_;
796 bool is_write_pipe_blocked_; 798 bool is_write_pipe_blocked_;
797 ScopedRunnableMethodFactory<SSLChan> method_factory_; 799 ScopedRunnableMethodFactory<SSLChan> method_factory_;
798 net::CompletionCallback socket_connect_callback_; 800 net::CompletionCallback socket_connect_callback_;
799 net::CompletionCallback ssl_handshake_callback_; 801 net::CompletionCallback ssl_handshake_callback_;
800 scoped_ptr<net::OldCompletionCallback> socket_read_callback_; 802 net::CompletionCallback socket_read_callback_;
801 scoped_ptr<net::OldCompletionCallback> socket_write_callback_; 803 scoped_ptr<net::OldCompletionCallback> socket_write_callback_;
802 MessageLoopForIO::FileDescriptorWatcher read_pipe_controller_; 804 MessageLoopForIO::FileDescriptorWatcher read_pipe_controller_;
803 MessageLoopForIO::FileDescriptorWatcher write_pipe_controller_; 805 MessageLoopForIO::FileDescriptorWatcher write_pipe_controller_;
804 806
805 friend class DeleteTask<SSLChan>; 807 friend class DeleteTask<SSLChan>;
806 DISALLOW_COPY_AND_ASSIGN(SSLChan); 808 DISALLOW_COPY_AND_ASSIGN(SSLChan);
807 }; 809 };
808 810
809 Serv::Serv(const std::vector<std::string>& allowed_origins) 811 Serv::Serv(const std::vector<std::string>& allowed_origins)
810 : allowed_origins_(allowed_origins), 812 : allowed_origins_(allowed_origins),
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1917 1919
1918 void WebSocketProxy::Shutdown() { 1920 void WebSocketProxy::Shutdown() {
1919 static_cast<Serv*>(impl_)->Shutdown(); 1921 static_cast<Serv*>(impl_)->Shutdown();
1920 } 1922 }
1921 1923
1922 void WebSocketProxy::OnNetworkChange() { 1924 void WebSocketProxy::OnNetworkChange() {
1923 static_cast<Serv*>(impl_)->OnNetworkChange(); 1925 static_cast<Serv*>(impl_)->OnNetworkChange();
1924 } 1926 }
1925 1927
1926 } // namespace chromeos 1928 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/p2p/socket_host_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698