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

Unified Diff: chrome/browser/ui/webui/options/options_ui.cc

Issue 7397021: Re-land r93365 - add RefCountedString (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 9 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/options/options_ui.cc
diff --git a/chrome/browser/ui/webui/options/options_ui.cc b/chrome/browser/ui/webui/options/options_ui.cc
index 0ace5df7f70759af5c5b042c10be3dc9caf46d63..de75ec6cf1f00c965496d3f821e063c22fb8a4de 100644
--- a/chrome/browser/ui/webui/options/options_ui.cc
+++ b/chrome/browser/ui/webui/options/options_ui.cc
@@ -116,35 +116,22 @@ OptionsUIHTMLSource::~OptionsUIHTMLSource() {}
void OptionsUIHTMLSource::StartDataRequest(const std::string& path,
bool is_incognito,
int request_id) {
- scoped_refptr<RefCountedBytes> response_bytes(new RefCountedBytes);
+ scoped_refptr<RefCountedMemory> response_bytes;
SetFontAndTextDirection(localized_strings_.get());
if (path == kLocalizedStringsFile) {
// Return dynamically-generated strings from memory.
- std::string template_data;
- jstemplate_builder::AppendJsonJS(localized_strings_.get(), &template_data);
- response_bytes->data.resize(template_data.size());
- std::copy(template_data.begin(),
- template_data.end(),
- response_bytes->data.begin());
+ std::string strings_js;
+ jstemplate_builder::AppendJsonJS(localized_strings_.get(), &strings_js);
+ response_bytes = base::RefCountedString::TakeString(&strings_js);
} else if (path == kOptionsBundleJsFile) {
// Return (and cache) the options javascript code.
- static const base::StringPiece options_javascript(
- ResourceBundle::GetSharedInstance().GetRawDataResource(
- IDR_OPTIONS_BUNDLE_JS));
- response_bytes->data.resize(options_javascript.size());
- std::copy(options_javascript.begin(),
- options_javascript.end(),
- response_bytes->data.begin());
+ response_bytes = ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
+ IDR_OPTIONS_BUNDLE_JS);
} else {
// Return (and cache) the main options html page as the default.
- static const base::StringPiece options_html(
- ResourceBundle::GetSharedInstance().GetRawDataResource(
- IDR_OPTIONS_HTML));
- response_bytes->data.resize(options_html.size());
- std::copy(options_html.begin(),
- options_html.end(),
- response_bytes->data.begin());
+ response_bytes = ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
+ IDR_OPTIONS_HTML);
}
SendResponse(request_id, response_bytes);
« no previous file with comments | « chrome/browser/ui/webui/ntp/ntp_resource_cache.cc ('k') | chrome/browser/ui/webui/print_preview_data_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698