Move the system string conversion functions from std::string to StringPiece.  We often work with char* in the system layer, so this should save extra copying.

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


CrOS-Libchrome-Original-Commit: 4bdaceb429c7cd6a3a2a8bc692f418969c24ff28
diff --git a/base/base_paths_linux.cc b/base/base_paths_linux.cc
index 298c231..a848440 100644
--- a/base/base_paths_linux.cc
+++ b/base/base_paths_linux.cc
@@ -34,6 +34,7 @@
 #include "base/file_util.h"
 #include "base/logging.h"
 #include "base/path_service.h"
+#include "base/string_piece.h"
 #include "base/sys_string_conversions.h"
 
 namespace base {
diff --git a/base/command_line.cc b/base/command_line.cc
index 8849149..0fb4624 100644
--- a/base/command_line.cc
+++ b/base/command_line.cc
@@ -38,6 +38,7 @@
 
 #include "base/logging.h"
 #include "base/singleton.h"
+#include "base/string_piece.h"
 #include "base/string_util.h"
 #include "base/sys_string_conversions.h"
 
diff --git a/base/logging.cc b/base/logging.cc
index 87ac934..27781ae 100644
--- a/base/logging.cc
+++ b/base/logging.cc
@@ -62,6 +62,7 @@
 #include "base/debug_util.h"
 #include "base/lock_impl.h"
 #include "base/logging.h"
+#include "base/string_piece.h"
 #include "base/string_util.h"
 #include "base/sys_string_conversions.h"
   
diff --git a/base/sys_string_conversions.h b/base/sys_string_conversions.h
index fc0a5eb..ed9b8fa 100644
--- a/base/sys_string_conversions.h
+++ b/base/sys_string_conversions.h
@@ -37,18 +37,20 @@
 #include <string>
 #include "base/basictypes.h"
 
+class StringPiece;
+
 namespace base {
 
 // Converts between wide and UTF-8 representations of a string. On error, the
 // result is system-dependent.
 std::string SysWideToUTF8(const std::wstring& wide);
-std::wstring SysUTF8ToWide(const std::string& utf8);
+std::wstring SysUTF8ToWide(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).
 std::string SysWideToNativeMB(const std::wstring& wide);
-std::wstring SysNativeMBToWide(const std::string& native_mb);
+std::wstring SysNativeMBToWide(StringPiece native_mb);
 
 // Windows-specific ------------------------------------------------------------
 
@@ -57,7 +59,7 @@
 // Converts between 8-bit and wide strings, using the given code page. The
 // code page identifier is one accepted by the Windows function
 // MultiByteToWideChar().
-std::wstring SysMultiByteToWide(const std::string& mb, uint32 code_page);
+std::wstring SysMultiByteToWide(StringPiece mb, uint32 code_page);
 std::string SysWideToMultiByte(const std::wstring& wide, uint32 code_page);
 
 #endif  // defined(OS_WIN)
diff --git a/base/sys_string_conversions_linux.cc b/base/sys_string_conversions_linux.cc
index 639b402..9547ef9 100644
--- a/base/sys_string_conversions_linux.cc
+++ b/base/sys_string_conversions_linux.cc
@@ -29,6 +29,7 @@
 
 #include "base/sys_string_conversions.h"
 
+#include "base/string_piece.h"
 #include "base/string_util.h"
 
 namespace base {
@@ -38,10 +39,12 @@
   // than our ICU, but this will do for now.
   return WideToUTF8(wide);
 }
-std::wstring SysUTF8ToWide(const std::string& utf8) {
+std::wstring SysUTF8ToWide(StringPiece utf8) {
   // In theory this should be using the system-provided conversion rather
   // than our ICU, but this will do for now.
-  return UTF8ToWide(utf8);
+  std::wstring out;
+  UTF8ToWide(utf8.data(), utf8.size(), &out);
+  return out;
 }
 
 std::string SysWideToNativeMB(const std::wstring& wide) {
@@ -49,7 +52,7 @@
   return SysWideToUTF8(wide);
 }
 
-std::wstring SysNativeMBToWide(const std::string& native_mb) {
+std::wstring SysNativeMBToWide(StringPiece native_mb) {
   // TODO(evanm): we can't assume Linux is UTF-8.
   return SysUTF8ToWide(native_mb);
 }