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

Side by Side Diff: Source/modules/mediastream/UserMediaRequest.cpp

Issue 173363002: Move mediastream module to oilpan transition types (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: WIP Created 6 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Ericsson AB. All rights reserved. 2 * Copyright (C) 2011 Ericsson AB. All rights reserved.
3 * Copyright (C) 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2012 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 29 matching lines...) Expand all
40 #include "core/dom/ExceptionCode.h" 40 #include "core/dom/ExceptionCode.h"
41 #include "core/dom/SpaceSplitString.h" 41 #include "core/dom/SpaceSplitString.h"
42 #include "modules/mediastream/MediaConstraintsImpl.h" 42 #include "modules/mediastream/MediaConstraintsImpl.h"
43 #include "modules/mediastream/MediaStream.h" 43 #include "modules/mediastream/MediaStream.h"
44 #include "modules/mediastream/UserMediaController.h" 44 #include "modules/mediastream/UserMediaController.h"
45 #include "platform/mediastream/MediaStreamCenter.h" 45 #include "platform/mediastream/MediaStreamCenter.h"
46 #include "platform/mediastream/MediaStreamDescriptor.h" 46 #include "platform/mediastream/MediaStreamDescriptor.h"
47 47
48 namespace WebCore { 48 namespace WebCore {
49 49
50 DEFINE_GC_INFO(UserMediaRequest);
51
50 static blink::WebMediaConstraints parseOptions(const Dictionary& options, const String& mediaType, ExceptionState& exceptionState) 52 static blink::WebMediaConstraints parseOptions(const Dictionary& options, const String& mediaType, ExceptionState& exceptionState)
51 { 53 {
52 blink::WebMediaConstraints constraints; 54 blink::WebMediaConstraints constraints;
53 55
54 Dictionary constraintsDictionary; 56 Dictionary constraintsDictionary;
55 bool ok = options.get(mediaType, constraintsDictionary); 57 bool ok = options.get(mediaType, constraintsDictionary);
56 if (ok && !constraintsDictionary.isUndefinedOrNull()) 58 if (ok && !constraintsDictionary.isUndefinedOrNull())
57 constraints = MediaConstraintsImpl::create(constraintsDictionary, except ionState); 59 constraints = MediaConstraintsImpl::create(constraintsDictionary, except ionState);
58 else { 60 else {
59 bool mediaRequested = false; 61 bool mediaRequested = false;
60 options.get(mediaType, mediaRequested); 62 options.get(mediaType, mediaRequested);
61 if (mediaRequested) 63 if (mediaRequested)
62 constraints = MediaConstraintsImpl::create(); 64 constraints = MediaConstraintsImpl::create();
63 } 65 }
64 66
65 return constraints; 67 return constraints;
66 } 68 }
67 69
68 PassRefPtr<UserMediaRequest> UserMediaRequest::create(ExecutionContext* context, UserMediaController* controller, const Dictionary& options, PassOwnPtr<Navigato rUserMediaSuccessCallback> successCallback, PassOwnPtr<NavigatorUserMediaErrorCa llback> errorCallback, ExceptionState& exceptionState) 70 PassRefPtrWillBeRawPtr<UserMediaRequest> UserMediaRequest::create(ExecutionConte xt* context, UserMediaController* controller, const Dictionary& options, PassOwn Ptr<NavigatorUserMediaSuccessCallback> successCallback, PassOwnPtr<NavigatorUser MediaErrorCallback> errorCallback, ExceptionState& exceptionState)
69 { 71 {
70 blink::WebMediaConstraints audio = parseOptions(options, "audio", exceptionS tate); 72 blink::WebMediaConstraints audio = parseOptions(options, "audio", exceptionS tate);
71 if (exceptionState.hadException()) 73 if (exceptionState.hadException())
72 return nullptr; 74 return nullptr;
73 75
74 blink::WebMediaConstraints video = parseOptions(options, "video", exceptionS tate); 76 blink::WebMediaConstraints video = parseOptions(options, "video", exceptionS tate);
75 if (exceptionState.hadException()) 77 if (exceptionState.hadException())
76 return nullptr; 78 return nullptr;
77 79
78 if (audio.isNull() && video.isNull()) { 80 if (audio.isNull() && video.isNull()) {
79 exceptionState.throwDOMException(SyntaxError, "At least one of audio and video must be requested"); 81 exceptionState.throwDOMException(SyntaxError, "At least one of audio and video must be requested");
80 return nullptr; 82 return nullptr;
81 } 83 }
82 84
83 return adoptRef(new UserMediaRequest(context, controller, audio, video, succ essCallback, errorCallback)); 85 return adoptRefWillBeNoop(new UserMediaRequest(context, controller, audio, v ideo, successCallback, errorCallback));
84 } 86 }
85 87
86 UserMediaRequest::UserMediaRequest(ExecutionContext* context, UserMediaControlle r* controller, blink::WebMediaConstraints audio, blink::WebMediaConstraints vide o, PassOwnPtr<NavigatorUserMediaSuccessCallback> successCallback, PassOwnPtr<Nav igatorUserMediaErrorCallback> errorCallback) 88 UserMediaRequest::UserMediaRequest(ExecutionContext* context, UserMediaControlle r* controller, blink::WebMediaConstraints audio, blink::WebMediaConstraints vide o, PassOwnPtr<NavigatorUserMediaSuccessCallback> successCallback, PassOwnPtr<Nav igatorUserMediaErrorCallback> errorCallback)
87 : ContextLifecycleObserver(context) 89 : ContextLifecycleObserver(context)
88 , m_audio(audio) 90 , m_audio(audio)
89 , m_video(video) 91 , m_video(video)
90 , m_controller(controller) 92 , m_controller(controller)
91 , m_successCallback(successCallback) 93 , m_successCallback(successCallback)
92 , m_errorCallback(errorCallback) 94 , m_errorCallback(errorCallback)
93 { 95 {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 { 132 {
131 if (m_controller) 133 if (m_controller)
132 m_controller->requestUserMedia(this); 134 m_controller->requestUserMedia(this);
133 } 135 }
134 136
135 void UserMediaRequest::succeed(PassRefPtr<MediaStreamDescriptor> streamDescripto r) 137 void UserMediaRequest::succeed(PassRefPtr<MediaStreamDescriptor> streamDescripto r)
136 { 138 {
137 if (!executionContext()) 139 if (!executionContext())
138 return; 140 return;
139 141
140 RefPtr<MediaStream> stream = MediaStream::create(executionContext(), streamD escriptor); 142 RefPtrWillBeRawPtr<MediaStream> stream = MediaStream::create(executionContex t(), streamDescriptor);
141 143
142 MediaStreamTrackVector audioTracks = stream->getAudioTracks(); 144 MediaStreamTrackVector audioTracks = stream->getAudioTracks();
143 for (MediaStreamTrackVector::iterator iter = audioTracks.begin(); iter != au dioTracks.end(); ++iter) { 145 for (MediaStreamTrackVector::iterator iter = audioTracks.begin(); iter != au dioTracks.end(); ++iter) {
144 (*iter)->component()->source()->setConstraints(m_audio); 146 (*iter)->component()->source()->setConstraints(m_audio);
145 } 147 }
146 148
147 MediaStreamTrackVector videoTracks = stream->getVideoTracks(); 149 MediaStreamTrackVector videoTracks = stream->getVideoTracks();
148 for (MediaStreamTrackVector::iterator iter = videoTracks.begin(); iter != vi deoTracks.end(); ++iter) { 150 for (MediaStreamTrackVector::iterator iter = videoTracks.begin(); iter != vi deoTracks.end(); ++iter) {
149 (*iter)->component()->source()->setConstraints(m_video); 151 (*iter)->component()->source()->setConstraints(m_video);
150 } 152 }
151 153
152 m_successCallback->handleEvent(stream.get()); 154 m_successCallback->handleEvent(stream.get());
153 } 155 }
154 156
155 void UserMediaRequest::fail(const String& description) 157 void UserMediaRequest::fail(const String& description)
156 { 158 {
157 if (!executionContext()) 159 if (!executionContext())
158 return; 160 return;
159 161
160 RefPtr<NavigatorUserMediaError> error = NavigatorUserMediaError::create(Navi gatorUserMediaError::NamePermissionDenied, description, String()); 162 RefPtrWillBeRawPtr<NavigatorUserMediaError> error = NavigatorUserMediaError: :create(NavigatorUserMediaError::NamePermissionDenied, description, String());
161 m_errorCallback->handleEvent(error.get()); 163 m_errorCallback->handleEvent(error.get());
162 } 164 }
163 165
164 void UserMediaRequest::failConstraint(const String& constraintName, const String & description) 166 void UserMediaRequest::failConstraint(const String& constraintName, const String & description)
165 { 167 {
166 ASSERT(!constraintName.isEmpty()); 168 ASSERT(!constraintName.isEmpty());
167 if (!executionContext()) 169 if (!executionContext())
168 return; 170 return;
169 171
170 RefPtr<NavigatorUserMediaError> error = NavigatorUserMediaError::create(Navi gatorUserMediaError::NameConstraintNotSatisfied, description, constraintName); 172 RefPtrWillBeRawPtr<NavigatorUserMediaError> error = NavigatorUserMediaError: :create(NavigatorUserMediaError::NameConstraintNotSatisfied, description, constr aintName);
171 m_errorCallback->handleEvent(error.get()); 173 m_errorCallback->handleEvent(error.get());
172 } 174 }
173 175
174 void UserMediaRequest::contextDestroyed() 176 void UserMediaRequest::contextDestroyed()
175 { 177 {
176 RefPtr<UserMediaRequest> protect(this); 178 RefPtrWillBeRawPtr<UserMediaRequest> protect(this);
177 179
178 if (m_controller) { 180 if (m_controller) {
179 m_controller->cancelUserMediaRequest(this); 181 m_controller->cancelUserMediaRequest(this);
180 m_controller = 0; 182 m_controller = 0;
181 } 183 }
182 184
183 ContextLifecycleObserver::contextDestroyed(); 185 ContextLifecycleObserver::contextDestroyed();
184 } 186 }
185 187
186 } // namespace WebCore 188 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698