Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Unified Diff: ppapi/proxy/network_list_resource.cc

Issue 23819033: Simplify PPB_NetworkMonitor proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix compilation after r169825 Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/proxy/network_list_resource.h ('k') | ppapi/proxy/network_monitor_resource.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/network_list_resource.cc
diff --git a/ppapi/shared_impl/ppb_network_list_private_shared.cc b/ppapi/proxy/network_list_resource.cc
similarity index 33%
rename from ppapi/shared_impl/ppb_network_list_private_shared.cc
rename to ppapi/proxy/network_list_resource.cc
index d299c0636a91068c5e381c0ece53fb068e5f46a8..62a342ce2de61e7c5d3aee062b24950e5b045f65 100644
--- a/ppapi/shared_impl/ppb_network_list_private_shared.cc
+++ b/ppapi/proxy/network_list_resource.cc
@@ -2,92 +2,57 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "ppapi/proxy/network_list_resource.h"
+
#include <algorithm>
#include "base/logging.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/shared_impl/array_writer.h"
-#include "ppapi/shared_impl/ppb_network_list_private_shared.h"
#include "ppapi/shared_impl/var.h"
#include "ppapi/thunk/enter.h"
namespace ppapi {
+namespace proxy {
-NetworkInfo::NetworkInfo()
- : type(PP_NETWORKLIST_UNKNOWN),
- state(PP_NETWORKLIST_DOWN),
- mtu(0) {
-}
-
-NetworkInfo::~NetworkInfo() {
-}
-
-NetworkListStorage::NetworkListStorage(const NetworkList& list)
- : list_(list) {
-}
-
-NetworkListStorage::~NetworkListStorage() {
-}
-
-PPB_NetworkList_Private_Shared::PPB_NetworkList_Private_Shared(
- ResourceObjectType type,
- PP_Instance instance,
- const scoped_refptr<NetworkListStorage>& list)
- : Resource(type, instance),
+NetworkListResource::NetworkListResource(PP_Instance instance,
+ const SerializedNetworkList& list)
+ : Resource(OBJECT_IS_PROXY, instance),
list_(list) {
}
-PPB_NetworkList_Private_Shared::~PPB_NetworkList_Private_Shared() {
-}
+NetworkListResource::~NetworkListResource() {}
-// static
-PP_Resource PPB_NetworkList_Private_Shared::Create(
- ResourceObjectType type,
- PP_Instance instance,
- const scoped_refptr<NetworkListStorage>& list) {
- scoped_refptr<PPB_NetworkList_Private_Shared> object(
- new PPB_NetworkList_Private_Shared(type, instance, list));
- return object->GetReference();
-}
-
-::ppapi::thunk::PPB_NetworkList_API*
-PPB_NetworkList_Private_Shared::AsPPB_NetworkList_API() {
+thunk::PPB_NetworkList_API* NetworkListResource::AsPPB_NetworkList_API() {
return this;
}
-const NetworkList& PPB_NetworkList_Private_Shared::GetNetworkListData() const {
- return list_->list();
-}
-
-uint32_t PPB_NetworkList_Private_Shared::GetCount() {
- return static_cast<uint32_t>(list_->list().size());
+uint32_t NetworkListResource::GetCount() {
+ return static_cast<uint32_t>(list_.size());
}
-PP_Var PPB_NetworkList_Private_Shared::GetName(uint32_t index) {
- if (index >= list_->list().size())
+PP_Var NetworkListResource::GetName(uint32_t index) {
+ if (index >= list_.size())
return PP_MakeUndefined();
- return StringVar::StringToPPVar(list_->list().at(index).name);
+ return StringVar::StringToPPVar(list_.at(index).name);
}
-PP_NetworkListType_Private PPB_NetworkList_Private_Shared::GetType(
- uint32_t index) {
- if (index >= list_->list().size())
+PP_NetworkListType_Private NetworkListResource::GetType(uint32_t index) {
+ if (index >= list_.size())
return PP_NETWORKLIST_UNKNOWN;
- return list_->list().at(index).type;
+ return list_.at(index).type;
}
-PP_NetworkListState_Private PPB_NetworkList_Private_Shared::GetState(
- uint32_t index) {
- if (index >= list_->list().size())
+PP_NetworkListState_Private NetworkListResource::GetState(uint32_t index) {
+ if (index >= list_.size())
return PP_NETWORKLIST_DOWN;
- return list_->list().at(index).state;
+ return list_.at(index).state;
}
-int32_t PPB_NetworkList_Private_Shared::GetIpAddresses(
- uint32_t index,
- const PP_ArrayOutput& output) {
+int32_t NetworkListResource::GetIpAddresses(uint32_t index,
+ const PP_ArrayOutput& output) {
ArrayWriter writer(output);
- if (index >= list_->list().size() || !writer.is_valid())
+ if (index >= list_.size() || !writer.is_valid())
return PP_ERROR_BADARGUMENT;
thunk::EnterResourceCreationNoLock enter(pp_instance());
@@ -95,7 +60,7 @@ int32_t PPB_NetworkList_Private_Shared::GetIpAddresses(
return PP_ERROR_FAILED;
const std::vector<PP_NetAddress_Private>& addresses =
- list_->list().at(index).addresses;
+ list_.at(index).addresses;
std::vector<PP_Resource> addr_resources;
for (size_t i = 0; i < addresses.size(); ++i) {
addr_resources.push_back(
@@ -108,16 +73,17 @@ int32_t PPB_NetworkList_Private_Shared::GetIpAddresses(
return PP_OK;
}
-PP_Var PPB_NetworkList_Private_Shared::GetDisplayName(uint32_t index) {
- if (index >= list_->list().size())
+PP_Var NetworkListResource::GetDisplayName(uint32_t index) {
+ if (index >= list_.size())
return PP_MakeUndefined();
- return StringVar::StringToPPVar(list_->list().at(index).display_name);
+ return StringVar::StringToPPVar(list_.at(index).display_name);
}
-uint32_t PPB_NetworkList_Private_Shared::GetMTU(uint32_t index) {
- if (index >= list_->list().size())
+uint32_t NetworkListResource::GetMTU(uint32_t index) {
+ if (index >= list_.size())
return 0;
- return list_->list().at(index).mtu;
+ return list_.at(index).mtu;
}
+} // namespace proxy
} // namespace thunk
« no previous file with comments | « ppapi/proxy/network_list_resource.h ('k') | ppapi/proxy/network_monitor_resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698