| 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_PROXY_HOST_RESOLVER_PRIVATE_RESOURCE_H_ |
| 6 #define PPAPI_SHARED_IMPL_PRIVATE_PPB_HOST_RESOLVER_SHARED_H_ | 6 #define PPAPI_PROXY_HOST_RESOLVER_PRIVATE_RESOURCE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 13 #include "ppapi/shared_impl/resource.h" | 14 #include "ppapi/proxy/plugin_resource.h" |
| 15 #include "ppapi/proxy/ppapi_proxy_export.h" |
| 14 #include "ppapi/shared_impl/tracked_callback.h" | 16 #include "ppapi/shared_impl/tracked_callback.h" |
| 15 #include "ppapi/thunk/ppb_host_resolver_private_api.h" | 17 #include "ppapi/thunk/ppb_host_resolver_private_api.h" |
| 16 | 18 |
| 17 namespace ppapi { | 19 namespace ppapi { |
| 18 | 20 |
| 19 struct HostPortPair { | 21 struct HostPortPair { |
| 20 std::string host; | 22 std::string host; |
| 21 uint16_t port; | 23 uint16_t port; |
| 22 }; | 24 }; |
| 23 | 25 |
| 24 class PPAPI_SHARED_EXPORT PPB_HostResolver_Shared | 26 namespace proxy { |
| 25 : public thunk::PPB_HostResolver_Private_API, | 27 |
| 26 public Resource { | 28 class PPAPI_PROXY_EXPORT HostResolverPrivateResource |
| 29 : public PluginResource, |
| 30 public thunk::PPB_HostResolver_Private_API { |
| 27 public: | 31 public: |
| 28 // C-tor used in Impl case. | 32 HostResolverPrivateResource(Connection connection, |
| 29 explicit PPB_HostResolver_Shared(PP_Instance instance); | 33 PP_Instance instance); |
| 34 virtual ~HostResolverPrivateResource(); |
| 30 | 35 |
| 31 // C-tor used in Proxy case. | 36 // PluginResource overrides. |
| 32 explicit PPB_HostResolver_Shared(const HostResource& resource); | 37 virtual thunk::PPB_HostResolver_Private_API* |
| 33 | |
| 34 virtual ~PPB_HostResolver_Shared(); | |
| 35 | |
| 36 // Resource overrides. | |
| 37 virtual PPB_HostResolver_Private_API* | |
| 38 AsPPB_HostResolver_Private_API() OVERRIDE; | 38 AsPPB_HostResolver_Private_API() OVERRIDE; |
| 39 | 39 |
| 40 // PPB_HostResolver_Private_API implementation. | 40 // PPB_HostResolver_Private_API implementation. |
| 41 virtual int32_t Resolve(const char* host, | 41 virtual int32_t Resolve(const char* host, |
| 42 uint16_t port, | 42 uint16_t port, |
| 43 const PP_HostResolver_Private_Hint* hint, | 43 const PP_HostResolver_Private_Hint* hint, |
| 44 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 44 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 45 virtual PP_Var GetCanonicalName() OVERRIDE; | 45 virtual PP_Var GetCanonicalName() OVERRIDE; |
| 46 virtual uint32_t GetSize() OVERRIDE; | 46 virtual uint32_t GetSize() OVERRIDE; |
| 47 virtual bool GetNetAddress(uint32_t index, | 47 virtual bool GetNetAddress(uint32_t index, |
| 48 PP_NetAddress_Private* address) OVERRIDE; | 48 PP_NetAddress_Private* address) OVERRIDE; |
| 49 | 49 |
| 50 void OnResolveCompleted( | 50 private: |
| 51 bool succeeded, | 51 // IPC message handlers. |
| 52 void OnPluginMsgResolveReply( |
| 53 const ResourceMessageReplyParams& params, |
| 52 const std::string& canonical_name, | 54 const std::string& canonical_name, |
| 53 const std::vector<PP_NetAddress_Private>& net_address_list); | 55 const std::vector<PP_NetAddress_Private>& net_address_list); |
| 54 | 56 |
| 55 // Send functions that need to be implemented differently for the | 57 void SendResolve(const HostPortPair& host_port, |
| 56 // proxied and non-proxied derived classes. | 58 const PP_HostResolver_Private_Hint* hint); |
| 57 virtual void SendResolve(const HostPortPair& host_port, | |
| 58 const PP_HostResolver_Private_Hint* hint) = 0; | |
| 59 | 59 |
| 60 protected: | |
| 61 static uint32 GenerateHostResolverID(); | |
| 62 bool ResolveInProgress() const; | 60 bool ResolveInProgress() const; |
| 63 | 61 |
| 64 const uint32 host_resolver_id_; | |
| 65 | |
| 66 scoped_refptr<TrackedCallback> resolve_callback_; | 62 scoped_refptr<TrackedCallback> resolve_callback_; |
| 67 | 63 |
| 68 std::string canonical_name_; | 64 std::string canonical_name_; |
| 69 std::vector<PP_NetAddress_Private> net_address_list_; | 65 std::vector<PP_NetAddress_Private> net_address_list_; |
| 70 | 66 |
| 71 DISALLOW_COPY_AND_ASSIGN(PPB_HostResolver_Shared); | 67 DISALLOW_COPY_AND_ASSIGN(HostResolverPrivateResource); |
| 72 }; | 68 }; |
| 73 | 69 |
| 70 } // namespace proxy |
| 74 } // namespace ppapi | 71 } // namespace ppapi |
| 75 | 72 |
| 76 #endif // PPAPI_SHARED_IMPL_PRIVATE_PPB_HOST_RESOLVER_SHARED_H_ | 73 #endif // PPAPI_PROXY_HOST_RESOLVER_PRIVATE_RESOURCE_H_ |
| OLD | NEW |