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

Side by Side Diff: base/android/java/src/org/chromium/base/UnguessableToken.java

Issue 2468353002: Added UnguessableToken.java . (Closed)
Patch Set: comments Created 4 years, 1 month 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
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.base;
6
7 import android.os.Parcel;
8 import android.os.Parcelable;
9
10 import org.chromium.base.annotations.CalledByNative;
11
12 /**
13 * This class mirrors unguessable_token.h . Since tokens are passed by value,
14 * we don't bother to maintain a native token. This implements Parcelable so
15 * that it may be sent via binder.
16 *
17 * To get one of these from native, one must start with a
18 * base::UnguessableToken, then create a java object from it. See
19 * jni_unguessable_token.h for information.
20 */
21 public class UnguessableToken implements Parcelable {
22 private long mHigh;
23 private long mLow;
24
25 private UnguessableToken(long high, long low) {
26 mHigh = high;
27 mLow = low;
28 }
29
30 @CalledByNative
31 private static UnguessableToken create(long high, long low) {
32 return new UnguessableToken(high, low);
33 }
34
35 @CalledByNative
36 private long getHighForSerialization() {
37 return mHigh;
38 }
39
40 @CalledByNative
41 private long getLowForSerialization() {
42 return mLow;
43 }
44
45 @Override
46 public int describeContents() {
47 return 0;
48 }
49
50 @Override
51 public void writeToParcel(Parcel dest, int flags) {
liberato (no reviews please) 2016/11/02 22:18:24 i need to add unit tests for these. didn't see an
52 dest.writeLong(mHigh);
53 dest.writeLong(mLow);
54 }
55
56 public static Parcelable.Creator<UnguessableToken> CREATOR =
57 new Parcelable.Creator<UnguessableToken>() {
58 @Override
59 public UnguessableToken createFromParcel(Parcel source) {
60 final long high = source.readLong();
61 final long low = source.readLong();
62 return new UnguessableToken(high, low);
63 }
64
65 @Override
66 public UnguessableToken[] newArray(int size) {
67 return new UnguessableToken[size];
68 }
69 };
70 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698