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

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: rebased onto r93582 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 2a44ad3c8147644715992e9ae5319d74dd11099a..55a9ec03665acec9466fed8ded1dc725bb5ea146 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);

Powered by Google App Engine
This is Rietveld 408576698