blob: b721e965dca23a170058d1f6c1002aa7cbb3d988 [file] [log] [blame]
Torne (Richard Coles)68043e12013-09-26 13:24:57 +01001// 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.
4
5#include "ppapi/cpp/network_monitor.h"
6
7#include "ppapi/c/ppb_network_monitor.h"
8#include "ppapi/cpp/completion_callback.h"
9#include "ppapi/cpp/instance.h"
10#include "ppapi/cpp/module_impl.h"
11#include "ppapi/cpp/network_list.h"
12
13namespace pp {
14
15namespace {
16
17template <> const char* interface_name<PPB_NetworkMonitor_1_0>() {
18 return PPB_NETWORKMONITOR_INTERFACE_1_0;
19}
20
21} // namespace
22
23NetworkMonitor::NetworkMonitor(const InstanceHandle& instance) {
24 if (has_interface<PPB_NetworkMonitor_1_0>()) {
25 PassRefFromConstructor(get_interface<PPB_NetworkMonitor_1_0>()->Create(
26 instance.pp_instance()));
27 }
28}
29
30int32_t NetworkMonitor::UpdateNetworkList(
31 const CompletionCallbackWithOutput<NetworkList>& callback) {
32 if (has_interface<PPB_NetworkMonitor_1_0>()) {
33 return get_interface<PPB_NetworkMonitor_1_0>()->UpdateNetworkList(
34 pp_resource(), callback.output(), callback.pp_completion_callback());
35 }
36 return callback.MayForce(PP_ERROR_NOINTERFACE);
37}
38
39// static
40bool NetworkMonitor::IsAvailable() {
41 return has_interface<PPB_NetworkMonitor_1_0>();
42}
43
44} // namespace pp