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

Side by Side Diff: extensions/browser/api/socket/udp_socket.h

Issue 664933004: Standardize usage of virtual/override/final in extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef EXTENSIONS_BROWSER_API_SOCKET_UDP_SOCKET_H_ 5 #ifndef EXTENSIONS_BROWSER_API_SOCKET_UDP_SOCKET_H_
6 #define EXTENSIONS_BROWSER_API_SOCKET_UDP_SOCKET_H_ 6 #define EXTENSIONS_BROWSER_API_SOCKET_UDP_SOCKET_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "extensions/browser/api/socket/socket.h" 11 #include "extensions/browser/api/socket/socket.h"
12 #include "net/udp/udp_socket.h" 12 #include "net/udp/udp_socket.h"
13 13
14 namespace extensions { 14 namespace extensions {
15 15
16 class UDPSocket : public Socket { 16 class UDPSocket : public Socket {
17 public: 17 public:
18 explicit UDPSocket(const std::string& owner_extension_id); 18 explicit UDPSocket(const std::string& owner_extension_id);
19 virtual ~UDPSocket(); 19 ~UDPSocket() override;
20 20
21 virtual void Connect(const std::string& address, 21 void Connect(const std::string& address,
22 int port, 22 int port,
23 const CompletionCallback& callback) override; 23 const CompletionCallback& callback) override;
24 virtual void Disconnect() override; 24 void Disconnect() override;
25 virtual int Bind(const std::string& address, int port) override; 25 int Bind(const std::string& address, int port) override;
26 virtual void Read(int count, const ReadCompletionCallback& callback) override; 26 void Read(int count, const ReadCompletionCallback& callback) override;
27 virtual void RecvFrom(int count, 27 void RecvFrom(int count, const RecvFromCompletionCallback& callback) override;
28 const RecvFromCompletionCallback& callback) override; 28 void SendTo(scoped_refptr<net::IOBuffer> io_buffer,
29 virtual void SendTo(scoped_refptr<net::IOBuffer> io_buffer, 29 int byte_count,
30 int byte_count, 30 const std::string& address,
31 const std::string& address, 31 int port,
32 int port, 32 const CompletionCallback& callback) override;
33 const CompletionCallback& callback) override;
34 33
35 virtual bool IsConnected() override; 34 bool IsConnected() override;
36 35
37 virtual bool GetPeerAddress(net::IPEndPoint* address) override; 36 bool GetPeerAddress(net::IPEndPoint* address) override;
38 virtual bool GetLocalAddress(net::IPEndPoint* address) override; 37 bool GetLocalAddress(net::IPEndPoint* address) override;
39 virtual Socket::SocketType GetSocketType() const override; 38 Socket::SocketType GetSocketType() const override;
40 39
41 bool IsBound(); 40 bool IsBound();
42 41
43 int JoinGroup(const std::string& address); 42 int JoinGroup(const std::string& address);
44 int LeaveGroup(const std::string& address); 43 int LeaveGroup(const std::string& address);
45 44
46 int SetMulticastTimeToLive(int ttl); 45 int SetMulticastTimeToLive(int ttl);
47 int SetMulticastLoopbackMode(bool loopback); 46 int SetMulticastLoopbackMode(bool loopback);
48 47
49 const std::vector<std::string>& GetJoinedGroups() const; 48 const std::vector<std::string>& GetJoinedGroups() const;
50 49
51 protected: 50 protected:
52 virtual int WriteImpl(net::IOBuffer* io_buffer, 51 int WriteImpl(net::IOBuffer* io_buffer,
53 int io_buffer_size, 52 int io_buffer_size,
54 const net::CompletionCallback& callback) override; 53 const net::CompletionCallback& callback) override;
55 54
56 private: 55 private:
57 // Make net::IPEndPoint can be refcounted 56 // Make net::IPEndPoint can be refcounted
58 typedef base::RefCountedData<net::IPEndPoint> IPEndPoint; 57 typedef base::RefCountedData<net::IPEndPoint> IPEndPoint;
59 58
60 void OnReadComplete(scoped_refptr<net::IOBuffer> io_buffer, int result); 59 void OnReadComplete(scoped_refptr<net::IOBuffer> io_buffer, int result);
61 void OnRecvFromComplete(scoped_refptr<net::IOBuffer> io_buffer, 60 void OnRecvFromComplete(scoped_refptr<net::IOBuffer> io_buffer,
62 scoped_refptr<IPEndPoint> address, 61 scoped_refptr<IPEndPoint> address,
63 int result); 62 int result);
64 void OnSendToComplete(int result); 63 void OnSendToComplete(int result);
(...skipping 10 matching lines...) Expand all
75 }; 74 };
76 75
77 // UDP Socket instances from the "sockets.udp" namespace. These are regular 76 // UDP Socket instances from the "sockets.udp" namespace. These are regular
78 // socket objects with additional properties related to the behavior defined in 77 // socket objects with additional properties related to the behavior defined in
79 // the "sockets.udp" namespace. 78 // the "sockets.udp" namespace.
80 class ResumableUDPSocket : public UDPSocket { 79 class ResumableUDPSocket : public UDPSocket {
81 public: 80 public:
82 explicit ResumableUDPSocket(const std::string& owner_extension_id); 81 explicit ResumableUDPSocket(const std::string& owner_extension_id);
83 82
84 // Overriden from ApiResource 83 // Overriden from ApiResource
85 virtual bool IsPersistent() const override; 84 bool IsPersistent() const override;
86 85
87 const std::string& name() const { return name_; } 86 const std::string& name() const { return name_; }
88 void set_name(const std::string& name) { name_ = name; } 87 void set_name(const std::string& name) { name_ = name; }
89 88
90 bool persistent() const { return persistent_; } 89 bool persistent() const { return persistent_; }
91 void set_persistent(bool persistent) { persistent_ = persistent; } 90 void set_persistent(bool persistent) { persistent_ = persistent; }
92 91
93 int buffer_size() const { return buffer_size_; } 92 int buffer_size() const { return buffer_size_; }
94 void set_buffer_size(int buffer_size) { buffer_size_ = buffer_size; } 93 void set_buffer_size(int buffer_size) { buffer_size_ = buffer_size; }
95 94
(...skipping 12 matching lines...) Expand all
108 // The size of the buffer used to receive data - see sockets_udp.idl. 107 // The size of the buffer used to receive data - see sockets_udp.idl.
109 int buffer_size_; 108 int buffer_size_;
110 // Flag indicating whether a connected socket blocks its peer from sending 109 // Flag indicating whether a connected socket blocks its peer from sending
111 // more data - see sockets_udp.idl. 110 // more data - see sockets_udp.idl.
112 bool paused_; 111 bool paused_;
113 }; 112 };
114 113
115 } // namespace extensions 114 } // namespace extensions
116 115
117 #endif // EXTENSIONS_BROWSER_API_SOCKET_UDP_SOCKET_H_ 116 #endif // EXTENSIONS_BROWSER_API_SOCKET_UDP_SOCKET_H_
OLDNEW
« no previous file with comments | « extensions/browser/api/socket/tls_socket.h ('k') | extensions/browser/api/sockets_tcp/sockets_tcp_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698