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

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

Issue 1661493002: Add promise-based addIceCandidate, setLocalDescription and setRemoteDescription to RTCPeerConnection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: philipj's comments on tests Created 4 years, 10 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) 2015 Google Inc. All rights reserved. 2 * Copyright (C) 2015 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 } 42 }
43 43
44 void MediaErrorState::throwTypeError(const String& message) 44 void MediaErrorState::throwTypeError(const String& message)
45 { 45 {
46 m_errorType = TypeError; 46 m_errorType = TypeError;
47 m_message = message; 47 m_message = message;
48 } 48 }
49 49
50 void MediaErrorState::throwDOMException(const ExceptionCode& code, const String& message) 50 void MediaErrorState::throwDOMException(const ExceptionCode& code, const String& message)
51 { 51 {
52 m_errorType = DOMError; 52 m_errorType = DOMException;
53 m_code = code; 53 m_code = code;
54 m_message = message; 54 m_message = message;
55 } 55 }
56 56
57 void MediaErrorState::throwConstraintError(const String& message, const String& constraint) 57 void MediaErrorState::throwConstraintError(const String& message, const String& constraint)
58 { 58 {
59 m_errorType = ConstraintError; 59 m_errorType = ConstraintError;
60 m_message = message; 60 m_message = message;
61 m_constraint = constraint; 61 m_constraint = constraint;
62 } 62 }
63 63
64 void MediaErrorState::reset() 64 void MediaErrorState::reset()
65 { 65 {
66 m_errorType = NoError; 66 m_errorType = NoError;
67 } 67 }
68 68
69 bool MediaErrorState::hadException() 69 bool MediaErrorState::hadException()
70 { 70 {
71 return m_errorType != NoError; 71 return m_errorType != NoError;
72 } 72 }
73 73
74 bool MediaErrorState::canGenerateException() 74 bool MediaErrorState::canGenerateException()
75 { 75 {
76 return m_errorType == TypeError || m_errorType == DOMError; 76 return m_errorType == TypeError || m_errorType == DOMException;
77 } 77 }
78 78
79 void MediaErrorState::raiseException(ExceptionState& target) 79 void MediaErrorState::raiseException(ExceptionState& target)
80 { 80 {
81 switch (m_errorType) { 81 switch (m_errorType) {
82 case NoError: 82 case NoError:
83 ASSERT_NOT_REACHED(); 83 ASSERT_NOT_REACHED();
84 break; 84 break;
85 case TypeError: 85 case TypeError:
86 target.throwTypeError(m_message); 86 target.throwTypeError(m_message);
87 break; 87 break;
88 case DOMError: 88 case DOMException:
89 target.throwDOMException(m_code, m_message); 89 target.throwDOMException(m_code, m_message);
90 break; 90 break;
91 case ConstraintError: 91 case ConstraintError:
92 // This is for the cases where we can't pass back a 92 // This is for the cases where we can't pass back a
93 // NavigatorUserMediaError. 93 // NavigatorUserMediaError.
94 // So far, we have this in the constructor of RTCPeerConnection, 94 // So far, we have this in the constructor of RTCPeerConnection,
95 // which is due to be deprecated. 95 // which is due to be deprecated.
96 // TODO(hta): Remove this code. https://crbug.com/576581 96 // TODO(hta): Remove this code. https://crbug.com/576581
97 target.throwDOMException(NotSupportedError, "Unsatisfiable constraint " + m_constraint); 97 target.throwDOMException(NotSupportedError, "Unsatisfiable constraint " + m_constraint);
98 break; 98 break;
99 default:
100 ASSERT_NOT_REACHED();
99 } 101 }
100 } 102 }
101 103
104 String MediaErrorState::getErrorMessage()
105 {
106 switch (m_errorType) {
107 case NoError:
108 ASSERT_NOT_REACHED();
109 break;
110 case TypeError:
111 case DOMException:
112 return m_message;
113 case ConstraintError:
114 // This is for the cases where we can't pass back a
115 // NavigatorUserMediaError.
116 // So far, we have this in the constructor of RTCPeerConnection,
117 // which is due to be deprecated.
118 // TODO(hta): Remove this code. https://crbug.com/576581
119 return "Unsatisfiable constraint " + m_constraint;
120 default:
121 ASSERT_NOT_REACHED();
122 }
123
124 return String();
125 }
126
102 NavigatorUserMediaError* MediaErrorState::createError() 127 NavigatorUserMediaError* MediaErrorState::createError()
103 { 128 {
104 ASSERT(m_errorType == ConstraintError); 129 ASSERT(m_errorType == ConstraintError);
105 return NavigatorUserMediaError::create(NavigatorUserMediaError::NameConstrai ntNotSatisfied, m_message, m_constraint); 130 return NavigatorUserMediaError::create(NavigatorUserMediaError::NameConstrai ntNotSatisfied, m_message, m_constraint);
106 } 131 }
107 132
108 133
109 } // namespace blink 134 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698