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

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

Issue 2411573002: media: Use new wrapper types for media mojo interfaces (Closed)
Patch Set: media: Use new wrapper types for media mojo interfaces Created 4 years, 2 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 #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 <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 29 matching lines...) Expand all
40 40
41 DCHECK(!callback_.is_null()); 41 DCHECK(!callback_.is_null());
42 RejectPromiseOnDestruction(); 42 RejectPromiseOnDestruction();
43 } 43 }
44 44
45 template <typename... T> 45 template <typename... T>
46 void MojoCdmPromise<T...>::resolve(const T&... result) { 46 void MojoCdmPromise<T...>::resolve(const T&... result) {
47 MarkPromiseSettled(); 47 MarkPromiseSettled();
48 mojom::CdmPromiseResultPtr cdm_promise_result(mojom::CdmPromiseResult::New()); 48 mojom::CdmPromiseResultPtr cdm_promise_result(mojom::CdmPromiseResult::New());
49 cdm_promise_result->success = true; 49 cdm_promise_result->success = true;
50 callback_.Run( 50 callback_.Run(std::move(cdm_promise_result), result...);
51 std::move(cdm_promise_result),
52 mojo::TypeConverter<typename MojoTypeTrait<T>::MojoType, T>::Convert(
53 result)...);
54 callback_.Reset(); 51 callback_.Reset();
55 } 52 }
56 53
57 template <typename... T> 54 template <typename... T>
58 void MojoCdmPromise<T...>::reject(MediaKeys::Exception exception, 55 void MojoCdmPromise<T...>::reject(MediaKeys::Exception exception,
59 uint32_t system_code, 56 uint32_t system_code,
60 const std::string& error_message) { 57 const std::string& error_message) {
61 MarkPromiseSettled(); 58 MarkPromiseSettled();
62 callback_.Run(GetRejectResult(exception, system_code, error_message), 59 callback_.Run(GetRejectResult(exception, system_code, error_message), T()...);
63 MojoTypeTrait<T>::DefaultValue()...);
64 callback_.Reset(); 60 callback_.Reset();
65 } 61 }
66 62
67 template class MojoCdmPromise<>; 63 template class MojoCdmPromise<>;
68 template class MojoCdmPromise<std::string>; 64 template class MojoCdmPromise<std::string>;
69 65
70 } // namespace media 66 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698