Move sys_string_conversions to base/strings.

This updates callers in base but I left a forwarding header so I can the rest in pieces (there are >300).

Review URL: https://codereview.chromium.org/12213061

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181345 0039d316-1c4b-4281-b951-d872f2087c98


CrOS-Libchrome-Original-Commit: 9fe1a5bcd6b3ca0118def30c8c02d01ba514deb2
diff --git a/base/base.gyp b/base/base.gyp
index 8febe46..1ae1d3b 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -533,6 +533,8 @@
         'strings/string_number_conversions_unittest.cc',
         'strings/string_tokenizer_unittest.cc',
         'strings/stringize_macros_unittest.cc',
+        'strings/sys_string_conversions_mac_unittest.mm',
+        'strings/sys_string_conversions_unittest.cc',
         'strings/utf_offset_string_conversions_unittest.cc',
         'synchronization/cancellation_flag_unittest.cc',
         'synchronization/condition_variable_unittest.cc',
@@ -540,8 +542,6 @@
         'synchronization/waitable_event_unittest.cc',
         'synchronization/waitable_event_watcher_unittest.cc',
         'sys_info_unittest.cc',
-        'sys_string_conversions_mac_unittest.mm',
-        'sys_string_conversions_unittest.cc',
         'system_monitor/system_monitor_unittest.cc',
         'task_runner_util_unittest.cc',
         'template_util_unittest.cc',
diff --git a/base/base.gypi b/base/base.gypi
index 7ab4d24..ae1b3da 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -400,6 +400,10 @@
           'strings/string_number_conversions.h',
           'strings/string_tokenizer.h',
           'strings/stringize_macros.h',
+          'strings/sys_string_conversions.h',
+          'strings/sys_string_conversions_mac.mm',
+          'strings/sys_string_conversions_posix.cc',
+          'strings/sys_string_conversions_win.cc',
           'strings/utf_offset_string_conversions.cc',
           'strings/utf_offset_string_conversions.h',
           'strings/utf_string_conversion_utils.cc',
@@ -443,10 +447,6 @@
           'sys_info_openbsd.cc',
           'sys_info_posix.cc',
           'sys_info_win.cc',
-          'sys_string_conversions.h',
-          'sys_string_conversions_mac.mm',
-          'sys_string_conversions_posix.cc',
-          'sys_string_conversions_win.cc',
           'task_runner.cc',
           'task_runner.h',
           'task_runner_util.h',
@@ -639,8 +639,8 @@
               ['include', '^files/file_path_watcher_linux\\.cc$'],
               ['include', '^process_util_linux\\.cc$'],
               ['include', '^posix/unix_domain_socket_linux\\.cc$'],
+              ['include', '^strings/sys_string_conversions_posix\\.cc$'],
               ['include', '^sys_info_linux\\.cc$'],
-              ['include', '^sys_string_conversions_posix\\.cc$'],
               ['include', '^worker_pool_linux\\.cc$'],
             ],
           }],
diff --git a/base/file_path.cc b/base/file_path.cc
index 70cfb51..fe2db15 100644
--- a/base/file_path.cc
+++ b/base/file_path.cc
@@ -15,7 +15,7 @@
 // when those functions are removed.
 #include "base/string_piece.h"
 #include "base/string_util.h"
-#include "base/sys_string_conversions.h"
+#include "base/strings/sys_string_conversions.h"
 #include "base/utf_string_conversions.h"
 
 #if defined(OS_MACOSX)
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index ebe3fbf..5bf4fb1 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -41,7 +41,7 @@
 #include "base/stl_util.h"
 #include "base/string_util.h"
 #include "base/stringprintf.h"
-#include "base/sys_string_conversions.h"
+#include "base/strings/sys_string_conversions.h"
 #include "base/threading/thread_restrictions.h"
 #include "base/time.h"
 #include "base/utf_string_conversions.h"
diff --git a/base/i18n/file_util_icu.cc b/base/i18n/file_util_icu.cc
index c542633..0b04370 100644
--- a/base/i18n/file_util_icu.cc
+++ b/base/i18n/file_util_icu.cc
@@ -12,8 +12,8 @@
 #include "base/memory/scoped_ptr.h"
 #include "base/memory/singleton.h"
 #include "base/string_util.h"
+#include "base/strings/sys_string_conversions.h"
 #include "base/utf_string_conversions.h"
-#include "base/sys_string_conversions.h"
 #include "build/build_config.h"
 #include "third_party/icu/public/common/unicode/uniset.h"
 #include "third_party/icu/public/i18n/unicode/coll.h"
diff --git a/base/i18n/icu_util.cc b/base/i18n/icu_util.cc
index 22d64bc..3cfd1d1 100644
--- a/base/i18n/icu_util.cc
+++ b/base/i18n/icu_util.cc
@@ -17,7 +17,7 @@
 #include "base/logging.h"
 #include "base/path_service.h"
 #include "base/string_util.h"
