Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ppapi/proxy/network_proxy_resource.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "ppapi/proxy/dispatch_reply_message.h" | |
| 9 #include "ppapi/proxy/ppapi_messages.h" | |
| 10 #include "ppapi/shared_impl/tracked_callback.h" | |
| 11 #include "ppapi/shared_impl/var.h" | |
| 12 | |
| 13 namespace ppapi { | |
| 14 namespace proxy { | |
| 15 | |
| 16 NetworkProxyResource::NetworkProxyResource(Connection connection, | |
| 17 PP_Instance instance) | |
| 18 : PluginResource(connection, instance) { | |
| 19 SendCreate(BROWSER, PpapiHostMsg_NetworkProxy_Create()); | |
| 20 } | |
| 21 | |
| 22 NetworkProxyResource::~NetworkProxyResource() { | |
| 23 } | |
| 24 | |
| 25 thunk::PPB_NetworkProxy_API* NetworkProxyResource::AsPPB_NetworkProxy_API() { | |
| 26 return this; | |
| 27 } | |
| 28 | |
| 29 int32_t NetworkProxyResource::GetProxyForURL( | |
| 30 PP_Instance /* instance */, | |
| 31 PP_Var url, | |
| 32 PP_Var* proxy_string, | |
| 33 scoped_refptr<TrackedCallback> callback) { | |
| 34 StringVar* string_url = StringVar::FromPPVar(url); | |
| 35 if (!string_url) | |
| 36 return PP_ERROR_BADARGUMENT; | |
| 37 Call<PpapiPluginMsg_NetworkProxy_GetProxyForURLReply>( | |
| 38 BROWSER, | |
| 39 PpapiHostMsg_NetworkProxy_GetProxyForURL(string_url->value()), | |
| 40 base::Bind(&NetworkProxyResource::OnPluginMsgGetProxyForURLReply, | |
| 41 base::Unretained(this), | |
| 42 base::Unretained(proxy_string), | |
| 43 callback)); | |
| 44 return PP_OK_COMPLETIONPENDING; | |
| 45 } | |
| 46 | |
| 47 void NetworkProxyResource::OnPluginMsgGetProxyForURLReply( | |
| 48 PP_Var* proxy_string_out_param, | |
| 49 scoped_refptr<TrackedCallback> callback, | |
| 50 const ResourceMessageReplyParams& params, | |
| 51 const std::string& proxy_string) { | |
| 52 DCHECK(TrackedCallback::IsPending(callback)); | |
|
yzshen1
2013/06/18 04:41:26
It seems better to me to still check whether it is
dmichael (off chromium)
2013/06/18 22:22:43
(This is also true of using base::Unretained(this)
yzshen1
2013/06/19 16:50:59
There is a comment in plugin_resource.h about pass
| |
| 53 if (params.result() == PP_OK) { | |
| 54 *proxy_string_out_param = (new StringVar(proxy_string))->GetPPVar(); | |
| 55 } | |
| 56 callback->Run(params.result()); | |
| 57 } | |
| 58 | |
| 59 } // namespace proxy | |
| 60 } // namespace ppapi | |
| OLD | NEW |