Skip to content

Commit

Permalink
[feature_engagement] Guard retrieving Tracker with null profile
Browse files Browse the repository at this point in the history
This CL builds on top of http://crrev.com/c/3818263.

Before this CL, if the `profile` passed in to
TrackerFactory#getTrackerForProfile is null, we would return null.
This would mean that if the Tracker is immediately in use, we'd
identify where. Otherwise, we might never see a crash (if the Tracker
is null-checked or otherwise not in use), or see a crash much later
if the Tracker is cached.

After this CL, we will throw an exception at the Tracker retrieval
instead. This will guarantee that we will be able to identify anyone
invoking this incorrectly.

(cherry picked from commit ba8df59)

Bug: 1346710
Change-Id: I5af1534df241a513e65481d45a6860ab6d5853c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3817568
Commit-Queue: Siddhartha S <ssid@chromium.org>
Reviewed-by: David Trainor <dtrainor@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1032834}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3816903
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Owners-Override: Krishna Govind <govind@chromium.org>
Cr-Commit-Position: refs/branch-heads/5228@{#4}
Cr-Branched-From: 24425f2-refs/heads/main@{#1032780}
  • Loading branch information
tommynyquist authored and Krishna Govind committed Aug 9, 2022
1 parent fe1b2d3 commit 9fb2e5a
Showing 1 changed file with 3 additions and 1 deletion.
Expand Up @@ -29,7 +29,9 @@ private TrackerFactory() {}
*/
public static Tracker getTrackerForProfile(Profile profile) {
if (sTestTracker != null) return sTestTracker;
if (profile == null) return null;
if (profile == null) {
throw new IllegalArgumentException("Profile is required for retrieving tracker.");
}

return TrackerFactoryJni.get().getTrackerForProfile(profile);
}
Expand Down

0 comments on commit 9fb2e5a

Please sign in to comment.