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

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

Issue 763883006: Add Mojo CDM Service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More updates. 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "media/mojo/services/mojo_cdm_promise.h"
6
7 #include "base/bind.h"
8 #include "base/logging.h"
9 #include "media/base/decryptor.h"
10
11 namespace media {
12
13 static mojo::CdmPromiseResultPtr GetRejectResult(
14 MediaKeys::Exception exception,
15 uint32 system_code,
16 const std::string& error_message) {
17 mojo::CdmPromiseResultPtr cdm_promise_result(mojo::CdmPromiseResult::New());
18 cdm_promise_result->success = false;
19 cdm_promise_result->exception = static_cast<mojo::CdmException>(exception);
20 cdm_promise_result->system_code = system_code;
21 cdm_promise_result->error_message = error_message;
22 return cdm_promise_result.Pass();
23 }
24
25 template <typename... T>
26 MojoCdmPromise<T...>::MojoCdmPromise(const CallbackType& callback)
27 : callback_(callback) {
28 DCHECK(!callback_.is_null());
29 }
30
31 template <typename... T>
32 MojoCdmPromise<T...>::~MojoCdmPromise() {
33 if (!callback_.is_null())
34 DVLOG(1) << "Promise not resolved before destruction.";
35 }
36
37 template <typename... T>
38 void MojoCdmPromise<T...>::resolve(const T&... result) {
39 mojo::CdmPromiseResultPtr cdm_promise_result(mojo::CdmPromiseResult::New());
40 cdm_promise_result->success = true;
41 callback_.Run(cdm_promise_result.Pass(),
42 MojoTypeTrait<T>::MojoType::From(result)...);
43 callback_.reset();
44 }
45
46 template <typename... T>
47 void MojoCdmPromise<T...>::reject(MediaKeys::Exception exception,
48 uint32 system_code,
49 const std::string& error_message) {
50 callback_.Run(GetRejectResult(exception, system_code, error_message),
51 MojoTypeTrait<T>::DefaultValue()...);
52 callback_.reset();
53 }
54
55 template class MojoCdmPromise<>;
56 template class MojoCdmPromise<std::string>;
ddorwin 2014/12/12 19:25:13 Need std includes: string and vector.
xhwang 2014/12/12 23:15:44 Done.
57 template class MojoCdmPromise<std::vector<std::vector<uint8_t>>>;
58
59 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698