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

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

Issue 2765453004: Moving FileDescriptorInfo from content/ to base/. (Closed)
Patch Set: Synced. Created 3 years, 9 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.base; 5 package org.chromium.base.process_launcher;
6 6
7 import android.annotation.SuppressLint;
8 import android.os.Parcel; 7 import android.os.Parcel;
9 import android.os.ParcelFileDescriptor; 8 import android.os.ParcelFileDescriptor;
10 import android.os.Parcelable; 9 import android.os.Parcelable;
11 10
11 import org.chromium.base.annotations.MainDex;
12 import org.chromium.base.annotations.UsedByReflection;
13
14 import javax.annotation.concurrent.Immutable;
15
12 /** 16 /**
13 * Parcelable class that contains file descriptor and a key that identifies it. 17 * Parcelable class that contains file descriptor and file region information to
14 * TODO(jcivelli): should be merged with 18 * be passed to child processes.
15 * org.chromium.content.common.FileDescriptorInfo
16 */ 19 */
17 @SuppressLint("ParcelClassLoader") 20 @Immutable
21 @MainDex
22 @UsedByReflection("child_process_launcher_helper_android.cc")
18 public final class FileDescriptorInfo implements Parcelable { 23 public final class FileDescriptorInfo implements Parcelable {
19 /** An consumer chosen ID that uniquely identifies a file descriptor. */ 24 public final int id;
20 public final int key; 25 public final ParcelFileDescriptor fd;
26 public final long offset;
27 public final long size;
21 28
22 /** A file descriptor to access the file. */ 29 public FileDescriptorInfo(int id, ParcelFileDescriptor fd, long offset, long size) {
23 public final ParcelFileDescriptor fd; 30 this.id = id;
24
25 public FileDescriptorInfo(int key, ParcelFileDescriptor fd) {
26 this.key = key;
27 this.fd = fd; 31 this.fd = fd;
32 this.offset = offset;
33 this.size = size;
28 } 34 }
29 35
30 FileDescriptorInfo(Parcel in) { 36 FileDescriptorInfo(Parcel in) {
31 key = in.readInt(); 37 id = in.readInt();
32 fd = in.readParcelable(null); 38 fd = in.readParcelable(ParcelFileDescriptor.class.getClassLoader());
39 offset = in.readLong();
40 size = in.readLong();
33 } 41 }
34 42
35 @Override 43 @Override
36 public int describeContents() { 44 public int describeContents() {
37 return CONTENTS_FILE_DESCRIPTOR; 45 return CONTENTS_FILE_DESCRIPTOR;
38 } 46 }
39 47
40 @Override 48 @Override
41 public void writeToParcel(Parcel dest, int flags) { 49 public void writeToParcel(Parcel dest, int flags) {
42 dest.writeInt(key); 50 dest.writeInt(id);
43 dest.writeParcelable(fd, CONTENTS_FILE_DESCRIPTOR); 51 dest.writeParcelable(fd, CONTENTS_FILE_DESCRIPTOR);
52 dest.writeLong(offset);
53 dest.writeLong(size);
44 } 54 }
45 55
46 public static final Parcelable.Creator<FileDescriptorInfo> CREATOR = 56 public static final Parcelable.Creator<FileDescriptorInfo> CREATOR =
47 new Parcelable.Creator<FileDescriptorInfo>() { 57 new Parcelable.Creator<FileDescriptorInfo>() {
48 @Override 58 @Override
49 public FileDescriptorInfo createFromParcel(Parcel in) { 59 public FileDescriptorInfo createFromParcel(Parcel in) {
50 return new FileDescriptorInfo(in); 60 return new FileDescriptorInfo(in);
51 } 61 }
52 62
53 @Override 63 @Override
54 public FileDescriptorInfo[] newArray(int size) { 64 public FileDescriptorInfo[] newArray(int size) {
55 return new FileDescriptorInfo[size]; 65 return new FileDescriptorInfo[size];
56 } 66 }
57 }; 67 };
58 } 68 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698