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

Unified Diff: net/udp/udp_socket_nacl.h

Issue 188873004: Compile src/net for PNaCl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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: net/udp/udp_socket_nacl.h
diff --git a/net/udp/udp_socket_win.h b/net/udp/udp_socket_nacl.h
similarity index 62%
copy from net/udp/udp_socket_win.h
copy to net/udp/udp_socket_nacl.h
index 28b7d4ae6699e172df6adc0a486cc98f4ba8d230..80158dc9cb110e57443ffda3eb21ba55c2bd57de 100644
--- a/net/udp/udp_socket_win.h
+++ b/net/udp/udp_socket_nacl.h
@@ -1,33 +1,32 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef NET_UDP_UDP_SOCKET_WIN_H_
-#define NET_UDP_UDP_SOCKET_WIN_H_
-
-#include <winsock2.h>
+#ifndef NET_UDP_UDP_SOCKET_NACL_H_
+#define NET_UDP_UDP_SOCKET_NACL_H_
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/message_loop/message_loop.h"
#include "base/threading/non_thread_safe.h"
-#include "base/win/object_watcher.h"
#include "net/base/completion_callback.h"
-#include "net/base/net_export.h"
-#include "net/base/rand_callback.h"
-#include "net/base/ip_endpoint.h"
#include "net/base/io_buffer.h"
+#include "net/base/ip_endpoint.h"
+#include "net/base/net_export.h"
#include "net/base/net_log.h"
+#include "net/base/rand_callback.h"
+#include "net/socket/socket_descriptor.h"
#include "net/udp/datagram_socket.h"
namespace net {
-class NET_EXPORT UDPSocketWin : NON_EXPORTED_BASE(public base::NonThreadSafe) {
+class NET_EXPORT UDPSocketNacl : public base::NonThreadSafe {
public:
- UDPSocketWin(DatagramSocket::BindType bind_type,
- const RandIntCallback& rand_int_cb,
- net::NetLog* net_log,
- const net::NetLog::Source& source);
- virtual ~UDPSocketWin();
+ UDPSocketNacl(DatagramSocket::BindType bind_type,
+ const RandIntCallback& rand_int_cb,
+ net::NetLog* net_log,
+ const net::NetLog::Source& source);
+ virtual ~UDPSocketNacl();
// Connect the socket to connect with a certain |address|.
// Returns a net error code.
@@ -101,7 +100,7 @@ class NET_EXPORT UDPSocketWin : NON_EXPORTED_BASE(public base::NonThreadSafe) {
bool SetSendBufferSize(int32 size);
// Returns true if the socket is already connected or bound.
- bool is_connected() const { return socket_ != INVALID_SOCKET; }
+ bool is_connected() const { return false; }
const BoundNetLog& NetLog() const { return net_log_; }
@@ -140,12 +139,14 @@ class NET_EXPORT UDPSocketWin : NON_EXPORTED_BASE(public base::NonThreadSafe) {
// group address. The default value of this option is 1.
// Cannot be negative or more than 255.
// Should be called before Bind().
+ // Return a network error code.
int SetMulticastTimeToLive(int time_to_live);
// Set the loopback flag for UDP socket. If this flag is true, the host
// will receive packets sent to the joined group from itself.
// The default value of this option is true.
// Should be called before Bind().
+ // Return a network error code.
//
// Note: the behavior of |SetMulticastLoopbackMode| is slightly
// different between Windows and Unix-like systems. The inconsistency only
@@ -159,105 +160,18 @@ class NET_EXPORT UDPSocketWin : NON_EXPORTED_BASE(public base::NonThreadSafe) {
// Set the differentiated services flags on outgoing packets. May not
// do anything on some platforms.
+ // Return a network error code.
int SetDiffServCodePoint(DiffServCodePoint dscp);
// Resets the thread to be used for thread-safety checks.
void DetachFromThread();
private:
- enum SocketOptions {
- SOCKET_OPTION_REUSE_ADDRESS = 1 << 0,
- SOCKET_OPTION_BROADCAST = 1 << 1,
- SOCKET_OPTION_MULTICAST_LOOP = 1 << 2
- };
-
- class Core;
-
- void DoReadCallback(int rv);
- void DoWriteCallback(int rv);
- void DidCompleteRead();
- void DidCompleteWrite();
-
- // Handles stats and logging. |result| is the number of bytes transferred, on
- // success, or the net error code on failure. LogRead retrieves the address
- // from |recv_addr_storage_|, while LogWrite takes it as an optional argument.
- void LogRead(int result, const char* bytes) const;
- void LogWrite(int result, const char* bytes, const IPEndPoint* address) const;
-
- // Returns the OS error code (or 0 on success).
- int CreateSocket(int addr_family);
-
- // Same as SendTo(), except that address is passed by pointer
- // instead of by reference. It is called from Write() with |address|
- // set to NULL.
- int SendToOrWrite(IOBuffer* buf,
- int buf_len,
- const IPEndPoint* address,
- const CompletionCallback& callback);
-
- int InternalConnect(const IPEndPoint& address);
- int InternalRecvFrom(IOBuffer* buf, int buf_len, IPEndPoint* address);
- int InternalSendTo(IOBuffer* buf, int buf_len, const IPEndPoint* address);
-
- // Applies |socket_options_| to |socket_|. Should be called before
- // Bind().
- int SetSocketOptions();
- int DoBind(const IPEndPoint& address);
- // Binds to a random port on |address|.
- int RandomBind(const IPAddressNumber& address);
-
- // Attempts to convert the data in |recv_addr_storage_| and |recv_addr_len_|
- // to an IPEndPoint and writes it to |address|. Returns true on success.
- bool ReceiveAddressToIPEndpoint(IPEndPoint* address) const;
-
- SOCKET socket_;
- int addr_family_;
-
- // Bitwise-or'd combination of SocketOptions. Specifies the set of
- // options that should be applied to |socket_| before Bind().
- int socket_options_;
-
- // Multicast interface.
- uint32 multicast_interface_;
-
- // Multicast socket options cached for SetSocketOption.
- // Cannot be used after Bind().
- int multicast_time_to_live_;
-
- // How to do source port binding, used only when UDPSocket is part of
- // UDPClientSocket, since UDPServerSocket provides Bind.
- DatagramSocket::BindType bind_type_;
-
- // PRNG function for generating port numbers.
- RandIntCallback rand_int_cb_;
-
- // These are mutable since they're just cached copies to make
- // GetPeerAddress/GetLocalAddress smarter.
- mutable scoped_ptr<IPEndPoint> local_address_;
- mutable scoped_ptr<IPEndPoint> remote_address_;
-
- // The core of the socket that can live longer than the socket itself. We pass
- // resources to the Windows async IO functions and we have to make sure that
- // they are not destroyed while the OS still references them.
- scoped_refptr<Core> core_;
-
- IPEndPoint* recv_from_address_;
-
- // Cached copy of the current address we're sending to, if any. Used for
- // logging.
- scoped_ptr<IPEndPoint> send_to_address_;
-
- // External callback; called when read is complete.
- CompletionCallback read_callback_;
-
- // External callback; called when write is complete.
- CompletionCallback write_callback_;
-
BoundNetLog net_log_;
- DISALLOW_COPY_AND_ASSIGN(UDPSocketWin);
+ DISALLOW_COPY_AND_ASSIGN(UDPSocketNacl);
};
} // namespace net
-#endif // NET_UDP_UDP_SOCKET_WIN_H_
+#endif // NET_UDP_UDP_SOCKET_NACL_H_
« net/net_nacl.gyp ('K') | « net/udp/udp_socket.h ('k') | net/udp/udp_socket_nacl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698