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

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

Issue 10310170: Improve socket.write() to make sure all data will be sent out. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix compile error on Mac Created 8 years, 7 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 (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 #ifndef CHROME_BROWSER_EXTENSIONS_API_SOCKET_UDP_SOCKET_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SOCKET_UDP_SOCKET_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_SOCKET_UDP_SOCKET_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_SOCKET_UDP_SOCKET_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "chrome/browser/extensions/api/socket/socket.h" 11 #include "chrome/browser/extensions/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 APIResourceEventNotifier; 16 class APIResourceEventNotifier;
17 17
18 class UDPSocket : public Socket { 18 class UDPSocket : public Socket {
19 public: 19 public:
20 explicit UDPSocket(APIResourceEventNotifier* event_notifier); 20 explicit UDPSocket(APIResourceEventNotifier* event_notifier);
21 virtual ~UDPSocket(); 21 virtual ~UDPSocket();
22 22
23 virtual void Connect(const std::string& address, 23 virtual void Connect(const std::string& address,
24 int port, 24 int port,
25 const CompletionCallback& callback) OVERRIDE; 25 const CompletionCallback& callback) OVERRIDE;
26 virtual void Disconnect() OVERRIDE; 26 virtual void Disconnect() OVERRIDE;
27 virtual int Bind(const std::string& address, int port) OVERRIDE; 27 virtual int Bind(const std::string& address, int port) OVERRIDE;
28 virtual void Read(int count, 28 virtual void Read(int count,
29 const ReadCompletionCallback& callback) OVERRIDE; 29 const ReadCompletionCallback& callback) OVERRIDE;
30 virtual void Write(scoped_refptr<net::IOBuffer> io_buffer,
31 int bytes,
32 const CompletionCallback& callback) OVERRIDE;
33 virtual void RecvFrom(int count, 30 virtual void RecvFrom(int count,
34 const RecvFromCompletionCallback& callback) OVERRIDE; 31 const RecvFromCompletionCallback& callback) OVERRIDE;
35 virtual void SendTo(scoped_refptr<net::IOBuffer> io_buffer, 32 virtual void SendTo(scoped_refptr<net::IOBuffer> io_buffer,
36 int byte_count, 33 int byte_count,
37 const std::string& address, 34 const std::string& address,
38 int port, 35 int port,
39 const CompletionCallback& callback) OVERRIDE; 36 const CompletionCallback& callback) OVERRIDE;
40 37
38 protected:
39 virtual int WriteImpl(net::IOBuffer* io_buffer,
40 int io_buffer_size,
41 const net::CompletionCallback& callback) OVERRIDE;
42
41 private: 43 private:
42 // Make net::IPEndPoint can be refcounted 44 // Make net::IPEndPoint can be refcounted
43 typedef base::RefCountedData<net::IPEndPoint> IPEndPoint; 45 typedef base::RefCountedData<net::IPEndPoint> IPEndPoint;
44 46
45 virtual void OnReadComplete(scoped_refptr<net::IOBuffer> io_buffer, 47 void OnReadComplete(scoped_refptr<net::IOBuffer> io_buffer,
46 int result); 48 int result);
47 virtual void OnWriteComplete(int result); 49 void OnRecvFromComplete(scoped_refptr<net::IOBuffer> io_buffer,
48 virtual void OnRecvFromComplete(scoped_refptr<net::IOBuffer> io_buffer, 50 scoped_refptr<IPEndPoint> address,
49 scoped_refptr<IPEndPoint> address, 51 int result);
50 int result); 52 void OnSendToComplete(int result);
51 virtual void OnSendToComplete(int result);
52 53
53 net::UDPSocket socket_; 54 net::UDPSocket socket_;
54 55
55 ReadCompletionCallback read_callback_; 56 ReadCompletionCallback read_callback_;
56 57
57 CompletionCallback write_callback_;
58
59 RecvFromCompletionCallback recv_from_callback_; 58 RecvFromCompletionCallback recv_from_callback_;
60 59
61 CompletionCallback send_to_callback_; 60 CompletionCallback send_to_callback_;
62 }; 61 };
63 62
64 } // namespace extensions 63 } // namespace extensions
65 64
66 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_UDP_SOCKET_H_ 65 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_UDP_SOCKET_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/socket/tcp_socket_unittest.cc ('k') | chrome/browser/extensions/api/socket/udp_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698