| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef PPAPI_SHARED_IMPL_PRIVATE_PPB_HOST_RESOLVER_SHARED_H_ | 5 #ifndef PPAPI_SHARED_IMPL_PRIVATE_PPB_HOST_RESOLVER_SHARED_H_ |
| 6 #define PPAPI_SHARED_IMPL_PRIVATE_PPB_HOST_RESOLVER_SHARED_H_ | 6 #define PPAPI_SHARED_IMPL_PRIVATE_PPB_HOST_RESOLVER_SHARED_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "ppapi/shared_impl/resource.h" | 13 #include "ppapi/shared_impl/resource.h" |
| 14 #include "ppapi/shared_impl/tracked_callback.h" | 14 #include "ppapi/shared_impl/tracked_callback.h" |
| 15 #include "ppapi/thunk/ppb_host_resolver_private_api.h" | 15 #include "ppapi/thunk/ppb_host_resolver_private_api.h" |
| 16 | 16 |
| 17 namespace net { | |
| 18 class AddressList; | |
| 19 } | |
| 20 | |
| 21 namespace ppapi { | 17 namespace ppapi { |
| 22 | 18 |
| 23 struct HostPortPair { | 19 struct HostPortPair { |
| 24 std::string host; | 20 std::string host; |
| 25 uint16_t port; | 21 uint16_t port; |
| 26 }; | 22 }; |
| 27 | 23 |
| 28 typedef std::vector<PP_NetAddress_Private> NetAddressList; | |
| 29 | |
| 30 #if !defined(OS_NACL) && !defined(NACL_WIN64) | |
| 31 PPAPI_SHARED_EXPORT NetAddressList* | |
| 32 CreateNetAddressListFromAddressList(const net::AddressList& list); | |
| 33 #endif | |
| 34 | |
| 35 class PPAPI_SHARED_EXPORT PPB_HostResolver_Shared | 24 class PPAPI_SHARED_EXPORT PPB_HostResolver_Shared |
| 36 : public thunk::PPB_HostResolver_Private_API, | 25 : public thunk::PPB_HostResolver_Private_API, |
| 37 public Resource { | 26 public Resource { |
| 38 public: | 27 public: |
| 39 // C-tor used in Impl case. | 28 // C-tor used in Impl case. |
| 40 explicit PPB_HostResolver_Shared(PP_Instance instance); | 29 explicit PPB_HostResolver_Shared(PP_Instance instance); |
| 41 | 30 |
| 42 // C-tor used in Proxy case. | 31 // C-tor used in Proxy case. |
| 43 explicit PPB_HostResolver_Shared(const HostResource& resource); | 32 explicit PPB_HostResolver_Shared(const HostResource& resource); |
| 44 | 33 |
| 45 virtual ~PPB_HostResolver_Shared(); | 34 virtual ~PPB_HostResolver_Shared(); |
| 46 | 35 |
| 47 // Resource overrides. | 36 // Resource overrides. |
| 48 virtual PPB_HostResolver_Private_API* | 37 virtual PPB_HostResolver_Private_API* |
| 49 AsPPB_HostResolver_Private_API() OVERRIDE; | 38 AsPPB_HostResolver_Private_API() OVERRIDE; |
| 50 | 39 |
| 51 // PPB_HostResolver_Private_API implementation. | 40 // PPB_HostResolver_Private_API implementation. |
| 52 virtual int32_t Resolve(const char* host, | 41 virtual int32_t Resolve(const char* host, |
| 53 uint16_t port, | 42 uint16_t port, |
| 54 const PP_HostResolver_Private_Hint* hint, | 43 const PP_HostResolver_Private_Hint* hint, |
| 55 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 44 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 56 virtual PP_Var GetCanonicalName() OVERRIDE; | 45 virtual PP_Var GetCanonicalName() OVERRIDE; |
| 57 virtual uint32_t GetSize() OVERRIDE; | 46 virtual uint32_t GetSize() OVERRIDE; |
| 58 virtual bool GetNetAddress(uint32_t index, | 47 virtual bool GetNetAddress(uint32_t index, |
| 59 PP_NetAddress_Private* address) OVERRIDE; | 48 PP_NetAddress_Private* address) OVERRIDE; |
| 60 | 49 |
| 61 void OnResolveCompleted(bool succeeded, | 50 void OnResolveCompleted( |
| 62 const std::string& canonical_name, | 51 bool succeeded, |
| 63 const NetAddressList& net_address_list); | 52 const std::string& canonical_name, |
| 53 const std::vector<PP_NetAddress_Private>& net_address_list); |
| 64 | 54 |
| 65 // Send functions that need to be implemented differently for the | 55 // Send functions that need to be implemented differently for the |
| 66 // proxied and non-proxied derived classes. | 56 // proxied and non-proxied derived classes. |
| 67 virtual void SendResolve(const HostPortPair& host_port, | 57 virtual void SendResolve(const HostPortPair& host_port, |
| 68 const PP_HostResolver_Private_Hint* hint) = 0; | 58 const PP_HostResolver_Private_Hint* hint) = 0; |
| 69 | 59 |
| 70 protected: | 60 protected: |
| 71 static uint32 GenerateHostResolverID(); | 61 static uint32 GenerateHostResolverID(); |
| 72 bool ResolveInProgress() const; | 62 bool ResolveInProgress() const; |
| 73 | 63 |
| 74 const uint32 host_resolver_id_; | 64 const uint32 host_resolver_id_; |
| 75 | 65 |
| 76 scoped_refptr<TrackedCallback> resolve_callback_; | 66 scoped_refptr<TrackedCallback> resolve_callback_; |
| 77 | 67 |
| 78 std::string canonical_name_; | 68 std::string canonical_name_; |
| 79 NetAddressList net_address_list_; | 69 std::vector<PP_NetAddress_Private> net_address_list_; |
| 80 | 70 |
| 81 DISALLOW_COPY_AND_ASSIGN(PPB_HostResolver_Shared); | 71 DISALLOW_COPY_AND_ASSIGN(PPB_HostResolver_Shared); |
| 82 }; | 72 }; |
| 83 | 73 |
| 84 } // namespace ppapi | 74 } // namespace ppapi |
| 85 | 75 |
| 86 #endif // PPAPI_SHARED_IMPL_PRIVATE_PPB_HOST_RESOLVER_SHARED_H_ | 76 #endif // PPAPI_SHARED_IMPL_PRIVATE_PPB_HOST_RESOLVER_SHARED_H_ |
| OLD | NEW |