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

Side by Side Diff: webrtc/examples/androidapp/src/org/appspot/apprtc/util/AppRTCUtils.java

Issue 1992813007: Remove AppRTCUtils.NonThreadSafe in AppRTC Android Demo (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Reorder imports Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « webrtc/examples/androidapp/src/org/appspot/apprtc/AppRTCProximitySensor.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2014 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 package org.appspot.apprtc.util; 11 package org.appspot.apprtc.util;
12 12
13 import android.os.Build; 13 import android.os.Build;
14 import android.util.Log; 14 import android.util.Log;
15 15
16 /** 16 /**
17 * AppRTCUtils provides helper functions for managing thread safety. 17 * AppRTCUtils provides helper functions for managing thread safety.
18 */ 18 */
19 public final class AppRTCUtils { 19 public final class AppRTCUtils {
20 20
21 private AppRTCUtils() { 21 private AppRTCUtils() {
22 } 22 }
23 23
24 /**
25 * NonThreadSafe is a helper class used to help verify that methods of a
26 * class are called from the same thread.
27 */
28 public static class NonThreadSafe {
29 private final Long threadId;
30
31 public NonThreadSafe() {
32 // Store thread ID of the creating thread.
33 threadId = Thread.currentThread().getId();
34 }
35
36 /** Checks if the method is called on the valid/creating thread. */
37 public boolean calledOnValidThread() {
38 return threadId.equals(Thread.currentThread().getId());
39 }
40 }
41
42 /** Helper method which throws an exception when an assertion has failed. */ 24 /** Helper method which throws an exception when an assertion has failed. */
43 public static void assertIsTrue(boolean condition) { 25 public static void assertIsTrue(boolean condition) {
44 if (!condition) { 26 if (!condition) {
45 throw new AssertionError("Expected condition to be true"); 27 throw new AssertionError("Expected condition to be true");
46 } 28 }
47 } 29 }
48 30
49 /** Helper method for building a string of thread information.*/ 31 /** Helper method for building a string of thread information.*/
50 public static String getThreadInfo() { 32 public static String getThreadInfo() {
51 return "@[name=" + Thread.currentThread().getName() 33 return "@[name=" + Thread.currentThread().getName()
52 + ", id=" + Thread.currentThread().getId() + "]"; 34 + ", id=" + Thread.currentThread().getId() + "]";
53 } 35 }
54 36
55 /** Information about the current build, taken from system properties. */ 37 /** Information about the current build, taken from system properties. */
56 public static void logDeviceInfo(String tag) { 38 public static void logDeviceInfo(String tag) {
57 Log.d(tag, "Android SDK: " + Build.VERSION.SDK_INT + ", " 39 Log.d(tag, "Android SDK: " + Build.VERSION.SDK_INT + ", "
58 + "Release: " + Build.VERSION.RELEASE + ", " 40 + "Release: " + Build.VERSION.RELEASE + ", "
59 + "Brand: " + Build.BRAND + ", " 41 + "Brand: " + Build.BRAND + ", "
60 + "Device: " + Build.DEVICE + ", " 42 + "Device: " + Build.DEVICE + ", "
61 + "Id: " + Build.ID + ", " 43 + "Id: " + Build.ID + ", "
62 + "Hardware: " + Build.HARDWARE + ", " 44 + "Hardware: " + Build.HARDWARE + ", "
63 + "Manufacturer: " + Build.MANUFACTURER + ", " 45 + "Manufacturer: " + Build.MANUFACTURER + ", "
64 + "Model: " + Build.MODEL + ", " 46 + "Model: " + Build.MODEL + ", "
65 + "Product: " + Build.PRODUCT); 47 + "Product: " + Build.PRODUCT);
66 } 48 }
67 } 49 }
OLDNEW
« no previous file with comments | « webrtc/examples/androidapp/src/org/appspot/apprtc/AppRTCProximitySensor.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698