summaryrefslogtreecommitdiffstats
path: root/mojo
diff options
context:
space:
mode:
authoryzshen <yzshen@chromium.org>2015-12-11 16:16:13 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-12 00:17:10 +0000
commit42b13e3af4be21f043908bccca0a8b40bce22b54 (patch)
tree21cc718397ed5e4fec27886cd0d865fd7c049180 /mojo
parentef8e116de39bc2c321cb120f5d5e1f2b8c6d1d98 (diff)
downloadchromium_src-42b13e3af4be21f043908bccca0a8b40bce22b54.zip
chromium_src-42b13e3af4be21f043908bccca0a8b40bce22b54.tar.gz
chromium_src-42b13e3af4be21f043908bccca0a8b40bce22b54.tar.bz2
Mojo C++ bindings: use base::ThreadChecker instead of mojo::internal::ThreadChecker.
BUG=None Review URL: https://codereview.chromium.org/1515033003 Cr-Commit-Position: refs/heads/master@{#364843}
Diffstat (limited to 'mojo')
-rw-r--r--mojo/public/cpp/bindings/BUILD.gn4
-rw-r--r--mojo/public/cpp/bindings/lib/router.h4
-rw-r--r--mojo/public/cpp/bindings/lib/shared_data.h4
-rw-r--r--mojo/public/cpp/bindings/lib/thread_checker.h37
-rw-r--r--mojo/public/cpp/bindings/lib/thread_checker_posix.cc24
-rw-r--r--mojo/public/cpp/bindings/lib/thread_checker_posix.h31
6 files changed, 5 insertions, 99 deletions
diff --git a/mojo/public/cpp/bindings/BUILD.gn b/mojo/public/cpp/bindings/BUILD.gn
index aa69882..3cc4dbf 100644
--- a/mojo/public/cpp/bindings/BUILD.gn
+++ b/mojo/public/cpp/bindings/BUILD.gn
@@ -100,12 +100,10 @@ source_set("callback") {
"lib/shared_data.h",
"lib/shared_ptr.h",
"lib/template_util.h",
- "lib/thread_checker.h",
- "lib/thread_checker_posix.cc",
- "lib/thread_checker_posix.h",
]
deps = [
+ "//base",
"//mojo/public/cpp/system",
]
}
diff --git a/mojo/public/cpp/bindings/lib/router.h b/mojo/public/cpp/bindings/lib/router.h
index 1697610..5ef78c6 100644
--- a/mojo/public/cpp/bindings/lib/router.h
+++ b/mojo/public/cpp/bindings/lib/router.h
@@ -7,11 +7,11 @@
#include <map>
+#include "base/threading/thread_checker.h"
#include "mojo/public/cpp/bindings/callback.h"
#include "mojo/public/cpp/bindings/lib/connector.h"
#include "mojo/public/cpp/bindings/lib/filter_chain.h"
#include "mojo/public/cpp/bindings/lib/shared_data.h"
-#include "mojo/public/cpp/bindings/lib/thread_checker.h"
#include "mojo/public/cpp/environment/environment.h"
#include "mojo/public/cpp/environment/logging.h"
@@ -132,7 +132,7 @@ class Router : public MessageReceiverWithResponder {
ResponderMap responders_;
uint64_t next_request_id_;
bool testing_mode_;
- ThreadChecker thread_checker_;
+ base::ThreadChecker thread_checker_;
};
} // namespace internal
diff --git a/mojo/public/cpp/bindings/lib/shared_data.h b/mojo/public/cpp/bindings/lib/shared_data.h
index 2676224..e2de974 100644
--- a/mojo/public/cpp/bindings/lib/shared_data.h
+++ b/mojo/public/cpp/bindings/lib/shared_data.h
@@ -7,7 +7,7 @@
#include <assert.h>
-#include "mojo/public/cpp/bindings/lib/thread_checker.h"
+#include "base/threading/thread_checker.h"
#include "mojo/public/cpp/system/macros.h"
namespace mojo {
@@ -70,7 +70,7 @@ class SharedData {
private:
int ref_count_;
- ThreadChecker thread_checker_;
+ base::ThreadChecker thread_checker_;
MOJO_DISALLOW_COPY_AND_ASSIGN(Holder);
};
diff --git a/mojo/public/cpp/bindings/lib/thread_checker.h b/mojo/public/cpp/bindings/lib/thread_checker.h
deleted file mode 100644
index da45d0a..0000000
--- a/mojo/public/cpp/bindings/lib/thread_checker.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// 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_
diff --git a/mojo/public/cpp/bindings/lib/thread_checker_posix.cc b/mojo/public/cpp/bindings/lib/thread_checker_posix.cc
deleted file mode 100644
index c8a16e2..0000000
--- a/mojo/public/cpp/bindings/lib/thread_checker_posix.cc
+++ /dev/null
@@ -1,24 +0,0 @@
-// 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.
-
-#include "mojo/public/cpp/bindings/lib/thread_checker_posix.h"
-
-#include <assert.h>
-
-namespace mojo {
-namespace internal {
-
-ThreadCheckerPosix::ThreadCheckerPosix() : attached_thread_id_(pthread_self()) {
-}
-
-ThreadCheckerPosix::~ThreadCheckerPosix() {
- assert(CalledOnValidThread());
-}
-
-bool ThreadCheckerPosix::CalledOnValidThread() const {
- return pthread_equal(pthread_self(), attached_thread_id_);
-}
-
-} // namespace internal
-} // namespace mojo
diff --git a/mojo/public/cpp/bindings/lib/thread_checker_posix.h b/mojo/public/cpp/bindings/lib/thread_checker_posix.h
deleted file mode 100644
index 4701b88..0000000
--- a/mojo/public/cpp/bindings/lib/thread_checker_posix.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// 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_POSIX_H_
-#define MOJO_PUBLIC_CPP_BINDINGS_LIB_THREAD_CHECKER_POSIX_H_
-
-#include <pthread.h>
-
-#include "mojo/public/cpp/system/macros.h"
-
-namespace mojo {
-namespace internal {
-
-// An implementation of ThreadChecker for POSIX systems.
-class ThreadCheckerPosix {
- public:
- ThreadCheckerPosix();
- ~ThreadCheckerPosix();
-
- bool CalledOnValidThread() const MOJO_WARN_UNUSED_RESULT;
- private:
- const pthread_t attached_thread_id_;
-
- MOJO_DISALLOW_COPY_AND_ASSIGN(ThreadCheckerPosix);
-};
-
-} // namespace internal
-} // namespace mojo
-
-#endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_THREAD_CHECKER_POSIX_H_