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

Side by Side Diff: chrome/browser/themes/browser_theme_pack.cc

Issue 10854003: Fix Mac ASAN build (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/themes/browser_theme_pack.h" 5 #include "chrome/browser/themes/browser_theme_pack.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/memory/ref_counted_memory.h" 9 #include "base/memory/ref_counted_memory.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 if (index >= expected.size()) 196 if (index >= expected.size())
197 return false; 197 return false;
198 if (*end != ui::GetScaleFactorScale(expected[index])) 198 if (*end != ui::GetScaleFactorScale(expected[index]))
199 return false; 199 return false;
200 index++; 200 index++;
201 } 201 }
202 return (index == expected.size()); 202 return (index == expected.size());
203 } 203 }
204 204
205 // Returns |scale_factors| as a string to be written to disk. 205 // Returns |scale_factors| as a string to be written to disk.
206 base::StringPiece GetScaleFactorsAsString( 206 std::string GetScaleFactorsAsString(
207 const std::vector<ui::ScaleFactor>& scale_factors) { 207 const std::vector<ui::ScaleFactor>& scale_factors) {
208 size_t scales_size = scale_factors.size() + 1; 208 size_t scales_size = scale_factors.size() + 1;
209 float* scales = new float[scales_size]; 209 float* scales = new float[scales_size];
210 for (size_t i = 0; i < scale_factors.size(); ++i) 210 for (size_t i = 0; i < scale_factors.size(); ++i)
211 scales[i] = ui::GetScaleFactorScale(scale_factors[i]); 211 scales[i] = ui::GetScaleFactorScale(scale_factors[i]);
212 scales[scales_size - 1] = -1.0f; 212 scales[scales_size - 1] = -1.0f;
213 base::StringPiece out_string = base::StringPiece( 213 std::string out_string = std::string(
214 reinterpret_cast<const char*>(&scales), 214 reinterpret_cast<const char*>(scales),
215 scales_size * sizeof(float)); 215 scales_size * sizeof(float));
216 delete[] scales; 216 delete[] scales;
217 return out_string; 217 return out_string;
218 } 218 }
219 219
220 struct StringToIntTable { 220 struct StringToIntTable {
221 const char* key; 221 const char* key;
222 int id; 222 int id;
223 }; 223 };
224 224
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 sizeof(DisplayPropertyPair[kDisplayPropertySize])); 533 sizeof(DisplayPropertyPair[kDisplayPropertySize]));
534 534
535 int source_count = 1; 535 int source_count = 1;
536 int* end = source_images_; 536 int* end = source_images_;
537 for (; *end != -1 ; end++) 537 for (; *end != -1 ; end++)
538 source_count++; 538 source_count++;
539 resources[kSourceImagesID] = base::StringPiece( 539 resources[kSourceImagesID] = base::StringPiece(
540 reinterpret_cast<const char*>(source_images_), 540 reinterpret_cast<const char*>(source_images_),
541 source_count * sizeof(*source_images_)); 541 source_count * sizeof(*source_images_));
542 542
543 resources[kScaleFactorsID] = GetScaleFactorsAsString(scale_factors_); 543 // Store results of GetScaleFactorsAsString() in std::string as
544 // base::StringPiece does not copy data in constructor.
545 std::string scale_factors_string = GetScaleFactorsAsString(scale_factors_);
546 resources[kScaleFactorsID] = scale_factors_string;
544 547
545 AddRawImagesTo(image_memory_, &resources); 548 AddRawImagesTo(image_memory_, &resources);
546 549
547 RawImages reencoded_images; 550 RawImages reencoded_images;
548 RepackImages(images_on_file_thread_, &reencoded_images); 551 RepackImages(images_on_file_thread_, &reencoded_images);
549 AddRawImagesTo(reencoded_images, &resources); 552 AddRawImagesTo(reencoded_images, &resources);
550 553
551 return ui::DataPack::WritePack(path, resources, ui::DataPack::BINARY); 554 return ui::DataPack::WritePack(path, resources, ui::DataPack::BINARY);
552 } 555 }
553 556
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 ui::ScaleFactor scale_factor) const { 1232 ui::ScaleFactor scale_factor) const {
1230 if (prs_id < 0) 1233 if (prs_id < 0)
1231 return -1; 1234 return -1;
1232 1235
1233 for (size_t i = 0; i < scale_factors_.size(); ++i) { 1236 for (size_t i = 0; i < scale_factors_.size(); ++i) {
1234 if (scale_factors_[i] == scale_factor) 1237 if (scale_factors_[i] == scale_factor)
1235 return static_cast<int>(kPersistingImagesLength * i) + prs_id; 1238 return static_cast<int>(kPersistingImagesLength * i) + prs_id;
1236 } 1239 }
1237 return -1; 1240 return -1;
1238 } 1241 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698