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

Side by Side Diff: chrome/browser/extensions/convert_web_app.cc

Issue 184563006: Move WriteFile and WriteFileDescriptor from file_util to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
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/extensions/convert_web_app.h" 5 #include "chrome/browser/extensions/convert_web_app.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 std::vector<unsigned char> image_data; 142 std::vector<unsigned char> image_data;
143 if (!gfx::PNGCodec::EncodeBGRASkBitmap(web_app.icons[i].data, 143 if (!gfx::PNGCodec::EncodeBGRASkBitmap(web_app.icons[i].data,
144 false, 144 false,
145 &image_data)) { 145 &image_data)) {
146 LOG(ERROR) << "Could not create icon file."; 146 LOG(ERROR) << "Could not create icon file.";
147 return NULL; 147 return NULL;
148 } 148 }
149 149
150 const char* image_data_ptr = reinterpret_cast<const char*>(&image_data[0]); 150 const char* image_data_ptr = reinterpret_cast<const char*>(&image_data[0]);
151 int size = base::checked_cast<int>(image_data.size()); 151 int size = base::checked_cast<int>(image_data.size());
152 if (file_util::WriteFile(icon_file, image_data_ptr, size) != size) { 152 if (base::WriteFile(icon_file, image_data_ptr, size) != size) {
153 LOG(ERROR) << "Could not write icon file."; 153 LOG(ERROR) << "Could not write icon file.";
154 return NULL; 154 return NULL;
155 } 155 }
156 } 156 }
157 157
158 // Finally, create the extension object to represent the unpacked directory. 158 // Finally, create the extension object to represent the unpacked directory.
159 std::string error; 159 std::string error;
160 scoped_refptr<Extension> extension = Extension::Create( 160 scoped_refptr<Extension> extension = Extension::Create(
161 temp_dir.path(), 161 temp_dir.path(),
162 Manifest::INTERNAL, 162 Manifest::INTERNAL,
163 *root, 163 *root,
164 Extension::FROM_BOOKMARK, 164 Extension::FROM_BOOKMARK,
165 &error); 165 &error);
166 if (!extension.get()) { 166 if (!extension.get()) {
167 LOG(ERROR) << error; 167 LOG(ERROR) << error;
168 return NULL; 168 return NULL;
169 } 169 }
170 170
171 temp_dir.Take(); // The caller takes ownership of the directory. 171 temp_dir.Take(); // The caller takes ownership of the directory.
172 return extension; 172 return extension;
173 } 173 }
174 174
175 } // namespace extensions 175 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/app_background_page_apitest.cc ('k') | chrome/browser/extensions/extension_creator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698