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

Unified Diff: chrome/android/java_staging/src/org/chromium/chrome/browser/util/NonThreadSafe.java

Issue 1206673003: Merge java_staging/src into java/src. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 6 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: chrome/android/java_staging/src/org/chromium/chrome/browser/util/NonThreadSafe.java
diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/util/NonThreadSafe.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/util/NonThreadSafe.java
deleted file mode 100644
index 9bfc32cede62bfd107833018628a35f492ea0425..0000000000000000000000000000000000000000
--- a/chrome/android/java_staging/src/org/chromium/chrome/browser/util/NonThreadSafe.java
+++ /dev/null
@@ -1,45 +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.
-
-package org.chromium.chrome.browser.util;
-
-import org.chromium.base.VisibleForTesting;
-import org.chromium.base.annotations.SuppressFBWarnings;
-
-/**
- * NonThreadSafe is a helper class used to help verify that methods of a
- * class are called from the same thread.
- */
-public class NonThreadSafe {
- private Long mThreadId = null;
-
- public NonThreadSafe() {
- ensureThreadIdAssigned();
- }
-
- /**
- * Changes the thread that is checked for in CalledOnValidThread. This may
- * be useful when an object may be created on one thread and then used
- * exclusively on another thread.
- */
- @SuppressFBWarnings("CHROMIUM_SYNCHRONIZED_METHOD")
- @VisibleForTesting
- public synchronized void detachFromThread() {
- mThreadId = null;
- }
-
- /**
- * Checks if the method is called on the valid thread.
- * Assigns the current thread if no thread was assigned.
- */
- @SuppressFBWarnings("CHROMIUM_SYNCHRONIZED_METHOD")
- public synchronized boolean calledOnValidThread() {
- ensureThreadIdAssigned();
- return mThreadId.equals(Thread.currentThread().getId());
- }
-
- private void ensureThreadIdAssigned() {
- if (mThreadId == null) mThreadId = Thread.currentThread().getId();
- }
-}

Powered by Google App Engine
This is Rietveld 408576698