summaryrefslogtreecommitdiffstats
path: root/remoting/client/plugin/pepper_util.h
blob: b106b2f4eab55145a86fcec35ffd35ac4a4d409f (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
// 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_PLUGIN_UTIL_H_
#define REMOTING_CLIENT_PLUGIN_PLUGIN_UTIL_H_

#include "base/basictypes.h"
#include "base/callback_forward.h"

#include "ppapi/cpp/completion_callback.h"

struct PP_NetAddress_Private;

namespace talk_base {
class SocketAddress;
}  // namespace talk_base

namespace remoting {

// Adapts a base::Callback to a pp::CompletionCallback, which may be passed to
// exactly one Pepper API. If the adapted callback is not used then a copy of
// |callback| will be leaked, including references & passed values bound to it.
pp::CompletionCallback PpCompletionCallback(base::Callback<void(int)> callback);

// Helpers to convert between different socket address representations.
bool SocketAddressToPpAddressWithPort(const talk_base::SocketAddress& address,
                                      PP_NetAddress_Private* pp_address,
                                      uint16_t port);
bool SocketAddressToPpAddress(const talk_base::SocketAddress& address,
                              PP_NetAddress_Private* pp_address);
bool PpAddressToSocketAddress(const PP_NetAddress_Private& pp_address,
                              talk_base::SocketAddress* address);

}  // namespace remoting

#endif  // REMOTING_CLIENT_PLUGIN_PLUGIN_UTIL_H_