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

Unified Diff: base/string_util.cc

Issue 39022: Convert NavigationEntry title to string16. TabContents::GetTitle no longer ne... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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
« no previous file with comments | « base/string_util.h ('k') | chrome/browser/browser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/string_util.cc
===================================================================
--- base/string_util.cc (revision 10809)
+++ base/string_util.cc (working copy)
@@ -27,6 +27,16 @@
namespace {
+// Force the singleton used by Empty[W]String[16] to be a unique type. This
+// prevents other code that might accidentally use Singleton<string> from
+// getting our internal one.
+struct EmptyStrings {
+ EmptyStrings() {}
+ const std::string s;
+ const std::wstring ws;
+ const string16 s16;
+};
+
// Hack to convert any char-like type to its unsigned counterpart.
// For example, it will convert char, signed char and unsigned char to unsigned
// char.
@@ -323,13 +333,17 @@
const std::string& EmptyString() {
- return *Singleton<std::string>::get();
+ return Singleton<EmptyStrings>::get()->s;
}
const std::wstring& EmptyWString() {
- return *Singleton<std::wstring>::get();
+ return Singleton<EmptyStrings>::get()->ws;
}
+const string16& EmptyString16() {
+ return Singleton<EmptyStrings>::get()->s16;
+}
+
const wchar_t kWhitespaceWide[] = {
0x0009, // <control-0009> to <control-000D>
0x000A,
« no previous file with comments | « base/string_util.h ('k') | chrome/browser/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698