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 ...@@ -191,7 +191,8 @@ class CAPTURE_EXPORT CameraHalDelegate final
// updated in GetDeviceDescriptors() and queried in // updated in GetDeviceDescriptors() and queried in
// GetCameraIdFromDeviceId(). // GetCameraIdFromDeviceId().
base::Lock device_id_to_camera_id_lock_; 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_); SEQUENCE_CHECKER(sequence_checker_);
......
...@@ -25,15 +25,16 @@ VideoCaptureJpegDecoderImpl::VideoCaptureJpegDecoderImpl( ...@@ -25,15 +25,16 @@ VideoCaptureJpegDecoderImpl::VideoCaptureJpegDecoderImpl(
decode_done_cb_(std::move(decode_done_cb)), decode_done_cb_(std::move(decode_done_cb)),
send_log_message_cb_(std::move(send_log_message_cb)), send_log_message_cb_(std::move(send_log_message_cb)),
has_received_decoded_frame_(false), has_received_decoded_frame_(false),
decoder_status_(INIT_PENDING),
next_task_id_(0), next_task_id_(0),
task_id_(chromeos_camera::MjpegDecodeAccelerator::kInvalidTaskId), task_id_(chromeos_camera::MjpegDecodeAccelerator::kInvalidTaskId) {}
decoder_status_(INIT_PENDING) {}
VideoCaptureJpegDecoderImpl::~VideoCaptureJpegDecoderImpl() { VideoCaptureJpegDecoderImpl::~VideoCaptureJpegDecoderImpl() {
DCHECK(decoder_task_runner_->RunsTasksInCurrentSequence()); DCHECK(decoder_task_runner_->RunsTasksInCurrentSequence());
} }
void VideoCaptureJpegDecoderImpl::Initialize() { void VideoCaptureJpegDecoderImpl::Initialize() {
base::AutoLock lock(lock_);
if (!IsVideoCaptureAcceleratedJpegDecodingEnabled()) { if (!IsVideoCaptureAcceleratedJpegDecodingEnabled()) {
decoder_status_ = FAILED; decoder_status_ = FAILED;
RecordInitDecodeUMA_Locked(); RecordInitDecodeUMA_Locked();
...@@ -236,6 +237,7 @@ bool VideoCaptureJpegDecoderImpl::IsDecoding_Locked() const { ...@@ -236,6 +237,7 @@ bool VideoCaptureJpegDecoderImpl::IsDecoding_Locked() const {
} }
void VideoCaptureJpegDecoderImpl::RecordInitDecodeUMA_Locked() { void VideoCaptureJpegDecoderImpl::RecordInitDecodeUMA_Locked() {
lock_.AssertAcquired();
UMA_HISTOGRAM_BOOLEAN("Media.VideoCaptureGpuJpegDecoder.InitDecodeSuccess", UMA_HISTOGRAM_BOOLEAN("Media.VideoCaptureGpuJpegDecoder.InitDecodeSuccess",
decoder_status_ == INIT_PASSED); decoder_status_ == INIT_PASSED);
} }
......
...@@ -87,11 +87,10 @@ class CAPTURE_EXPORT VideoCaptureJpegDecoderImpl ...@@ -87,11 +87,10 @@ class CAPTURE_EXPORT VideoCaptureJpegDecoderImpl
const base::RepeatingCallback<void(const std::string&)> send_log_message_cb_; const base::RepeatingCallback<void(const std::string&)> send_log_message_cb_;
bool has_received_decoded_frame_; 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. // 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. // Next id for input BitstreamBuffer.
int32_t next_task_id_; int32_t next_task_id_;
...@@ -104,8 +103,6 @@ class CAPTURE_EXPORT VideoCaptureJpegDecoderImpl ...@@ -104,8 +103,6 @@ class CAPTURE_EXPORT VideoCaptureJpegDecoderImpl
base::UnsafeSharedMemoryRegion in_shared_region_; base::UnsafeSharedMemoryRegion in_shared_region_;
base::WritableSharedMemoryMapping in_shared_mapping_; base::WritableSharedMemoryMapping in_shared_mapping_;
STATUS decoder_status_;
SEQUENCE_CHECKER(sequence_checker_); SEQUENCE_CHECKER(sequence_checker_);
base::WeakPtrFactory<VideoCaptureJpegDecoderImpl> weak_ptr_factory_{this}; 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