Commit 62664fac authored by Alex Gough's avatar Alex Gough Committed by Commit Bot

Use ReadOnlyFile for android font lookup

Bug: 1130762
Change-Id: Ied886fdf383eea4a8cdf733ae71996b7df6bd6a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2464147Reviewed-by: default avatarNatalie Chouinard <chouinard@chromium.org>
Commit-Queue: Alex Gough <ajgo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#817564}
parent 136df175
...@@ -30,7 +30,7 @@ import org.chromium.mojo.bindings.ExecutorFactory; ...@@ -30,7 +30,7 @@ import org.chromium.mojo.bindings.ExecutorFactory;
import org.chromium.mojo.system.Core; import org.chromium.mojo.system.Core;
import org.chromium.mojo.system.MojoException; import org.chromium.mojo.system.MojoException;
import org.chromium.mojo.system.impl.CoreImpl; import org.chromium.mojo.system.impl.CoreImpl;
import org.chromium.mojo_base.mojom.File; import org.chromium.mojo_base.mojom.ReadOnlyFile;
import org.chromium.services.service_manager.InterfaceFactory; import org.chromium.services.service_manager.InterfaceFactory;
import java.io.IOException; import java.io.IOException;
...@@ -163,7 +163,7 @@ public class AndroidFontLookupImpl implements AndroidFontLookup { ...@@ -163,7 +163,7 @@ public class AndroidFontLookupImpl implements AndroidFontLookup {
// Post synchronous font request to background worker thread. // Post synchronous font request to background worker thread.
PostTask.postTask(TaskTraits.USER_BLOCKING, () -> { PostTask.postTask(TaskTraits.USER_BLOCKING, () -> {
File file = null; ReadOnlyFile file = null;
ParcelFileDescriptor fileDescriptor = tryFetchFont(fontUniqueName); ParcelFileDescriptor fileDescriptor = tryFetchFont(fontUniqueName);
if (fileDescriptor == null) { if (fileDescriptor == null) {
...@@ -171,12 +171,12 @@ public class AndroidFontLookupImpl implements AndroidFontLookup { ...@@ -171,12 +171,12 @@ public class AndroidFontLookupImpl implements AndroidFontLookup {
mExpectedFonts.remove(fontUniqueName); mExpectedFonts.remove(fontUniqueName);
} else { } else {
// Wrap file descriptor as an opened Mojo file handle. // Wrap file descriptor as an opened Mojo file handle.
file = new File(); file = new ReadOnlyFile();
file.fd = core.wrapFileDescriptor(fileDescriptor); file.fd = core.wrapFileDescriptor(fileDescriptor);
file.async = false; file.async = false;
} }
final File result = file; final ReadOnlyFile result = file;
RecordHistogram.recordTimesHistogram(MATCH_LOCAL_FONT_BY_UNIQUE_NAME_HISTOGRAM, RecordHistogram.recordTimesHistogram(MATCH_LOCAL_FONT_BY_UNIQUE_NAME_HISTOGRAM,
SystemClock.elapsedRealtime() - startTimeMs); SystemClock.elapsedRealtime() - startTimeMs);
executor.execute(() -> callback.call(result)); executor.execute(() -> callback.call(result));
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
module blink.mojom; module blink.mojom;
import "mojo/public/mojom/base/file.mojom"; import "mojo/public/mojom/base/read_only_file.mojom";
// Interface for renderer to request Android downloaded fonts from font // Interface for renderer to request Android downloaded fonts from font
// providers on-device. // providers on-device.
...@@ -22,5 +22,5 @@ interface AndroidFontLookup { ...@@ -22,5 +22,5 @@ interface AndroidFontLookup {
// is synchronous for the renderer to avoid unnecessary re-layout jank. // is synchronous for the renderer to avoid unnecessary re-layout jank.
[Sync] [Sync]
MatchLocalFontByUniqueName(string font_unique_name) MatchLocalFontByUniqueName(string font_unique_name)
=> (mojo_base.mojom.File? font_file_handle); => (mojo_base.mojom.ReadOnlyFile? font_file_handle);
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment