OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |