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

Unified Diff: media/capture/video/scoped_result_callback.h

Issue 2143903003: [WIP] Move media/capture to device/capture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/capture/video/mac/video_capture_device_mac.mm ('k') | media/capture/video/video_capture_device.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/capture/video/scoped_result_callback.h
diff --git a/media/capture/video/scoped_result_callback.h b/media/capture/video/scoped_result_callback.h
deleted file mode 100644
index af4edc1740504fa04b343400a30ee6a8d7deba88..0000000000000000000000000000000000000000
--- a/media/capture/video/scoped_result_callback.h
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef MEDIA_CAPTURE_VIDEO_SCOPED_RESULT_CALLBACK_H_
-#define MEDIA_CAPTURE_VIDEO_SCOPED_RESULT_CALLBACK_H_
-
-#include "base/callback.h"
-#include "base/callback_helpers.h"
-#include "base/macros.h"
-
-namespace media {
-
-// This class guarantees that |callback_| has either been called or will pass it
-// to |on_error_callback_| on destruction. Inspired by ScopedWebCallbacks<>.
-template <typename CallbackType>
-class ScopedResultCallback {
- public:
- using OnErrorCallback = base::Callback<void(const CallbackType&)>;
- ScopedResultCallback(const CallbackType& callback,
- const OnErrorCallback& on_error_callback)
- : callback_(callback), on_error_callback_(on_error_callback) {}
-
- ~ScopedResultCallback() {
- if (!callback_.is_null())
- on_error_callback_.Run(callback_);
- }
-
- ScopedResultCallback(ScopedResultCallback&& other) {
- *this = std::move(other);
- }
-
- ScopedResultCallback& operator=(ScopedResultCallback&& other) {
- callback_ = other.callback_;
- other.callback_.Reset();
- on_error_callback_ = other.on_error_callback_;
- other.on_error_callback_.Reset();
- return *this;
- }
-
- template <typename... Args>
- void Run(Args... args) {
- on_error_callback_.Reset();
- base::ResetAndReturn(&callback_).Run(std::forward<Args>(args)...);
- }
-
- private:
- CallbackType callback_;
- OnErrorCallback on_error_callback_;
-
- DISALLOW_COPY_AND_ASSIGN(ScopedResultCallback);
-};
-
-} // namespace media
-
-#endif // MEDIA_CAPTURE_VIDEO_SCOPED_RESULT_CALLBACK_H_
« no previous file with comments | « media/capture/video/mac/video_capture_device_mac.mm ('k') | media/capture/video/video_capture_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698