Chromium Code Reviews| 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 39% |
| rename from ppapi/shared_impl/ppb_network_list_private_shared.cc |
| rename to ppapi/proxy/network_list_resource.cc |
| index d299c0636a91068c5e381c0ece53fb068e5f46a8..4335c2fd972bbcac1ca7d460bf1307a8f6156a2f 100644 |
| --- a/ppapi/shared_impl/ppb_network_list_private_shared.cc |
| +++ b/ppapi/proxy/network_list_resource.cc |
| @@ -2,16 +2,18 @@ |
| // 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), |
| @@ -19,75 +21,48 @@ NetworkInfo::NetworkInfo() |
| mtu(0) { |
| } |
| -NetworkInfo::~NetworkInfo() { |
| -} |
| - |
| -NetworkListStorage::NetworkListStorage(const NetworkList& list) |
| - : list_(list) { |
| -} |
| - |
| -NetworkListStorage::~NetworkListStorage() { |
| -} |
| +NetworkInfo::~NetworkInfo() {} |
| -PPB_NetworkList_Private_Shared::PPB_NetworkList_Private_Shared( |
| - ResourceObjectType type, |
| - PP_Instance instance, |
| - const scoped_refptr<NetworkListStorage>& list) |
| +NetworkListResource::NetworkListResource(ResourceObjectType type, |
| + PP_Instance instance, |
| + const NetworkList& list) |
| : Resource(type, instance), |
| list_(list) { |
| } |
| -PPB_NetworkList_Private_Shared::~PPB_NetworkList_Private_Shared() { |
| -} |
| - |
| -// 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(); |
| -} |
| +NetworkListResource::~NetworkListResource() {} |
| ::ppapi::thunk::PPB_NetworkList_API* |
|
yzshen1
2013/09/13 17:47:10
maybe we don't need ::ppapi?
Sergey Ulanov
2013/09/13 18:35:00
Done.
|
| -PPB_NetworkList_Private_Shared::AsPPB_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 +70,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 +83,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 |