Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: ppapi/shared_impl/private/ppb_host_resolver_shared.cc

Issue 10081020: PPAPI: Make blocking completion callbacks work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: export AssertLockHeld Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 thunk::PPB_HostResolver_Private_API* 47 thunk::PPB_HostResolver_Private_API*
48 PPB_HostResolver_Shared::AsPPB_HostResolver_Private_API() { 48 PPB_HostResolver_Shared::AsPPB_HostResolver_Private_API() {
49 return this; 49 return this;
50 } 50 }
51 51
52 int32_t PPB_HostResolver_Shared::Resolve( 52 int32_t PPB_HostResolver_Shared::Resolve(
53 const char* host, 53 const char* host,
54 uint16_t port, 54 uint16_t port,
55 const PP_HostResolver_Private_Hint* hint, 55 const PP_HostResolver_Private_Hint* hint,
56 PP_CompletionCallback callback) { 56 scoped_refptr<TrackedCallback> callback) {
57 if (!host) 57 if (!host)
58 return PP_ERROR_BADARGUMENT; 58 return PP_ERROR_BADARGUMENT;
59 if (!callback.func)
60 return PP_ERROR_BLOCKS_MAIN_THREAD;
61 if (ResolveInProgress()) 59 if (ResolveInProgress())
62 return PP_ERROR_INPROGRESS; 60 return PP_ERROR_INPROGRESS;
63 61
64 resolve_callback_ = new TrackedCallback(this, callback); 62 resolve_callback_ = callback;
65 63
66 HostPortPair host_port; 64 HostPortPair host_port;
67 host_port.host = host; 65 host_port.host = host;
68 host_port.port = port; 66 host_port.port = port;
69 67
70 SendResolve(host_port, hint); 68 SendResolve(host_port, hint);
71 return PP_OK_COMPLETIONPENDING; 69 return PP_OK_COMPLETIONPENDING;
72 } 70 }
73 71
74 PP_Var PPB_HostResolver_Shared::GetCanonicalName() { 72 PP_Var PPB_HostResolver_Shared::GetCanonicalName() {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 uint32 PPB_HostResolver_Shared::GenerateHostResolverID() { 106 uint32 PPB_HostResolver_Shared::GenerateHostResolverID() {
109 static uint32 host_resolver_id = 0; 107 static uint32 host_resolver_id = 0;
110 return host_resolver_id++; 108 return host_resolver_id++;
111 } 109 }
112 110
113 bool PPB_HostResolver_Shared::ResolveInProgress() const { 111 bool PPB_HostResolver_Shared::ResolveInProgress() const {
114 return TrackedCallback::IsPending(resolve_callback_); 112 return TrackedCallback::IsPending(resolve_callback_);
115 } 113 }
116 114
117 } // namespace ppapi 115 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/shared_impl/private/ppb_host_resolver_shared.h ('k') | ppapi/shared_impl/private/ppb_tcp_server_socket_shared.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698