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

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

Issue 1977173002: Rename media::interfaces to media::mojom. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: android + chromeos files Created 4 years, 7 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
« no previous file with comments | « media/mojo/services/mojo_cdm_promise.h ('k') | media/mojo/services/mojo_cdm_service.h » ('j') | 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 <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "media/base/decryptor.h" 13 #include "media/base/decryptor.h"
14 #include "media/base/media_keys.h" 14 #include "media/base/media_keys.h"
15 15
16 namespace media { 16 namespace media {
17 17
18 static interfaces::CdmPromiseResultPtr GetRejectResult( 18 static mojom::CdmPromiseResultPtr GetRejectResult(
19 MediaKeys::Exception exception, 19 MediaKeys::Exception exception,
20 uint32_t system_code, 20 uint32_t system_code,
21 const std::string& error_message) { 21 const std::string& error_message) {
22 interfaces::CdmPromiseResultPtr cdm_promise_result( 22 mojom::CdmPromiseResultPtr cdm_promise_result(mojom::CdmPromiseResult::New());
23 interfaces::CdmPromiseResult::New());
24 cdm_promise_result->success = false; 23 cdm_promise_result->success = false;
25 cdm_promise_result->exception = 24 cdm_promise_result->exception = static_cast<mojom::CdmException>(exception);
26 static_cast<interfaces::CdmException>(exception);
27 cdm_promise_result->system_code = system_code; 25 cdm_promise_result->system_code = system_code;
28 cdm_promise_result->error_message = error_message; 26 cdm_promise_result->error_message = error_message;
29 return cdm_promise_result; 27 return cdm_promise_result;
30 } 28 }
31 29
32 template <typename... T> 30 template <typename... T>
33 MojoCdmPromise<T...>::MojoCdmPromise(const CallbackType& callback) 31 MojoCdmPromise<T...>::MojoCdmPromise(const CallbackType& callback)
34 : callback_(callback) { 32 : callback_(callback) {
35 DCHECK(!callback_.is_null()); 33 DCHECK(!callback_.is_null());
36 } 34 }
37 35
38 template <typename... T> 36 template <typename... T>
39 MojoCdmPromise<T...>::~MojoCdmPromise() { 37 MojoCdmPromise<T...>::~MojoCdmPromise() {
40 if (IsPromiseSettled()) 38 if (IsPromiseSettled())
41 return; 39 return;
42 40
43 DCHECK(!callback_.is_null()); 41 DCHECK(!callback_.is_null());
44 RejectPromiseOnDestruction(); 42 RejectPromiseOnDestruction();
45 } 43 }
46 44
47 template <typename... T> 45 template <typename... T>
48 void MojoCdmPromise<T...>::resolve(const T&... result) { 46 void MojoCdmPromise<T...>::resolve(const T&... result) {
49 MarkPromiseSettled(); 47 MarkPromiseSettled();
50 interfaces::CdmPromiseResultPtr cdm_promise_result( 48 mojom::CdmPromiseResultPtr cdm_promise_result(mojom::CdmPromiseResult::New());
51 interfaces::CdmPromiseResult::New());
52 cdm_promise_result->success = true; 49 cdm_promise_result->success = true;
53 callback_.Run( 50 callback_.Run(
54 std::move(cdm_promise_result), 51 std::move(cdm_promise_result),
55 mojo::TypeConverter<typename MojoTypeTrait<T>::MojoType, T>::Convert( 52 mojo::TypeConverter<typename MojoTypeTrait<T>::MojoType, T>::Convert(
56 result)...); 53 result)...);
57 callback_.reset(); 54 callback_.reset();
58 } 55 }
59 56
60 template <typename... T> 57 template <typename... T>
61 void MojoCdmPromise<T...>::reject(MediaKeys::Exception exception, 58 void MojoCdmPromise<T...>::reject(MediaKeys::Exception exception,
62 uint32_t system_code, 59 uint32_t system_code,
63 const std::string& error_message) { 60 const std::string& error_message) {
64 MarkPromiseSettled(); 61 MarkPromiseSettled();
65 callback_.Run(GetRejectResult(exception, system_code, error_message), 62 callback_.Run(GetRejectResult(exception, system_code, error_message),
66 MojoTypeTrait<T>::DefaultValue()...); 63 MojoTypeTrait<T>::DefaultValue()...);
67 callback_.reset(); 64 callback_.reset();
68 } 65 }
69 66
70 template class MojoCdmPromise<>; 67 template class MojoCdmPromise<>;
71 template class MojoCdmPromise<std::string>; 68 template class MojoCdmPromise<std::string>;
72 69
73 } // namespace media 70 } // namespace media
OLDNEW
« no previous file with comments | « media/mojo/services/mojo_cdm_promise.h ('k') | media/mojo/services/mojo_cdm_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698