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

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

Issue 6539017: Initialize media library on service process startup. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Add missing include under Mac OS X Created 9 years, 10 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/DEPS ('k') | no next file » | 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"
11 #include "base/environment.h" 11 #include "base/environment.h"
12 #include "base/i18n/rtl.h" 12 #include "base/i18n/rtl.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/singleton.h" 14 #include "base/singleton.h"
15 #include "base/string16.h" 15 #include "base/string16.h"
16 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "chrome/common/chrome_constants.h" 18 #include "chrome/common/chrome_constants.h"
19 #include "chrome/common/chrome_paths.h" 19 #include "chrome/common/chrome_paths.h"
20 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
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/service_ipc_server.h" 26 #include "chrome/service/service_ipc_server.h"
27 #include "chrome/service/service_process_prefs.h" 27 #include "chrome/service/service_process_prefs.h"
28 #include "grit/chromium_strings.h" 28 #include "grit/chromium_strings.h"
29 #include "grit/generated_resources.h" 29 #include "grit/generated_resources.h"
30 #include "media/base/media.h"
30 #include "net/base/network_change_notifier.h" 31 #include "net/base/network_change_notifier.h"
31 #include "ui/base/l10n/l10n_util.h" 32 #include "ui/base/l10n/l10n_util.h"
32 #include "ui/base/resource/resource_bundle.h" 33 #include "ui/base/resource/resource_bundle.h"
33 #include "ui/base/ui_base_switches.h" 34 #include "ui/base/ui_base_switches.h"
34 35
35 #if defined(ENABLE_REMOTING) 36 #if defined(ENABLE_REMOTING)
36 #include "chrome/service/remoting/chromoting_host_manager.h" 37 #include "chrome/service/remoting/chromoting_host_manager.h"
38 #if defined(OS_MACOSX)
39 #include "base/mac/mac_util.h"
40 #endif // defined(OS_MACOSX)
37 #endif // defined(ENABLED_REMOTING) 41 #endif // defined(ENABLED_REMOTING)
38 42
39 ServiceProcess* g_service_process = NULL; 43 ServiceProcess* g_service_process = NULL;
40 44
41 namespace { 45 namespace {
42 46
43 // Delay in millseconds after the last service is disabled before we attempt 47 // Delay in millseconds after the last service is disabled before we attempt
44 // a shutdown. 48 // a shutdown.
45 const int64 kShutdownDelay = 60000; 49 const int64 kShutdownDelay = 60000;
46 50
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 service_prefs_->GetString(prefs::kApplicationLocale, &locale); 157 service_prefs_->GetString(prefs::kApplicationLocale, &locale);
154 // If no locale was specified anywhere, use the default one. 158 // If no locale was specified anywhere, use the default one.
155 if (locale.empty()) 159 if (locale.empty())
156 locale = kDefaultServiceProcessLocale; 160 locale = kDefaultServiceProcessLocale;
157 } 161 }
158 ResourceBundle::InitSharedInstance(locale); 162 ResourceBundle::InitSharedInstance(locale);
159 163
160 PrepareRestartOnCrashEnviroment(command_line); 164 PrepareRestartOnCrashEnviroment(command_line);
161 165
162 #if defined(ENABLE_REMOTING) 166 #if defined(ENABLE_REMOTING)
167 // Load media codecs, required by the Chromoting host
168 bool initialized_media_library = false;
169 #if defined(OS_MACOSX)
170 FilePath bundle_path = base::mac::MainAppBundlePath();
171
172 initialized_media_library =
173 media::InitializeMediaLibrary(bundle_path.Append("Libraries"));
174 #else
175 FilePath module_path;
176 initialized_media_library =
177 PathService::Get(base::DIR_MODULE, &module_path) &&
178 media::InitializeMediaLibrary(module_path);
179 #endif
180
163 // Initialize chromoting host manager. 181 // Initialize chromoting host manager.
164 remoting_host_manager_ = new remoting::ChromotingHostManager(this); 182 remoting_host_manager_ = new remoting::ChromotingHostManager(this);
165 remoting_host_manager_->Initialize(message_loop, 183 remoting_host_manager_->Initialize(message_loop,
166 file_thread_->message_loop_proxy()); 184 file_thread_->message_loop_proxy());
167 #endif 185 #endif // ENABLE_REMOTING
168 186
169 // Enable Cloud Print if needed. First check the command-line. 187 // Enable Cloud Print if needed. First check the command-line.
170 bool cloud_print_proxy_enabled = 188 bool cloud_print_proxy_enabled =
171 command_line.HasSwitch(switches::kEnableCloudPrintProxy); 189 command_line.HasSwitch(switches::kEnableCloudPrintProxy);
172 if (!cloud_print_proxy_enabled) { 190 if (!cloud_print_proxy_enabled) {
173 // Then check if the cloud print proxy was previously enabled. 191 // Then check if the cloud print proxy was previously enabled.
174 service_prefs_->GetBoolean(prefs::kCloudPrintProxyEnabled, 192 service_prefs_->GetBoolean(prefs::kCloudPrintProxyEnabled,
175 &cloud_print_proxy_enabled); 193 &cloud_print_proxy_enabled);
176 } 194 }
177 195
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 static void QuitMessageLoop(MessageLoop* message_loop) { 235 static void QuitMessageLoop(MessageLoop* message_loop) {
218 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 236 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask());
219 } 237 }
220 238
221 // This method is called when a shutdown command is received from IPC channel 239 // This method is called when a shutdown command is received from IPC channel
222 // or there was an error in the IPC channel. 240 // or there was an error in the IPC channel.
223 void ServiceProcess::Shutdown() { 241 void ServiceProcess::Shutdown() {
224 #if defined(ENABLE_REMOTING) 242 #if defined(ENABLE_REMOTING)
225 // During shutdown of remoting host it has some left over operations on 243 // During shutdown of remoting host it has some left over operations on
226 // the UI thread. So we let the teardown to proceed asynchronously 244 // the UI thread. So we let the teardown to proceed asynchronously
227 remoting_host_manager_->Teardown( 245 if (remoting_host_manager_.get()) {
228 NewRunnableFunction(&QuitMessageLoop, main_message_loop_)); 246 remoting_host_manager_->Teardown(
247 NewRunnableFunction(&QuitMessageLoop, main_message_loop_));
248 }
229 #else 249 #else
230 // Quit the main message loop. 250 // Quit the main message loop.
231 main_message_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 251 main_message_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask());
232 #endif 252 #endif
233 } 253 }
234 254
235 bool ServiceProcess::HandleClientDisconnect() { 255 bool ServiceProcess::HandleClientDisconnect() {
236 // If there are no enabled services or if there is an update available 256 // If there are no enabled services or if there is an update available
237 // we want to shutdown right away. Else we want to keep listening for 257 // we want to shutdown right away. Else we want to keep listening for
238 // new connections. 258 // new connections.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 } 336 }
317 337
318 ServiceProcess::~ServiceProcess() { 338 ServiceProcess::~ServiceProcess() {
319 Teardown(); 339 Teardown();
320 g_service_process = NULL; 340 g_service_process = NULL;
321 } 341 }
322 342
323 // Disable refcounting for runnable method because it is really not needed 343 // Disable refcounting for runnable method because it is really not needed
324 // when we post tasks on the main message loop. 344 // when we post tasks on the main message loop.
325 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcess); 345 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcess);
OLDNEW
« no previous file with comments | « chrome/service/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698