Skip to content

Commit

Permalink
Update ppapi/ to use scoped_refptr<T>::get() rather than implicit "op…
Browse files Browse the repository at this point in the history
…erator T*"

Linux fixes

BUG=110610
TBR=darin

Review URL: https://chromiumcodereview.appspot.com/15806016

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203629 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
rsleevi@chromium.org committed Jun 2, 2013
1 parent 9ce15e1 commit f0c8624
Show file tree
Hide file tree
Showing 22 changed files with 55 additions and 61 deletions.
2 changes: 1 addition & 1 deletion ppapi/host/resource_message_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void ResourceMessageFilter::OnFilterDestroyed() {
bool ResourceMessageFilter::HandleMessage(const IPC::Message& msg,
HostMessageContext* context) {
scoped_refptr<base::TaskRunner> runner = OverrideTaskRunnerForMessage(msg);
if (runner) {
if (runner.get()) {
// TODO(raymes): We need to make a copy so the context can be used on other
// threads. It would be better to have a thread-safe refcounted context.
HostMessageContext context_copy = *context;
Expand Down
2 changes: 1 addition & 1 deletion ppapi/proxy/pdf_resource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void PDFResource::HistogramPDFPageCount(int count) {
void PDFResource::UserMetricsRecordAction(const PP_Var& action) {
scoped_refptr<ppapi::StringVar> action_str(
ppapi::StringVar::FromPPVar(action));
if (action_str) {
if (action_str.get()) {
Post(RENDERER,
PpapiHostMsg_PDF_UserMetricsRecordAction(action_str->value()));
}
Expand Down
2 changes: 1 addition & 1 deletion ppapi/proxy/plugin_dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ InstanceData::InstanceData()

InstanceData::~InstanceData() {
// Run any pending mouse lock callback to prevent leaks.
if (mouse_lock_callback)
if (mouse_lock_callback.get())
mouse_lock_callback->Abort();
}

Expand Down
2 changes: 1 addition & 1 deletion ppapi/proxy/plugin_globals.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ PluginGlobals::~PluginGlobals() {
// count, so this will delete the MessageLoop resource. We do this before
// we clear plugin_globals_, because the Resource destructor tries to access
// this PluginGlobals.
DCHECK(!loop_for_main_thread_ || loop_for_main_thread_->HasOneRef());
DCHECK(!loop_for_main_thread_.get() || loop_for_main_thread_->HasOneRef());
loop_for_main_thread_ = NULL;
}
plugin_globals_ = NULL;
Expand Down
2 changes: 1 addition & 1 deletion ppapi/proxy/plugin_var_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ PP_Var PluginVarTracker::ReceiveObjectPassRef(const PP_Var& host_var,
// two references on our behalf. We want to transfer that extra reference
// to our list. This means we addref in the plugin, and release the extra
// one in the renderer.
SendReleaseObjectMsg(*object);
SendReleaseObjectMsg(*object.get());
}
info.ref_count++;
return ret;
Expand Down
16 changes: 6 additions & 10 deletions ppapi/proxy/plugin_var_tracker_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,9 @@ TEST_F(PluginVarTrackerTest, PluginObjectInstanceDeleted) {
// Make a var with one reference.
scoped_refptr<ProxyObjectVar> object(
new ProxyObjectVar(plugin_dispatcher(), host_object.value.as_id));
PP_Var plugin_var = MakeObject(var_tracker().AddVar(object));
var_tracker().PluginImplementedObjectCreated(pp_instance,
plugin_var,
&mark_on_deallocate_class,
user_data);
PP_Var plugin_var = MakeObject(var_tracker().AddVar(object.get()));
var_tracker().PluginImplementedObjectCreated(
pp_instance, plugin_var, &mark_on_deallocate_class, user_data);

// Release the plugin ref to the var. WebKit hasn't called destroy so
// we won't get a destroy call.
Expand All @@ -230,11 +228,9 @@ TEST_F(PluginVarTrackerTest, PluginObjectLeaked) {
// Make a var with one reference.
scoped_refptr<ProxyObjectVar> object(
new ProxyObjectVar(plugin_dispatcher(), host_object.value.as_id));
PP_Var plugin_var = MakeObject(var_tracker().AddVar(object));
var_tracker().PluginImplementedObjectCreated(pp_instance,
plugin_var,
&mark_on_deallocate_class,
user_data);
PP_Var plugin_var = MakeObject(var_tracker().AddVar(object.get()));
var_tracker().PluginImplementedObjectCreated(
pp_instance, plugin_var, &mark_on_deallocate_class, user_data);

// Destroy the instance. This should not call deallocate since the plugin
// still has a ref.
Expand Down
2 changes: 1 addition & 1 deletion ppapi/proxy/ppb_instance_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ Resource* PPB_Instance_Proxy::GetSingletonResource(PP_Instance instance,
#endif // !defined(OS_NACL) && !defined(NACL_WIN64)
}

if (!new_singleton) {
if (!new_singleton.get()) {
// Getting here implies that a constructor is missing in the above switch.
NOTREACHED();
return NULL;
Expand Down
7 changes: 3 additions & 4 deletions ppapi/proxy/ppb_message_loop_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,9 @@ void MessageLoopResource::PostClosure(
const tracked_objects::Location& from_here,
const base::Closure& closure,
int64 delay_ms) {
if (loop_proxy_) {
loop_proxy_->PostDelayedTask(from_here,
closure,
base::TimeDelta::FromMilliseconds(delay_ms));
if (loop_proxy_.get()) {
loop_proxy_->PostDelayedTask(
from_here, closure, base::TimeDelta::FromMilliseconds(delay_ms));
} else {
TaskInfo info;
info.from_here = FROM_HERE;
Expand Down
6 changes: 3 additions & 3 deletions ppapi/proxy/resource_creation_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ PP_Resource ResourceCreationProxy::CreateFileChooser(
PP_FileChooserMode_Dev mode,
const PP_Var& accept_types) {
scoped_refptr<StringVar> string_var = StringVar::FromPPVar(accept_types);
std::string str = string_var ? string_var->value() : std::string();
return (new FileChooserResource(GetConnection(), instance, mode,
str.c_str()))->GetReference();
std::string str = string_var.get() ? string_var->value() : std::string();
return (new FileChooserResource(GetConnection(), instance, mode, str.c_str()))
->GetReference();
}

PP_Resource ResourceCreationProxy::CreateGraphics2D(PP_Instance instance,
Expand Down
6 changes: 3 additions & 3 deletions ppapi/proxy/serialized_var.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ SerializedVar::Inner::~Inner() {
}

PP_Var SerializedVar::Inner::GetVar() {
DCHECK(serialization_rules_);
DCHECK(serialization_rules_.get());

#if defined(NACL_WIN64)
NOTREACHED();
Expand All @@ -74,7 +74,7 @@ PP_Var SerializedVar::Inner::GetVar() {
void SerializedVar::Inner::SetVar(PP_Var var) {
// Sanity check, when updating the var we should have received a
// serialization rules pointer already.
DCHECK(serialization_rules_);
DCHECK(serialization_rules_.get());
var_ = var;
raw_var_data_.reset(NULL);
}
Expand All @@ -100,7 +100,7 @@ void SerializedVar::Inner::WriteToMessage(IPC::Message* m) const {
// that returns a var. This means the message handler didn't write to the
// output parameter, or possibly you used the wrong helper class
// (normally SerializedVarReturnValue).
DCHECK(serialization_rules_);
DCHECK(serialization_rules_.get());

#ifndef NDEBUG
// We should only be serializing something once.
Expand Down
2 changes: 1 addition & 1 deletion ppapi/proxy/serialized_var.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class PPAPI_PROXY_EXPORT SerializedVar {
~Inner();

VarSerializationRules* serialization_rules() {
return serialization_rules_;
return serialization_rules_.get();
}
void set_serialization_rules(VarSerializationRules* serialization_rules) {
serialization_rules_ = serialization_rules;
Expand Down
2 changes: 1 addition & 1 deletion ppapi/proxy/truetype_font_singleton_resource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ int32_t TrueTypeFontSingletonResource::GetFontsInFamily(
const scoped_refptr<TrackedCallback>& callback) {
scoped_refptr<StringVar> family_var = StringVar::FromPPVar(family);
const uint32_t kMaxFamilySizeInBytes = 1024;
if (!family_var || family_var->value().size() > kMaxFamilySizeInBytes)
if (!family_var.get() || family_var->value().size() > kMaxFamilySizeInBytes)
return PP_ERROR_BADARGUMENT;
Call<PpapiPluginMsg_TrueTypeFontSingleton_GetFontsInFamilyReply>(BROWSER,
PpapiHostMsg_TrueTypeFontSingleton_GetFontsInFamily(family_var->value()),
Expand Down
2 changes: 1 addition & 1 deletion ppapi/proxy/url_loader_resource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ void URLLoaderResource::SetDefersLoading(bool defers_loading) {

int32_t URLLoaderResource::ValidateCallback(
scoped_refptr<TrackedCallback> callback) {
DCHECK(callback);
DCHECK(callback.get());
if (TrackedCallback::IsPending(pending_callback_))
return PP_ERROR_INPROGRESS;
return PP_OK;
Expand Down
2 changes: 1 addition & 1 deletion ppapi/proxy/video_destination_resource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int32_t VideoDestinationResource::Open(

scoped_refptr<StringVar> stream_url_var = StringVar::FromPPVar(stream_url);
const uint32_t kMaxStreamIdSizeInBytes = 16384;
if (!stream_url_var ||
if (!stream_url_var.get() ||
stream_url_var->value().size() > kMaxStreamIdSizeInBytes)
return PP_ERROR_BADARGUMENT;
Call<PpapiPluginMsg_VideoDestination_OpenReply>(RENDERER,
Expand Down
2 changes: 1 addition & 1 deletion ppapi/proxy/video_source_resource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int32_t VideoSourceResource::Open(

scoped_refptr<StringVar> stream_url_var = StringVar::FromPPVar(stream_url);
const uint32_t kMaxStreamIdSizeInBytes = 16384;
if (!stream_url_var ||
if (!stream_url_var.get() ||
stream_url_var->value().size() > kMaxStreamIdSizeInBytes)
return PP_ERROR_BADARGUMENT;
Call<PpapiPluginMsg_VideoSource_OpenReply>(RENDERER,
Expand Down
20 changes: 10 additions & 10 deletions ppapi/proxy/websocket_resource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ int32_t WebSocketResource::Connect(

// Get the URL.
url_ = StringVar::FromPPVar(url);
if (!url_)
if (!url_.get())
return PP_ERROR_BADARGUMENT;

// Get the protocols.
Expand All @@ -100,7 +100,7 @@ int32_t WebSocketResource::Connect(
scoped_refptr<StringVar> protocol(StringVar::FromPPVar(protocols[i]));

// Check invalid and empty entries.
if (!protocol || !protocol->value().length())
if (!protocol.get() || !protocol->value().length())
return PP_ERROR_BADARGUMENT;

// Check duplicated protocol entries.
Expand Down Expand Up @@ -157,7 +157,7 @@ int32_t WebSocketResource::Close(uint16_t code,
if (reason.type != PP_VARTYPE_UNDEFINED) {
// Validate |reason|.
reason_string_var = StringVar::FromPPVar(reason);
if (!reason_string_var ||
if (!reason_string_var.get() ||
reason_string_var->value().size() > kMaxReasonSizeInBytes)
return PP_ERROR_BADARGUMENT;
reason_string = reason_string_var->value();
Expand Down Expand Up @@ -246,12 +246,12 @@ int32_t WebSocketResource::SendMessage(const PP_Var& message) {
uint64_t payload_size = 0;
if (message.type == PP_VARTYPE_STRING) {
scoped_refptr<StringVar> message_string = StringVar::FromPPVar(message);
if (message_string)
if (message_string.get())
payload_size += message_string->value().length();
} else if (message.type == PP_VARTYPE_ARRAY_BUFFER) {
scoped_refptr<ArrayBufferVar> message_array_buffer =
ArrayBufferVar::FromPPVar(message);
if (message_array_buffer)
if (message_array_buffer.get())
payload_size += message_array_buffer->ByteLength();
} else {
// TODO(toyoshim): Support Blob.
Expand All @@ -268,14 +268,14 @@ int32_t WebSocketResource::SendMessage(const PP_Var& message) {
if (message.type == PP_VARTYPE_STRING) {
// Convert message to std::string, then send it.
scoped_refptr<StringVar> message_string = StringVar::FromPPVar(message);
if (!message_string)
if (!message_string.get())
return PP_ERROR_BADARGUMENT;
Post(RENDERER, PpapiHostMsg_WebSocket_SendText(message_string->value()));
} else if (message.type == PP_VARTYPE_ARRAY_BUFFER) {
// Convert message to std::vector<uint8_t>, then send it.
scoped_refptr<ArrayBufferVar> message_arraybuffer =
ArrayBufferVar::FromPPVar(message);
if (!message_arraybuffer)
if (!message_arraybuffer.get())
return PP_ERROR_BADARGUMENT;
uint8_t* message_data = static_cast<uint8_t*>(message_arraybuffer->Map());
uint32 message_length = message_arraybuffer->ByteLength();
Expand All @@ -298,7 +298,7 @@ uint16_t WebSocketResource::GetCloseCode() {
}

PP_Var WebSocketResource::GetCloseReason() {
if (!close_reason_)
if (!close_reason_.get())
return empty_string_->GetPPVar();
return close_reason_->GetPPVar();
}
Expand All @@ -312,7 +312,7 @@ PP_Var WebSocketResource::GetExtensions() {
}

PP_Var WebSocketResource::GetProtocol() {
if (!protocol_)
if (!protocol_.get())
return empty_string_->GetPPVar();
return protocol_->GetPPVar();
}
Expand All @@ -322,7 +322,7 @@ PP_WebSocketReadyState WebSocketResource::GetReadyState() {
}

PP_Var WebSocketResource::GetURL() {
if (!url_)
if (!url_.get())
return empty_string_->GetPPVar();
return url_->GetPPVar();
}
Expand Down
2 changes: 1 addition & 1 deletion ppapi/shared_impl/thread_aware_callback.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ bool ThreadAwareCallbackBase::HasTargetLoop() {

void ThreadAwareCallbackBase::InternalRunOnTargetThread(
const base::Closure& closure) {
if (target_loop_ != PpapiGlobals::Get()->GetCurrentMessageLoop()) {
if (target_loop_.get() != PpapiGlobals::Get()->GetCurrentMessageLoop()) {
target_loop_->PostClosure(
FROM_HERE,
RunWhileLocked(base::Bind(&Core::RunIfNotAborted, core_, closure)),
Expand Down
6 changes: 3 additions & 3 deletions ppapi/shared_impl/tracked_callback.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ void TrackedCallback::Run(int32_t result) {
} else {
// If there's a target_loop_, and we're not on the right thread, we need to
// post to target_loop_.
if (target_loop_ &&
target_loop_ != PpapiGlobals::Get()->GetCurrentMessageLoop()) {
if (target_loop_.get() &&
target_loop_.get() != PpapiGlobals::Get()->GetCurrentMessageLoop()) {
PostRun(result);
return;
}
Expand Down Expand Up @@ -152,7 +152,7 @@ void TrackedCallback::PostRun(int32_t result) {

base::Closure callback_closure(
RunWhileLocked(base::Bind(&TrackedCallback::Run, this, result)));
if (!target_loop_) {
if (!target_loop_.get()) {
// We must be running in-process and on the main thread (the Enter
// classes protect against having a null target_loop_ otherwise).
DCHECK(IsMainThread());
Expand Down
4 changes: 1 addition & 3 deletions ppapi/shared_impl/tracked_callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,7 @@ class PPAPI_SHARED_EXPORT TrackedCallback
return (callback_.func &&
(callback_.flags & PP_COMPLETIONCALLBACK_FLAG_OPTIONAL));
}
bool has_null_target_loop() const {
return target_loop_ == NULL;
}
bool has_null_target_loop() const { return target_loop_.get() == NULL; }

private:
// TrackedCallback and EnterBase manage dealing with how to invoke callbacks
Expand Down
6 changes: 3 additions & 3 deletions ppapi/shared_impl/var.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ PP_Var StringVar::StringToPPVar(const std::string& var) {
// static
PP_Var StringVar::StringToPPVar(const char* data, uint32 len) {
scoped_refptr<StringVar> str(new StringVar(data, len));
if (!str || !IsStringUTF8(str->value()))
if (!str.get() || !IsStringUTF8(str->value()))
return PP_MakeNull();
return str->GetPPVar();
}
Expand All @@ -168,7 +168,7 @@ StringVar* StringVar::FromPPVar(PP_Var var) {
return NULL;
scoped_refptr<Var> var_object(
PpapiGlobals::Get()->GetVarTracker()->GetVar(var));
if (!var_object)
if (!var_object.get())
return NULL;
return var_object->AsStringVar();
}
Expand Down Expand Up @@ -202,7 +202,7 @@ ArrayBufferVar* ArrayBufferVar::FromPPVar(PP_Var var) {
return NULL;
scoped_refptr<Var> var_object(
PpapiGlobals::Get()->GetVarTracker()->GetVar(var));
if (!var_object)
if (!var_object.get())
return NULL;
return var_object->AsArrayBufferVar();
}
Expand Down
4 changes: 2 additions & 2 deletions ppapi/shared_impl/var_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ PP_Var VarTracker::MakeArrayBufferPPVar(uint32 size_in_bytes) {
CheckThreadingPreconditions();

scoped_refptr<ArrayBufferVar> array_buffer(CreateArrayBuffer(size_in_bytes));
if (!array_buffer)
if (!array_buffer.get())
return PP_MakeNull();
return array_buffer->GetPPVar();
}
Expand Down Expand Up @@ -229,7 +229,7 @@ PP_Var VarTracker::MakeArrayBufferPPVar(uint32 size_in_bytes,

scoped_refptr<ArrayBufferVar> array_buffer(
CreateShmArrayBuffer(size_in_bytes, handle));
if (!array_buffer)
if (!array_buffer.get())
return PP_MakeNull();
return array_buffer->GetPPVar();
}
Expand Down
Loading

0 comments on commit f0c8624

Please sign in to comment.