TopSites: Clear thumbnails from the cache when their URLs get removed

We already cleared the thumbnails from persistent storage, but they
remained in the in-memory cache, so they remained accessible (until the
next Chrome restart) even after all browsing data was cleared.

Bug: 758169
Change-Id: Id916d22358430a82e6d5043ac04fa463a32f824f
Reviewed-on: https://chromium-review.googlesource.com/758640
Commit-Queue: Marc Treib <treib@chromium.org>
Reviewed-by: Sylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#514861}
bool TopSitesImpl::SetPageThumbnail(const GURL& url,
                                    const gfx::Image& thumbnail,
                                    const ThumbnailScore& score) {
  ThumbnailEvent result = SetPageThumbnailImpl(url, thumbnail, score);

  UMA_HISTOGRAM_ENUMERATION("Thumbnails.AddedToTopSites", result,
                            THUMBNAIL_EVENT_COUNT);

  switch (result) {
    case THUMBNAIL_FAILURE:
    case THUMBNAIL_TOPSITES_FULL:
    case THUMBNAIL_KEPT_EXISTING:
      return false;
    case THUMBNAIL_ADDED_TEMP:
    case THUMBNAIL_ADDED_REGULAR:
      return true;
    case THUMBNAIL_PROMOTED_TEMP_TO_REGULAR:
    case THUMBNAIL_EVENT_COUNT:
      NOTREACHED();
  }

  return false;
}

bool TopSitesImpl::SetPageThumbnail(const GURL& url,
                                    const gfx::Image& thumbnail,
                                    const ThumbnailScore& score) {
  ThumbnailEvent result = SetPageThumbnailImpl(url, thumbnail, score);

  UMA_HISTOGRAM_ENUMERATION("Thumbnails.AddedToTopSites", result,
                            THUMBNAIL_EVENT_COUNT);

  switch (result) {
    case THUMBNAIL_FAILURE:
    case THUMBNAIL_TOPSITES_FULL:
    case THUMBNAIL_KEPT_EXISTING:
      return false;
    case THUMBNAIL_ADDED_TEMP:
    case THUMBNAIL_ADDED_REGULAR:
      return true;
    case THUMBNAIL_PROMOTED_TEMP_TO_REGULAR:
    case THUMBNAIL_EVENT_COUNT:
      NOTREACHED();
  }

  return false;
}
