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

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

Issue 497723004: Remove implicit conversions from scoped_refptr to T* in components/search_provider_logos/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | components/search_provider_logos/logo_cache_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/file_util.h" 7 #include "base/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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 189
190 std::string str; 190 std::string str;
191 LogoMetadataToString(*metadata_, logo_num_bytes_, &str); 191 LogoMetadataToString(*metadata_, logo_num_bytes_, &str);
192 base::WriteFile(GetMetadataPath(), str.data(), static_cast<int>(str.size())); 192 base::WriteFile(GetMetadataPath(), str.data(), static_cast<int>(str.size()));
193 } 193 }
194 194
195 void LogoCache::WriteLogo(scoped_refptr<base::RefCountedMemory> encoded_image) { 195 void LogoCache::WriteLogo(scoped_refptr<base::RefCountedMemory> encoded_image) {
196 if (!EnsureCacheDirectoryExists()) 196 if (!EnsureCacheDirectoryExists())
197 return; 197 return;
198 198
199 if (!metadata_ || !encoded_image) { 199 if (!metadata_ || !encoded_image.get()) {
200 DeleteLogoAndMetadata(); 200 DeleteLogoAndMetadata();
201 return; 201 return;
202 } 202 }
203 203
204 // To minimize the chances of ending up in an undetectably broken state: 204 // To minimize the chances of ending up in an undetectably broken state:
205 // First, delete the metadata file, then update the logo file, then update the 205 // First, delete the metadata file, then update the logo file, then update the
206 // metadata file. 206 // metadata file.
207 base::FilePath logo_path = GetLogoPath(); 207 base::FilePath logo_path = GetLogoPath();
208 base::FilePath metadata_path = GetMetadataPath(); 208 base::FilePath metadata_path = GetMetadataPath();
209 209
(...skipping 16 matching lines...) Expand all
226 base::DeleteFile(GetMetadataPath(), false); 226 base::DeleteFile(GetMetadataPath(), false);
227 } 227 }
228 228
229 bool LogoCache::EnsureCacheDirectoryExists() { 229 bool LogoCache::EnsureCacheDirectoryExists() {
230 if (base::DirectoryExists(cache_directory_)) 230 if (base::DirectoryExists(cache_directory_))
231 return true; 231 return true;
232 return base::CreateDirectory(cache_directory_); 232 return base::CreateDirectory(cache_directory_);
233 } 233 }
234 234
235 } // namespace search_provider_logos 235 } // namespace search_provider_logos
OLDNEW
« no previous file with comments | « no previous file | components/search_provider_logos/logo_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698