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

Side by Side Diff: chrome/browser/extensions/api/socket/tcp_socket.cc

Issue 10692160: Support socket endpoint permissions for AppsV2 Socket API. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix review issues and add some unit tests Created 8 years, 4 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extensions/api/socket/tcp_socket.h" 5 #include "chrome/browser/extensions/api/socket/tcp_socket.h"
6 6
7 #include "chrome/browser/extensions/api/api_resource.h" 7 #include "chrome/browser/extensions/api/api_resource.h"
8 #include "chrome/browser/extensions/api/api_resource_event_notifier.h" 8 #include "chrome/browser/extensions/api/api_resource_event_notifier.h"
9 #include "net/base/address_list.h" 9 #include "net/base/address_list.h"
10 #include "net/base/ip_endpoint.h" 10 #include "net/base/ip_endpoint.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 return false; 133 return false;
134 return socket_->SetKeepAlive(enable, delay); 134 return socket_->SetKeepAlive(enable, delay);
135 } 135 }
136 136
137 bool TCPSocket::SetNoDelay(bool no_delay) { 137 bool TCPSocket::SetNoDelay(bool no_delay) {
138 if (!socket_.get()) 138 if (!socket_.get())
139 return false; 139 return false;
140 return socket_->SetNoDelay(no_delay); 140 return socket_->SetNoDelay(no_delay);
141 } 141 }
142 142
143 Socket::SocketType TCPSocket::socket_type() const {
144 return Socket::TYPE_TCP;
145 }
146
143 int TCPSocket::WriteImpl(net::IOBuffer* io_buffer, 147 int TCPSocket::WriteImpl(net::IOBuffer* io_buffer,
144 int io_buffer_size, 148 int io_buffer_size,
145 const net::CompletionCallback& callback) { 149 const net::CompletionCallback& callback) {
146 if (!socket_.get() || !socket_->IsConnected()) 150 if (!socket_.get() || !socket_->IsConnected())
147 return net::ERR_SOCKET_NOT_CONNECTED; 151 return net::ERR_SOCKET_NOT_CONNECTED;
148 else 152 else
149 return socket_->Write(io_buffer, io_buffer_size, callback); 153 return socket_->Write(io_buffer, io_buffer_size, callback);
150 } 154 }
151 155
152 void TCPSocket::OnConnectComplete(int result) { 156 void TCPSocket::OnConnectComplete(int result) {
153 DCHECK(!connect_callback_.is_null()); 157 DCHECK(!connect_callback_.is_null());
154 DCHECK(!is_connected_); 158 DCHECK(!is_connected_);
155 is_connected_ = result == net::OK; 159 is_connected_ = result == net::OK;
156 connect_callback_.Run(result); 160 connect_callback_.Run(result);
157 connect_callback_.Reset(); 161 connect_callback_.Reset();
158 } 162 }
159 163
160 void TCPSocket::OnReadComplete(scoped_refptr<net::IOBuffer> io_buffer, 164 void TCPSocket::OnReadComplete(scoped_refptr<net::IOBuffer> io_buffer,
161 int result) { 165 int result) {
162 DCHECK(!read_callback_.is_null()); 166 DCHECK(!read_callback_.is_null());
163 read_callback_.Run(result, io_buffer); 167 read_callback_.Run(result, io_buffer);
164 read_callback_.Reset(); 168 read_callback_.Reset();
165 } 169 }
166 170
167 } // namespace extensions 171 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698