summaryrefslogtreecommitdiffstats
path: root/content/browser/renderer_host/p2p_sockets_host.h
blob: 32757d09be9d1689421af3bcd8b560087f0819b3 (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
// Copyright (c) 2011 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 CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKETS_HOST_H_
#define CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKETS_HOST_H_

#include "base/id_map.h"
#include "content/browser/browser_message_filter.h"
#include "content/common/p2p_sockets.h"
#include "net/base/ip_endpoint.h"

class P2PSocketHost;

class P2PSocketsHost : public BrowserMessageFilter {
 public:
  P2PSocketsHost();
  virtual ~P2PSocketsHost();

  // BrowserMessageFilter overrides.
  virtual void OnChannelClosing();
  virtual void OnDestruct() const;
  virtual bool OnMessageReceived(const IPC::Message& message,
                                 bool* message_was_ok);

 private:
  void OnCreateSocket(const IPC::Message& msg, P2PSocketType type,
                      int socket_id, const net::IPEndPoint& remote_address);
  void OnSend(const IPC::Message& msg, int socket_id,
              const net::IPEndPoint& socket_address,
              const std::vector<char>& data);
  void OnDestroySocket(const IPC::Message& msg, int socket_id);

  IDMap<P2PSocketHost, IDMapOwnPointer> sockets_;

  DISALLOW_COPY_AND_ASSIGN(P2PSocketsHost);
};

#endif  // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKETS_HOST_H_