| 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 #include "ppapi/shared_impl/private/ppb_host_resolver_shared.h" | 5 #include "ppapi/shared_impl/private/ppb_host_resolver_shared.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "ppapi/c/pp_errors.h" | 11 #include "ppapi/c/pp_errors.h" |
| 12 #include "ppapi/shared_impl/private/net_address_private_impl.h" | 12 #include "ppapi/shared_impl/private/net_address_private_impl.h" |
| 13 #include "ppapi/shared_impl/var.h" | 13 #include "ppapi/shared_impl/var.h" |
| 14 #include "ppapi/thunk/thunk.h" | 14 #include "ppapi/thunk/thunk.h" |
| 15 | 15 |
| 16 namespace ppapi { | 16 namespace ppapi { |
| 17 | 17 |
| 18 PPB_HostResolver_Shared::PPB_HostResolver_Shared(PP_Instance instance) | |
| 19 : Resource(OBJECT_IS_IMPL, instance), | |
| 20 host_resolver_id_(GenerateHostResolverID()) { | |
| 21 } | |
| 22 | |
| 23 PPB_HostResolver_Shared::PPB_HostResolver_Shared( | |
| 24 const HostResource& resource) | |
| 25 : Resource(OBJECT_IS_PROXY, resource), | |
| 26 host_resolver_id_(GenerateHostResolverID()) { | |
| 27 } | |
| 28 | |
| 29 PPB_HostResolver_Shared::~PPB_HostResolver_Shared() { | |
| 30 } | |
| 31 | |
| 32 thunk::PPB_HostResolver_Private_API* | |
| 33 PPB_HostResolver_Shared::AsPPB_HostResolver_Private_API() { | |
| 34 return this; | |
| 35 } | |
| 36 | |
| 37 int32_t PPB_HostResolver_Shared::Resolve( | 18 int32_t PPB_HostResolver_Shared::Resolve( |
| 38 const char* host, | 19 const char* host, |
| 39 uint16_t port, | 20 uint16_t port, |
| 40 const PP_HostResolver_Private_Hint* hint, | 21 const PP_HostResolver_Private_Hint* hint, |
| 41 scoped_refptr<TrackedCallback> callback) { | 22 scoped_refptr<TrackedCallback> callback) { |
| 42 if (!host) | 23 if (!host) |
| 43 return PP_ERROR_BADARGUMENT; | 24 return PP_ERROR_BADARGUMENT; |
| 44 if (ResolveInProgress()) | 25 if (ResolveInProgress()) |
| 45 return PP_ERROR_INPROGRESS; | 26 return PP_ERROR_INPROGRESS; |
| 46 | 27 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 canonical_name_ = canonical_name; | 61 canonical_name_ = canonical_name; |
| 81 net_address_list_ = net_address_list; | 62 net_address_list_ = net_address_list; |
| 82 } else { | 63 } else { |
| 83 canonical_name_.clear(); | 64 canonical_name_.clear(); |
| 84 net_address_list_.clear(); | 65 net_address_list_.clear(); |
| 85 } | 66 } |
| 86 | 67 |
| 87 resolve_callback_->Run(succeeded ? PP_OK : PP_ERROR_FAILED); | 68 resolve_callback_->Run(succeeded ? PP_OK : PP_ERROR_FAILED); |
| 88 } | 69 } |
| 89 | 70 |
| 90 uint32 PPB_HostResolver_Shared::GenerateHostResolverID() { | |
| 91 static uint32 host_resolver_id = 0; | |
| 92 return host_resolver_id++; | |
| 93 } | |
| 94 | |
| 95 bool PPB_HostResolver_Shared::ResolveInProgress() const { | 71 bool PPB_HostResolver_Shared::ResolveInProgress() const { |
| 96 return TrackedCallback::IsPending(resolve_callback_); | 72 return TrackedCallback::IsPending(resolve_callback_); |
| 97 } | 73 } |
| 98 | 74 |
| 99 } // namespace ppapi | 75 } // namespace ppapi |
| OLD | NEW |