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

Side by Side Diff: media/mojo/services/mojo_cdm_promise.cc

Issue 817143003: Fix MojoCdmPromise resolving. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « media/mojo/services/mojo_cdm_promise.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "media/mojo/services/mojo_cdm_promise.h" 5 #include "media/mojo/services/mojo_cdm_promise.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 22 matching lines...) Expand all
33 } 33 }
34 34
35 template <typename... T> 35 template <typename... T>
36 MojoCdmPromise<T...>::~MojoCdmPromise() { 36 MojoCdmPromise<T...>::~MojoCdmPromise() {
37 if (!callback_.is_null()) 37 if (!callback_.is_null())
38 DVLOG(1) << "Promise not resolved before destruction."; 38 DVLOG(1) << "Promise not resolved before destruction.";
39 } 39 }
40 40
41 template <typename... T> 41 template <typename... T>
42 void MojoCdmPromise<T...>::resolve(const T&... result) { 42 void MojoCdmPromise<T...>::resolve(const T&... result) {
43 MarkPromiseSettled();
43 mojo::CdmPromiseResultPtr cdm_promise_result(mojo::CdmPromiseResult::New()); 44 mojo::CdmPromiseResultPtr cdm_promise_result(mojo::CdmPromiseResult::New());
44 cdm_promise_result->success = true; 45 cdm_promise_result->success = true;
45 callback_.Run(cdm_promise_result.Pass(), 46 callback_.Run(cdm_promise_result.Pass(),
46 MojoTypeTrait<T>::MojoType::From(result)...); 47 MojoTypeTrait<T>::MojoType::From(result)...);
47 callback_.reset(); 48 callback_.reset();
48 } 49 }
49 50
50 template <typename... T> 51 template <typename... T>
51 void MojoCdmPromise<T...>::reject(MediaKeys::Exception exception, 52 void MojoCdmPromise<T...>::reject(MediaKeys::Exception exception,
52 uint32_t system_code, 53 uint32_t system_code,
53 const std::string& error_message) { 54 const std::string& error_message) {
55 MarkPromiseSettled();
54 callback_.Run(GetRejectResult(exception, system_code, error_message), 56 callback_.Run(GetRejectResult(exception, system_code, error_message),
55 MojoTypeTrait<T>::DefaultValue()...); 57 MojoTypeTrait<T>::DefaultValue()...);
56 callback_.reset(); 58 callback_.reset();
57 } 59 }
58 60
59 template class MojoCdmPromise<>; 61 template class MojoCdmPromise<>;
60 template class MojoCdmPromise<std::string>; 62 template class MojoCdmPromise<std::string>;
61 63
62 } // namespace media 64 } // namespace media
OLDNEW
« no previous file with comments | « media/mojo/services/mojo_cdm_promise.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698