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

Side by Side Diff: content/browser/renderer_host/media/web_contents_video_capture_device_unittest.cc

Issue 16294003: Update content/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/renderer_host/media/web_contents_video_capture_device. h" 5 #include "content/browser/renderer_host/media/web_contents_video_capture_device. h"
6 6
7 #include "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/debug/debugger.h" 8 #include "base/debug/debugger.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 168
169 virtual bool CanCopyToVideoFrame() const OVERRIDE { 169 virtual bool CanCopyToVideoFrame() const OVERRIDE {
170 return controller_->CanCopyToVideoFrame(); 170 return controller_->CanCopyToVideoFrame();
171 } 171 }
172 172
173 virtual void CopyFromCompositingSurfaceToVideoFrame( 173 virtual void CopyFromCompositingSurfaceToVideoFrame(
174 const gfx::Rect& src_subrect, 174 const gfx::Rect& src_subrect,
175 const scoped_refptr<media::VideoFrame>& target, 175 const scoped_refptr<media::VideoFrame>& target,
176 const base::Callback<void(bool)>& callback) OVERRIDE { 176 const base::Callback<void(bool)>& callback) OVERRIDE {
177 SkColor c = ConvertRgbToYuv(controller_->GetSolidColor()); 177 SkColor c = ConvertRgbToYuv(controller_->GetSolidColor());
178 media::FillYUV(target, SkColorGetR(c), SkColorGetG(c), SkColorGetB(c)); 178 media::FillYUV(
179 target.get(), SkColorGetR(c), SkColorGetG(c), SkColorGetB(c));
179 callback.Run(true); 180 callback.Run(true);
180 controller_->SignalCopy(); 181 controller_->SignalCopy();
181 } 182 }
182 183
183 virtual void BeginFrameSubscription( 184 virtual void BeginFrameSubscription(
184 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) OVERRIDE { 185 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) OVERRIDE {
185 subscriber_.reset(subscriber.release()); 186 subscriber_.reset(subscriber.release());
186 } 187 }
187 188
188 virtual void EndFrameSubscription() OVERRIDE { 189 virtual void EndFrameSubscription() OVERRIDE {
189 subscriber_.reset(); 190 subscriber_.reset();
190 } 191 }
191 192
192 // Simulate a compositor paint event for our subscriber. 193 // Simulate a compositor paint event for our subscriber.
193 void SimulateUpdate() { 194 void SimulateUpdate() {
194 const base::Time present_time = base::Time::Now(); 195 const base::Time present_time = base::Time::Now();
195 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback; 196 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback;
196 scoped_refptr<media::VideoFrame> target; 197 scoped_refptr<media::VideoFrame> target;
197 if (subscriber_ && subscriber_->ShouldCaptureFrame(present_time, 198 if (subscriber_ && subscriber_->ShouldCaptureFrame(present_time,
198 &target, &callback)) { 199 &target, &callback)) {
199 SkColor c = ConvertRgbToYuv(controller_->GetSolidColor()); 200 SkColor c = ConvertRgbToYuv(controller_->GetSolidColor());
200 media::FillYUV(target, SkColorGetR(c), SkColorGetG(c), SkColorGetB(c)); 201 media::FillYUV(
201 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 202 target.get(), SkColorGetR(c), SkColorGetG(c), SkColorGetB(c));
202 base::Bind(callback, present_time, true)); 203 BrowserThread::PostTask(BrowserThread::UI,
204 FROM_HERE,
205 base::Bind(callback, present_time, true));
203 controller_->SignalCopy(); 206 controller_->SignalCopy();
204 } 207 }
205 } 208 }
206 209
207 private: 210 private:
208 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber_; 211 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber_;
209 CaptureTestSourceController* const controller_; 212 CaptureTestSourceController* const controller_;
210 213
211 DISALLOW_IMPLICIT_CONSTRUCTORS(CaptureTestView); 214 DISALLOW_IMPLICIT_CONSTRUCTORS(CaptureTestView);
212 }; 215 };
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 render_view_host_factory_.reset( 443 render_view_host_factory_.reset(
441 new CaptureTestRenderViewHostFactory(&controller_)); 444 new CaptureTestRenderViewHostFactory(&controller_));
442 445
443 browser_context_.reset(new TestBrowserContext()); 446 browser_context_.reset(new TestBrowserContext());
444 447
445 scoped_refptr<SiteInstance> site_instance = 448 scoped_refptr<SiteInstance> site_instance =
446 SiteInstance::Create(browser_context_.get()); 449 SiteInstance::Create(browser_context_.get());
447 static_cast<SiteInstanceImpl*>(site_instance.get())-> 450 static_cast<SiteInstanceImpl*>(site_instance.get())->
448 set_render_process_host_factory(render_process_host_factory_.get()); 451 set_render_process_host_factory(render_process_host_factory_.get());
449 web_contents_.reset( 452 web_contents_.reset(
450 TestWebContents::Create(browser_context_.get(), site_instance)); 453 TestWebContents::Create(browser_context_.get(), site_instance.get()));
451 454
452 // This is actually a CaptureTestRenderViewHost. 455 // This is actually a CaptureTestRenderViewHost.
453 RenderWidgetHostImpl* rwh = 456 RenderWidgetHostImpl* rwh =
454 RenderWidgetHostImpl::From(web_contents_->GetRenderViewHost()); 457 RenderWidgetHostImpl::From(web_contents_->GetRenderViewHost());
455 458
456 std::string device_id = 459 std::string device_id =
457 WebContentsCaptureUtil::AppendWebContentsDeviceScheme( 460 WebContentsCaptureUtil::AppendWebContentsDeviceScheme(
458 base::StringPrintf("%d:%d", rwh->GetProcess()->GetID(), 461 base::StringPrintf("%d:%d", rwh->GetProcess()->GetID(),
459 rwh->GetRoutingID())); 462 rwh->GetRoutingID()));
460 463
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 ASSERT_NO_FATAL_FAILURE(consumer()->WaitForNextColor(SK_ColorGREEN)); 725 ASSERT_NO_FATAL_FAILURE(consumer()->WaitForNextColor(SK_ColorGREEN));
723 source()->SetSolidColor(SK_ColorRED); 726 source()->SetSolidColor(SK_ColorRED);
724 ASSERT_NO_FATAL_FAILURE(consumer()->WaitForNextColor(SK_ColorRED)); 727 ASSERT_NO_FATAL_FAILURE(consumer()->WaitForNextColor(SK_ColorRED));
725 728
726 device()->Stop(); 729 device()->Stop();
727 device()->DeAllocate(); 730 device()->DeAllocate();
728 } 731 }
729 732
730 } // namespace 733 } // namespace
731 } // namespace content 734 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698