| 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 "net/base/sys_addrinfo.h" | 10 #include "net/base/sys_addrinfo.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 thunk::PPB_HostResolver_Private_API* | 48 thunk::PPB_HostResolver_Private_API* |
| 49 PPB_HostResolver_Shared::AsPPB_HostResolver_Private_API() { | 49 PPB_HostResolver_Shared::AsPPB_HostResolver_Private_API() { |
| 50 return this; | 50 return this; |
| 51 } | 51 } |
| 52 | 52 |
| 53 int32_t PPB_HostResolver_Shared::Resolve( | 53 int32_t PPB_HostResolver_Shared::Resolve( |
| 54 const char* host, | 54 const char* host, |
| 55 uint16_t port, | 55 uint16_t port, |
| 56 const PP_HostResolver_Private_Hint* hint, | 56 const PP_HostResolver_Private_Hint* hint, |
| 57 PP_CompletionCallback callback) { | 57 ApiCallbackType callback) { |
| 58 if (!host) | 58 if (!host) |
| 59 return PP_ERROR_BADARGUMENT; | 59 return PP_ERROR_BADARGUMENT; |
| 60 if (!callback.func) | |
| 61 return PP_ERROR_BLOCKS_MAIN_THREAD; | |
| 62 if (ResolveInProgress()) | 60 if (ResolveInProgress()) |
| 63 return PP_ERROR_INPROGRESS; | 61 return PP_ERROR_INPROGRESS; |
| 64 | 62 |
| 65 resolve_callback_ = new TrackedCallback(this, callback); | 63 resolve_callback_ = callback; |
| 66 | 64 |
| 67 HostPortPair host_port; | 65 HostPortPair host_port; |
| 68 host_port.host = host; | 66 host_port.host = host; |
| 69 host_port.port = port; | 67 host_port.port = port; |
| 70 | 68 |
| 71 SendResolve(host_port, hint); | 69 SendResolve(host_port, hint); |
| 72 return PP_OK_COMPLETIONPENDING; | 70 return PP_OK_COMPLETIONPENDING; |
| 73 } | 71 } |
| 74 | 72 |
| 75 PP_Var PPB_HostResolver_Shared::GetCanonicalName() { | 73 PP_Var PPB_HostResolver_Shared::GetCanonicalName() { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 uint32 PPB_HostResolver_Shared::GenerateHostResolverID() { | 107 uint32 PPB_HostResolver_Shared::GenerateHostResolverID() { |
| 110 static uint32 host_resolver_id = 0; | 108 static uint32 host_resolver_id = 0; |
| 111 return host_resolver_id++; | 109 return host_resolver_id++; |
| 112 } | 110 } |
| 113 | 111 |
| 114 bool PPB_HostResolver_Shared::ResolveInProgress() const { | 112 bool PPB_HostResolver_Shared::ResolveInProgress() const { |
| 115 return TrackedCallback::IsPending(resolve_callback_); | 113 return TrackedCallback::IsPending(resolve_callback_); |
| 116 } | 114 } |
| 117 | 115 |
| 118 } // namespace ppapi | 116 } // namespace ppapi |
| OLD | NEW |