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

Side by Side Diff: mojo/services/public/interfaces/network/udp_socket.mojom

Issue 612403003: Mojo UDP socket API definition review. (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
« no previous file with comments | « mojo/services/public/interfaces/network/net_address.mojom ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import "mojo/services/public/interfaces/network/net_address.mojom" 5 import "mojo/services/public/interfaces/network/net_address.mojom"
6 import "mojo/services/public/interfaces/network/network_error.mojom" 6 import "mojo/services/public/interfaces/network/network_error.mojom"
7 7
8 module mojo { 8 module mojo {
9 9
10 // UDPSocket and UDPSocketClient represent a UDP socket and its client. The 10 // UDPSocket and UDPSocketClient represent a UDP socket and its client. The
11 // typical flow of using the interfaces is: 11 // typical flow of using the interfaces is:
12 // - Acquire a UDPSocket interface pointer and set a UDPSocketClient instance. 12 // - Acquire a UDPSocket interface pointer and set a UDPSocketClient instance.
13 // - (optional) Set options which are allowed prior to Bind(). 13 // - (optional) Set options which are allowed prior to Bind().
14 // - Bind the socket. 14 // - Bind the socket.
15 // - (optional) Set options which are allowed after Bind(). 15 // - (optional) Set options which are allowed after Bind().
16 // - Send / request to receive packets. Received packets will be delivered to 16 // - Send / request to receive packets. Received packets will be delivered to
17 // UDPSocketClient.OnReceived(). 17 // UDPSocketClient.OnReceived().
18
18 [Client=UDPSocketClient] 19 [Client=UDPSocketClient]
19 interface UDPSocket { 20 interface UDPSocket {
20 // Allows the socket to share the local address to which it will be bound with 21 // Allows the socket to share the local address to which it will be bound with
21 // other processes. Should be called before Bind(). 22 // other processes. Should be called before Bind().
22 // (This is equivalent to SO_REUSEADDR of the POSIX socket API.) 23 // (This is equivalent to SO_REUSEADDR of the POSIX socket API.)
23 AllowAddressReuse() => (NetworkError result); 24 AllowAddressReuse() => (NetworkError result);
24 25
25 // Binds the socket to the given address. 26 // Binds the socket to the given address.
26 // |bound_addr| is non-NULL on success. It might not be the same as |addr|. 27 // |bound_addr| is non-NULL on success. It might not be the same as |addr|.
27 // For example, if port 0 is used in |addr|, a random port is picked and 28 // For example, if port 0 is used in |addr|, a random port is picked and
28 // returned in |bound_addr|. 29 // returned in |bound_addr|.
29 Bind(NetAddress addr) => (NetworkError result, NetAddress? bound_addr); 30 Bind(NetAddress addr) => (NetworkError result, NetAddress? bound_addr);
30 31
31 // Sets the send buffer size (in bytes) for the socket. The socket must be 32 // Sets the OS send buffer size (in bytes) for the socket. The socket must be
32 // bound. 33 // bound.
33 // 34 //
34 // Note: This is only treated as a hint. Even if it succeeds, the service 35 // Note: This is only treated as a hint. Even if it succeeds, the service
35 // doesn't guarantee it will conform to the size. 36 // doesn't guarantee it will conform to the size.
wtc 2014/10/02 22:14:05 I believe this note can be deleted. If this note i
yzshen1 2014/10/02 22:40:31 Done.
36 SetSendBufferSize(uint32 size) => (NetworkError result); 37 SetSendBufferSize(uint32 size) => (NetworkError result);
37 38
38 // Sets the receive buffer size (in bytes) for the socket. The socket must be 39 // Sets the OS receive buffer size (in bytes) for the socket. The socket must
39 // bound. 40 // be bound.
40 // 41 //
41 // Note: This is only treated as a hint. Even if it succeeds, the service 42 // Note: This is only treated as a hint. Even if it succeeds, the service
42 // doesn't guarantee it will conform to the size. 43 // doesn't guarantee it will conform to the size.
43 SetReceiveBufferSize(uint32 size) => (NetworkError result); 44 SetReceiveBufferSize(uint32 size) => (NetworkError result);
44 45
46 // Negotiates the maximum number of pending SendTo() requests. If
47 // |requested_size| is set to 0, this method queries the current settings.
48 //
49 // The service stores SendTo() requests in a queue while they are waiting to
50 // be executed (i.e., while they are waiting to be placed in the OS send
51 // buffer and send out). This method negotiates how many requests (not bytes)
52 // this queue is able to store. If the queue is full, the service fails new
53 // requests directly with error code ERR_INSUFFICIENT_RESOURCES and discard
54 // those packets. If the client wants to avoid such failure, it needs to keep
55 // track of how many SendTo() calls are pending and make sure the number
56 // doesn't exceed the result of this method.
57 NegotiateMaxPendingSendRequests(uint32 requested_size)
58 => (uint32 actual_size);
59
45 // Notifies that the client is ready to accept |number| of packets. 60 // Notifies that the client is ready to accept |number| of packets.
wtc 2014/10/02 22:14:05 Nit: it would be good to explain why it is useful
yzshen1 2014/10/02 22:40:31 Done.
46 // Correspondingly, OnReceived() of the UDPSocketClient interface will be 61 // Correspondingly, OnReceived() of the UDPSocketClient interface will be
47 // called |number| times (errors also count), unless the connection is closed 62 // called |number| times (errors also count), unless the connection is closed
48 // before that. The socket must be bound. 63 // before that. The socket must be bound.
49 // 64 //
50 // It is allowed to call this method again before the previous request is 65 // It is allowed to call this method again before the previous request is
51 // completely satisfied. For example: 66 // completely satisfied. For example:
52 // service->ReceiveMorePackets(3); 67 // service->ReceiveMorePackets(3);
53 // ... 68 // ...
54 // // OnReceived() is called. 69 // // OnReceived() is called.
55 // // OnReceived() is called. 70 // // OnReceived() is called.
56 // ... 71 // ...
57 // service->ReceiveMorePackets(3); 72 // service->ReceiveMorePackets(3);
58 // // The client expects 4 more calls to OnReceived(). 73 // // The client expects 4 more calls to OnReceived().
59 ReceiveMorePackets(uint32 number); 74 ReceiveMorePackets(uint32 number);
60 75
61 // Sends data to the specified destination. The socket must be bound. 76 // Sends data to the specified destination. The socket must be bound.
62 // The method doesn't report the result of the operation. 77 // On success, |result.code| is a non-negative number indicating how many
63 SendToAndForget(NetAddress addr, uint8[] data); 78 // bytes have been written. Otherwise, it is a network error code, including
64 79 // (but not limited to):
65 // Sends data to the specified destination. The socket must be bound. 80 // - ERR_INSUFFICIENT_RESOURCES (-12): The service doesn't have sufficient
66 SendTo(NetAddress addr, uint8[] data) => (NetworkError result); 81 // resource to complete the operation. One possible cause is that the client
82 // tries to send too many packets in a short period of time.
83 SendTo(NetAddress dest_addr, uint8[] data) => (NetworkError result);
67 }; 84 };
68 85
69 interface UDPSocketClient { 86 interface UDPSocketClient {
70 // |addr| and |data| are non-NULL on success. 87 // On success, |src_addr| and |data| are non-NULL, |result.code| is a
71 OnReceived(NetworkError result, NetAddress? addr, uint8[]? data); 88 // non-negative number indicating how many bytes have been received.
89 OnReceived(NetworkError result, NetAddress? src_addr, uint8[]? data);
72 }; 90 };
73 91
74 } 92 }
OLDNEW
« no previous file with comments | « mojo/services/public/interfaces/network/net_address.mojom ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698