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

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

Issue 10919201: Make sure that a given app/extension requests only its own resources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Improve tests; fix merge conflicts. Created 8 years, 3 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 | Annotate | Revision Log
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"
11 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
12 #include "net/base/rand_callback.h" 12 #include "net/base/rand_callback.h"
13 #include "net/socket/tcp_client_socket.h" 13 #include "net/socket/tcp_client_socket.h"
14 14
15 namespace extensions { 15 namespace extensions {
16 16
17 TCPSocket::TCPSocket(ApiResourceEventNotifier* event_notifier) 17 TCPSocket::TCPSocket(const std::string& owner_extension_id,
18 : Socket(event_notifier) { 18 ApiResourceEventNotifier* event_notifier)
19 : Socket(owner_extension_id, event_notifier) {
19 } 20 }
20 21
21 // For testing. 22 // For testing.
22 TCPSocket::TCPSocket(net::TCPClientSocket* tcp_client_socket, 23 TCPSocket::TCPSocket(net::TCPClientSocket* tcp_client_socket,
24 const std::string& owner_extension_id,
23 ApiResourceEventNotifier* event_notifier) 25 ApiResourceEventNotifier* event_notifier)
24 : Socket(event_notifier), 26 : Socket(owner_extension_id, event_notifier),
25 socket_(tcp_client_socket) { 27 socket_(tcp_client_socket) {
26 } 28 }
27 29
28 // static 30 // static
29 TCPSocket* TCPSocket::CreateSocketForTesting( 31 TCPSocket* TCPSocket::CreateSocketForTesting(
30 net::TCPClientSocket* tcp_client_socket, 32 net::TCPClientSocket* tcp_client_socket,
33 const std::string& owner_extension_id,
31 ApiResourceEventNotifier* event_notifier) { 34 ApiResourceEventNotifier* event_notifier) {
32 return new TCPSocket(tcp_client_socket, event_notifier); 35 return new TCPSocket(tcp_client_socket, owner_extension_id, event_notifier);
33 } 36 }
34 37
35 TCPSocket::~TCPSocket() { 38 TCPSocket::~TCPSocket() {
36 if (is_connected_) { 39 if (is_connected_) {
37 Disconnect(); 40 Disconnect();
38 } 41 }
39 } 42 }
40 43
41 void TCPSocket::Connect(const std::string& address, 44 void TCPSocket::Connect(const std::string& address,
42 int port, 45 int port,
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 } 177 }
175 178
176 void TCPSocket::OnReadComplete(scoped_refptr<net::IOBuffer> io_buffer, 179 void TCPSocket::OnReadComplete(scoped_refptr<net::IOBuffer> io_buffer,
177 int result) { 180 int result) {
178 DCHECK(!read_callback_.is_null()); 181 DCHECK(!read_callback_.is_null());
179 read_callback_.Run(result, io_buffer); 182 read_callback_.Run(result, io_buffer);
180 read_callback_.Reset(); 183 read_callback_.Reset();
181 } 184 }
182 185
183 } // namespace extensions 186 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/socket/tcp_socket.h ('k') | chrome/browser/extensions/api/socket/tcp_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698