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

Unified Diff: third_party/mojo/src/mojo/public/cpp/bindings/lib/thread_checker.h

Issue 1380043002: Implement a simple ThreadChecker for Mojo and add to |internal::SharedData| and |internal::Router|. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build rules. Created 5 years, 3 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
Index: third_party/mojo/src/mojo/public/cpp/bindings/lib/thread_checker.h
diff --git a/third_party/mojo/src/mojo/public/cpp/bindings/lib/thread_checker.h b/third_party/mojo/src/mojo/public/cpp/bindings/lib/thread_checker.h
new file mode 100644
index 0000000000000000000000000000000000000000..da45d0a15f257760828ce8e0ed4082fb9fde4f17
--- /dev/null
+++ b/third_party/mojo/src/mojo/public/cpp/bindings/lib/thread_checker.h
@@ -0,0 +1,37 @@
+// Copyright 2015 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 MOJO_PUBLIC_CPP_BINDINGS_LIB_THREAD_CHECKER_H_
+#define MOJO_PUBLIC_CPP_BINDINGS_LIB_THREAD_CHECKER_H_
+
+#include "mojo/public/cpp/system/macros.h"
+
+#if !defined(_WIN32)
+#include "mojo/public/cpp/bindings/lib/thread_checker_posix.h"
+#endif
+
+namespace mojo {
+namespace internal {
+
+class ThreadCheckerDoNothing {
+ public:
+ bool CalledOnValidThread() const MOJO_WARN_UNUSED_RESULT {
+ return true;
+ }
+};
+
+// ThreadChecker is a class used to verify that some methods of a class are
+// called from the same thread. It is meant to be a member variable of a class.
+// The entire lifecycle of a ThreadChecker must occur on a single thread.
+// In Release mode (without dcheck_always_on), ThreadChecker does nothing.
+#if !defined(_WIN32) && (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
+using ThreadChecker = ThreadCheckerPosix;
+#else
+using ThreadChecker = ThreadCheckerDoNothing;
+#endif
+
+} // namespace internal
+} // namespace mojo
+
+#endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_THREAD_CHECKER_H_

Powered by Google App Engine
This is Rietveld 408576698