Commit 03b78e9d authored by Xiaohui Chen's avatar Xiaohui Chen Committed by Commit Bot

ambient: fix cache file name

Name cannot directly use binary data, convert to base64 instead sans
the path divider.

Bug: None
Change-Id: Ibb0a7d4dfe749fee50ac2812b55280850f1284ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2318479Reviewed-by: default avatarTao Wu <wutao@chromium.org>
Commit-Queue: Xiaohui Chen <xiaohuic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791936}
parent 4408a0fa
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "ash/public/cpp/ambient/ambient_client.h" #include "ash/public/cpp/ambient/ambient_client.h"
#include "ash/public/cpp/image_downloader.h" #include "ash/public/cpp/image_downloader.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "base/base64.h"
#include "base/base_paths.h" #include "base/base_paths.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/callback.h" #include "base/callback.h"
...@@ -22,6 +23,7 @@ ...@@ -22,6 +23,7 @@
#include "base/optional.h" #include "base/optional.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/rand_util.h" #include "base/rand_util.h"
#include "base/strings/string_util.h"
#include "base/system/sys_info.h" #include "base/system/sys_info.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "base/task/task_traits.h" #include "base/task/task_traits.h"
...@@ -85,7 +87,11 @@ void DeletePathRecursively(const base::FilePath& path) { ...@@ -85,7 +87,11 @@ void DeletePathRecursively(const base::FilePath& path) {
} }
std::string ToPhotoFileName(const std::string& url) { std::string ToPhotoFileName(const std::string& url) {
return base::SHA1HashString(url) + std::string(kPhotoFileExt); std::string hash_tag;
base::Base64Encode(base::SHA1HashString(url), &hash_tag);
// Replace path divider.
base::ReplaceSubstringsAfterOffset(&hash_tag, 0, "/", "_");
return hash_tag + std::string(kPhotoFileExt);
} }
void ToImageSkia(DownloadCallback callback, const SkBitmap& image) { void ToImageSkia(DownloadCallback callback, const SkBitmap& image) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment