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

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

Issue 2859553002: Revert of [blink] Unique pointers in Platform.h (Closed)
Patch Set: 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 = Platform::Current()->CreateCanvasCaptureHandler(size, frame_rate, 59 handler = WTF::WrapUnique(Platform::Current()->CreateCanvasCaptureHandler(
60 &track); 60 size, frame_rate, &track));
61 } else { 61 else
62 handler = Platform::Current()->CreateCanvasCaptureHandler( 62 handler = WTF::WrapUnique(Platform::Current()->CreateCanvasCaptureHandler(
63 size, kDefaultFrameRate, &track); 63 size, kDefaultFrameRate, &track));
64 }
65 64
66 if (!handler) { 65 if (!handler) {
67 exception_state.ThrowDOMException( 66 exception_state.ThrowDOMException(
68 kNotSupportedError, "No CanvasCapture handler can be created."); 67 kNotSupportedError, "No CanvasCapture handler can be created.");
69 return nullptr; 68 return nullptr;
70 } 69 }
71 70
72 CanvasCaptureMediaStreamTrack* canvas_track; 71 CanvasCaptureMediaStreamTrack* canvas_track;
73 if (given_frame_rate) 72 if (given_frame_rate)
74 canvas_track = CanvasCaptureMediaStreamTrack::Create( 73 canvas_track = CanvasCaptureMediaStreamTrack::Create(
75 track, &element, std::move(handler), frame_rate); 74 track, &element, std::move(handler), frame_rate);
76 else 75 else
77 canvas_track = CanvasCaptureMediaStreamTrack::Create(track, &element, 76 canvas_track = CanvasCaptureMediaStreamTrack::Create(track, &element,
78 std::move(handler)); 77 std::move(handler));
79 // We want to capture a frame in the beginning. 78 // We want to capture a frame in the beginning.
80 canvas_track->requestFrame(); 79 canvas_track->requestFrame();
81 80
82 MediaStreamTrackVector tracks; 81 MediaStreamTrackVector tracks;
83 tracks.push_back(canvas_track); 82 tracks.push_back(canvas_track);
84 return MediaStream::Create(element.GetExecutionContext(), tracks); 83 return MediaStream::Create(element.GetExecutionContext(), tracks);
85 } 84 }
86 85
87 } // namespace blink 86 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698