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

Unified Diff: extensions/browser/api/sockets_tcp/sockets_tcp_api.cc

Issue 1842953002: [Extensions] Convert APIs to use movable types [13] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: extensions/browser/api/sockets_tcp/sockets_tcp_api.cc
diff --git a/extensions/browser/api/sockets_tcp/sockets_tcp_api.cc b/extensions/browser/api/sockets_tcp/sockets_tcp_api.cc
index 3bef4ca9ac14697e811a0fab59c6af1c7dde3ac4..be36153cbbc87f1e00f0066fe2b853c0227300e5 100644
--- a/extensions/browser/api/sockets_tcp/sockets_tcp_api.cc
+++ b/extensions/browser/api/sockets_tcp/sockets_tcp_api.cc
@@ -26,28 +26,27 @@ const char kInvalidSocketStateError[] =
"Socket must be a connected client TCP socket.";
const char kSocketNotConnectedError[] = "Socket not connected";
-linked_ptr<SocketInfo> CreateSocketInfo(int socket_id,
- ResumableTCPSocket* socket) {
- linked_ptr<SocketInfo> socket_info(new SocketInfo());
+SocketInfo CreateSocketInfo(int socket_id, ResumableTCPSocket* socket) {
+ SocketInfo socket_info;
// This represents what we know about the socket, and does not call through
// to the system.
- socket_info->socket_id = socket_id;
+ socket_info.socket_id = socket_id;
if (!socket->name().empty()) {
- socket_info->name.reset(new std::string(socket->name()));
+ socket_info.name.reset(new std::string(socket->name()));
}
- socket_info->persistent = socket->persistent();
+ socket_info.persistent = socket->persistent();
if (socket->buffer_size() > 0) {
- socket_info->buffer_size.reset(new int(socket->buffer_size()));
+ socket_info.buffer_size.reset(new int(socket->buffer_size()));
}
- socket_info->paused = socket->paused();
- socket_info->connected = socket->IsConnected();
+ socket_info.paused = socket->paused();
+ socket_info.connected = socket->IsConnected();
// Grab the local address as known by the OS.
net::IPEndPoint localAddress;
if (socket->GetLocalAddress(&localAddress)) {
- socket_info->local_address.reset(
+ socket_info.local_address.reset(
new std::string(localAddress.ToStringWithoutPort()));
- socket_info->local_port.reset(new int(localAddress.port()));
+ socket_info.local_port.reset(new int(localAddress.port()));
}
// Grab the peer address as known by the OS. This and the call below will
@@ -56,9 +55,9 @@ linked_ptr<SocketInfo> CreateSocketInfo(int socket_id,
// that it should be closed locally.
net::IPEndPoint peerAddress;
if (socket->GetPeerAddress(&peerAddress)) {
- socket_info->peer_address.reset(
+ socket_info.peer_address.reset(
new std::string(peerAddress.ToStringWithoutPort()));
- socket_info->peer_port.reset(new int(peerAddress.port()));
+ socket_info.peer_port.reset(new int(peerAddress.port()));
}
return socket_info;
@@ -421,9 +420,9 @@ void SocketsTcpGetInfoFunction::Work() {
return;
}
- linked_ptr<sockets_tcp::SocketInfo> socket_info =
+ sockets_tcp::SocketInfo socket_info =
CreateSocketInfo(params_->socket_id, socket);
- results_ = sockets_tcp::GetInfo::Results::Create(*socket_info);
+ results_ = sockets_tcp::GetInfo::Results::Create(socket_info);
}
SocketsTcpGetSocketsFunction::SocketsTcpGetSocketsFunction() {}
@@ -433,13 +432,10 @@ SocketsTcpGetSocketsFunction::~SocketsTcpGetSocketsFunction() {}
bool SocketsTcpGetSocketsFunction::Prepare() { return true; }
void SocketsTcpGetSocketsFunction::Work() {
- std::vector<linked_ptr<sockets_tcp::SocketInfo> > socket_infos;
+ std::vector<sockets_tcp::SocketInfo> socket_infos;
base::hash_set<int>* resource_ids = GetSocketIds();
if (resource_ids != NULL) {
- for (base::hash_set<int>::iterator it = resource_ids->begin();
- it != resource_ids->end();
- ++it) {
- int socket_id = *it;
+ for (int socket_id : *resource_ids) {
ResumableTCPSocket* socket = GetTcpSocket(socket_id);
if (socket) {
socket_infos.push_back(CreateSocketInfo(socket_id, socket));
« no previous file with comments | « extensions/browser/api/socket/socket_api.cc ('k') | extensions/browser/api/sockets_tcp_server/sockets_tcp_server_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698