Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 namespace socket { | 5 namespace socket { |
| 6 enum SocketType { | 6 enum SocketType { |
| 7 tcp, | 7 tcp, |
| 8 udp | 8 udp |
| 9 }; | 9 }; |
| 10 | 10 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 callback JoinGroupCallback = void (long result); | 117 callback JoinGroupCallback = void (long result); |
| 118 | 118 |
| 119 callback LeaveGroupCallback = void (long result); | 119 callback LeaveGroupCallback = void (long result); |
| 120 | 120 |
| 121 callback SetMulticastTimeToLiveCallback = void (long result); | 121 callback SetMulticastTimeToLiveCallback = void (long result); |
| 122 | 122 |
| 123 callback SetMulticastLoopbackModeCallback = void (long result); | 123 callback SetMulticastLoopbackModeCallback = void (long result); |
| 124 | 124 |
| 125 callback GetJoinedGroupsCallback = void (DOMString[] groups); | 125 callback GetJoinedGroupsCallback = void (DOMString[] groups); |
| 126 | 126 |
| 127 callback AllowAddressReuseCallback = void (long result); | |
| 128 | |
| 127 interface Functions { | 129 interface Functions { |
| 128 // Creates a socket of the specified type that will connect to the specified | 130 // Creates a socket of the specified type that will connect to the specified |
| 129 // remote machine. | 131 // remote machine. |
| 130 // |type| : The type of socket to create. Must be <code>tcp</code> or | 132 // |type| : The type of socket to create. Must be <code>tcp</code> or |
| 131 // <code>udp</code>. | 133 // <code>udp</code>. |
| 132 // |options| : The socket options. | 134 // |options| : The socket options. |
| 133 // |callback| : Called when the socket has been created. | 135 // |callback| : Called when the socket has been created. |
| 134 static void create(SocketType type, | 136 static void create(SocketType type, |
| 135 optional CreateOptions options, | 137 optional CreateOptions options, |
| 136 CreateCallback callback); | 138 CreateCallback callback); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 260 | 262 |
| 261 // Retrieves information about local adapters on this system. | 263 // Retrieves information about local adapters on this system. |
| 262 // |callback| : Called when local adapter information is available. | 264 // |callback| : Called when local adapter information is available. |
| 263 static void getNetworkList(GetNetworkCallback callback); | 265 static void getNetworkList(GetNetworkCallback callback); |
| 264 | 266 |
| 265 // Join the multicast group and start to receive packets from that group. | 267 // Join the multicast group and start to receive packets from that group. |
| 266 // The socket must be of UDP type and must be bound to a local port | 268 // The socket must be of UDP type and must be bound to a local port |
| 267 // before calling this method. | 269 // before calling this method. |
| 268 // |socketId| : The socketId. | 270 // |socketId| : The socketId. |
| 269 // |address| : The group address to join. Domain names are not supported. | 271 // |address| : The group address to join. Domain names are not supported. |
| 270 // |callback| : Called when the join group operation is done with an | 272 // |callback| : Called when the join group operation is done with an |
| 271 // integer parameter indicating the platform-independent error code. | 273 // integer parameter indicating the platform-independent error code. |
| 272 static void joinGroup(long socketId, | 274 static void joinGroup(long socketId, |
| 273 DOMString address, | 275 DOMString address, |
| 274 JoinGroupCallback callback); | 276 JoinGroupCallback callback); |
| 275 | 277 |
| 276 // Leave the multicast group previously joined using <code>joinGroup</code>. | 278 // Leave the multicast group previously joined using <code>joinGroup</code>. |
| 277 // It's not necessary to leave the multicast group before destroying the | 279 // It's not necessary to leave the multicast group before destroying the |
| 278 // socket or exiting. This is automatically called by the OS. | 280 // socket or exiting. This is automatically called by the OS. |
| 279 // | 281 // |
| 280 // Leaving the group will prevent the router from sending multicast | 282 // Leaving the group will prevent the router from sending multicast |
| 281 // datagrams to the local host, presuming no other process on the host is | 283 // datagrams to the local host, presuming no other process on the host is |
| 282 // still joined to the group. | 284 // still joined to the group. |
| 283 // | 285 // |
| 284 // |socketId| : The socketId. | 286 // |socketId| : The socketId. |
| 285 // |address| : The group address to leave. Domain names are not supported. | 287 // |address| : The group address to leave. Domain names are not supported. |
| 286 // |callback| : Called when the leave group operation is done with an | 288 // |callback| : Called when the leave group operation is done with an |
| 287 // integer parameter indicating the platform-independent error code. | 289 // integer parameter indicating the platform-independent error code. |
| 288 static void leaveGroup(long socketId, DOMString address, | 290 static void leaveGroup(long socketId, DOMString address, |
| 289 LeaveGroupCallback callback); | 291 LeaveGroupCallback callback); |
| 290 | 292 |
| 291 // Set the time-to-live of multicast packets sent to the multicast group. | 293 // Set the time-to-live of multicast packets sent to the multicast group. |
| 292 // | 294 // |
| 293 // Calling this method does not require multicast permissions. | 295 // Calling this method does not require multicast permissions. |
| 294 // | 296 // |
| 295 // |socketId| : The socketId. | 297 // |socketId| : The socketId. |
| 296 // |ttl| : The time-to-live value. | 298 // |ttl| : The time-to-live value. |
| 297 // |callback| : Called when the configuration operation is done. | 299 // |callback| : Called when the configuration operation is done. |
| 298 static void setMulticastTimeToLive( | 300 static void setMulticastTimeToLive( |
| 299 long socketId, | 301 long socketId, |
| 300 long ttl, | 302 long ttl, |
| 301 SetMulticastTimeToLiveCallback callback); | 303 SetMulticastTimeToLiveCallback callback); |
| 302 | 304 |
| 303 // Set whether multicast packets sent from the host to the multicast | 305 // Set whether multicast packets sent from the host to the multicast |
| 304 // group will be looped back to the host. | 306 // group will be looped back to the host. |
| 305 // | 307 // |
| 306 // Note: the behavior of <code>setMulticastLoopbackMode</code> is slightly | 308 // Note: the behavior of <code>setMulticastLoopbackMode</code> is slightly |
| 307 // different between Windows and Unix-like systems. The inconsistency | 309 // different between Windows and Unix-like systems. The inconsistency |
| 308 // happens only when there is more than one application on the same host | 310 // happens only when there is more than one application on the same host |
| 309 // joined to the same multicast group while having different settings on | 311 // joined to the same multicast group while having different settings on |
| 310 // multicast loopback mode. On Windows, the applications with loopback off | 312 // multicast loopback mode. On Windows, the applications with loopback off |
| 311 // will not RECEIVE the loopback packets; while on Unix-like systems, the | 313 // will not RECEIVE the loopback packets; while on Unix-like systems, the |
| 312 // applications with loopback off will not SEND the loopback packets to | 314 // applications with loopback off will not SEND the loopback packets to |
| 313 // other applications on the same host. See MSDN: http://goo.gl/6vqbj | 315 // other applications on the same host. See MSDN: http://goo.gl/6vqbj |
| 314 // | 316 // |
| 315 // Calling this method does not require multicast permissions. | 317 // Calling this method does not require multicast permissions. |
| 316 // | 318 // |
| 317 // |socketId| : The socketId. | 319 // |socketId| : The socketId. |
| 318 // |enabled| : Indicate whether to enable loopback mode. | 320 // |enabled| : Indicate whether to enable loopback mode. |
| 319 // |callback| : Called when the configuration operation is done. | 321 // |callback| : Called when the configuration operation is done. |
| 320 static void setMulticastLoopbackMode( | 322 static void setMulticastLoopbackMode( |
| 321 long socketId, | 323 long socketId, |
| 322 boolean enabled, | 324 boolean enabled, |
| 323 SetMulticastLoopbackModeCallback callback); | 325 SetMulticastLoopbackModeCallback callback); |
| 324 | 326 |
| 325 // Get the multicast group addresses the socket is currently joined to. | 327 // Get the multicast group addresses the socket is currently joined to. |
| 326 // |socketId| : The socketId. | 328 // |socketId| : The socketId. |
| 327 // |callback| : Called with an array of strings of the result. | 329 // |callback| : Called with an array of strings of the result. |
| 328 static void getJoinedGroups(long socketId, | 330 static void getJoinedGroups(long socketId, |
| 329 GetJoinedGroupsCallback callback); | 331 GetJoinedGroupsCallback callback); |
| 332 | |
| 333 // Allow a UDP socket to bind to an already-bound address. Note that binding | |
|
miket_OOO
2013/05/24 20:53:48
I know you were just following convention, but we
Noam Samuel
2013/05/24 21:43:53
Done.
| |
| 334 // two sockets to the same address leads to undefined behavior for packets | |
| 335 // not sent to a broadcast or multicast address. | |
| 336 // |callback| : Called when the operation is done. | |
| 337 static void allowAddressReuse(long socketId, | |
| 338 AllowAddressReuseCallback callback); | |
| 330 }; | 339 }; |
| 331 | 340 |
| 332 }; | 341 }; |
| OLD | NEW |