summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/api/socket/udp_socket.h
blob: 6511e5def792bf87c38ceee42378245a79d438f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_EXTENSIONS_API_SOCKET_UDP_SOCKET_H_
#define CHROME_BROWSER_EXTENSIONS_API_SOCKET_UDP_SOCKET_H_
#pragma once

#include <string>

#include "chrome/browser/extensions/api/socket/socket.h"
#include "chrome/browser/extensions/api/socket/socket_event_notifier.h"

// This looks like it should be forward-declarable, but it does some tricky
// moves that make it easier to just include it.
#include "net/udp/datagram_client_socket.h"

namespace net {
class Socket;
}

namespace extensions {

class UDPSocket : public Socket {
 public:
  UDPSocket(net::DatagramClientSocket* datagram_client_socket,
            const std::string& address, int port,
            SocketEventNotifier* event_notifier);
  virtual ~UDPSocket();

  virtual int Connect() OVERRIDE;
  virtual void Disconnect() OVERRIDE;

 protected:
  virtual net::Socket* socket() OVERRIDE;

 private:
  scoped_ptr<net::DatagramClientSocket> socket_;
  const std::string address_;
  int port_;
};

}  //  namespace extensions

#endif  // CHROME_BROWSER_EXTENSIONS_API_SOCKET_UDP_SOCKET_H_