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

Side by Side Diff: services/media/framework/safe_clone.h

Issue 1822333002: Motown: wholesale clang-format (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: dalesat Created 4 years, 9 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef SERVICES_MEDIA_FRAMEWORK_SAFE_CLONE_H_ 5 #ifndef SERVICES_MEDIA_FRAMEWORK_SAFE_CLONE_H_
6 #define SERVICES_MEDIA_FRAMEWORK_SAFE_CLONE_H_ 6 #define SERVICES_MEDIA_FRAMEWORK_SAFE_CLONE_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
11 namespace mojo { 11 namespace mojo {
12 namespace media { 12 namespace media {
13 13
14 template<typename T> 14 template <typename T>
15 std::unique_ptr<T> SafeClone(const std::unique_ptr<T>& t_ptr) { 15 std::unique_ptr<T> SafeClone(const std::unique_ptr<T>& t_ptr) {
16 return t_ptr ? t_ptr.get()->Clone() : nullptr; 16 return t_ptr ? t_ptr.get()->Clone() : nullptr;
17 } 17 }
18 18
19 template<typename T> 19 template <typename T>
20 std::unique_ptr<std::vector<std::unique_ptr<T>>> SafeClone( 20 std::unique_ptr<std::vector<std::unique_ptr<T>>> SafeClone(
21 const std::unique_ptr<std::vector<std::unique_ptr<T>>>& vec) { 21 const std::unique_ptr<std::vector<std::unique_ptr<T>>>& vec) {
22 if (vec == nullptr) { 22 if (vec == nullptr) {
23 return nullptr; 23 return nullptr;
24 } 24 }
25 25
26 std::unique_ptr<std::vector<std::unique_ptr<T>>> result = 26 std::unique_ptr<std::vector<std::unique_ptr<T>>> result =
27 std::unique_ptr<std::vector<std::unique_ptr<T>>>( 27 std::unique_ptr<std::vector<std::unique_ptr<T>>>(
28 new std::vector<std::unique_ptr<T>>(vec->size())); 28 new std::vector<std::unique_ptr<T>>(vec->size()));
29 29
30 for (const std::unique_ptr<T>& t_ptr : *vec.get()) { 30 for (const std::unique_ptr<T>& t_ptr : *vec.get()) {
31 result->push_back(SafeClone(t_ptr)); 31 result->push_back(SafeClone(t_ptr));
32 } 32 }
33 33
34 return result; 34 return result;
35 } 35 }
36 36
37 } // namespace media 37 } // namespace media
38 } // namespace mojo 38 } // namespace mojo
39 39
40 #endif // SERVICES_MEDIA_FRAMEWORK_SAFE_CLONE_H_ 40 #endif // SERVICES_MEDIA_FRAMEWORK_SAFE_CLONE_H_
OLDNEW
« no previous file with comments | « services/media/framework/result.h ('k') | services/media/framework/stages/active_multistream_sink_stage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698