• wutao's avatar
    ambient: Use cached photos for display · b92e226e
    wutao authored
    There are several situations we can use cached photos for display:
    1. No internet.
    2. No access token.
    3. Failed to fetch topics.
    4. Failed to download photos.
    
    When failure happens, we use cache as a ring buffer to get next
    available photo on disk. The cached photos are saved during normal
    workflow when fetching topics and photos succeeds.
    
    When reading from cache, for simplicity, we can try to read max times,
    e.g. loop from index 0 to 99, for all possible file names. If failed,
    means no disk cache available, reading from disk will pause until next
    time the photo is downloaded successfully.
    
    Cache will be cleared when Settings changes.
    
    Bug: b/162945419
    Test: Added new AmbientPhotoControllerTest.
    Change-Id: I7d4d04ee1f6e9f40c64a23f6e04c35d0ce46c01f
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2348689
    Commit-Queue: Tao Wu <wutao@chromium.org>
    Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#799540}
    b92e226e
ambient_backend_controller_impl.cc 19.5 KB