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

Side by Side Diff: device/capture/video/scoped_result_callback.h

Issue 2214533002: move //media/capture to //device/capture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 MEDIA_CAPTURE_VIDEO_SCOPED_RESULT_CALLBACK_H_ 5 #ifndef DEVICE_CAPTURE_VIDEO_SCOPED_RESULT_CALLBACK_H_
6 #define MEDIA_CAPTURE_VIDEO_SCOPED_RESULT_CALLBACK_H_ 6 #define DEVICE_CAPTURE_VIDEO_SCOPED_RESULT_CALLBACK_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 11
12 namespace media { 12 namespace device {
13 13
14 // This class guarantees that |callback_| has either been called or will pass it 14 // This class guarantees that |callback_| has either been called or will pass it
15 // to |on_error_callback_| on destruction. Inspired by ScopedWebCallbacks<>. 15 // to |on_error_callback_| on destruction. Inspired by ScopedWebCallbacks<>.
16 template <typename CallbackType> 16 template <typename CallbackType>
17 class ScopedResultCallback { 17 class ScopedResultCallback {
18 public: 18 public:
19 using OnErrorCallback = base::Callback<void(const CallbackType&)>; 19 using OnErrorCallback = base::Callback<void(const CallbackType&)>;
20 ScopedResultCallback(const CallbackType& callback, 20 ScopedResultCallback(const CallbackType& callback,
21 const OnErrorCallback& on_error_callback) 21 const OnErrorCallback& on_error_callback)
22 : callback_(callback), on_error_callback_(on_error_callback) {} 22 : callback_(callback), on_error_callback_(on_error_callback) {}
(...skipping 21 matching lines...) Expand all
44 base::ResetAndReturn(&callback_).Run(std::forward<Args>(args)...); 44 base::ResetAndReturn(&callback_).Run(std::forward<Args>(args)...);
45 } 45 }
46 46
47 private: 47 private:
48 CallbackType callback_; 48 CallbackType callback_;
49 OnErrorCallback on_error_callback_; 49 OnErrorCallback on_error_callback_;
50 50
51 DISALLOW_COPY_AND_ASSIGN(ScopedResultCallback); 51 DISALLOW_COPY_AND_ASSIGN(ScopedResultCallback);
52 }; 52 };
53 53
54 } // namespace media 54 } // namespace device
55 55
56 #endif // MEDIA_CAPTURE_VIDEO_SCOPED_RESULT_CALLBACK_H_ 56 #endif // DEVICE_CAPTURE_VIDEO_SCOPED_RESULT_CALLBACK_H_
OLDNEW
« no previous file with comments | « device/capture/video/mac/video_capture_device_mac.mm ('k') | device/capture/video/video_capture_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698