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

Side by Side Diff: chrome/browser/ui/webui/extensions/extension_icon_source.cc

Issue 2197483004: [Extensions] rm unnecessary GetRawDataResource().as_string() to reduce string copy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Devlin@ Created 4 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
« no previous file with comments | « chrome/browser/extensions/component_loader.cc ('k') | 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/ui/webui/extensions/extension_icon_source.h" 5 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 extension->id().c_str(), 90 extension->id().c_str(),
91 icon_size, 91 icon_size,
92 match, 92 match,
93 grayscale ? "?grayscale=true" : "")); 93 grayscale ? "?grayscale=true" : ""));
94 CHECK(icon_url.is_valid()); 94 CHECK(icon_url.is_valid());
95 return icon_url; 95 return icon_url;
96 } 96 }
97 97
98 // static 98 // static
99 SkBitmap* ExtensionIconSource::LoadImageByResourceId(int resource_id) { 99 SkBitmap* ExtensionIconSource::LoadImageByResourceId(int resource_id) {
100 std::string contents = ResourceBundle::GetSharedInstance() 100 base::StringPiece contents =
101 .GetRawDataResourceForScale(resource_id, 101 ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
102 ui::SCALE_FACTOR_100P).as_string(); 102 resource_id, ui::SCALE_FACTOR_100P);
103 103
104 // Convert and return it. 104 // Convert and return it.
105 const unsigned char* data = 105 const unsigned char* data =
106 reinterpret_cast<const unsigned char*>(contents.data()); 106 reinterpret_cast<const unsigned char*>(contents.data());
107 return ToBitmap(data, contents.length()); 107 return ToBitmap(data, contents.length());
108 } 108 }
109 109
110 std::string ExtensionIconSource::GetSource() const { 110 std::string ExtensionIconSource::GetSource() const {
111 return chrome::kChromeUIExtensionIconHost; 111 return chrome::kChromeUIExtensionIconHost;
112 } 112 }
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 std::map<int, ExtensionIconRequest*>::iterator i = 343 std::map<int, ExtensionIconRequest*>::iterator i =
344 request_map_.find(request_id); 344 request_map_.find(request_id);
345 if (i == request_map_.end()) 345 if (i == request_map_.end())
346 return; 346 return;
347 347
348 delete i->second; 348 delete i->second;
349 request_map_.erase(i); 349 request_map_.erase(i);
350 } 350 }
351 351
352 } // namespace extensions 352 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/component_loader.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698