Commit 37594cbf authored by kylechar's avatar kylechar Committed by Commit Bot

Fix assigning NULL to scoped_refptr

Update code where NULL or 0 is assigned to a scoped_refptr to reset it. Just
call reset() instead. If operator=(std::nullptr_t) is added these assignments
become ambiguous.

This CL was uploaded by git cl split.

R=raymes@chromium.org

Bug: 1024981
Change-Id: Ia3973b95ed896197678e47de7697f68c3ab2e784
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1918156
Auto-Submit: kylechar <kylechar@chromium.org>
Reviewed-by: default avatarRaymes Khoury <raymes@chromium.org>
Commit-Queue: kylechar <kylechar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715710}
parent a82404ca
......@@ -402,7 +402,7 @@ void FileIOResource::Close() {
}
if (file_holder_.get())
file_holder_ = NULL;
file_holder_.reset();
Post(BROWSER, PpapiHostMsg_FileIO_Close(
FileGrowth(max_written_offset_, append_mode_write_amount_)));
......@@ -669,7 +669,7 @@ void FileIOResource::OnPluginMsgOpenFileComplete(
FileIOStateManager::OPERATION_EXCLUSIVE);
// Release the FileRef resource.
file_ref_ = NULL;
file_ref_.reset();
int32_t result = params.result();
if (result == PP_OK) {
state_manager_.SetOpenSucceed();
......
......@@ -142,7 +142,7 @@ void MediaStreamAudioTrackResource::Close() {
if (TrackedCallback::IsPending(get_buffer_callback_)) {
*get_buffer_output_ = 0;
get_buffer_callback_->PostAbort();
get_buffer_callback_ = NULL;
get_buffer_callback_.reset();
get_buffer_output_ = 0;
}
......@@ -183,7 +183,7 @@ void MediaStreamAudioTrackResource::ReleaseBuffers() {
// Just invalidate and release VideoBufferResorce, but keep PP_Resource.
// So plugin can still use |RecycleBuffer()|.
it->second->Invalidate();
it->second = NULL;
it->second.reset();
}
}
......
......@@ -151,7 +151,7 @@ void MediaStreamVideoTrackResource::Close() {
if (TrackedCallback::IsPending(get_frame_callback_)) {
*get_frame_output_ = 0;
get_frame_callback_->PostAbort();
get_frame_callback_ = NULL;
get_frame_callback_.reset();
get_frame_output_ = 0;
}
......@@ -203,7 +203,7 @@ void MediaStreamVideoTrackResource::ReleaseFrames() {
// Just invalidate and release VideoFrameResorce, but keep PP_Resource.
// So plugin can still use |RecycleFrame()|.
it->second->Invalidate();
it->second = NULL;
it->second.reset();
}
}
......
......@@ -97,7 +97,7 @@ PluginGlobals::~PluginGlobals() {
// we clear plugin_globals_, because the Resource destructor tries to access
// this PluginGlobals.
DCHECK(!loop_for_main_thread_.get() || loop_for_main_thread_->HasOneRef());
loop_for_main_thread_ = NULL;
loop_for_main_thread_.reset();
}
plugin_globals_ = NULL;
}
......
......@@ -209,7 +209,7 @@ TEST_F(PluginVarTrackerTest, PluginObjectInstanceDeleted) {
// Release the plugin ref to the var. WebKit hasn't called destroy so
// we won't get a destroy call.
object = NULL;
object.reset();
var_tracker().ReleaseVar(plugin_var);
EXPECT_EQ(0, deallocate_called);
......@@ -243,7 +243,7 @@ TEST_F(PluginVarTrackerTest, PluginObjectLeaked) {
// Release the plugin ref to the var. Since the instance is gone this should
// call deallocate.
object = NULL;
object.reset();
var_tracker().ReleaseVar(plugin_var);
EXPECT_EQ(1, deallocate_called);
}
......
......@@ -371,12 +371,12 @@ void PluginProxyMultiThreadTest::RunTest() {
// The destruction requires a valid PpapiGlobals instance, so we should
// explicitly release it.
secondary_thread_message_loop_ = NULL;
secondary_thread_message_loop_.reset();
}
secondary_thread_.reset(NULL);
nested_main_thread_message_loop_.reset(NULL);
main_thread_task_runner_ = NULL;
main_thread_task_runner_.reset();
}
void PluginProxyMultiThreadTest::CheckOnThread(ThreadType thread_type) {
......
......@@ -122,7 +122,7 @@ int32_t MessageLoopResource::Run() {
run_loop_ = previous_run_loop;
if (should_destroy_ && nested_invocations_ == 0) {
task_runner_ = NULL;
task_runner_.reset();
single_thread_task_executor_.reset();
destroyed_ = true;
}
......@@ -171,7 +171,7 @@ MessageLoopResource* MessageLoopResource::GetCurrent() {
void MessageLoopResource::DetachFromThread() {
// Note that the task executor must be destroyed on the thread it was created
// on.
task_runner_ = NULL;
task_runner_.reset();
single_thread_task_executor_.reset();
// Cancel out the AddRef in AttachToCurrentThread().
......
......@@ -308,7 +308,7 @@ void TCPSocketResourceBase::CloseImpl() {
PostAbortIfNecessary(&accept_callback_);
read_buffer_ = NULL;
bytes_to_read_ = -1;
server_certificate_ = NULL;
server_certificate_.reset();
accepted_tcp_socket_ = NULL;
}
......
......@@ -102,7 +102,7 @@ void UMAPrivateResource::OnPluginMsgIsCrashReportingEnabled(
const ResourceMessageReplyParams& params) {
if (TrackedCallback::IsPending(pending_callback_))
pending_callback_->Run(params.result());
pending_callback_ = NULL;
pending_callback_.reset();
}
} // namespace proxy
......
......@@ -335,10 +335,10 @@ int32_t VideoDecoderResource::Reset(scoped_refptr<TrackedCallback> callback) {
// to avoid reentering the plugin.
if (TrackedCallback::IsPending(decode_callback_))
decode_callback_->PostAbort();
decode_callback_ = NULL;
decode_callback_.reset();
if (TrackedCallback::IsPending(get_picture_callback_))
get_picture_callback_->PostAbort();
get_picture_callback_ = NULL;
get_picture_callback_.reset();
Call<PpapiPluginMsg_VideoDecoder_ResetReply>(
RENDERER,
PpapiHostMsg_VideoDecoder_Reset(),
......
......@@ -72,7 +72,7 @@ TEST_F(ResourceTrackerTest, LastPluginRef) {
EXPECT_EQ(1, mock_resource_alive_count);
resource_tracker().DidDeleteInstance(instance);
resource = NULL;
resource.reset();
EXPECT_FALSE(resource_tracker().GetResource(pp_resource));
}
......@@ -117,7 +117,7 @@ TEST_F(ResourceTrackerTest, InstanceDeletedWithBothRefed) {
EXPECT_EQ(1, instance_was_deleted_count);
EXPECT_EQ(0, resource->pp_instance());
resource = NULL;
resource.reset();
EXPECT_EQ(0, mock_resource_alive_count);
}
......
......@@ -230,13 +230,13 @@ void TrackedCallback::MarkAsCompletedWithLock() {
// We may not have a valid resource, in which case we're not in the tracker.
if (resource_id_)
tracker_->Remove(thiz);
tracker_ = NULL;
tracker_.reset();
// Relax the cross-thread access restriction to non-thread-safe RefCount.
// |lock_| protects the access to Resource instances.
base::ScopedAllowCrossThreadRefCountAccess
allow_cross_thread_ref_count_access;
target_loop_ = NULL;
target_loop_.reset();
}
void TrackedCallback::PostRunWithLock(int32_t result) {
......
......@@ -69,7 +69,7 @@ TEST_F(VarTrackerTest, LastResourceRef) {
EXPECT_FALSE(var->HasValidVarID());
EXPECT_EQ(1, mock_var_alive_count);
var = NULL;
var.reset();
EXPECT_EQ(0, mock_var_alive_count);
}
......@@ -94,10 +94,10 @@ TEST_F(VarTrackerTest, GetPluginRefAgain) {
EXPECT_FALSE(var->HasValidVarID());
EXPECT_EQ(1, mock_var_alive_count);
var = NULL;
var.reset();
EXPECT_FALSE(var_tracker().GetVar(pp_var));
EXPECT_EQ(1, mock_var_alive_count);
another_var = NULL;
another_var.reset();
EXPECT_FALSE(var_tracker().GetVar(pp_var));
EXPECT_EQ(0, mock_var_alive_count);
}
......@@ -110,7 +110,7 @@ TEST_F(VarTrackerTest, PluginRefWithoutVarRef) {
scoped_refptr<MockStringVar> var(new MockStringVar(std::string("zzz")));
PP_Var pp_var = var->GetPPVar();
EXPECT_EQ(1, mock_var_alive_count);
var = NULL;
var.reset();
EXPECT_EQ(1, mock_var_alive_count);
// The var is owned only by VarTracker. PP_Var must be still valid.
......@@ -139,10 +139,10 @@ TEST_F(VarTrackerTest, ObjectRef) {
EXPECT_EQ(1, mock_var_alive_count);
// Releasing all references, then only VarTracker own the instance.
var = NULL;
var.reset();
EXPECT_TRUE(var_tracker().GetVar(pp_var));
EXPECT_EQ(1, mock_var_alive_count);
another_var = NULL;
another_var.reset();
EXPECT_TRUE(var_tracker().GetVar(pp_var));
EXPECT_EQ(1, mock_var_alive_count);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment