OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/search_provider_logos/logo_cache.h" | 5 #include "components/search_provider_logos/logo_cache.h" |
6 | 6 |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 dict.SetString(kSourceUrlKey, metadata.source_url); | 145 dict.SetString(kSourceUrlKey, metadata.source_url); |
146 dict.SetString(kFingerprintKey, metadata.fingerprint); | 146 dict.SetString(kFingerprintKey, metadata.fingerprint); |
147 dict.SetString(kOnClickURLKey, metadata.on_click_url); | 147 dict.SetString(kOnClickURLKey, metadata.on_click_url); |
148 dict.SetString(kAltTextKey, metadata.alt_text); | 148 dict.SetString(kAltTextKey, metadata.alt_text); |
149 dict.SetString(kAnimatedUrlKey, metadata.animated_url); | 149 dict.SetString(kAnimatedUrlKey, metadata.animated_url); |
150 dict.SetString(kMimeTypeKey, metadata.mime_type); | 150 dict.SetString(kMimeTypeKey, metadata.mime_type); |
151 dict.SetBoolean(kCanShowAfterExpirationKey, | 151 dict.SetBoolean(kCanShowAfterExpirationKey, |
152 metadata.can_show_after_expiration); | 152 metadata.can_show_after_expiration); |
153 dict.SetInteger(kNumBytesKey, num_bytes); | 153 dict.SetInteger(kNumBytesKey, num_bytes); |
154 SetTimeValue(dict, kExpirationTimeKey, metadata.expiration_time); | 154 SetTimeValue(dict, kExpirationTimeKey, metadata.expiration_time); |
155 base::JSONWriter::Write(&dict, str); | 155 base::JSONWriter::Write(dict, str); |
156 } | 156 } |
157 | 157 |
158 base::FilePath LogoCache::GetLogoPath() { | 158 base::FilePath LogoCache::GetLogoPath() { |
159 return cache_directory_.Append(FILE_PATH_LITERAL("logo")); | 159 return cache_directory_.Append(FILE_PATH_LITERAL("logo")); |
160 } | 160 } |
161 | 161 |
162 base::FilePath LogoCache::GetMetadataPath() { | 162 base::FilePath LogoCache::GetMetadataPath() { |
163 return cache_directory_.Append(FILE_PATH_LITERAL("metadata")); | 163 return cache_directory_.Append(FILE_PATH_LITERAL("metadata")); |
164 } | 164 } |
165 | 165 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 base::DeleteFile(GetMetadataPath(), false); | 229 base::DeleteFile(GetMetadataPath(), false); |
230 } | 230 } |
231 | 231 |
232 bool LogoCache::EnsureCacheDirectoryExists() { | 232 bool LogoCache::EnsureCacheDirectoryExists() { |
233 if (base::DirectoryExists(cache_directory_)) | 233 if (base::DirectoryExists(cache_directory_)) |
234 return true; | 234 return true; |
235 return base::CreateDirectory(cache_directory_); | 235 return base::CreateDirectory(cache_directory_); |
236 } | 236 } |
237 | 237 |
238 } // namespace search_provider_logos | 238 } // namespace search_provider_logos |
OLD | NEW |