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

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

Issue 8819029: Fix leak; remove "explicit" keyword from multi-argument constructor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use scoped_ptr, silly! 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 | tools/heapcheck/suppressions.txt » ('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 "base/json/json_writer.h" 5 #include "base/json/json_writer.h"
6 #include "base/stl_util.h" 6 #include "base/stl_util.h"
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/extensions/api/socket/socket_api_controller.h" 8 #include "chrome/browser/extensions/api/socket/socket_api_controller.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.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/udp/datagram_socket.h" 13 #include "net/udp/datagram_socket.h"
14 #include "net/udp/udp_client_socket.h" 14 #include "net/udp/udp_client_socket.h"
15 #include "net/udp/udp_socket.h" 15 #include "net/udp/udp_socket.h"
16 16
17 using namespace net; 17 using namespace net;
18 18
19 namespace extensions { 19 namespace extensions {
20 20
21 // A Socket wraps a low-level socket and includes housekeeping information that 21 // A Socket wraps a low-level socket and includes housekeeping information that
22 // we need to manage it in the context of an extension. 22 // we need to manage it in the context of an extension.
23 class Socket { 23 class Socket {
24 public: 24 public:
25 explicit Socket(const Profile* profile, const std::string& src_extension_id, 25 Socket(const Profile* profile, const std::string& src_extension_id,
26 const GURL& src_url); 26 const GURL& src_url);
27 ~Socket(); 27 ~Socket();
28 28
29 bool Connect(const net::IPEndPoint& ip_end_point); 29 bool Connect(const net::IPEndPoint& ip_end_point);
30 void Close(); 30 void Close();
31 int Write(const std::string message); 31 int Write(const std::string message);
32 32
33 private: 33 private:
34 // TODO(miket): this metadata will enable us to pass events back to the 34 // TODO(miket): this metadata will enable us to pass events back to the
35 // extension that created this Socket. 35 // extension that created this Socket.
36 const Profile* profile_; 36 const Profile* profile_;
37 int id_; 37 int id_;
38 std::string src_extension_id_; 38 std::string src_extension_id_;
39 GURL src_url_; 39 GURL src_url_;
40 40
41 net::UDPClientSocket* udp_client_socket_; 41 scoped_ptr<net::UDPClientSocket> udp_client_socket_;
42 bool is_connected_; 42 bool is_connected_;
43 net::OldCompletionCallbackImpl<Socket> io_callback_; 43 net::OldCompletionCallbackImpl<Socket> io_callback_;
44 44
45 // A callback required by UDPClientSocket::Write(). 45 // A callback required by UDPClientSocket::Write().
46 void OnIOComplete(int result); 46 void OnIOComplete(int result);
47 }; 47 };
48 48
49 Socket::Socket(const Profile* profile, const std::string& src_extension_id, 49 Socket::Socket(const Profile* profile, const std::string& src_extension_id,
50 const GURL& src_url) 50 const GURL& src_url)
51 : profile_(profile), 51 : profile_(profile),
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 172
173 int SocketController::WriteUdp(int socket_id, const std::string message) { 173 int SocketController::WriteUdp(int socket_id, const std::string message) {
174 Socket* socket = GetSocket(socket_id); 174 Socket* socket = GetSocket(socket_id);
175 if (!socket) { 175 if (!socket) {
176 return -1; 176 return -1;
177 } 177 }
178 return socket->Write(message); 178 return socket->Write(message);
179 } 179 }
180 180
181 } // namespace extensions 181 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | tools/heapcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698