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

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

Issue 2378763003: Add ability to reuse address in chrome.sockets.udp
Patch Set: Created 4 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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 21 matching lines...) Expand all
32 const CompletionCallback& callback) override; 32 const CompletionCallback& callback) override;
33 33
34 bool IsConnected() override; 34 bool IsConnected() override;
35 35
36 bool GetPeerAddress(net::IPEndPoint* address) override; 36 bool GetPeerAddress(net::IPEndPoint* address) override;
37 bool GetLocalAddress(net::IPEndPoint* address) override; 37 bool GetLocalAddress(net::IPEndPoint* address) override;
38 Socket::SocketType GetSocketType() const override; 38 Socket::SocketType GetSocketType() const override;
39 39
40 bool IsBound(); 40 bool IsBound();
41 41
42 virtual bool IsReusable();
43
42 int JoinGroup(const std::string& address); 44 int JoinGroup(const std::string& address);
43 int LeaveGroup(const std::string& address); 45 int LeaveGroup(const std::string& address);
44 46
45 int SetMulticastTimeToLive(int ttl); 47 int SetMulticastTimeToLive(int ttl);
46 int SetMulticastLoopbackMode(bool loopback); 48 int SetMulticastLoopbackMode(bool loopback);
47 49
48 int SetBroadcast(bool enabled); 50 int SetBroadcast(bool enabled);
49 51
50 const std::vector<std::string>& GetJoinedGroups() const; 52 const std::vector<std::string>& GetJoinedGroups() const;
51 53
(...skipping 26 matching lines...) Expand all
78 // UDP Socket instances from the "sockets.udp" namespace. These are regular 80 // UDP Socket instances from the "sockets.udp" namespace. These are regular
79 // socket objects with additional properties related to the behavior defined in 81 // socket objects with additional properties related to the behavior defined in
80 // the "sockets.udp" namespace. 82 // the "sockets.udp" namespace.
81 class ResumableUDPSocket : public UDPSocket { 83 class ResumableUDPSocket : public UDPSocket {
82 public: 84 public:
83 explicit ResumableUDPSocket(const std::string& owner_extension_id); 85 explicit ResumableUDPSocket(const std::string& owner_extension_id);
84 86
85 // Overriden from ApiResource 87 // Overriden from ApiResource
86 bool IsPersistent() const override; 88 bool IsPersistent() const override;
87 89
90 bool IsReusable() override;
91
88 const std::string& name() const { return name_; } 92 const std::string& name() const { return name_; }
89 void set_name(const std::string& name) { name_ = name; } 93 void set_name(const std::string& name) { name_ = name; }
90 94
91 bool persistent() const { return persistent_; } 95 bool persistent() const { return persistent_; }
92 void set_persistent(bool persistent) { persistent_ = persistent; } 96 void set_persistent(bool persistent) { persistent_ = persistent; }
93 97
94 int buffer_size() const { return buffer_size_; } 98 int buffer_size() const { return buffer_size_; }
95 void set_buffer_size(int buffer_size) { buffer_size_ = buffer_size; } 99 void set_buffer_size(int buffer_size) { buffer_size_ = buffer_size; }
96 100
97 bool paused() const { return paused_; } 101 bool paused() const { return paused_; }
98 void set_paused(bool paused) { paused_ = paused; } 102 void set_paused(bool paused) { paused_ = paused; }
99 103
104 bool allow_address_reuse() const { return allow_address_reuse_; }
105 void set_allow_address_reuse(bool allow) { allow_address_reuse_ = allow; }
106
100 private: 107 private:
101 friend class ApiResourceManager<ResumableUDPSocket>; 108 friend class ApiResourceManager<ResumableUDPSocket>;
102 static const char* service_name() { return "ResumableUDPSocketManager"; } 109 static const char* service_name() { return "ResumableUDPSocketManager"; }
103 110
104 // Application-defined string - see sockets_udp.idl. 111 // Application-defined string - see sockets_udp.idl.
105 std::string name_; 112 std::string name_;
106 // Flag indicating whether the socket is left open when the application is 113 // Flag indicating whether the socket is left open when the application is
107 // suspended - see sockets_udp.idl. 114 // suspended - see sockets_udp.idl.
108 bool persistent_; 115 bool persistent_;
109 // The size of the buffer used to receive data - see sockets_udp.idl. 116 // The size of the buffer used to receive data - see sockets_udp.idl.
110 int buffer_size_; 117 int buffer_size_;
111 // Flag indicating whether a connected socket blocks its peer from sending 118 // Flag indicating whether a connected socket blocks its peer from sending
112 // more data - see sockets_udp.idl. 119 // more data - see sockets_udp.idl.
113 bool paused_; 120 bool paused_;
121 // Flag indicating whether the address can be bound by multiple sockets - see
122 // sockets_udp.idl
123 bool allow_address_reuse_;
Reilly Grant (use Gerrit) 2016/09/29 06:55:55 Instead of adding this field to ResumableUDPSocket
srsudar 2016/09/29 19:32:58 Done.
114 }; 124 };
115 125
116 } // namespace extensions 126 } // namespace extensions
117 127
118 #endif // EXTENSIONS_BROWSER_API_SOCKET_UDP_SOCKET_H_ 128 #endif // EXTENSIONS_BROWSER_API_SOCKET_UDP_SOCKET_H_
OLDNEW
« no previous file with comments | « no previous file | extensions/browser/api/socket/udp_socket.cc » ('j') | extensions/test/data/sockets_udp/api/background.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698