OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/service/service_process.h" | 5 #include "chrome/service/service_process.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT))); | 115 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT))); |
116 base::i18n::AdjustStringForLocaleDirection(&adjusted_string); | 116 base::i18n::AdjustStringForLocaleDirection(&adjusted_string); |
117 dlg_strings.append(adjusted_string); | 117 dlg_strings.append(adjusted_string); |
118 dlg_strings.push_back('|'); | 118 dlg_strings.push_back('|'); |
119 dlg_strings.append(base::ASCIIToUTF16( | 119 dlg_strings.append(base::ASCIIToUTF16( |
120 base::i18n::IsRTL() ? env_vars::kRtlLocale : env_vars::kLtrLocale)); | 120 base::i18n::IsRTL() ? env_vars::kRtlLocale : env_vars::kLtrLocale)); |
121 | 121 |
122 env->SetVar(env_vars::kRestartInfo, base::UTF16ToUTF8(dlg_strings)); | 122 env->SetVar(env_vars::kRestartInfo, base::UTF16ToUTF8(dlg_strings)); |
123 } | 123 } |
124 | 124 |
125 #if defined(OS_POSIX) | |
126 mojo::edk::ScopedPlatformHandle CreateServerHandle( | |
127 const IPC::ChannelHandle& channel_handle) { | |
128 #if defined(OS_MACOSX) | |
129 mojo::edk::PlatformHandle platform_handle(channel_handle.socket.fd); | |
130 platform_handle.needs_connection = true; | |
131 return mojo::edk::ScopedPlatformHandle(platform_handle); | |
132 #else | |
133 return mojo::edk::CreateServerHandle( | |
134 mojo::edk::NamedPlatformHandle(channel_handle.name)); | |
135 #endif | |
136 } | |
137 #endif | |
138 | |
139 } // namespace | 125 } // namespace |
140 | 126 |
141 ServiceProcess::ServiceProcess() | 127 ServiceProcess::ServiceProcess() |
142 : shutdown_event_(base::WaitableEvent::ResetPolicy::MANUAL, | 128 : shutdown_event_(base::WaitableEvent::ResetPolicy::MANUAL, |
143 base::WaitableEvent::InitialState::NOT_SIGNALED), | 129 base::WaitableEvent::InitialState::NOT_SIGNALED), |
144 main_message_loop_(NULL), | 130 main_message_loop_(NULL), |
145 enabled_services_(0), | 131 enabled_services_(0), |
146 update_available_(false) { | 132 update_available_(false) { |
147 DCHECK(!g_service_process); | 133 DCHECK(!g_service_process); |
148 g_service_process = this; | 134 g_service_process = this; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 // new connections. | 299 // new connections. |
314 if (!enabled_services_ || update_available_) { | 300 if (!enabled_services_ || update_available_) { |
315 Shutdown(); | 301 Shutdown(); |
316 return false; | 302 return false; |
317 } | 303 } |
318 return true; | 304 return true; |
319 } | 305 } |
320 | 306 |
321 mojo::ScopedMessagePipeHandle ServiceProcess::CreateChannelMessagePipe() { | 307 mojo::ScopedMessagePipeHandle ServiceProcess::CreateChannelMessagePipe() { |
322 if (!server_handle_.is_valid()) { | 308 if (!server_handle_.is_valid()) { |
323 #if defined(OS_POSIX) | 309 #if defined(OS_MACOSX) |
324 server_handle_ = | 310 mojo::edk::PlatformHandle platform_handle( |
325 CreateServerHandle(service_process_state_->GetServiceProcessChannel()); | 311 service_process_state_->GetServiceProcessChannel().release()); |
| 312 platform_handle.needs_connection = true; |
| 313 server_handle_.reset(platform_handle); |
| 314 #elif defined(OS_POSIX) |
| 315 server_handle_ = mojo::edk::CreateServerHandle( |
| 316 service_process_state_->GetServiceProcessChannel()); |
326 #elif defined(OS_WIN) | 317 #elif defined(OS_WIN) |
327 server_handle_ = mojo::edk::NamedPlatformHandle( | 318 server_handle_ = service_process_state_->GetServiceProcessChannel(); |
328 service_process_state_->GetServiceProcessChannel().name); | |
329 #endif | 319 #endif |
330 DCHECK(server_handle_.is_valid()); | 320 DCHECK(server_handle_.is_valid()); |
331 } | 321 } |
332 | 322 |
333 mojo::edk::ScopedPlatformHandle channel_handle; | 323 mojo::edk::ScopedPlatformHandle channel_handle; |
334 #if defined(OS_POSIX) | 324 #if defined(OS_POSIX) |
335 channel_handle = mojo::edk::DuplicatePlatformHandle(server_handle_.get()); | 325 channel_handle = mojo::edk::DuplicatePlatformHandle(server_handle_.get()); |
336 #elif defined(OS_WIN) | 326 #elif defined(OS_WIN) |
337 mojo::edk::CreateServerHandleOptions options; | 327 mojo::edk::CreateServerHandleOptions options; |
338 options.enforce_uniqueness = false; | 328 options.enforce_uniqueness = false; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 } else { | 408 } else { |
419 Shutdown(); | 409 Shutdown(); |
420 } | 410 } |
421 } | 411 } |
422 } | 412 } |
423 | 413 |
424 ServiceProcess::~ServiceProcess() { | 414 ServiceProcess::~ServiceProcess() { |
425 Teardown(); | 415 Teardown(); |
426 g_service_process = NULL; | 416 g_service_process = NULL; |
427 } | 417 } |
OLD | NEW |