summaryrefslogtreecommitdiffstats
path: root/remoting/client/plugin/pepper_port_allocator.h
blob: c98c242c0091f7b4ae6313d34176463e0a64f78a (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
46
47
48
49
50
51
52
// 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 REMOTING_CLIENT_PLUGIN_PEPPER_PORT_ALLOCATOR_H_
#define REMOTING_CLIENT_PLUGIN_PEPPER_PORT_ALLOCATOR_H_

#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "ppapi/cpp/instance_handle.h"
#include "third_party/webrtc/p2p/client/httpportallocator.h"

namespace remoting {

// An implementation of cricket::PortAllocator for libjingle that is
// used by the client plugin. There are two differences from
// cricket::HttpPortAllocator:
//   * PepperPortAllocator uses Pepper URLLoader API when creating
//     relay sessions.
//   * PepperPortAllocator resolves STUN DNS names and passes IP
//     addresses to BasicPortAllocator (it uses HostResolverPrivate API
//     for that). This is needed because libjingle's DNS resolution
//     code doesn't work in sandbox.
class PepperPortAllocator : public cricket::HttpPortAllocatorBase {
 public:
  static scoped_ptr<PepperPortAllocator> Create(
      const pp::InstanceHandle& instance);
  ~PepperPortAllocator() override;

  // cricket::HttpPortAllocatorBase overrides.
  cricket::PortAllocatorSession* CreateSessionInternal(
      const std::string& content_name,
      int component,
      const std::string& ice_username_fragment,
      const std::string& ice_password) override;

 private:
  PepperPortAllocator(
      const pp::InstanceHandle& instance,
      scoped_ptr<rtc::NetworkManager> network_manager,
      scoped_ptr<rtc::PacketSocketFactory> socket_factory);

  pp::InstanceHandle instance_;
  scoped_ptr<rtc::NetworkManager> network_manager_;
  scoped_ptr<rtc::PacketSocketFactory> socket_factory_;

  DISALLOW_COPY_AND_ASSIGN(PepperPortAllocator);
};

}  // namespace remoting

#endif  // REMOTING_CLIENT_PLUGIN_PEPPER_PORT_ALLOCATOR_H_