-#include "base/sys_string_conversions.h"
+#include "base/strings/sys_string_conversions.h"
 #include "third_party/icu/public/common/unicode/putil.h"
 #include "third_party/icu/public/common/unicode/udata.h"
 
diff --git a/base/i18n/rtl.cc b/base/i18n/rtl.cc
index d9fa019..821548f 100644
--- a/base/i18n/rtl.cc
+++ b/base/i18n/rtl.cc
@@ -7,8 +7,8 @@
 #include "base/file_path.h"
 #include "base/logging.h"
 #include "base/string_util.h"
+#include "base/strings/sys_string_conversions.h"
 #include "base/utf_string_conversions.h"
-#include "base/sys_string_conversions.h"
 #include "third_party/icu/public/common/unicode/locid.h"
 #include "third_party/icu/public/common/unicode/uchar.h"
 #include "third_party/icu/public/common/unicode/uscript.h"
diff --git a/base/i18n/rtl_unittest.cc b/base/i18n/rtl_unittest.cc
index 53ba971..ed661a9 100644
--- a/base/i18n/rtl_unittest.cc
+++ b/base/i18n/rtl_unittest.cc
@@ -8,8 +8,8 @@
 
 #include "base/file_path.h"
 #include "base/string_util.h"
+#include "base/strings/sys_string_conversions.h"
 #include "base/utf_string_conversions.h"
-#include "base/sys_string_conversions.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "testing/platform_test.h"
 #include "third_party/icu/public/i18n/unicode/usearch.h"
diff --git a/base/strings/sys_string_conversions.h b/base/strings/sys_string_conversions.h
new file mode 100644
index 0000000..8c800c0
--- /dev/null
+++ b/base/strings/sys_string_conversions.h
@@ -0,0 +1,83 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BASE_STRINGS_SYS_STRING_CONVERSIONS_H_
+#define BASE_STRINGS_SYS_STRING_CONVERSIONS_H_
+
+// Provides system-dependent string type conversions for cases where it's
+// necessary to not use ICU. Generally, you should not need this in Chrome,
+// but it is used in some shared code. Dependencies should be minimal.
+
+#include <string>
+
+#include "base/base_export.h"
+#include "base/basictypes.h"
+#include "base/string16.h"
+#include "base/string_piece.h"
+
+#if defined(OS_MACOSX)
+#include <CoreFoundation/CoreFoundation.h>
+#ifdef __OBJC__
+@class NSString;
+#else
+class NSString;
+#endif
+#endif  // OS_MACOSX
+
+namespace base {
+
+// Converts between wide and UTF-8 representations of a string. On error, the
+// result is system-dependent.
+BASE_EXPORT std::string SysWideToUTF8(const std::wstring& wide);
+BASE_EXPORT std::wstring SysUTF8ToWide(const StringPiece& utf8);
+
+// Converts between wide and the system multi-byte representations of a string.
+// DANGER: This will lose information and can change (on Windows, this can
+// change between reboots).
+BASE_EXPORT std::string SysWideToNativeMB(const std::wstring& wide);
+BASE_EXPORT std::wstring SysNativeMBToWide(const StringPiece& native_mb);
+
+// Windows-specific ------------------------------------------------------------
+
+#if defined(OS_WIN)
+
+// Converts between 8-bit and wide strings, using the given code page. The
+// code page identifier is one accepted by the Windows function
+// MultiByteToWideChar().
+BASE_EXPORT std::wstring SysMultiByteToWide(const StringPiece& mb,
+                                            uint32 code_page);
+BASE_EXPORT std::string SysWideToMultiByte(const std::wstring& wide,
+                                           uint32 code_page);
+
+#endif  // defined(OS_WIN)
+
+// Mac-specific ----------------------------------------------------------------
+
+#if defined(OS_MACOSX)
+
+// Converts between STL strings and CFStringRefs/NSStrings.
+
+// Creates a string, and returns it with a refcount of 1. You are responsible
+// for releasing it. Returns NULL on failure.
+BASE_EXPORT CFStringRef SysUTF8ToCFStringRef(const std::string& utf8);
+BASE_EXPORT CFStringRef SysUTF16ToCFStringRef(const string16& utf16);
+
+// Same, but returns an autoreleased NSString.
+BASE_EXPORT NSString* SysUTF8ToNSString(const std::string& utf8);
+BASE_EXPORT NSString* SysUTF16ToNSString(const string16& utf16);
+
+// Converts a CFStringRef to an STL string. Returns an empty string on failure.
+BASE_EXPORT std::string SysCFStringRefToUTF8(CFStringRef ref);
+BASE_EXPORT string16 SysCFStringRefToUTF16(CFStringRef ref);
+
+// Same, but accepts NSString input. Converts nil NSString* to the appropriate
+// string type of length 0.
+BASE_EXPORT std::string SysNSStringToUTF8(NSString* ref);
+BASE_EXPORT string16 SysNSStringToUTF16(NSString* ref);
+
+#endif  // defined(OS_MACOSX)
+
+}  // namespace base
+
+#endif  // BASE_STRINGS_SYS_STRING_CONVERSIONS_H_
diff --git a/base/sys_string_conversions_posix.cc b/base/strings/sys_string_conversions_posix.cc
similarity index 98%
rename from base/sys_string_conversions_posix.cc
rename to base/strings/sys_string_conversions_posix.cc
index a2bf52a..e5be290 100644
--- a/base/sys_string_conversions_posix.cc
+++ b/base/strings/sys_string_conversions_posix.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "base/sys_string_conversions.h"
+#include "base/strings/sys_string_conversions.h"
 
 #include <wchar.h>
 
