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

Side by Side Diff: chrome/service/service_process.cc

Issue 6955010: Remove the Remoting Host component from Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove an errant include. Created 9 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/service/service_process.h ('k') | chrome/service/service_process_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 10 matching lines...) Expand all
21 #include "chrome/common/env_vars.h" 21 #include "chrome/common/env_vars.h"
22 #include "chrome/common/net/url_fetcher.h" 22 #include "chrome/common/net/url_fetcher.h"
23 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
24 #include "chrome/common/service_process_util.h" 24 #include "chrome/common/service_process_util.h"
25 #include "chrome/service/cloud_print/cloud_print_proxy.h" 25 #include "chrome/service/cloud_print/cloud_print_proxy.h"
26 #include "chrome/service/net/service_url_request_context.h" 26 #include "chrome/service/net/service_url_request_context.h"
27 #include "chrome/service/service_ipc_server.h" 27 #include "chrome/service/service_ipc_server.h"
28 #include "chrome/service/service_process_prefs.h" 28 #include "chrome/service/service_process_prefs.h"
29 #include "grit/chromium_strings.h" 29 #include "grit/chromium_strings.h"
30 #include "grit/generated_resources.h" 30 #include "grit/generated_resources.h"
31 #include "media/base/media.h"
32 #include "net/base/network_change_notifier.h" 31 #include "net/base/network_change_notifier.h"
33 #include "ui/base/l10n/l10n_util.h" 32 #include "ui/base/l10n/l10n_util.h"
34 #include "ui/base/resource/resource_bundle.h" 33 #include "ui/base/resource/resource_bundle.h"
35 #include "ui/base/ui_base_switches.h" 34 #include "ui/base/ui_base_switches.h"
36 35
37 #if defined(TOOLKIT_USES_GTK) 36 #if defined(TOOLKIT_USES_GTK)
38 #include "ui/gfx/gtk_util.h" 37 #include "ui/gfx/gtk_util.h"
39 #include <gtk/gtk.h> 38 #include <gtk/gtk.h>
40 #endif 39 #endif
41 40
42 #if defined(ENABLE_REMOTING)
43 #include "chrome/service/remoting/chromoting_host_manager.h"
44 #if defined(OS_MACOSX)
45 #include "base/mac/mac_util.h"
46 #endif // defined(OS_MACOSX)
47 #endif // defined(ENABLED_REMOTING)
48
49 ServiceProcess* g_service_process = NULL; 41 ServiceProcess* g_service_process = NULL;
50 42
51 namespace { 43 namespace {
52 44
53 // Delay in millseconds after the last service is disabled before we attempt 45 // Delay in millseconds after the last service is disabled before we attempt
54 // a shutdown. 46 // a shutdown.
55 const int64 kShutdownDelay = 60000; 47 const int64 kShutdownDelay = 60000;
56 48
57 const char kDefaultServiceProcessLocale[] = "en-US"; 49 const char kDefaultServiceProcessLocale[] = "en-US";
58 50
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // the prefs. 173 // the prefs.
182 service_prefs_->GetString(prefs::kApplicationLocale, &locale); 174 service_prefs_->GetString(prefs::kApplicationLocale, &locale);
183 // If no locale was specified anywhere, use the default one. 175 // If no locale was specified anywhere, use the default one.
184 if (locale.empty()) 176 if (locale.empty())
185 locale = kDefaultServiceProcessLocale; 177 locale = kDefaultServiceProcessLocale;
186 } 178 }
187 ResourceBundle::InitSharedInstance(locale); 179 ResourceBundle::InitSharedInstance(locale);
188 180
189 PrepareRestartOnCrashEnviroment(command_line); 181 PrepareRestartOnCrashEnviroment(command_line);
190 182
191 #if defined(ENABLE_REMOTING)
192 // Load media codecs, required by the Chromoting host
193 FilePath module_path;
194 if (PathService::Get(chrome::DIR_MEDIA_LIBS, &module_path) &&
195 media::InitializeMediaLibrary(module_path)) {
196 // Initialize chromoting host manager.
197 remoting_host_manager_ = new remoting::ChromotingHostManager(this);
198 remoting_host_manager_->Initialize(message_loop,
199 file_thread_->message_loop_proxy());
200 }
201 #endif // ENABLE_REMOTING
202
203 // Enable Cloud Print if needed. First check the command-line. 183 // Enable Cloud Print if needed. First check the command-line.
204 bool cloud_print_proxy_enabled = 184 bool cloud_print_proxy_enabled =
205 command_line.HasSwitch(switches::kEnableCloudPrintProxy); 185 command_line.HasSwitch(switches::kEnableCloudPrintProxy);
206 if (!cloud_print_proxy_enabled) { 186 if (!cloud_print_proxy_enabled) {
207 // Then check if the cloud print proxy was previously enabled. 187 // Then check if the cloud print proxy was previously enabled.
208 service_prefs_->GetBoolean(prefs::kCloudPrintProxyEnabled, 188 service_prefs_->GetBoolean(prefs::kCloudPrintProxyEnabled,
209 &cloud_print_proxy_enabled); 189 &cloud_print_proxy_enabled);
210 } 190 }
211 191
212 if (cloud_print_proxy_enabled) { 192 if (cloud_print_proxy_enabled) {
(...skipping 28 matching lines...) Expand all
241 io_thread_.reset(); 221 io_thread_.reset();
242 file_thread_.reset(); 222 file_thread_.reset();
243 // The NetworkChangeNotifier must be destroyed after all other threads that 223 // The NetworkChangeNotifier must be destroyed after all other threads that
244 // might use it have been shut down. 224 // might use it have been shut down.
245 network_change_notifier_.reset(); 225 network_change_notifier_.reset();
246 226
247 service_process_state_->SignalStopped(); 227 service_process_state_->SignalStopped();
248 return true; 228 return true;
249 } 229 }
250 230
251 #if defined(ENABLE_REMOTING)
252 static void QuitMessageLoop(MessageLoop* message_loop) {
253 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask());
254 }
255 #endif
256
257 // This method is called when a shutdown command is received from IPC channel 231 // This method is called when a shutdown command is received from IPC channel
258 // or there was an error in the IPC channel. 232 // or there was an error in the IPC channel.
259 void ServiceProcess::Shutdown() { 233 void ServiceProcess::Shutdown() {
260 #if defined(ENABLE_REMOTING)
261 // During shutdown of remoting host it has some left over operations on
262 // the UI thread. So we let the teardown to proceed asynchronously
263 if (remoting_host_manager_.get()) {
264 remoting_host_manager_->Teardown(
265 NewRunnableFunction(&QuitMessageLoop, main_message_loop_));
266 }
267 #else
268 // Quit the main message loop. 234 // Quit the main message loop.
269 main_message_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 235 main_message_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask());
270 #endif
271 } 236 }
272 237
273 bool ServiceProcess::HandleClientDisconnect() { 238 bool ServiceProcess::HandleClientDisconnect() {
274 // If there are no enabled services or if there is an update available 239 // If there are no enabled services or if there is an update available
275 // we want to shutdown right away. Else we want to keep listening for 240 // we want to shutdown right away. Else we want to keep listening for
276 // new connections. 241 // new connections.
277 if (!enabled_services_ || update_available()) { 242 if (!enabled_services_ || update_available()) {
278 Shutdown(); 243 Shutdown();
279 return false; 244 return false;
280 } 245 }
(...skipping 19 matching lines...) Expand all
300 265
301 void ServiceProcess::OnCloudPrintProxyDisabled(bool persist_state) { 266 void ServiceProcess::OnCloudPrintProxyDisabled(bool persist_state) {
302 if (persist_state) { 267 if (persist_state) {
303 // Save the preference that we have disabled the cloud print proxy. 268 // Save the preference that we have disabled the cloud print proxy.
304 service_prefs_->SetBoolean(prefs::kCloudPrintProxyEnabled, false); 269 service_prefs_->SetBoolean(prefs::kCloudPrintProxyEnabled, false);
305 service_prefs_->WritePrefs(); 270 service_prefs_->WritePrefs();
306 } 271 }
307 OnServiceDisabled(); 272 OnServiceDisabled();
308 } 273 }
309 274
310 void ServiceProcess::OnChromotingHostEnabled() {
311 OnServiceEnabled();
312 }
313
314 void ServiceProcess::OnChromotingHostDisabled() {
315 OnServiceDisabled();
316 }
317
318 ServiceURLRequestContextGetter* 275 ServiceURLRequestContextGetter*
319 ServiceProcess::GetServiceURLRequestContextGetter() { 276 ServiceProcess::GetServiceURLRequestContextGetter() {
320 DCHECK(request_context_getter_.get()); 277 DCHECK(request_context_getter_.get());
321 return request_context_getter_.get(); 278 return request_context_getter_.get();
322 } 279 }
323 280
324 void ServiceProcess::OnServiceEnabled() { 281 void ServiceProcess::OnServiceEnabled() {
325 enabled_services_++; 282 enabled_services_++;
326 if ((1 == enabled_services_) && 283 if ((1 == enabled_services_) &&
327 !CommandLine::ForCurrentProcess()->HasSwitch( 284 !CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 } else { 321 } else {
365 Shutdown(); 322 Shutdown();
366 } 323 }
367 } 324 }
368 } 325 }
369 326
370 ServiceProcess::~ServiceProcess() { 327 ServiceProcess::~ServiceProcess() {
371 Teardown(); 328 Teardown();
372 g_service_process = NULL; 329 g_service_process = NULL;
373 } 330 }
OLDNEW
« no previous file with comments | « chrome/service/service_process.h ('k') | chrome/service/service_process_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698