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

Side by Side Diff: third_party/WebKit/Source/modules/imagecapture/ImageCapture.cpp

Issue 1890313002: MediaStream Image Capture (1): idl and wireframe .h/.cpp/LayoutTest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: haraken@ comment: make ImageCapture a ContextLifecycleObserver iso an ActiveDOMObject Created 4 years, 8 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "modules/imagecapture/ImageCapture.h"
6
7 #include "bindings/core/v8/ScriptPromiseResolver.h"
8 #include "core/dom/DOMException.h"
9 #include "core/dom/ExceptionCode.h"
10 #include "modules/EventTargetModules.h"
11 #include "modules/mediastream/MediaStreamTrack.h"
12 #include "public/platform/Platform.h"
13
14 namespace blink {
15
16 ImageCapture* ImageCapture::create(ExecutionContext* context, MediaStreamTrack* track, ExceptionState& exceptionState)
17 {
18 if (track->kind() != "video")
19 exceptionState.throwDOMException(NotSupportedError, "Cannot create an Im ageCapturer from a non-video Track.");
haraken 2016/04/20 00:41:04 You're throwing an exception but creating a new Im
mcasas 2016/04/20 00:53:41 Oops, no, it isn't, sorry.
20
21 return new ImageCapture(context, track);
22 }
23
24 const AtomicString& ImageCapture::interfaceName() const
25 {
26 return EventTargetNames::ImageCapture;
27 }
28
29 ExecutionContext* ImageCapture::getExecutionContext() const
30 {
31 return ContextLifecycleObserver::getExecutionContext();
32 }
33
34 bool ImageCapture::hasPendingActivity() const
35 {
36 return hasEventListeners();
haraken 2016/04/20 00:41:04 Can we add a test to check that ImageCapture is ke
mcasas 2016/04/20 00:53:42 Added one in contextDestroyed() and in the dtor.
37 }
38
39 void ImageCapture::contextDestroyed()
40 {
41 removeAllEventListeners();
42 }
43
44 ScriptPromise ImageCapture::grabFrame(ScriptState* scriptState, ExceptionState& exceptionState)
45 {
46 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
47 ScriptPromise promise = resolver->promise();
48
49 // Spec instructs to return an exception if the track's ready state is not " live". Also reject if the track is disabled or muted.
50 if (m_streamTrack->readyState() != "live" || !m_streamTrack->enabled() || m_ streamTrack->muted()) {
51 resolver->reject(DOMException::create(InvalidStateError, "The associated Track is in an invalid state."));
52 return promise;
53 }
54
55 resolver->reject(DOMException::create(NotSupportedError, "Not implemented ye t"));
56 return promise;
57 }
58
59 ImageCapture::ImageCapture(ExecutionContext* context, MediaStreamTrack* track)
60 : ActiveScriptWrappable(this)
61 , ContextLifecycleObserver(context)
62 , m_streamTrack(track)
63 {
64 DCHECK(m_streamTrack);
65 }
66
67 bool ImageCapture::addEventListenerInternal(const AtomicString& eventType, Event Listener* listener, const EventListenerOptions& options)
68 {
69 return EventTarget::addEventListenerInternal(eventType, listener, options);
70 }
71
72 DEFINE_TRACE(ImageCapture)
73 {
74 visitor->trace(m_streamTrack);
75 EventTargetWithInlineData::trace(visitor);
76 ContextLifecycleObserver::trace(visitor);
77 }
78
79 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698