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

Side by Side Diff: third_party/WebKit/Source/modules/mediastream/MediaDevicesRequest.cpp

Issue 1758783002: Revert of Reduce ActiveDOMObjects from modules/mediastream/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 18 matching lines...) Expand all
29 #include "bindings/core/v8/ScriptState.h" 29 #include "bindings/core/v8/ScriptState.h"
30 #include "core/dom/DOMException.h" 30 #include "core/dom/DOMException.h"
31 #include "core/dom/Document.h" 31 #include "core/dom/Document.h"
32 #include "core/dom/ExceptionCode.h" 32 #include "core/dom/ExceptionCode.h"
33 #include "modules/mediastream/UserMediaController.h" 33 #include "modules/mediastream/UserMediaController.h"
34 34
35 namespace blink { 35 namespace blink {
36 36
37 MediaDevicesRequest* MediaDevicesRequest::create(ScriptState* state, UserMediaCo ntroller* controller) 37 MediaDevicesRequest* MediaDevicesRequest::create(ScriptState* state, UserMediaCo ntroller* controller)
38 { 38 {
39 return new MediaDevicesRequest(state, controller); 39 MediaDevicesRequest* request = new MediaDevicesRequest(state, controller);
40 request->suspendIfNeeded();
41 return request;
40 } 42 }
41 43
42 MediaDevicesRequest::MediaDevicesRequest(ScriptState* state, UserMediaController * controller) 44 MediaDevicesRequest::MediaDevicesRequest(ScriptState* state, UserMediaController * controller)
43 : ContextLifecycleObserver(state->executionContext()) 45 : ActiveDOMObject(state->executionContext())
44 , m_controller(controller) 46 , m_controller(controller)
45 , m_resolver(ScriptPromiseResolver::create(state)) 47 , m_resolver(ScriptPromiseResolver::create(state))
46 { 48 {
47 } 49 }
48 50
51 MediaDevicesRequest::~MediaDevicesRequest()
52 {
53 }
54
49 Document* MediaDevicesRequest::ownerDocument() 55 Document* MediaDevicesRequest::ownerDocument()
50 { 56 {
51 if (ExecutionContext* context = executionContext()) { 57 if (ExecutionContext* context = executionContext()) {
52 return toDocument(context); 58 return toDocument(context);
53 } 59 }
54 60
55 return 0; 61 return 0;
56 } 62 }
57 63
58 ScriptPromise MediaDevicesRequest::start() 64 ScriptPromise MediaDevicesRequest::start()
59 { 65 {
60 ASSERT(m_controller); 66 ASSERT(m_controller);
61 m_resolver->keepAliveWhilePending(); 67 m_resolver->keepAliveWhilePending();
62 m_controller->requestMediaDevices(this); 68 m_controller->requestMediaDevices(this);
63 return m_resolver->promise(); 69 return m_resolver->promise();
64 } 70 }
65 71
66 void MediaDevicesRequest::succeed(const MediaDeviceInfoVector& mediaDevices) 72 void MediaDevicesRequest::succeed(const MediaDeviceInfoVector& mediaDevices)
67 { 73 {
68 if (!executionContext() || !m_resolver) 74 if (!executionContext() || !m_resolver)
69 return; 75 return;
70 76
71 m_resolver->resolve(mediaDevices); 77 m_resolver->resolve(mediaDevices);
72 } 78 }
73 79
74 void MediaDevicesRequest::contextDestroyed() 80 void MediaDevicesRequest::stop()
75 { 81 {
76 m_controller.clear(); 82 m_controller.clear();
77 m_resolver.clear(); 83 m_resolver.clear();
78 } 84 }
79 85
80 DEFINE_TRACE(MediaDevicesRequest) 86 DEFINE_TRACE(MediaDevicesRequest)
81 { 87 {
82 visitor->trace(m_controller); 88 visitor->trace(m_controller);
83 visitor->trace(m_resolver); 89 visitor->trace(m_resolver);
84 ContextLifecycleObserver::trace(visitor); 90 ActiveDOMObject::trace(visitor);
85 } 91 }
86 92
87 } // namespace blink 93 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698