diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-22 06:34:03 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-22 06:34:03 +0000 |
commit | 86fbad285cb3697e662e2f0b34f82dd2fba2f71e (patch) | |
tree | 6b261d3363dee8f179a5c71dcba5667db8957a78 /ppapi/cpp | |
parent | d394d9761b6749ad61a001b0ea69850f937f60c9 (diff) | |
download | chromium_src-86fbad285cb3697e662e2f0b34f82dd2fba2f71e.zip chromium_src-86fbad285cb3697e662e2f0b34f82dd2fba2f71e.tar.gz chromium_src-86fbad285cb3697e662e2f0b34f82dd2fba2f71e.tar.bz2 |
Make NetworkList and NetworkMonitor APIs public
BUG=281781
R=nfullagar@chromium.org, thakis@chromium.org, yzshen@chromium.org
TBR=cevans@chromium.org
Review URL: https://codereview.chromium.org/23450012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@224626 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/cpp')
-rw-r--r-- | ppapi/cpp/network_list.cc | 94 | ||||
-rw-r--r-- | ppapi/cpp/network_list.h (renamed from ppapi/cpp/private/network_list_private.h) | 18 | ||||
-rw-r--r-- | ppapi/cpp/network_monitor.cc | 44 | ||||
-rw-r--r-- | ppapi/cpp/network_monitor.h (renamed from ppapi/cpp/private/network_monitor_private.h) | 16 | ||||
-rw-r--r-- | ppapi/cpp/private/network_list_private.cc | 94 | ||||
-rw-r--r-- | ppapi/cpp/private/network_monitor_private.cc | 44 |
6 files changed, 155 insertions, 155 deletions
diff --git a/ppapi/cpp/network_list.cc b/ppapi/cpp/network_list.cc new file mode 100644 index 0000000..12c3bf4 --- /dev/null +++ b/ppapi/cpp/network_list.cc @@ -0,0 +1,94 @@ +// 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. + +#include "ppapi/cpp/network_list.h" + +#include "ppapi/c/pp_errors.h" +#include "ppapi/cpp/array_output.h" +#include "ppapi/cpp/logging.h" +#include "ppapi/cpp/module_impl.h" +#include "ppapi/cpp/net_address.h" +#include "ppapi/cpp/var.h" + +namespace pp { + +namespace { + +template <> const char* interface_name<PPB_NetworkList_1_0>() { + return PPB_NETWORKLIST_INTERFACE_1_0; +} + +} // namespace + +NetworkList::NetworkList() { +} + +NetworkList::NetworkList(PassRef, PP_Resource resource) + : Resource(PASS_REF, resource) { +} + +// static +bool NetworkList::IsAvailable() { + return has_interface<PPB_NetworkList_1_0>(); +} + +uint32_t NetworkList::GetCount() const { + if (!has_interface<PPB_NetworkList_1_0>()) + return 0; + return get_interface<PPB_NetworkList_1_0>()->GetCount(pp_resource()); +} + +std::string NetworkList::GetName(uint32_t index) const { + if (!has_interface<PPB_NetworkList_1_0>()) + return std::string(); + Var result(PASS_REF, + get_interface<PPB_NetworkList_1_0>()->GetName( + pp_resource(), index)); + return result.is_string() ? result.AsString() : std::string(); +} + +PP_NetworkList_Type NetworkList::GetType(uint32_t index) const { + if (!has_interface<PPB_NetworkList_1_0>()) + return PP_NETWORKLIST_TYPE_ETHERNET; + return get_interface<PPB_NetworkList_1_0>()->GetType( + pp_resource(), index); +} + +PP_NetworkList_State NetworkList::GetState(uint32_t index) const { + if (!has_interface<PPB_NetworkList_1_0>()) + return PP_NETWORKLIST_STATE_DOWN; + return get_interface<PPB_NetworkList_1_0>()->GetState( + pp_resource(), index); +} + +int32_t NetworkList::GetIpAddresses( + uint32_t index, + std::vector<NetAddress>* addresses) const { + if (!has_interface<PPB_NetworkList_1_0>()) + return PP_ERROR_NOINTERFACE; + if (!addresses) + return PP_ERROR_BADARGUMENT; + + ResourceArrayOutputAdapter<NetAddress> adapter(addresses); + return get_interface<PPB_NetworkList_1_0>()->GetIpAddresses( + pp_resource(), index, adapter.pp_array_output()); +} + +std::string NetworkList::GetDisplayName(uint32_t index) const { + if (!has_interface<PPB_NetworkList_1_0>()) + return std::string(); + Var result(PASS_REF, + get_interface<PPB_NetworkList_1_0>()->GetDisplayName( + pp_resource(), index)); + return result.is_string() ? result.AsString() : std::string(); +} + +uint32_t NetworkList::GetMTU(uint32_t index) const { + if (!has_interface<PPB_NetworkList_1_0>()) + return 0; + return get_interface<PPB_NetworkList_1_0>()->GetMTU( + pp_resource(), index); +} + +} // namespace pp diff --git a/ppapi/cpp/private/network_list_private.h b/ppapi/cpp/network_list.h index c338aa6..d479129 100644 --- a/ppapi/cpp/private/network_list_private.h +++ b/ppapi/cpp/network_list.h @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef PPAPI_CPP_PRIVATE_NETWORK_LIST_PRIVATE_H_ -#define PPAPI_CPP_PRIVATE_NETWORK_LIST_PRIVATE_H_ +#ifndef PPAPI_CPP_NETWORK_LIST_H_ +#define PPAPI_CPP_NETWORK_LIST_H_ #include <string> #include <vector> -#include "ppapi/c/private/ppb_network_list_private.h" +#include "ppapi/c/ppb_network_list.h" #include "ppapi/cpp/pass_ref.h" #include "ppapi/cpp/resource.h" @@ -16,10 +16,10 @@ namespace pp { class NetAddress; -class NetworkListPrivate : public Resource { +class NetworkList : public Resource { public: - NetworkListPrivate(); - NetworkListPrivate(PassRef, PP_Resource resource); + NetworkList(); + NetworkList(PassRef, PP_Resource resource); /// Returns true if the required interface is available. static bool IsAvailable(); @@ -34,11 +34,11 @@ class NetworkListPrivate : public Resource { /// @return Returns the type of the network interface with the /// specified <code>index</code>. - PP_NetworkListType_Private GetType(uint32_t index) const; + PP_NetworkList_Type GetType(uint32_t index) const; /// @return Returns the current state of the network interface with /// the specified <code>index</code>. - PP_NetworkListState_Private GetState(uint32_t index) const; + PP_NetworkList_State GetState(uint32_t index) const; /// Gets the list of IP addresses for the network interface with the /// specified <code>index</code> and stores them in @@ -57,4 +57,4 @@ class NetworkListPrivate : public Resource { } // namespace pp -#endif // PPAPI_CPP_PRIVATE_NETWORK_LIST_PRIVATE_H_ +#endif // PPAPI_CPP_NETWORK_LIST_H_ diff --git a/ppapi/cpp/network_monitor.cc b/ppapi/cpp/network_monitor.cc new file mode 100644 index 0000000..b721e96 --- /dev/null +++ b/ppapi/cpp/network_monitor.cc @@ -0,0 +1,44 @@ +// 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. + +#include "ppapi/cpp/network_monitor.h" + +#include "ppapi/c/ppb_network_monitor.h" +#include "ppapi/cpp/completion_callback.h" +#include "ppapi/cpp/instance.h" +#include "ppapi/cpp/module_impl.h" +#include "ppapi/cpp/network_list.h" + +namespace pp { + +namespace { + +template <> const char* interface_name<PPB_NetworkMonitor_1_0>() { + return PPB_NETWORKMONITOR_INTERFACE_1_0; +} + +} // namespace + +NetworkMonitor::NetworkMonitor(const InstanceHandle& instance) { + if (has_interface<PPB_NetworkMonitor_1_0>()) { + PassRefFromConstructor(get_interface<PPB_NetworkMonitor_1_0>()->Create( + instance.pp_instance())); + } +} + +int32_t NetworkMonitor::UpdateNetworkList( + const CompletionCallbackWithOutput<NetworkList>& callback) { + if (has_interface<PPB_NetworkMonitor_1_0>()) { + return get_interface<PPB_NetworkMonitor_1_0>()->UpdateNetworkList( + pp_resource(), callback.output(), callback.pp_completion_callback()); + } + return callback.MayForce(PP_ERROR_NOINTERFACE); +} + +// static +bool NetworkMonitor::IsAvailable() { + return has_interface<PPB_NetworkMonitor_1_0>(); +} + +} // namespace pp diff --git a/ppapi/cpp/private/network_monitor_private.h b/ppapi/cpp/network_monitor.h index b8fbe0f..bce731d9 100644 --- a/ppapi/cpp/private/network_monitor_private.h +++ b/ppapi/cpp/network_monitor.h @@ -2,25 +2,25 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef PPAPI_CPP_PRIVATE_NETWORK_MONITOR_PRIVATE_H_ -#define PPAPI_CPP_PRIVATE_NETWORK_MONITOR_PRIVATE_H_ +#ifndef PPAPI_CPP_NETWORK_MONITOR_H_ +#define PPAPI_CPP_NETWORK_MONITOR_H_ -#include "ppapi/cpp/resource.h" #include "ppapi/cpp/instance_handle.h" +#include "ppapi/cpp/resource.h" namespace pp { class Instance; -class NetworkListPrivate; +class NetworkList; template <typename T> class CompletionCallbackWithOutput; -class NetworkMonitorPrivate : public Resource { +class NetworkMonitor : public Resource { public: - explicit NetworkMonitorPrivate(const InstanceHandle& instance); + explicit NetworkMonitor(const InstanceHandle& instance); int32_t UpdateNetworkList( - const CompletionCallbackWithOutput<NetworkListPrivate>& callback); + const CompletionCallbackWithOutput<NetworkList>& callback); // Returns true if the required interface is available. static bool IsAvailable(); @@ -28,4 +28,4 @@ class NetworkMonitorPrivate : public Resource { } // namespace pp -#endif // PPAPI_CPP_PRIVATE_NETWORK_MONITOR_PRIVATE_H_ +#endif // PPAPI_CPP_NETWORK_MONITOR_H_ diff --git a/ppapi/cpp/private/network_list_private.cc b/ppapi/cpp/private/network_list_private.cc deleted file mode 100644 index 5a3a5be..0000000 --- a/ppapi/cpp/private/network_list_private.cc +++ /dev/null @@ -1,94 +0,0 @@ -// 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. - -#include "ppapi/cpp/private/network_list_private.h" - -#include "ppapi/c/pp_errors.h" -#include "ppapi/cpp/array_output.h" -#include "ppapi/cpp/logging.h" -#include "ppapi/cpp/module_impl.h" -#include "ppapi/cpp/net_address.h" -#include "ppapi/cpp/var.h" - -namespace pp { - -namespace { - -template <> const char* interface_name<PPB_NetworkList_Private_0_3>() { - return PPB_NETWORKLIST_PRIVATE_INTERFACE_0_3; -} - -} // namespace - -NetworkListPrivate::NetworkListPrivate() { -} - -NetworkListPrivate::NetworkListPrivate(PassRef, PP_Resource resource) - : Resource(PASS_REF, resource) { -} - -// static -bool NetworkListPrivate::IsAvailable() { - return has_interface<PPB_NetworkList_Private_0_3>(); -} - -uint32_t NetworkListPrivate::GetCount() const { - if (!has_interface<PPB_NetworkList_Private_0_3>()) - return 0; - return get_interface<PPB_NetworkList_Private_0_3>()->GetCount(pp_resource()); -} - -std::string NetworkListPrivate::GetName(uint32_t index) const { - if (!has_interface<PPB_NetworkList_Private_0_3>()) - return std::string(); - Var result(PASS_REF, - get_interface<PPB_NetworkList_Private_0_3>()->GetName( - pp_resource(), index)); - return result.is_string() ? result.AsString() : std::string(); -} - -PP_NetworkListType_Private NetworkListPrivate::GetType(uint32_t index) const { - if (!has_interface<PPB_NetworkList_Private_0_3>()) - return PP_NETWORKLIST_ETHERNET; - return get_interface<PPB_NetworkList_Private_0_3>()->GetType( - pp_resource(), index); -} - -PP_NetworkListState_Private NetworkListPrivate::GetState(uint32_t index) const { - if (!has_interface<PPB_NetworkList_Private_0_3>()) - return PP_NETWORKLIST_DOWN; - return get_interface<PPB_NetworkList_Private_0_3>()->GetState( - pp_resource(), index); -} - -int32_t NetworkListPrivate::GetIpAddresses( - uint32_t index, - std::vector<NetAddress>* addresses) const { - if (!has_interface<PPB_NetworkList_Private_0_3>()) - return PP_ERROR_NOINTERFACE; - if (!addresses) - return PP_ERROR_BADARGUMENT; - - ResourceArrayOutputAdapter<NetAddress> adapter(addresses); - return get_interface<PPB_NetworkList_Private_0_3>()->GetIpAddresses( - pp_resource(), index, adapter.pp_array_output()); -} - -std::string NetworkListPrivate::GetDisplayName(uint32_t index) const { - if (!has_interface<PPB_NetworkList_Private_0_3>()) - return std::string(); - Var result(PASS_REF, - get_interface<PPB_NetworkList_Private_0_3>()->GetDisplayName( - pp_resource(), index)); - return result.is_string() ? result.AsString() : std::string(); -} - -uint32_t NetworkListPrivate::GetMTU(uint32_t index) const { - if (!has_interface<PPB_NetworkList_Private_0_3>()) - return 0; - return get_interface<PPB_NetworkList_Private_0_3>()->GetMTU( - pp_resource(), index); -} - -} // namespace pp diff --git a/ppapi/cpp/private/network_monitor_private.cc b/ppapi/cpp/private/network_monitor_private.cc deleted file mode 100644 index 7cef97f..0000000 --- a/ppapi/cpp/private/network_monitor_private.cc +++ /dev/null @@ -1,44 +0,0 @@ -// 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. - -#include "ppapi/cpp/private/network_monitor_private.h" - -#include "ppapi/c/private/ppb_network_monitor_private.h" -#include "ppapi/cpp/completion_callback.h" -#include "ppapi/cpp/instance.h" -#include "ppapi/cpp/module_impl.h" -#include "ppapi/cpp/private/network_list_private.h" - -namespace pp { - -namespace { - -template <> const char* interface_name<PPB_NetworkMonitor_Private_0_3>() { - return PPB_NETWORKMONITOR_PRIVATE_INTERFACE_0_3; -} - -} // namespace - -NetworkMonitorPrivate::NetworkMonitorPrivate(const InstanceHandle& instance) { - if (has_interface<PPB_NetworkMonitor_Private_0_3>()) { - PassRefFromConstructor(get_interface<PPB_NetworkMonitor_Private_0_3>()-> - Create(instance.pp_instance())); - } -} - -int32_t NetworkMonitorPrivate::UpdateNetworkList( - const CompletionCallbackWithOutput<NetworkListPrivate>& callback) { - if (has_interface<PPB_NetworkMonitor_Private_0_3>()) { - return get_interface<PPB_NetworkMonitor_Private_0_3>()->UpdateNetworkList( - pp_resource(), callback.output(), callback.pp_completion_callback()); - } - return callback.MayForce(PP_ERROR_NOINTERFACE); -} - -// static -bool NetworkMonitorPrivate::IsAvailable() { - return has_interface<PPB_NetworkMonitor_Private_0_3>(); -} - -} // namespace pp |