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

Unified Diff: webkit/plugins/ppapi/ppb_transport_impl.cc

Issue 7669055: Remove webkit::ppapi::Resource. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix self-assignment Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: webkit/plugins/ppapi/ppb_transport_impl.cc
diff --git a/webkit/plugins/ppapi/ppb_transport_impl.cc b/webkit/plugins/ppapi/ppb_transport_impl.cc
index 3048c60a3f5af5a68122e3a26ca4de21065159f6..9f1630fbf61bed1dc90743a36ddc8c6a2c752190 100644
--- a/webkit/plugins/ppapi/ppb_transport_impl.cc
+++ b/webkit/plugins/ppapi/ppb_transport_impl.cc
@@ -16,6 +16,7 @@
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
+#include "webkit/plugins/ppapi/resource_helper.h"
using ppapi::StringVar;
using ppapi::thunk::PPB_Transport_API;
@@ -47,7 +48,7 @@ int MapNetError(int result) {
} // namespace
-PPB_Transport_Impl::PPB_Transport_Impl(PluginInstance* instance)
+PPB_Transport_Impl::PPB_Transport_Impl(PP_Instance instance)
: Resource(instance),
started_(false),
writable_(false),
@@ -61,7 +62,7 @@ PPB_Transport_Impl::~PPB_Transport_Impl() {
}
// static
-PP_Resource PPB_Transport_Impl::Create(PluginInstance* instance,
+PP_Resource PPB_Transport_Impl::Create(PP_Instance instance,
const char* name,
const char* proto) {
scoped_refptr<PPB_Transport_Impl> t(new PPB_Transport_Impl(instance));
@@ -86,7 +87,8 @@ bool PPB_Transport_Impl::Init(const char* name, const char* proto) {
return false;
}
- p2p_transport_.reset(instance()->delegate()->CreateP2PTransport());
+ p2p_transport_.reset(
+ ResourceHelper::GetPluginDelegate(this)->CreateP2PTransport());
return p2p_transport_.get() != NULL;
}
@@ -113,8 +115,9 @@ int32_t PPB_Transport_Impl::Connect(PP_CompletionCallback callback) {
started_ = true;
+ PluginModule* module = ResourceHelper::GetPluginModule(this);
connect_callback_ = new TrackedCompletionCallback(
- instance()->module()->GetCallbackTracker(), pp_resource(), callback);
+ module->GetCallbackTracker(), pp_resource(), callback);
return PP_OK_COMPLETIONPENDING;
}
@@ -126,15 +129,16 @@ int32_t PPB_Transport_Impl::GetNextAddress(PP_Var* address,
if (next_address_callback_.get() && !next_address_callback_->completed())
return PP_ERROR_INPROGRESS;
+ PluginModule* module = ResourceHelper::GetPluginModule(this);
if (!local_candidates_.empty()) {
- *address = StringVar::StringToPPVar(instance()->module()->pp_module(),
+ *address = StringVar::StringToPPVar(module->pp_module(),
local_candidates_.front());
local_candidates_.pop_front();
return PP_OK;
}
next_address_callback_ = new TrackedCompletionCallback(
- instance()->module()->GetCallbackTracker(), pp_resource(), callback);
+ module->GetCallbackTracker(), pp_resource(), callback);
return PP_OK_COMPLETIONPENDING;
}
@@ -162,12 +166,14 @@ int32_t PPB_Transport_Impl::Recv(void* data, uint32_t len,
if (!channel)
return PP_ERROR_FAILED;
+ PluginModule* module = ResourceHelper::GetPluginModule(this);
+
scoped_refptr<net::IOBuffer> buffer =
new net::WrappedIOBuffer(static_cast<const char*>(data));
int result = MapNetError(channel->Read(buffer, len, &channel_read_callback_));
if (result == PP_OK_COMPLETIONPENDING) {
recv_callback_ = new TrackedCompletionCallback(
- instance()->module()->GetCallbackTracker(), pp_resource(), callback);
+ module->GetCallbackTracker(), pp_resource(), callback);
}
return result;
@@ -185,13 +191,15 @@ int32_t PPB_Transport_Impl::Send(const void* data, uint32_t len,
if (!channel)
return PP_ERROR_FAILED;
+ PluginModule* module = ResourceHelper::GetPluginModule(this);
+
scoped_refptr<net::IOBuffer> buffer =
new net::WrappedIOBuffer(static_cast<const char*>(data));
int result = MapNetError(channel->Write(buffer, len,
&channel_write_callback_));
if (result == PP_OK_COMPLETIONPENDING) {
send_callback_ = new TrackedCompletionCallback(
- instance()->module()->GetCallbackTracker(), pp_resource(), callback);
+ module->GetCallbackTracker(), pp_resource(), callback);
}
return result;
@@ -202,7 +210,7 @@ int32_t PPB_Transport_Impl::Close() {
return PP_ERROR_FAILED;
p2p_transport_.reset();
- instance()->module()->GetCallbackTracker()->AbortAll();
+ ResourceHelper::GetPluginModule(this)->GetCallbackTracker()->AbortAll();
return PP_OK;
}

Powered by Google App Engine
This is Rietveld 408576698