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

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

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

Powered by Google App Engine
This is Rietveld 408576698