diff --git a/base/sys_string_conversions_unittest.cc b/base/strings/sys_string_conversions_unittest.cc
similarity index 91%
rename from base/sys_string_conversions_unittest.cc
rename to base/strings/sys_string_conversions_unittest.cc
index a3393ba..0c9c924 100644
--- a/base/sys_string_conversions_unittest.cc
+++ b/base/strings/sys_string_conversions_unittest.cc
@@ -2,14 +2,13 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-
 #include <string>
 
 #include "base/basictypes.h"
 #include "base/string_piece.h"
+#include "base/strings/sys_string_conversions.h"
 #include "base/test/scoped_locale.h"
 #include "base/utf_string_conversions.h"
-#include "base/sys_string_conversions.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 #ifdef WCHAR_T_IS_UTF32
@@ -18,8 +17,9 @@
 static const std::wstring kSysWideOldItalicLetterA = L"\xd800\xdf00";
 #endif
 
+namespace base {
+
 TEST(SysStrings, SysWideToUTF8) {
-  using base::SysWideToUTF8;
   EXPECT_EQ("Hello, world", SysWideToUTF8(L"Hello, world"));
   EXPECT_EQ("\xe4\xbd\xa0\xe5\xa5\xbd", SysWideToUTF8(L"\x4f60\x597d"));
 
@@ -48,7 +48,6 @@
 }
 
 TEST(SysStrings, SysUTF8ToWide) {
-  using base::SysUTF8ToWide;
   EXPECT_EQ(L"Hello, world", SysUTF8ToWide("Hello, world"));
   EXPECT_EQ(L"\x4f60\x597d", SysUTF8ToWide("\xe4\xbd\xa0\xe5\xa5\xbd"));
   // >16 bits
@@ -76,8 +75,7 @@
 #if defined(OS_LINUX)  // Tests depend on setting a specific Linux locale.
 
 TEST(SysStrings, SysWideToNativeMB) {
-  using base::SysWideToNativeMB;
-  base::ScopedLocale locale("en_US.utf-8");
+  ScopedLocale locale("en_US.utf-8");
   EXPECT_EQ("Hello, world", SysWideToNativeMB(L"Hello, world"));
   EXPECT_EQ("\xe4\xbd\xa0\xe5\xa5\xbd", SysWideToNativeMB(L"\x4f60\x597d"));
 
@@ -107,8 +105,7 @@
 
 // We assume the test is running in a UTF8 locale.
 TEST(SysStrings, SysNativeMBToWide) {
-  using base::SysNativeMBToWide;
-  base::ScopedLocale locale("en_US.utf-8");
+  ScopedLocale locale("en_US.utf-8");
   EXPECT_EQ(L"Hello, world", SysNativeMBToWide("Hello, world"));
   EXPECT_EQ(L"\x4f60\x597d", SysNativeMBToWide("\xe4\xbd\xa0\xe5\xa5\xbd"));
   // >16 bits
@@ -162,10 +159,10 @@
 
 
 TEST(SysStrings, SysNativeMBAndWide) {
-  base::ScopedLocale locale("en_US.utf-8");
+  ScopedLocale locale("en_US.utf-8");
   for (size_t i = 0; i < arraysize(kConvertRoundtripCases); ++i) {
     std::wstring wide = kConvertRoundtripCases[i];
-    std::wstring trip = base::SysNativeMBToWide(base::SysWideToNativeMB(wide));
+    std::wstring trip = SysNativeMBToWide(SysWideToNativeMB(wide));
     EXPECT_EQ(wide.size(), trip.size());
     EXPECT_EQ(wide, trip);
   }
@@ -173,16 +170,18 @@
   // We assume our test is running in UTF-8, so double check through ICU.
   for (size_t i = 0; i < arraysize(kConvertRoundtripCases); ++i) {
     std::wstring wide = kConvertRoundtripCases[i];
-    std::wstring trip = base::SysNativeMBToWide(WideToUTF8(wide));
+    std::wstring trip = SysNativeMBToWide(WideToUTF8(wide));
     EXPECT_EQ(wide.size(), trip.size());
     EXPECT_EQ(wide, trip);
   }
 
   for (size_t i = 0; i < arraysize(kConvertRoundtripCases); ++i) {
     std::wstring wide = kConvertRoundtripCases[i];
-    std::wstring trip = UTF8ToWide(base::SysWideToNativeMB(wide));
+    std::wstring trip = UTF8ToWide(SysWideToNativeMB(wide));
     EXPECT_EQ(wide.size(), trip.size());
     EXPECT_EQ(wide, trip);
   }
 }
 #endif  // OS_LINUX
+
+}  // namespace base
diff --git a/base/sys_string_conversions.h b/base/sys_string_conversions.h
index 3f7631c..36e51c8 100644
--- a/base/sys_string_conversions.h
+++ b/base/sys_string_conversions.h
@@ -1,83 +1,7 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef BASE_SYS_STRING_CONVERSIONS_H_
-#define BASE_SYS_STRING_CONVERSIONS_H_
-
-// Provides system-dependent string type conversions for cases where it's
-// necessary to not use ICU. Generally, you should not need this in Chrome,
-// but it is used in some shared code. Dependencies should be minimal.
-
-#include <string>
-
-#include "base/base_export.h"
-#include "base/basictypes.h"
-#include "base/string16.h"
-#include "base/string_piece.h"
-
-#if defined(OS_MACOSX)
-#include <CoreFoundation/CoreFoundation.h>
-#ifdef __OBJC__
-@class NSString;
-#else
-class NSString;
-#endif
-#endif  // OS_MACOSX
-
-namespace base {
-
-// Converts between wide and UTF-8 representations of a string. On error, the
-// result is system-dependent.
-BASE_EXPORT std::string SysWideToUTF8(const std::wstring& wide);
-BASE_EXPORT std::wstring SysUTF8ToWide(const StringPiece& utf8);
-
-// Converts between wide and the system multi-byte representations of a string.
-// DANGER: This will lose information and can change (on Windows, this can
-// change between reboots).
-BASE_EXPORT std::string SysWideToNativeMB(const std::wstring& wide);
-BASE_EXPORT std::wstring SysNativeMBToWide(const StringPiece& native_mb);
-
-// Windows-specific ------------------------------------------------------------
-
-#if defined(OS_WIN)
-
-// Converts between 8-bit and wide strings, using the given code page. The
-// code page identifier is one accepted by the Windows function
-// MultiByteToWideChar().
-BASE_EXPORT std::wstring SysMultiByteToWide(const StringPiece& mb,
-                                            uint32 code_page);
-BASE_EXPORT std::string SysWideToMultiByte(const std::wstring& wide,
-                                           uint32 code_page);
-
-#endif  // defined(OS_WIN)
-
-// Mac-specific ----------------------------------------------------------------
-
-#if defined(OS_MACOSX)
-
-// Converts between STL strings and CFStringRefs/NSStrings.
-
-// Creates a string, and returns it with a refcount of 1. You are responsible
-// for releasing it. Returns NULL on failure.
-BASE_EXPORT CFStringRef SysUTF8ToCFStringRef(const std::string& utf8);
-BASE_EXPORT CFStringRef SysUTF16ToCFStringRef(const string16& utf16);
-
-// Same, but returns an autoreleased NSString.
-BASE_EXPORT NSString* SysUTF8ToNSString(const std::string& utf8);
-BASE_EXPORT NSString* SysUTF16ToNSString(const string16& utf16);
-
-// Converts a CFStringRef to an STL string. Returns an empty string on failure.
-BASE_EXPORT std::string SysCFStringRefToUTF8(CFStringRef ref);
-BASE_EXPORT string16 SysCFStringRefToUTF16(CFStringRef ref);
-
-// Same, but accepts NSString input. Converts nil NSString* to the appropriate
-// string type of length 0.
-BASE_EXPORT std::string SysNSStringToUTF8(NSString* ref);
-BASE_EXPORT string16 SysNSStringToUTF16(NSString* ref);
-
-#endif  // defined(OS_MACOSX)
-
-}  // namespace base
-
-#endif  // BASE_SYS_STRING_CONVERSIONS_H_
+// TODO(brettw) remove this file when all callers are updated to the new
+// location.
+#include "base/strings/sys_string_conversions.h"
diff --git a/base/time.cc b/base/time.cc
index e5afa12..26fd500 100644
--- a/base/time.cc
+++ b/base/time.cc
@@ -11,7 +11,7 @@
 
 #include <limits>
 
-#include "base/sys_string_conversions.h"
+#include "base/strings/sys_string_conversions.h"
 #include "base/third_party/nspr/prtime.h"
 
 #include "base/logging.h"