Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / remoting / client / plugin / pepper_port_allocator.h
blobc98c242c0091f7b4ae6313d34176463e0a64f78a
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
3 // found in the LICENSE file.
5 #ifndef REMOTING_CLIENT_PLUGIN_PEPPER_PORT_ALLOCATOR_H_
6 #define REMOTING_CLIENT_PLUGIN_PEPPER_PORT_ALLOCATOR_H_
8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "ppapi/cpp/instance_handle.h"
11 #include "third_party/webrtc/p2p/client/httpportallocator.h"
13 namespace remoting {
15 // An implementation of cricket::PortAllocator for libjingle that is
16 // used by the client plugin. There are two differences from
17 // cricket::HttpPortAllocator:
18 // * PepperPortAllocator uses Pepper URLLoader API when creating
19 // relay sessions.
20 // * PepperPortAllocator resolves STUN DNS names and passes IP
21 // addresses to BasicPortAllocator (it uses HostResolverPrivate API
22 // for that). This is needed because libjingle's DNS resolution
23 // code doesn't work in sandbox.
24 class PepperPortAllocator : public cricket::HttpPortAllocatorBase {
25 public:
26 static scoped_ptr<PepperPortAllocator> Create(
27 const pp::InstanceHandle& instance);
28 ~PepperPortAllocator() override;
30 // cricket::HttpPortAllocatorBase overrides.
31 cricket::PortAllocatorSession* CreateSessionInternal(
32 const std::string& content_name,
33 int component,
34 const std::string& ice_username_fragment,
35 const std::string& ice_password) override;
37 private:
38 PepperPortAllocator(
39 const pp::InstanceHandle& instance,
40 scoped_ptr<rtc::NetworkManager> network_manager,
41 scoped_ptr<rtc::PacketSocketFactory> socket_factory);
43 pp::InstanceHandle instance_;
44 scoped_ptr<rtc::NetworkManager> network_manager_;
45 scoped_ptr<rtc::PacketSocketFactory> socket_factory_;
47 DISALLOW_COPY_AND_ASSIGN(PepperPortAllocator);
50 } // namespace remoting
52 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_PORT_ALLOCATOR_H_