Chromium Code Reviews| OLD | NEW |
|---|---|
| (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.annotation.SuppressLint; | |
| 8 import android.os.Parcel; | |
| 9 import android.os.ParcelFileDescriptor; | |
| 10 import android.os.Parcelable; | |
| 11 | |
| 12 /** | |
| 13 * Parcelable class that contains file descriptor and an ID. | |
| 14 * TODO(jcivelli): should be merged with | |
| 15 * org.chromium.content.common.FileDescriptorInfo | |
| 16 */ | |
| 17 @SuppressLint("ParcelClassLoader") | |
| 18 public final class FileDescriptorInfo implements Parcelable { | |
| 19 /** An consumer chosen ID that uniquely identifies a file descriptor. */ | |
| 20 public final int id; | |
|
Robert Sesek
2016/12/20 20:44:34
Since the base C++ calls this "key" -- why not do
Jay Civelli
2016/12/20 23:07:26
Good idea, done.
| |
| 21 | |
| 22 /** A file descriptor to access the file. */ | |
| 23 public final ParcelFileDescriptor fd; | |
| 24 | |
| 25 public FileDescriptorInfo(int id, ParcelFileDescriptor fd) { | |
| 26 this.id = id; | |
| 27 this.fd = fd; | |
| 28 } | |
| 29 | |
| 30 FileDescriptorInfo(Parcel in) { | |
| 31 id = in.readInt(); | |
| 32 fd = in.readParcelable(null); | |
| 33 } | |
| 34 | |
| 35 @Override | |
| 36 public int describeContents() { | |
| 37 return CONTENTS_FILE_DESCRIPTOR; | |
| 38 } | |
| 39 | |
| 40 @Override | |
| 41 public void writeToParcel(Parcel dest, int flags) { | |
| 42 dest.writeInt(id); | |
| 43 dest.writeParcelable(fd, CONTENTS_FILE_DESCRIPTOR); | |
| 44 } | |
| 45 | |
| 46 public static final Parcelable.Creator<FileDescriptorInfo> CREATOR = | |
| 47 new Parcelable.Creator<FileDescriptorInfo>() { | |
| 48 @Override | |
| 49 public FileDescriptorInfo createFromParcel(Parcel in) { | |
| 50 return new FileDescriptorInfo(in); | |
| 51 } | |
| 52 | |
| 53 @Override | |
| 54 public FileDescriptorInfo[] newArray(int size) { | |
| 55 return new FileDescriptorInfo[size]; | |
| 56 } | |
| 57 }; | |
| 58 } | |
| OLD | NEW |