| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/profiles/profile_info_cache.h" | 5 #include "chrome/browser/profiles/profile_info_cache.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/i18n/case_conversion.h" | 10 #include "base/i18n/case_conversion.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // |success| is set to true on success and false on failure. | 118 // |success| is set to true on success and false on failure. |
| 119 void SaveBitmap(ImageData* data, | 119 void SaveBitmap(ImageData* data, |
| 120 const base::FilePath& image_path, | 120 const base::FilePath& image_path, |
| 121 bool* success) { | 121 bool* success) { |
| 122 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 122 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 123 scoped_ptr<ImageData> data_owner(data); | 123 scoped_ptr<ImageData> data_owner(data); |
| 124 *success = false; | 124 *success = false; |
| 125 | 125 |
| 126 // Make sure the destination directory exists. | 126 // Make sure the destination directory exists. |
| 127 base::FilePath dir = image_path.DirName(); | 127 base::FilePath dir = image_path.DirName(); |
| 128 if (!base::DirectoryExists(dir) && !file_util::CreateDirectory(dir)) { | 128 if (!base::DirectoryExists(dir) && !base::CreateDirectory(dir)) { |
| 129 LOG(ERROR) << "Failed to create parent directory."; | 129 LOG(ERROR) << "Failed to create parent directory."; |
| 130 return; | 130 return; |
| 131 } | 131 } |
| 132 | 132 |
| 133 if (file_util::WriteFile(image_path, | 133 if (file_util::WriteFile(image_path, |
| 134 reinterpret_cast<char*>(&(*data)[0]), | 134 reinterpret_cast<char*>(&(*data)[0]), |
| 135 data->size()) == -1) { | 135 data->size()) == -1) { |
| 136 LOG(ERROR) << "Failed to save image to file."; | 136 LOG(ERROR) << "Failed to save image to file."; |
| 137 return; | 137 return; |
| 138 } | 138 } |
| (...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 info->GetString(kNameKey, &name); | 897 info->GetString(kNameKey, &name); |
| 898 names.push_back(name); | 898 names.push_back(name); |
| 899 } | 899 } |
| 900 return names; | 900 return names; |
| 901 } | 901 } |
| 902 | 902 |
| 903 // static | 903 // static |
| 904 void ProfileInfoCache::RegisterPrefs(PrefRegistrySimple* registry) { | 904 void ProfileInfoCache::RegisterPrefs(PrefRegistrySimple* registry) { |
| 905 registry->RegisterDictionaryPref(prefs::kProfileInfoCache); | 905 registry->RegisterDictionaryPref(prefs::kProfileInfoCache); |
| 906 } | 906 } |
| OLD | NEW |