Close a window for a race with the system linker
[chromium-blink-merge.git] / ppapi / cpp / network_monitor.cc
blobb721e965dca23a170058d1f6c1002aa7cbb3d988
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 #include "ppapi/cpp/network_monitor.h"
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"
13 namespace pp {
15 namespace {
17 template <> const char* interface_name<PPB_NetworkMonitor_1_0>() {
18 return PPB_NETWORKMONITOR_INTERFACE_1_0;
21 } // namespace
23 NetworkMonitor::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()));
30 int32_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());
36 return callback.MayForce(PP_ERROR_NOINTERFACE);
39 // static
40 bool NetworkMonitor::IsAvailable() {
41 return has_interface<PPB_NetworkMonitor_1_0>();
44 } // namespace pp