Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1237)

Unified Diff: content/renderer/media/video_capture_impl.cc

Issue 964293002: VideoCaptureImpl & relatives small cleanup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: emircan@s comments Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/video_capture_impl.cc
diff --git a/content/renderer/media/video_capture_impl.cc b/content/renderer/media/video_capture_impl.cc
index 7f395cd97e6f8ba8358a190ef4ff6c7345da66ca..5cd18456ea9ee197085e79310dbbd2cb2d4e5ee0 100644
--- a/content/renderer/media/video_capture_impl.cc
+++ b/content/renderer/media/video_capture_impl.cc
@@ -198,7 +198,7 @@ void VideoCaptureImpl::OnBufferCreated(
void VideoCaptureImpl::OnBufferDestroyed(int buffer_id) {
DCHECK(thread_checker_.CalledOnValidThread());
- ClientBufferMap::iterator iter = client_buffers_.find(buffer_id);
+ const ClientBufferMap::iterator iter = client_buffers_.find(buffer_id);
if (iter == client_buffers_.end())
return;
@@ -232,7 +232,7 @@ void VideoCaptureImpl::OnBufferReceived(int buffer_id,
"timestamp", timestamp.ToInternalValue(),
"time_delta", (timestamp - first_frame_timestamp_).ToInternalValue());
- ClientBufferMap::iterator iter = client_buffers_.find(buffer_id);
+ const ClientBufferMap::const_iterator iter = client_buffers_.find(buffer_id);
DCHECK(iter != client_buffers_.end());
scoped_refptr<ClientBuffer> buffer = iter->second;
scoped_refptr<media::VideoFrame> frame =
@@ -253,10 +253,8 @@ void VideoCaptureImpl::OnBufferReceived(int buffer_id,
buffer,
0)));
- for (ClientInfoMap::iterator it = clients_.begin(); it != clients_.end();
- ++it) {
- it->second.deliver_frame_cb.Run(frame, format, timestamp);
- }
+ for (const auto& it : clients_)
wolenetz 2015/03/02 23:51:09 nit: s/it/something-more-type-descriptive/ ?
mcasas 2015/03/03 15:40:52 Done.
+ it.second.deliver_frame_cb.Run(frame, format, timestamp);
}
void VideoCaptureImpl::OnMailboxBufferReceived(
@@ -283,10 +281,8 @@ void VideoCaptureImpl::OnMailboxBufferReceived(
last_frame_format_.frame_size, gfx::Rect(last_frame_format_.frame_size),
last_frame_format_.frame_size, timestamp - first_frame_timestamp_, false);
- for (ClientInfoMap::iterator it = clients_.begin(); it != clients_.end();
- ++it) {
- it->second.deliver_frame_cb.Run(frame, format, timestamp);
- }
+ for (const auto& it : clients_)
wolenetz 2015/03/02 23:51:09 nit: ditto here and elsewhere in this CL.
mcasas 2015/03/03 15:40:52 Done.
+ it.second.deliver_frame_cb.Run(frame, format, timestamp);
}
void VideoCaptureImpl::OnClientBufferFinished(
@@ -315,26 +311,21 @@ void VideoCaptureImpl::OnStateChanged(VideoCaptureState state) {
RestartCapture();
break;
case VIDEO_CAPTURE_STATE_PAUSED:
- for (ClientInfoMap::iterator it = clients_.begin();
- it != clients_.end(); ++it) {
- it->second.state_update_cb.Run(VIDEO_CAPTURE_STATE_PAUSED);
- }
+ for (const auto& it : clients_)
+ it.second.state_update_cb.Run(VIDEO_CAPTURE_STATE_PAUSED);
break;
case VIDEO_CAPTURE_STATE_ERROR:
DVLOG(1) << "OnStateChanged: error!, device_id = " << device_id_;
- for (ClientInfoMap::iterator it = clients_.begin();
- it != clients_.end(); ++it) {
- it->second.state_update_cb.Run(VIDEO_CAPTURE_STATE_ERROR);
- }
+ for (const auto& it : clients_)
+ it.second.state_update_cb.Run(VIDEO_CAPTURE_STATE_ERROR);
clients_.clear();
state_ = VIDEO_CAPTURE_STATE_ERROR;
break;
case VIDEO_CAPTURE_STATE_ENDED:
DVLOG(1) << "OnStateChanged: ended!, device_id = " << device_id_;
- for (ClientInfoMap::iterator it = clients_.begin();
- it != clients_.end(); ++it) {
+ for (const auto& it : clients_) {
// We'll only notify the client that the stream has stopped.
- it->second.state_update_cb.Run(VIDEO_CAPTURE_STATE_STOPPED);
+ it.second.state_update_cb.Run(VIDEO_CAPTURE_STATE_STOPPED);
}
clients_.clear();
state_ = VIDEO_CAPTURE_STATE_ENDED;
@@ -365,18 +356,11 @@ void VideoCaptureImpl::OnDelegateAdded(int32 device_id) {
DVLOG(1) << "OnDelegateAdded: device_id " << device_id;
device_id_ = device_id;
- for (ClientInfoMap::iterator it = clients_pending_on_filter_.begin();
- it != clients_pending_on_filter_.end(); ) {
- int client_id = it->first;
- VideoCaptureStateUpdateCB state_update_cb =
- it->second.state_update_cb;
- VideoCaptureDeliverFrameCB deliver_frame_cb =
- it->second.deliver_frame_cb;
- const media::VideoCaptureParams params = it->second.params;
- clients_pending_on_filter_.erase(it++);
- StartCapture(client_id, params, state_update_cb,
- deliver_frame_cb);
+ for (const auto& it = clients_pending_on_filter_) {
wolenetz 2015/03/02 23:51:09 s/=/:/ ? I don't know this code, this for loop now
mcasas 2015/03/03 15:40:52 Done.
+ StartCapture(it.first, it.second.params, it.second.state_update_cb,
+ it.second.deliver_frame_cb);
}
+ clients_pending_on_filter_.clear();
}
void VideoCaptureImpl::StopDevice() {
@@ -398,12 +382,11 @@ void VideoCaptureImpl::RestartCapture() {
clients_.insert(clients_pending_on_restart_.begin(),
clients_pending_on_restart_.end());
clients_pending_on_restart_.clear();
- for (ClientInfoMap::iterator it = clients_.begin();
- it != clients_.end(); ++it) {
+ for (const auto& it : clients_) {
width = std::max(width,
- it->second.params.requested_format.frame_size.width());
+ it.second.params.requested_format.frame_size.width());
height = std::max(height,
- it->second.params.requested_format.frame_size.height());
+ it.second.params.requested_format.frame_size.height());
}
params_.requested_format.frame_size.SetSize(width, height);
DVLOG(1) << "RestartCapture, "
@@ -428,7 +411,7 @@ bool VideoCaptureImpl::RemoveClient(int client_id, ClientInfoMap* clients) {
DCHECK(thread_checker_.CalledOnValidThread());
bool found = false;
- ClientInfoMap::iterator it = clients->find(client_id);
+ const ClientInfoMap::iterator it = clients->find(client_id);
if (it != clients->end()) {
it->second.state_update_cb.Run(VIDEO_CAPTURE_STATE_STOPPED);
clients->erase(it);

Powered by Google App Engine
This is Rietveld 408576698