OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/singleton.h" | 12 #include "base/singleton.h" |
13 #include "base/string16.h" | 13 #include "base/string16.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "chrome/common/chrome_constants.h" | 16 #include "chrome/common/chrome_constants.h" |
17 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/common/net/url_fetcher.h" | 19 #include "chrome/common/net/url_fetcher.h" |
20 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
21 #include "chrome/common/service_process_util.h" | 21 #include "chrome/common/service_process_util.h" |
22 #include "chrome/service/cloud_print/cloud_print_proxy.h" | 22 #include "chrome/service/cloud_print/cloud_print_proxy.h" |
23 #include "chrome/service/service_ipc_server.h" | 23 #include "chrome/service/service_ipc_server.h" |
24 #include "chrome/service/service_process_prefs.h" | 24 #include "chrome/service/service_process_prefs.h" |
25 #include "net/base/network_change_notifier.h" | 25 #include "net/base/network_change_notifier.h" |
26 #include "ui/base/resource/resource_bundle.h" | 26 #include "ui/base/resource/resource_bundle.h" |
27 #include "ui/base/ui_base_switches.h" | 27 #include "ui/base/ui_base_switches.h" |
28 | 28 |
| 29 #if defined(TOOLKIT_USES_GTK) |
| 30 #include "ui/gfx/gtk_util.h" |
| 31 #endif |
| 32 |
29 #if defined(ENABLE_REMOTING) | 33 #if defined(ENABLE_REMOTING) |
30 #include "chrome/service/remoting/chromoting_host_manager.h" | 34 #include "chrome/service/remoting/chromoting_host_manager.h" |
31 #endif // defined(ENABLED_REMOTING) | 35 #endif // defined(ENABLED_REMOTING) |
32 | 36 |
33 ServiceProcess* g_service_process = NULL; | 37 ServiceProcess* g_service_process = NULL; |
34 | 38 |
35 namespace { | 39 namespace { |
36 | 40 |
37 // Delay in millseconds after the last service is disabled before we attempt | 41 // Delay in millseconds after the last service is disabled before we attempt |
38 // a shutdown. | 42 // a shutdown. |
(...skipping 28 matching lines...) Expand all Loading... |
67 | 71 |
68 ServiceProcess::ServiceProcess() | 72 ServiceProcess::ServiceProcess() |
69 : shutdown_event_(true, false), | 73 : shutdown_event_(true, false), |
70 main_message_loop_(NULL), | 74 main_message_loop_(NULL), |
71 enabled_services_(0), | 75 enabled_services_(0), |
72 update_available_(false) { | 76 update_available_(false) { |
73 DCHECK(!g_service_process); | 77 DCHECK(!g_service_process); |
74 g_service_process = this; | 78 g_service_process = this; |
75 } | 79 } |
76 | 80 |
77 bool ServiceProcess::Initialize(MessageLoop* message_loop, | 81 bool ServiceProcess::Initialize(MessageLoopForUI* message_loop, |
78 const CommandLine& command_line) { | 82 const CommandLine& command_line) { |
| 83 #if defined(TOOLKIT_USES_GTK) |
| 84 gfx::GtkInitFromCommandLine(command_line); |
| 85 #endif |
79 main_message_loop_ = message_loop; | 86 main_message_loop_ = message_loop; |
80 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); | 87 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); |
81 base::Thread::Options options; | 88 base::Thread::Options options; |
82 options.message_loop_type = MessageLoop::TYPE_IO; | 89 options.message_loop_type = MessageLoop::TYPE_IO; |
83 io_thread_.reset(new ServiceIOThread("ServiceProcess_IO")); | 90 io_thread_.reset(new ServiceIOThread("ServiceProcess_IO")); |
84 file_thread_.reset(new base::Thread("ServiceProcess_File")); | 91 file_thread_.reset(new base::Thread("ServiceProcess_File")); |
85 if (!io_thread_->StartWithOptions(options) || | 92 if (!io_thread_->StartWithOptions(options) || |
86 !file_thread_->StartWithOptions(options)) { | 93 !file_thread_->StartWithOptions(options)) { |
87 NOTREACHED(); | 94 NOTREACHED(); |
88 Teardown(); | 95 Teardown(); |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 } | 280 } |
274 | 281 |
275 ServiceProcess::~ServiceProcess() { | 282 ServiceProcess::~ServiceProcess() { |
276 Teardown(); | 283 Teardown(); |
277 g_service_process = NULL; | 284 g_service_process = NULL; |
278 } | 285 } |
279 | 286 |
280 // Disable refcounting for runnable method because it is really not needed | 287 // Disable refcounting for runnable method because it is really not needed |
281 // when we post tasks on the main message loop. | 288 // when we post tasks on the main message loop. |
282 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcess); | 289 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcess); |
OLD | NEW |