
This CL applies //tools/clang/base_bind_rewriters to //content/{child,common,network,public/browser}. It rewrites base::Bind to base::BindOnce where the resulting base::Callback is immediately converted to base::OnceCallback, which is considered safe to use base::BindOnce. E.g.: base::PostTask(FROM_HERE, base::Bind([]{})); base::OnceClosure cb = base::Bind([]{}); are converted to: base::PostTask(FROM_HERE, base::BindOnce([]{})); base::OnceClosure cb = base::BindOnce([]{}); Change-Id: I1cd7feb405b643704aa7da904da5202ef5686cf4 Reviewed-on: https://chromium-review.googlesource.com/619106 Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Commit-Queue: Taiju Tsuiki <tzik@chromium.org> Cr-Commit-Position: refs/heads/master@{#495566}
38 lines
1.1 KiB
C++
38 lines
1.1 KiB
C++
// Copyright 2013 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "content/child/scoped_child_process_reference.h"
|
|
|
|
#include "base/bind.h"
|
|
#include "base/location.h"
|
|
#include "base/single_thread_task_runner.h"
|
|
#include "base/threading/thread_task_runner_handle.h"
|
|
#include "base/time/time.h"
|
|
#include "content/child/child_process.h"
|
|
|
|
namespace content {
|
|
|
|
ScopedChildProcessReference::ScopedChildProcessReference()
|
|
: has_reference_(true) {
|
|
ChildProcess::current()->AddRefProcess();
|
|
}
|
|
|
|
ScopedChildProcessReference::~ScopedChildProcessReference() {
|
|
if (has_reference_)
|
|
ChildProcess::current()->ReleaseProcess();
|
|
}
|
|
|
|
void ScopedChildProcessReference::ReleaseWithDelay(
|
|
const base::TimeDelta& delay) {
|
|
DCHECK(has_reference_);
|
|
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
|
|
FROM_HERE,
|
|
base::BindOnce(&ChildProcess::ReleaseProcess,
|
|
base::Unretained(ChildProcess::current())),
|
|
delay);
|
|
has_reference_ = false;
|
|
}
|
|
|
|
} // namespace content
|