logd: track SerializedFlushToState instances within SerializedLogChunk

Previously, NotifyReadersOfPrune() would iterate through the list of
reader_threads_ to find SerializedFlushToState instances, but that
misses some instances, which leads to violating important CHECK()'s.

This change 'attaches' a SerializedFlushToState instance to a
SerializedLogChunk instance when it begins reading from it and
'detaches' it when it has finished with it.  This allows a new
SerializedLogChunk::NotifyReadersOfPrune() function to notify exactly
those SerializedFlushToState instances that are currently 'attached'
to it.

Bug: 169736426
Bug: 172279637
Test: logging unit tests
Change-Id: I0ab4979c8fe2b84a0e23fc5ea5fb6dd54fadc691
diff --git a/logd/SerializedFlushToStateTest.cpp b/logd/SerializedFlushToStateTest.cpp
index f41de37..12904cb 100644
--- a/logd/SerializedFlushToStateTest.cpp
+++ b/logd/SerializedFlushToStateTest.cpp
@@ -306,5 +306,5 @@
     auto state = SerializedFlushToState{1, kLogMaskAll, log_chunks};
     ASSERT_TRUE(state.HasUnreadLogs());
 
-    state.Prune(LOG_ID_MAIN, log_chunks[LOG_ID_MAIN].begin());
+    state.Prune(LOG_ID_MAIN);
 }