Commit 69928ee1 authored by Wei Lee's avatar Wei Lee Committed by Chromium LUCI CQ

VCD: Add GUARDED_BY() for variables need lock

So that it will report error at compile time when we forget to request
the lock before accessing the variables.

Bug: b/176461326
Test: Build successfully
Change-Id: Iac8404fc609ec7a6b2e86bbbdb3e71662e71aa69
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2602966
Commit-Queue: Wei Lee <wtlee@chromium.org>
Reviewed-by: default avatarShik Chen <shik@chromium.org>
Auto-Submit: Wei Lee <wtlee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841932}
parent 939164be
......@@ -191,7 +191,8 @@ class CAPTURE_EXPORT CameraHalDelegate final
// updated in GetDeviceDescriptors() and queried in
// GetCameraIdFromDeviceId().
base::Lock device_id_to_camera_id_lock_;
std::map<std::string, int> device_id_to_camera_id_;
std::map<std::string, int> device_id_to_camera_id_
GUARDED_BY(device_id_to_camera_id_lock_);
SEQUENCE_CHECKER(sequence_checker_);
......
......@@ -25,15 +25,16 @@ VideoCaptureJpegDecoderImpl::VideoCaptureJpegDecoderImpl(
decode_done_cb_(std::move(decode_done_cb)),
send_log_message_cb_(std::move(send_log_message_cb)),
has_received_decoded_frame_(false),
decoder_status_(INIT_PENDING),
next_task_id_(0),
task_id_(chromeos_camera::MjpegDecodeAccelerator::kInvalidTaskId),
decoder_status_(INIT_PENDING) {}
task_id_(chromeos_camera::MjpegDecodeAccelerator::kInvalidTaskId) {}
VideoCaptureJpegDecoderImpl::~VideoCaptureJpegDecoderImpl() {
DCHECK(decoder_task_runner_->RunsTasksInCurrentSequence());
}
void VideoCaptureJpegDecoderImpl::Initialize() {
base::AutoLock lock(lock_);
if (!IsVideoCaptureAcceleratedJpegDecodingEnabled()) {
decoder_status_ = FAILED;
RecordInitDecodeUMA_Locked();
......@@ -236,6 +237,7 @@ bool VideoCaptureJpegDecoderImpl::IsDecoding_Locked() const {
}
void VideoCaptureJpegDecoderImpl::RecordInitDecodeUMA_Locked() {
lock_.AssertAcquired();
UMA_HISTOGRAM_BOOLEAN("Media.VideoCaptureGpuJpegDecoder.InitDecodeSuccess",
decoder_status_ == INIT_PASSED);
}
......
......@@ -87,11 +87,10 @@ class CAPTURE_EXPORT VideoCaptureJpegDecoderImpl
const base::RepeatingCallback<void(const std::string&)> send_log_message_cb_;
bool has_received_decoded_frame_;
// Guards |decode_done_closure_| and |decoder_status_|.
mutable base::Lock lock_;
// The closure of |decode_done_cb_| with bound parameters.
base::OnceClosure decode_done_closure_;
mutable base::Lock lock_;
STATUS decoder_status_ GUARDED_BY(lock_);
base::OnceClosure decode_done_closure_ GUARDED_BY(lock_);
// Next id for input BitstreamBuffer.
int32_t next_task_id_;
......@@ -104,8 +103,6 @@ class CAPTURE_EXPORT VideoCaptureJpegDecoderImpl
base::UnsafeSharedMemoryRegion in_shared_region_;
base::WritableSharedMemoryMapping in_shared_mapping_;
STATUS decoder_status_;
SEQUENCE_CHECKER(sequence_checker_);
base::WeakPtrFactory<VideoCaptureJpegDecoderImpl> weak_ptr_factory_{this};
......
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