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

Unified Diff: remoting/host/screen_recorder.cc

Issue 8495024: Access ChromotingHost::clients_ only on network thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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: remoting/host/screen_recorder.cc
diff --git a/remoting/host/screen_recorder.cc b/remoting/host/screen_recorder.cc
index 9c23874da2a60dd298adddd1a0cd1a2f8efa039b..3f8aad1ac6d60fb9e3f27d02d858dec2c931eb7a 100644
--- a/remoting/host/screen_recorder.cc
+++ b/remoting/host/screen_recorder.cc
@@ -81,27 +81,28 @@ void ScreenRecorder::Stop(const base::Closure& done_task) {
void ScreenRecorder::AddConnection(
scoped_refptr<ConnectionToClient> connection) {
+ DCHECK(network_loop_->BelongsToCurrentThread());
+ connections_.push_back(connection);
+
capture_loop_->PostTask(
FROM_HERE,
NewRunnableMethod(this, &ScreenRecorder::DoInvalidateFullScreen));
-
- // Add the client to the list so it can receive update stream.
- network_loop_->PostTask(
- FROM_HERE,
- NewRunnableMethod(this, &ScreenRecorder::DoAddConnection, connection));
}
void ScreenRecorder::RemoveConnection(
scoped_refptr<ConnectionToClient> connection) {
- network_loop_->PostTask(
- FROM_HERE,
- NewRunnableMethod(this, &ScreenRecorder::DoRemoveClient, connection));
+ DCHECK(network_loop_->BelongsToCurrentThread());
+
+ ConnectionToClientList::iterator it =
+ std::find(connections_.begin(), connections_.end(), connection);
+ if (it != connections_.end()) {
+ connections_.erase(it);
+ }
}
void ScreenRecorder::RemoveAllConnections() {
- network_loop_->PostTask(
- FROM_HERE,
- NewRunnableMethod(this, &ScreenRecorder::DoRemoveAllClients));
+ DCHECK(network_loop_->BelongsToCurrentThread());
+ connections_.clear();
}
void ScreenRecorder::UpdateSequenceNumber(int64 sequence_number) {
@@ -277,31 +278,6 @@ void ScreenRecorder::FrameSentCallback(VideoPacket* packet) {
&ScreenRecorder::DoFinishOneRecording));
}
-void ScreenRecorder::DoAddConnection(
- scoped_refptr<ConnectionToClient> connection) {
- DCHECK(network_loop_->BelongsToCurrentThread());
-
- connections_.push_back(connection);
-}
-
-void ScreenRecorder::DoRemoveClient(
- scoped_refptr<ConnectionToClient> connection) {
- DCHECK(network_loop_->BelongsToCurrentThread());
-
- ConnectionToClientList::iterator it =
- std::find(connections_.begin(), connections_.end(), connection);
- if (it != connections_.end()) {
- connections_.erase(it);
- }
-}
-
-void ScreenRecorder::DoRemoveAllClients() {
- DCHECK(network_loop_->BelongsToCurrentThread());
-
- // Clear the list of connections.
- connections_.clear();
-}
-
void ScreenRecorder::DoStopOnNetworkThread(const base::Closure& done_task) {
DCHECK(network_loop_->BelongsToCurrentThread());

Powered by Google App Engine
This is Rietveld 408576698