Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Side by Side Diff: components/search_provider_logos/logo_cache.cc

Issue 1551433002: Switch to standard integer types in components/, part 3 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h>
8 #include <stdint.h>
9
7 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
8 #include "base/json/json_reader.h" 11 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 12 #include "base/json/json_writer.h"
10 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
11 #include "base/values.h" 14 #include "base/values.h"
12 15
13 namespace { 16 namespace {
14 17
15 // The cached logo metadata is persisted as JSON using these keys. 18 // The cached logo metadata is persisted as JSON using these keys.
16 const char kSourceUrlKey[] = "url"; 19 const char kSourceUrlKey[] = "url";
17 const char kExpirationTimeKey[] = "expiration_time"; 20 const char kExpirationTimeKey[] = "expiration_time";
18 const char kCanShowAfterExpirationKey[] = "can_show_after_expiration"; 21 const char kCanShowAfterExpirationKey[] = "can_show_after_expiration";
19 const char kFingerprintKey[] = "fingerprint"; 22 const char kFingerprintKey[] = "fingerprint";
20 const char kOnClickURLKey[] = "on_click_url"; 23 const char kOnClickURLKey[] = "on_click_url";
21 const char kAltTextKey[] = "alt_text"; 24 const char kAltTextKey[] = "alt_text";
22 const char kMimeTypeKey[] = "mime_type"; 25 const char kMimeTypeKey[] = "mime_type";
23 const char kNumBytesKey[] = "num_bytes"; 26 const char kNumBytesKey[] = "num_bytes";
24 const char kAnimatedUrlKey[] = "animated_url"; 27 const char kAnimatedUrlKey[] = "animated_url";
25 28
26 bool GetTimeValue(const base::DictionaryValue& dict, 29 bool GetTimeValue(const base::DictionaryValue& dict,
27 const std::string& key, 30 const std::string& key,
28 base::Time* time) { 31 base::Time* time) {
29 std::string str; 32 std::string str;
30 int64 internal_time_value; 33 int64_t internal_time_value;
31 if (dict.GetString(key, &str) && 34 if (dict.GetString(key, &str) &&
32 base::StringToInt64(str, &internal_time_value)) { 35 base::StringToInt64(str, &internal_time_value)) {
33 *time = base::Time::FromInternalValue(internal_time_value); 36 *time = base::Time::FromInternalValue(internal_time_value);
34 return true; 37 return true;
35 } 38 }
36 return false; 39 return false;
37 } 40 }
38 41
39 void SetTimeValue(base::DictionaryValue& dict, 42 void SetTimeValue(base::DictionaryValue& dict,
40 const std::string& key, 43 const std::string& key,
41 const base::Time& time) { 44 const base::Time& time) {
42 int64 internal_time_value = time.ToInternalValue(); 45 int64_t internal_time_value = time.ToInternalValue();
43 dict.SetString(key, base::Int64ToString(internal_time_value)); 46 dict.SetString(key, base::Int64ToString(internal_time_value));
44 } 47 }
45 48
46 } // namespace 49 } // namespace
47 50
48 namespace search_provider_logos { 51 namespace search_provider_logos {
49 52
50 LogoCache::LogoCache(const base::FilePath& cache_directory) 53 LogoCache::LogoCache(const base::FilePath& cache_directory)
51 : cache_directory_(cache_directory), 54 : cache_directory_(cache_directory),
52 metadata_is_valid_(false) { 55 metadata_is_valid_(false) {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 base::DeleteFile(GetMetadataPath(), false); 232 base::DeleteFile(GetMetadataPath(), false);
230 } 233 }
231 234
232 bool LogoCache::EnsureCacheDirectoryExists() { 235 bool LogoCache::EnsureCacheDirectoryExists() {
233 if (base::DirectoryExists(cache_directory_)) 236 if (base::DirectoryExists(cache_directory_))
234 return true; 237 return true;
235 return base::CreateDirectory(cache_directory_); 238 return base::CreateDirectory(cache_directory_);
236 } 239 }
237 240
238 } // namespace search_provider_logos 241 } // namespace search_provider_logos
OLDNEW
« no previous file with comments | « components/search_provider_logos/logo_cache.h ('k') | components/search_provider_logos/logo_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698