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

Unified Diff: mojo/public/cpp/bindings/lib/may_auto_lock.h

Issue 2707483002: Mojo C++ bindings: change some std::unique_ptr<base::Lock> to base::Optional<base::Lock>. (Closed)
Patch Set: Created 3 years, 10 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 | « mojo/public/cpp/bindings/lib/connector.cc ('k') | mojo/public/cpp/bindings/lib/multiplex_router.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/lib/may_auto_lock.h
diff --git a/mojo/public/cpp/bindings/lib/may_auto_lock.h b/mojo/public/cpp/bindings/lib/may_auto_lock.h
index 42bbfae5d64ef0e10c771c598b6db819e0932f53..06091fee90c91dcc8ee7896aa362e69c67acc917 100644
--- a/mojo/public/cpp/bindings/lib/may_auto_lock.h
+++ b/mojo/public/cpp/bindings/lib/may_auto_lock.h
@@ -6,6 +6,7 @@
#define MOJO_PUBLIC_CPP_BINDINGS_LIB_MAY_AUTO_LOCK_H_
#include "base/macros.h"
+#include "base/optional.h"
#include "base/synchronization/lock.h"
namespace mojo {
@@ -15,7 +16,8 @@ namespace internal {
// the constructor is null.
class MayAutoLock {
public:
- explicit MayAutoLock(base::Lock* lock) : lock_(lock) {
+ explicit MayAutoLock(base::Optional<base::Lock>* lock)
+ : lock_(lock->has_value() ? &lock->value() : nullptr) {
if (lock_)
lock_->Acquire();
}
@@ -36,7 +38,8 @@ class MayAutoLock {
// into the constructor is null.
class MayAutoUnlock {
public:
- explicit MayAutoUnlock(base::Lock* lock) : lock_(lock) {
+ explicit MayAutoUnlock(base::Optional<base::Lock>* lock)
+ : lock_(lock->has_value() ? &lock->value() : nullptr) {
if (lock_) {
lock_->AssertAcquired();
lock_->Release();
« no previous file with comments | « mojo/public/cpp/bindings/lib/connector.cc ('k') | mojo/public/cpp/bindings/lib/multiplex_router.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698