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

Side by Side Diff: media/base/cdm_promise.h

Issue 1729063003: media: Reject pending CDM promise during destruction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef MEDIA_BASE_CDM_PROMISE_H_ 5 #ifndef MEDIA_BASE_CDM_PROMISE_H_
6 #define MEDIA_BASE_CDM_PROMISE_H_ 6 #define MEDIA_BASE_CDM_PROMISE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 // CdmPromise implementation. 92 // CdmPromise implementation.
93 virtual void reject(MediaKeys::Exception exception_code, 93 virtual void reject(MediaKeys::Exception exception_code,
94 uint32_t system_code, 94 uint32_t system_code,
95 const std::string& error_message) = 0; 95 const std::string& error_message) = 0;
96 96
97 ResolveParameterType GetResolveParameterType() const override { 97 ResolveParameterType GetResolveParameterType() const override {
98 return CdmPromiseTraits<T...>::kType; 98 return CdmPromiseTraits<T...>::kType;
99 } 99 }
100 100
101 protected: 101 protected:
102 bool IsPromiseSettled() const { return is_settled_; }
103
102 // All implementations must call this method in resolve() and reject() methods 104 // All implementations must call this method in resolve() and reject() methods
103 // to indicate that the promise has been settled. 105 // to indicate that the promise has been settled.
104 void MarkPromiseSettled() { 106 void MarkPromiseSettled() {
105 // Promise can only be settled once. 107 // Promise can only be settled once.
106 DCHECK(!is_settled_); 108 DCHECK(!is_settled_);
107 is_settled_ = true; 109 is_settled_ = true;
108 } 110 }
109 111
112 void RejectPromiseOnDestruction() {
ddorwin 2016/02/26 17:29:28 // Must be called by the concrete destructor if !I
xhwang 2016/02/26 20:52:21 Done.
113 DCHECK(!is_settled_);
114 std::string message =
115 "Unfulfilled promise rejected automatically during destruction.";
116 DVLOG(1) << message;
117 reject(MediaKeys::INVALID_STATE_ERROR, 0, message);
118 DCHECK(is_settled_);
119 }
120
110 private: 121 private:
111 // Keep track of whether the promise has been resolved or rejected yet. 122 // Keep track of whether the promise has been resolved or rejected yet.
112 bool is_settled_; 123 bool is_settled_;
113 124
114 DISALLOW_COPY_AND_ASSIGN(CdmPromiseTemplate); 125 DISALLOW_COPY_AND_ASSIGN(CdmPromiseTemplate);
115 }; 126 };
116 127
117 } // namespace media 128 } // namespace media
118 129
119 #endif // MEDIA_BASE_CDM_PROMISE_H_ 130 #endif // MEDIA_BASE_CDM_PROMISE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698