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 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "net/base/network_change_notifier.h" | 32 #include "net/base/network_change_notifier.h" |
33 #include "net/url_request/url_fetcher.h" | 33 #include "net/url_request/url_fetcher.h" |
34 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
35 #include "ui/base/resource/resource_bundle.h" | 35 #include "ui/base/resource/resource_bundle.h" |
36 #include "ui/base/ui_base_switches.h" | 36 #include "ui/base/ui_base_switches.h" |
37 | 37 |
38 #if defined(USE_GLIB) | 38 #if defined(USE_GLIB) |
39 #include <glib-object.h> | 39 #include <glib-object.h> |
40 #endif | 40 #endif |
41 | 41 |
42 #if defined(TOOLKIT_GTK) | |
43 #include <gtk/gtk.h> | |
44 #include "ui/gfx/gtk_util.h" | |
45 #endif | |
46 | |
47 ServiceProcess* g_service_process = NULL; | 42 ServiceProcess* g_service_process = NULL; |
48 | 43 |
49 namespace { | 44 namespace { |
50 | 45 |
51 // Delay in seconds after the last service is disabled before we attempt | 46 // Delay in seconds after the last service is disabled before we attempt |
52 // a shutdown. | 47 // a shutdown. |
53 const int kShutdownDelaySeconds = 60; | 48 const int kShutdownDelaySeconds = 60; |
54 | 49 |
55 // Delay in hours between launching a browser process to check the | 50 // Delay in hours between launching a browser process to check the |
56 // policy for us. | 51 // policy for us. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 main_message_loop_(NULL), | 118 main_message_loop_(NULL), |
124 enabled_services_(0), | 119 enabled_services_(0), |
125 update_available_(false) { | 120 update_available_(false) { |
126 DCHECK(!g_service_process); | 121 DCHECK(!g_service_process); |
127 g_service_process = this; | 122 g_service_process = this; |
128 } | 123 } |
129 | 124 |
130 bool ServiceProcess::Initialize(base::MessageLoopForUI* message_loop, | 125 bool ServiceProcess::Initialize(base::MessageLoopForUI* message_loop, |
131 const CommandLine& command_line, | 126 const CommandLine& command_line, |
132 ServiceProcessState* state) { | 127 ServiceProcessState* state) { |
133 #if defined(TOOLKIT_GTK) | 128 #if defined(USE_GLIB) |
134 // TODO(jamiewalch): Calling GtkInitFromCommandLine here causes the process | |
135 // to abort if run headless. The correct fix for this is to refactor the | |
136 // service process to be more modular, a task that is currently underway. | |
137 // However, since this problem is blocking cloud print, the following quick | |
138 // hack will have to do. Note that the situation with this hack in place is | |
139 // no worse than it was when we weren't initializing GTK at all. | |
140 int argc = 1; | |
141 scoped_ptr<char*[]> argv(new char*[2]); | |
142 argv[0] = strdup(command_line.argv()[0].c_str()); | |
143 argv[1] = NULL; | |
144 char **argv_pointer = argv.get(); | |
145 gtk_init_check(&argc, &argv_pointer); | |
146 free(argv[0]); | |
147 #elif defined(USE_GLIB) | |
148 // g_type_init has been deprecated since version 2.35. | 129 // g_type_init has been deprecated since version 2.35. |
149 #if !GLIB_CHECK_VERSION(2, 35, 0) | 130 #if !GLIB_CHECK_VERSION(2, 35, 0) |
150 // GLib type system initialization is needed for gconf. | 131 // GLib type system initialization is needed for gconf. |
151 g_type_init(); | 132 g_type_init(); |
152 #endif | 133 #endif |
153 #endif // defined(OS_LINUX) || defined(OS_OPENBSD) | 134 #endif // defined(OS_LINUX) || defined(OS_OPENBSD) |
154 main_message_loop_ = message_loop; | 135 main_message_loop_ = message_loop; |
155 service_process_state_.reset(state); | 136 service_process_state_.reset(state); |
156 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); | 137 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); |
157 base::Thread::Options options; | 138 base::Thread::Options options; |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 if (enabled_services_ && !ipc_server_->is_client_connected()) { | 363 if (enabled_services_ && !ipc_server_->is_client_connected()) { |
383 GetCloudPrintProxy()->CheckCloudPrintProxyPolicy(); | 364 GetCloudPrintProxy()->CheckCloudPrintProxyPolicy(); |
384 } | 365 } |
385 ScheduleCloudPrintPolicyCheck(); | 366 ScheduleCloudPrintPolicyCheck(); |
386 } | 367 } |
387 | 368 |
388 ServiceProcess::~ServiceProcess() { | 369 ServiceProcess::~ServiceProcess() { |
389 Teardown(); | 370 Teardown(); |
390 g_service_process = NULL; | 371 g_service_process = NULL; |
391 } | 372 } |
OLD | NEW |