Revert 144993 - gdata: Remove invalid files in the cache directories

Broke linux_chromeos_valgrind:
http://build.chromium.org/p/chromium.memory.fyi/builders/Chromium%20OS%20%28valgrind%29%285%29/builds/8628/steps/memory%20test%3A%20unit/logs/stdio

In theory, we shouldn't have any invalid files left in the
cache directories, but things can go wrong and invalid files
may be left if the device shuts down unexpectedly, for instance.
Besides, it's good to be defensive.

BUG=134862
TEST=added unit tests

Review URL: https://chromiumcodereview.appspot.com/10693020

TBR=satorux@chromium.org

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145029 0039d316-1c4b-4281-b951-d872f2087c98
void GDataCacheMetadataMap::RemoveTemporaryFiles() {
  AssertOnSequencedWorkerPool();

  CacheMap::iterator iter = cache_map_.begin();
  while (iter != cache_map_.end()) {
    if (iter->second.sub_dir_type == GDataCache::CACHE_TYPE_TMP) {
      cache_map_.erase(iter++);
    } else {
      ++iter;
    }
  }
}

void GDataCacheMetadataMap::RemoveTemporaryFiles() {
  AssertOnSequencedWorkerPool();

  CacheMap::iterator iter = cache_map_.begin();
  while (iter != cache_map_.end()) {
    if (iter->second.sub_dir_type == GDataCache::CACHE_TYPE_TMP) {
      cache_map_.erase(iter++);
    } else {
      ++iter;
    }
  }
}
