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

Side by Side Diff: third_party/WebKit/Source/modules/mediacapturefromelement/HTMLCanvasElementCapture.cpp

Issue 2846843002: [blink] Unique pointers in Platform.h (Closed)
Patch Set: fix compilation (and again) Created 3 years, 7 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "modules/mediacapturefromelement/HTMLCanvasElementCapture.h" 5 #include "modules/mediacapturefromelement/HTMLCanvasElementCapture.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "core/dom/ExceptionCode.h" 8 #include "core/dom/ExceptionCode.h"
9 #include "core/html/HTMLCanvasElement.h" 9 #include "core/html/HTMLCanvasElement.h"
10 #include "modules/mediacapturefromelement/CanvasCaptureMediaStreamTrack.h" 10 #include "modules/mediacapturefromelement/CanvasCaptureMediaStreamTrack.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 double frame_rate, 48 double frame_rate,
49 ExceptionState& exception_state) { 49 ExceptionState& exception_state) {
50 if (!element.OriginClean()) { 50 if (!element.OriginClean()) {
51 exception_state.ThrowSecurityError("Canvas is not origin-clean."); 51 exception_state.ThrowSecurityError("Canvas is not origin-clean.");
52 return nullptr; 52 return nullptr;
53 } 53 }
54 54
55 WebMediaStreamTrack track; 55 WebMediaStreamTrack track;
56 const WebSize size(element.width(), element.height()); 56 const WebSize size(element.width(), element.height());
57 std::unique_ptr<WebCanvasCaptureHandler> handler; 57 std::unique_ptr<WebCanvasCaptureHandler> handler;
58 if (given_frame_rate) 58 if (given_frame_rate) {
59 handler = WTF::WrapUnique(Platform::Current()->CreateCanvasCaptureHandler( 59 handler = Platform::Current()->CreateCanvasCaptureHandler(size, frame_rate,
60 size, frame_rate, &track)); 60 &track);
61 else 61 } else {
62 handler = WTF::WrapUnique(Platform::Current()->CreateCanvasCaptureHandler( 62 handler = Platform::Current()->CreateCanvasCaptureHandler(
63 size, kDefaultFrameRate, &track)); 63 size, kDefaultFrameRate, &track);
64 }
64 65
65 if (!handler) { 66 if (!handler) {
66 exception_state.ThrowDOMException( 67 exception_state.ThrowDOMException(
67 kNotSupportedError, "No CanvasCapture handler can be created."); 68 kNotSupportedError, "No CanvasCapture handler can be created.");
68 return nullptr; 69 return nullptr;
69 } 70 }
70 71
71 CanvasCaptureMediaStreamTrack* canvas_track; 72 CanvasCaptureMediaStreamTrack* canvas_track;
72 if (given_frame_rate) 73 if (given_frame_rate)
73 canvas_track = CanvasCaptureMediaStreamTrack::Create( 74 canvas_track = CanvasCaptureMediaStreamTrack::Create(
74 track, &element, std::move(handler), frame_rate); 75 track, &element, std::move(handler), frame_rate);
75 else 76 else
76 canvas_track = CanvasCaptureMediaStreamTrack::Create(track, &element, 77 canvas_track = CanvasCaptureMediaStreamTrack::Create(track, &element,
77 std::move(handler)); 78 std::move(handler));
78 // We want to capture a frame in the beginning. 79 // We want to capture a frame in the beginning.
79 canvas_track->requestFrame(); 80 canvas_track->requestFrame();
80 81
81 MediaStreamTrackVector tracks; 82 MediaStreamTrackVector tracks;
82 tracks.push_back(canvas_track); 83 tracks.push_back(canvas_track);
83 return MediaStream::Create(element.GetExecutionContext(), tracks); 84 return MediaStream::Create(element.GetExecutionContext(), tracks);
84 } 85 }
85 86
86 } // namespace blink 87 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698