Move reporting of CONTENT_STORAGE_MISSING_ITEM to the call site
used for binding features.

PiperOrigin-RevId: 263842615
Change-Id: Ia9c4b3a77a87158b039d8dc36245fd1e734def70
diff --git a/src/main/java/com/google/android/libraries/feed/feedsessionmanager/FeedSessionManagerImpl.java b/src/main/java/com/google/android/libraries/feed/feedsessionmanager/FeedSessionManagerImpl.java
index 4d83dd0..845a3c8 100644
--- a/src/main/java/com/google/android/libraries/feed/feedsessionmanager/FeedSessionManagerImpl.java
+++ b/src/main/java/com/google/android/libraries/feed/feedsessionmanager/FeedSessionManagerImpl.java
@@ -657,6 +657,14 @@
             "getStreamFeatures; requestedItems(%d), result(%d)",
             cacheMisses.size(),
             contentResult.getValue().size());
+        if (contentResult.getValue().size() < cacheMisses.size()) {
+          Logger.e(TAG, "ContentStorage is missing content");
+          mainThreadRunner.execute(
+              "CONTENT_STORAGE_MISSING_ITEM",
+              () -> {
+                basicLoggingApi.onInternalError(InternalFeedError.CONTENT_STORAGE_MISSING_ITEM);
+              });
+        }
         results.addAll(contentResult.getValue());
       } else {
         if (contentResult.isSuccessful()) {
diff --git a/src/main/java/com/google/android/libraries/feed/feedstore/internal/PersistentFeedStore.java b/src/main/java/com/google/android/libraries/feed/feedstore/internal/PersistentFeedStore.java
index 84dfca1..f26a5f2 100644
--- a/src/main/java/com/google/android/libraries/feed/feedstore/internal/PersistentFeedStore.java
+++ b/src/main/java/com/google/android/libraries/feed/feedstore/internal/PersistentFeedStore.java
@@ -128,15 +128,6 @@
       return Result.failure();
     }
 
-    if (contentResult.getValue().entrySet().size() != contentIds.size()) {
-      Logger.e(TAG, "ContentStorage is missing content");
-      mainThreadRunner.execute(
-          "CONTENT_STORAGE_MISSING_ITEM",
-          () -> {
-            basicLoggingApi.onInternalError(InternalFeedError.CONTENT_STORAGE_MISSING_ITEM);
-          });
-    }
-
     for (Map.Entry<String, byte[]> entry : contentResult.getValue().entrySet()) {
       try {
         StreamPayload streamPayload =
diff --git a/src/test/java/com/google/android/libraries/feed/feedsessionmanager/FeedSessionManagerImplTest.java b/src/test/java/com/google/android/libraries/feed/feedsessionmanager/FeedSessionManagerImplTest.java
index 985be3d..0a884ea 100644
--- a/src/test/java/com/google/android/libraries/feed/feedsessionmanager/FeedSessionManagerImplTest.java
+++ b/src/test/java/com/google/android/libraries/feed/feedsessionmanager/FeedSessionManagerImplTest.java
@@ -378,6 +378,8 @@
     ModelProvider modelProvider = getModelProvider(sessionManager);
     assertThat(modelProvider).isNotNull();
     assertThat(fakeStore.isEphemeralMode()).isFalse();
+    assertThat(fakeBasicLoggingApi.lastInternalError)
+        .isEqualTo(InternalFeedError.CONTENT_STORAGE_MISSING_ITEM);
   }
 
   @Test
diff --git a/src/test/java/com/google/android/libraries/feed/feedstore/internal/PersistentFeedStoreTest.java b/src/test/java/com/google/android/libraries/feed/feedstore/internal/PersistentFeedStoreTest.java
index d0b9072..c6d4d14 100644
--- a/src/test/java/com/google/android/libraries/feed/feedstore/internal/PersistentFeedStoreTest.java
+++ b/src/test/java/com/google/android/libraries/feed/feedstore/internal/PersistentFeedStoreTest.java
@@ -434,8 +434,6 @@
         getStore(mainThreadRunner).getPayloads(ImmutableList.of("foo"));
     assertThat(result.isSuccessful()).isTrue();
     assertThat(result.getValue()).isEmpty();
-    assertThat(basicLoggingApi.lastInternalError)
-        .isEqualTo(InternalFeedError.CONTENT_STORAGE_MISSING_ITEM);
   }
 
   @Test