summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authoralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-14 05:21:54 +0000
committeralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-14 05:21:54 +0000
commit96e2c5522647935d4be7179c28b3f2359cdf3880 (patch)
treeb02ac36cba362dd529da49a17f3c97002b4eeb2a /remoting
parent45b1d04e99a13b60194a108a3b582268ae56916f (diff)
downloadchromium_src-96e2c5522647935d4be7179c28b3f2359cdf3880.zip
chromium_src-96e2c5522647935d4be7179c28b3f2359cdf3880.tar.gz
chromium_src-96e2c5522647935d4be7179c28b3f2359cdf3880.tar.bz2
Avoiding unnecessary conversion to UTF16 in runtime.
Review URL: http://codereview.chromium.org/10073028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132326 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/host/branding.cc3
-rw-r--r--remoting/host/branding.h2
-rw-r--r--remoting/host/elevated_controller_win.cc10
-rw-r--r--remoting/host/host_service_win.cc48
-rw-r--r--remoting/host/plugin/daemon_controller_win.cc3
-rw-r--r--remoting/host/sas_injector_win.cc21
-rw-r--r--remoting/host/wts_session_process_launcher_win.cc19
7 files changed, 50 insertions, 56 deletions
diff --git a/remoting/host/branding.cc b/remoting/host/branding.cc
index 1316139a..956f36e 100644
--- a/remoting/host/branding.cc
+++ b/remoting/host/branding.cc
@@ -6,6 +6,7 @@
#include "base/file_util.h"
#include "base/path_service.h"
+#include "base/stringize_macros.h"
namespace {
@@ -35,7 +36,7 @@ const FilePath::CharType kConfigDir[] =
namespace remoting {
#if defined(OS_WIN)
-const char kWindowsServiceName[] = "chromoting";
+const char16 kWindowsServiceName[] = TO_L_STRING("chromoting");
#endif
FilePath GetConfigDir() {
diff --git a/remoting/host/branding.h b/remoting/host/branding.h
index e780bc3..610a47c 100644
--- a/remoting/host/branding.h
+++ b/remoting/host/branding.h
@@ -11,7 +11,7 @@ namespace remoting {
#if defined(OS_WIN)
// Windows chromoting service name.
-extern const char kWindowsServiceName[];
+extern const char16 kWindowsServiceName[];
#endif
// Returns the location of the host configuration directory.
diff --git a/remoting/host/elevated_controller_win.cc b/remoting/host/elevated_controller_win.cc
index 4d510fc..e5b655e 100644
--- a/remoting/host/elevated_controller_win.cc
+++ b/remoting/host/elevated_controller_win.cc
@@ -12,6 +12,7 @@
#include "base/json/json_writer.h"
#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
+#include "base/stringize_macros.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "base/win/scoped_handle.h"
@@ -29,8 +30,8 @@ const FilePath::CharType kTempFileExtension[] = FILE_PATH_LITERAL("json~");
// The host configuration file security descriptor that enables full access to
// Local System and built-in administrators only.
-const char kConfigFileSecurityDescriptor[] =
- "O:BA" "G:BA" "D:(A;;GA;;;SY)(A;;GA;;;BA)";
+const char16 kConfigFileSecurityDescriptor[] =
+ TO_L_STRING("O:BAG:BAD:(A;;GA;;;SY)(A;;GA;;;BA)");
// The maximum size of the configuration file. "1MB ought to be enough" for any
// reasonable configuration we will ever need. 1MB is low enough to make
@@ -126,7 +127,7 @@ HRESULT WriteConfig(const FilePath& filename,
security_attributes.bInheritHandle = FALSE;
ULONG security_descriptor_length = 0;
- if (!ConvertStringSecurityDescriptorToSecurityDescriptorA(
+ if (!ConvertStringSecurityDescriptorToSecurityDescriptorW(
kConfigFileSecurityDescriptor,
SDDL_REVISION_1,
reinterpret_cast<PSECURITY_DESCRIPTOR*>(
@@ -346,8 +347,7 @@ HRESULT ElevatedControllerWin::OpenService(ScopedScHandle* service_out) {
DWORD desired_access = SERVICE_CHANGE_CONFIG | SERVICE_QUERY_STATUS |
SERVICE_START | SERVICE_STOP;
ScopedScHandle service(
- ::OpenServiceW(scmanager, UTF8ToUTF16(kWindowsServiceName).c_str(),
- desired_access));
+ ::OpenServiceW(scmanager, kWindowsServiceName, desired_access));
if (!service.IsValid()) {
error = GetLastError();
LOG_GETLASTERROR(ERROR)
diff --git a/remoting/host/host_service_win.cc b/remoting/host/host_service_win.cc
index 6a455df..af91f53 100644
--- a/remoting/host/host_service_win.cc
+++ b/remoting/host/host_service_win.cc
@@ -19,9 +19,9 @@
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/path_service.h"
+#include "base/stringize_macros.h"
#include "base/stringprintf.h"
#include "base/threading/thread.h"
-#include "base/utf_string_conversions.h"
#include "base/win/wrapped_window_proc.h"
#include "remoting/base/scoped_sc_handle_win.h"
@@ -35,10 +35,11 @@ using base::StringPrintf;
namespace {
// TODO(alexeypa): investigate and migrate this over to Chrome's i18n framework.
-const char kMuiStringFormat[] = "@%ls,-%d";
-const char kServiceDependencies[] = "";
+const char16 kMuiStringFormat[] = TO_L_STRING("@%ls,-%d");
+const char16 kServiceDependencies[] = TO_L_STRING("");
-const char kServiceCommandLineFormat[] = "\"%ls\" --host-binary=\"%ls\"";
+const char16 kServiceCommandLineFormat[] =
+ TO_L_STRING("\"%ls\" --host-binary=\"%ls\"");
const DWORD kServiceStopTimeoutMs = 30 * 1000;
@@ -48,18 +49,18 @@ const uint32 kInvalidSession = 0xffffffff;
const char kIoThreadName[] = "I/O thread";
// A window class for the session change notifications window.
-static const char kSessionNotificationWindowClass[] =
- "Chromoting_SessionNotificationWindow";
+const char16 kSessionNotificationWindowClass[] =
+ TO_L_STRING("Chromoting_SessionNotificationWindow");
// Command line actions and switches:
// "run" sumply runs the service as usual.
-const char kRunActionName[] = "run";
+const char16 kRunActionName[] = TO_L_STRING("run");
// "install" requests the service to be installed.
-const char kInstallActionName[] = "install";
+const char16 kInstallActionName[] = TO_L_STRING("install");
// "remove" uninstalls the service.
-const char kRemoveActionName[] = "remove";
+const char16 kRemoveActionName[] = TO_L_STRING("remove");
// "--console" runs the service interactively for debugging purposes.
const char kConsoleSwitchName[] = "console";
@@ -102,7 +103,7 @@ HostService::HostService() :
console_session_id_(kInvalidSession),
message_loop_(NULL),
run_routine_(&HostService::RunAsService),
- service_name_(UTF8ToUTF16(kWindowsServiceName)),
+ service_name_(kWindowsServiceName),
service_status_handle_(0),
shutting_down_(false),
stopped_event_(true, false) {
@@ -186,12 +187,12 @@ bool HostService::InitWithCommandLine(const CommandLine* command_line) {
LOG(ERROR) << "Invalid command line: more than one action requested.";
return false;
}
- if (args[0] == ASCIIToUTF16(kInstallActionName)) {
+ if (args[0] == kInstallActionName) {
run_routine_ = &HostService::Install;
- } else if (args[0] == ASCIIToUTF16(kRemoveActionName)) {
+ } else if (args[0] == kRemoveActionName) {
run_routine_ = &HostService::Remove;
host_binary_required = false;
- } else if (args[0] != ASCIIToUTF16(kRunActionName)) {
+ } else if (args[0] != kRunActionName) {
LOG(ERROR) << "Invalid command line: invalid action specified: "
<< args[0];
return false;
@@ -233,7 +234,7 @@ int HostService::Install() {
return kErrorExitCode;
}
- string16 name = StringPrintf(ASCIIToUTF16(kMuiStringFormat).c_str(),
+ string16 name = StringPrintf(kMuiStringFormat,
exe.value().c_str(),
IDS_DISPLAY_SERVICE_NAME);
@@ -243,10 +244,9 @@ int HostService::Install() {
return kErrorExitCode;
}
- string16 command_line = StringPrintf(
- ASCIIToUTF16(kServiceCommandLineFormat).c_str(),
- exe.value().c_str(),
- host_binary_.value().c_str());
+ string16 command_line = StringPrintf(kServiceCommandLineFormat,
+ exe.value().c_str(),
+ host_binary_.value().c_str());
ScopedScHandle service(
CreateServiceW(scmanager,
service_name_.c_str(),
@@ -257,16 +257,15 @@ int HostService::Install() {
command_line.c_str(),
NULL,
NULL,
- ASCIIToUTF16(kServiceDependencies).c_str(),
+ kServiceDependencies,
NULL,
NULL));
if (service.IsValid()) {
// Set the service description if the service is freshly installed.
- string16 description = StringPrintf(
- ASCIIToUTF16(kMuiStringFormat).c_str(),
- exe.value().c_str(),
- IDS_SERVICE_DESCRIPTION);
+ string16 description = StringPrintf(kMuiStringFormat,
+ exe.value().c_str(),
+ IDS_SERVICE_DESCRIPTION);
SERVICE_DESCRIPTIONW info;
info.lpDescription = const_cast<LPWSTR>(description.c_str());
@@ -421,13 +420,12 @@ int HostService::RunInConsole() {
LPCWSTR atom = NULL;
HWND window = NULL;
HINSTANCE instance = GetModuleHandle(NULL);
- string16 window_class = ASCIIToUTF16(kSessionNotificationWindowClass);
WNDCLASSEX wc = {0};
wc.cbSize = sizeof(wc);
wc.lpfnWndProc = base::win::WrappedWindowProc<SessionChangeNotificationProc>;
wc.hInstance = instance;
- wc.lpszClassName = window_class.c_str();
+ wc.lpszClassName = kSessionNotificationWindowClass;
atom = reinterpret_cast<LPCWSTR>(RegisterClassExW(&wc));
if (atom == NULL) {
LOG_GETLASTERROR(ERROR)
diff --git a/remoting/host/plugin/daemon_controller_win.cc b/remoting/host/plugin/daemon_controller_win.cc
index 4b011db..13f3725 100644
--- a/remoting/host/plugin/daemon_controller_win.cc
+++ b/remoting/host/plugin/daemon_controller_win.cc
@@ -290,8 +290,7 @@ DWORD DaemonControllerWin::OpenService(ScopedScHandle* service_out) {
}
ScopedScHandle service(
- ::OpenServiceW(scmanager, UTF8ToUTF16(kWindowsServiceName).c_str(),
- SERVICE_QUERY_STATUS));
+ ::OpenServiceW(scmanager, kWindowsServiceName, SERVICE_QUERY_STATUS));
if (!service.IsValid()) {
DWORD error = GetLastError();
if (error != ERROR_SERVICE_DOES_NOT_EXIST) {
diff --git a/remoting/host/sas_injector_win.cc b/remoting/host/sas_injector_win.cc
index 3dd55f1..33e3b49 100644
--- a/remoting/host/sas_injector_win.cc
+++ b/remoting/host/sas_injector_win.cc
@@ -11,7 +11,7 @@
#include "base/file_path.h"
#include "base/native_library.h"
#include "base/path_service.h"
-#include "base/utf_string_conversions.h"
+#include "base/stringize_macros.h"
#include "base/win/registry.h"
#include "base/win/windows_version.h"
@@ -29,9 +29,10 @@ typedef VOID (WINAPI *SendSasFunc)(BOOL);
// The registry key and value holding the policy controlling software SAS
// generation.
-const char kSystemPolicyKeyName[] =
- "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System";
-const char kSoftwareSasValueName[] = "SoftwareSASGeneration";
+const char16 kSystemPolicyKeyName[] =
+ TO_L_STRING("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\")
+ TO_L_STRING("System");
+const char16 kSoftwareSasValueName[] = TO_L_STRING("SoftwareSASGeneration");
const DWORD kEnableSoftwareSasByServices = 1;
@@ -48,9 +49,6 @@ class ScopedSoftwareSasPolicy {
// The handle of the registry key were SoftwareSASGeneration policy is stored.
base::win::RegKey system_policy_;
- // Name of the registry value holding the policy.
- string16 value_name_;
-
// True if the policy needs to be restored.
bool restore_policy_;
@@ -64,7 +62,7 @@ ScopedSoftwareSasPolicy::ScopedSoftwareSasPolicy()
ScopedSoftwareSasPolicy::~ScopedSoftwareSasPolicy() {
// Restore the default policy by deleting the value that we have set.
if (restore_policy_) {
- LONG result = system_policy_.DeleteValue(value_name_.c_str());
+ LONG result = system_policy_.DeleteValue(kSoftwareSasValueName);
if (result != ERROR_SUCCESS) {
SetLastError(result);
LOG_GETLASTERROR(ERROR)
@@ -76,7 +74,7 @@ ScopedSoftwareSasPolicy::~ScopedSoftwareSasPolicy() {
bool ScopedSoftwareSasPolicy::Apply() {
// Query the currently set SoftwareSASGeneration policy.
LONG result = system_policy_.Open(HKEY_LOCAL_MACHINE,
- ASCIIToUTF16(kSystemPolicyKeyName).c_str(),
+ kSystemPolicyKeyName,
KEY_QUERY_VALUE | KEY_SET_VALUE |
KEY_WOW64_64KEY);
if (result != ERROR_SUCCESS) {
@@ -86,12 +84,11 @@ bool ScopedSoftwareSasPolicy::Apply() {
return false;
}
- value_name_ = ASCIIToUTF16(kSoftwareSasValueName);
- bool custom_policy = system_policy_.HasValue(value_name_.c_str());
+ bool custom_policy = system_policy_.HasValue(kSoftwareSasValueName);
// Override the default policy (i.e. there is no value in the registry) only.
if (!custom_policy) {
- result = system_policy_.WriteValue(value_name_.c_str(),
+ result = system_policy_.WriteValue(kSoftwareSasValueName,
kEnableSoftwareSasByServices);
if (result != ERROR_SUCCESS) {
SetLastError(result);
diff --git a/remoting/host/wts_session_process_launcher_win.cc b/remoting/host/wts_session_process_launcher_win.cc
index 645fd03..eced4f5 100644
--- a/remoting/host/wts_session_process_launcher_win.cc
+++ b/remoting/host/wts_session_process_launcher_win.cc
@@ -19,8 +19,8 @@
#include "base/process_util.h"
#include "base/rand_util.h"
#include "base/string16.h"
+#include "base/stringize_macros.h"
#include "base/stringprintf.h"
-#include "base/utf_string_conversions.h"
#include "base/win/scoped_handle.h"
#include "base/win/scoped_process_information.h"
#include "ipc/ipc_channel_proxy.h"
@@ -46,10 +46,10 @@ const int kMaxLaunchDelaySeconds = 60;
const int kMinLaunchDelaySeconds = 1;
// Name of the default session desktop.
-const char kDefaultDesktopName[] = "winsta0\\default";
+char16 kDefaultDesktopName[] = TO_L_STRING("winsta0\\default");
// Match the pipe name prefix used by Chrome IPC channels.
-const char kChromePipeNamePrefix[] = "\\\\.\\pipe\\chrome.";
+const char16 kChromePipeNamePrefix[] = TO_L_STRING("\\\\.\\pipe\\chrome.");
// The IPC channel name is passed to the host in the command line.
const char kChromotingIpcSwitchName[] = "chromoting-ipc";
@@ -60,8 +60,8 @@ const char* kCopiedSwitchNames[] = { "auth-config", "host-config" };
// The security descriptor of the Chromoting IPC channel. It gives full access
// to LocalSystem and denies access by anyone else.
-const char kChromotingChannelSecurityDescriptor[] =
- "O:SY" "G:SY" "D:(A;;GA;;;SY)";
+const char16 kChromotingChannelSecurityDescriptor[] =
+ TO_L_STRING("O:SYG:SYD:(A;;GA;;;SY)");
// Takes the process token and makes a copy of it. The returned handle will have
// |desired_access| rights.
@@ -152,7 +152,7 @@ bool CreateSessionToken(uint32 session_id,
// Generates random channel ID.
// N.B. Stolen from src/content/common/child_process_host_impl.cc
string16 GenerateRandomChannelId(void* instance) {
- return base::StringPrintf(ASCIIToUTF16("%d.%p.%d").c_str(),
+ return base::StringPrintf(TO_L_STRING("%d.%p.%d"),
base::GetCurrentProcId(), instance,
base::RandInt(0, std::numeric_limits<int>::max()));
}
@@ -168,7 +168,7 @@ bool CreatePipeForIpcChannel(void* instance,
security_attributes.bInheritHandle = FALSE;
ULONG security_descriptor_length = 0;
- if (!ConvertStringSecurityDescriptorToSecurityDescriptorA(
+ if (!ConvertStringSecurityDescriptorToSecurityDescriptorW(
kChromotingChannelSecurityDescriptor,
SDDL_REVISION_1,
reinterpret_cast<PSECURITY_DESCRIPTOR*>(
@@ -183,7 +183,7 @@ bool CreatePipeForIpcChannel(void* instance,
string16 channel_name(GenerateRandomChannelId(instance));
// Convert it to the pipe name.
- string16 pipe_name(ASCIIToUTF16(kChromePipeNamePrefix));
+ string16 pipe_name(kChromePipeNamePrefix);
pipe_name.append(channel_name);
// Create the server end of the pipe. This code should match the code in
@@ -217,14 +217,13 @@ bool LaunchProcessAsUser(const FilePath& binary,
HANDLE user_token,
base::Process* process_out) {
string16 application_name = binary.value();
- string16 desktop = ASCIIToUTF16(kDefaultDesktopName);
base::win::ScopedProcessInformation process_info;
STARTUPINFOW startup_info;
memset(&startup_info, 0, sizeof(startup_info));
startup_info.cb = sizeof(startup_info);
- startup_info.lpDesktop = const_cast<LPWSTR>(desktop.c_str());
+ startup_info.lpDesktop = kDefaultDesktopName;
if (!CreateProcessAsUserW(user_token,
application_name.c_str(),