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

Side by Side Diff: content/renderer/media/android/stream_texture_factory_synchronous_impl.cc

Issue 594273003: aw: Prevent multiple AddObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/android/stream_texture_factory_synchronous_impl .h" 5 #include "content/renderer/media/android/stream_texture_factory_synchronous_impl .h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 const CreateContextProviderCallback& try_create_callback, 159 const CreateContextProviderCallback& try_create_callback,
160 int frame_id) 160 int frame_id)
161 : create_context_provider_callback_(try_create_callback), 161 : create_context_provider_callback_(try_create_callback),
162 context_provider_(create_context_provider_callback_.Run()), 162 context_provider_(create_context_provider_callback_.Run()),
163 frame_id_(frame_id), 163 frame_id_(frame_id),
164 observer_(NULL) {} 164 observer_(NULL) {}
165 165
166 StreamTextureFactorySynchronousImpl::~StreamTextureFactorySynchronousImpl() {} 166 StreamTextureFactorySynchronousImpl::~StreamTextureFactorySynchronousImpl() {}
167 167
168 StreamTextureProxy* StreamTextureFactorySynchronousImpl::CreateProxy() { 168 StreamTextureProxy* StreamTextureFactorySynchronousImpl::CreateProxy() {
169 if (!context_provider_) 169 bool had_proxy = !!context_provider_;
170 if (!had_proxy)
170 context_provider_ = create_context_provider_callback_.Run(); 171 context_provider_ = create_context_provider_callback_.Run();
171 172
172 if (!context_provider_) 173 if (!context_provider_)
173 return NULL; 174 return NULL;
174 175
175 if (observer_) 176 if (observer_ && !had_proxy)
176 context_provider_->AddObserver(observer_); 177 context_provider_->AddObserver(observer_);
177 return new StreamTextureProxyImpl(context_provider_); 178 return new StreamTextureProxyImpl(context_provider_);
178 } 179 }
179 180
180 void StreamTextureFactorySynchronousImpl::EstablishPeer(int32 stream_id, 181 void StreamTextureFactorySynchronousImpl::EstablishPeer(int32 stream_id,
181 int player_id) { 182 int player_id) {
182 DCHECK(context_provider_); 183 DCHECK(context_provider_);
183 scoped_refptr<gfx::SurfaceTexture> surface_texture = 184 scoped_refptr<gfx::SurfaceTexture> surface_texture =
184 context_provider_->GetSurfaceTexture(stream_id); 185 context_provider_->GetSurfaceTexture(stream_id);
185 if (surface_texture) { 186 if (surface_texture) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 227
227 void StreamTextureFactorySynchronousImpl::RemoveObserver( 228 void StreamTextureFactorySynchronousImpl::RemoveObserver(
228 StreamTextureFactoryContextObserver* obs) { 229 StreamTextureFactoryContextObserver* obs) {
229 DCHECK_EQ(observer_, obs); 230 DCHECK_EQ(observer_, obs);
230 observer_ = NULL; 231 observer_ = NULL;
231 if (context_provider_) 232 if (context_provider_)
232 context_provider_->RemoveObserver(obs); 233 context_provider_->RemoveObserver(obs);
233 } 234 }
234 235
235 } // namespace content 236 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698