OLD | NEW |
---|---|
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/browser/browser_process_impl.h" | 5 #include "chrome/browser/browser_process_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/synchronization/waitable_event.h" | |
12 #include "base/task.h" | 13 #include "base/task.h" |
13 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
14 #include "base/threading/thread_restrictions.h" | 15 #include "base/threading/thread_restrictions.h" |
15 #include "base/synchronization/waitable_event.h" | |
16 #include "chrome/browser/automation/automation_provider_list.h" | 16 #include "chrome/browser/automation/automation_provider_list.h" |
17 #include "chrome/browser/browser_child_process_host.h" | 17 #include "chrome/browser/browser_child_process_host.h" |
18 #include "chrome/browser/browser_list.h" | 18 #include "chrome/browser/browser_list.h" |
19 #include "chrome/browser/browser_main.h" | 19 #include "chrome/browser/browser_main.h" |
20 #include "chrome/browser/browser_process_sub_thread.h" | 20 #include "chrome/browser/browser_process_sub_thread.h" |
21 #include "chrome/browser/browser_thread.h" | 21 #include "chrome/browser/browser_thread.h" |
22 #include "chrome/browser/browser_trial.h" | 22 #include "chrome/browser/browser_trial.h" |
23 #include "chrome/browser/debugger/browser_list_tabcontents_provider.h" | 23 #include "chrome/browser/debugger/browser_list_tabcontents_provider.h" |
24 #include "chrome/browser/debugger/devtools_http_protocol_handler.h" | 24 #include "chrome/browser/debugger/devtools_http_protocol_handler.h" |
25 #include "chrome/browser/debugger/devtools_manager.h" | 25 #include "chrome/browser/debugger/devtools_manager.h" |
26 #include "chrome/browser/debugger/devtools_protocol_handler.h" | 26 #include "chrome/browser/debugger/devtools_protocol_handler.h" |
27 #include "chrome/browser/download/download_file_manager.h" | 27 #include "chrome/browser/download/download_file_manager.h" |
28 #include "chrome/browser/download/save_file_manager.h" | 28 #include "chrome/browser/download/save_file_manager.h" |
29 #include "chrome/browser/first_run/first_run.h" | 29 #include "chrome/browser/first_run/first_run.h" |
30 #include "chrome/browser/google/google_url_tracker.h" | 30 #include "chrome/browser/google/google_url_tracker.h" |
31 #include "chrome/browser/icon_manager.h" | 31 #include "chrome/browser/icon_manager.h" |
32 #include "chrome/browser/intranet_redirect_detector.h" | 32 #include "chrome/browser/intranet_redirect_detector.h" |
33 #include "chrome/browser/io_thread.h" | 33 #include "chrome/browser/io_thread.h" |
34 #include "chrome/browser/metrics/metrics_service.h" | 34 #include "chrome/browser/metrics/metrics_service.h" |
35 #include "chrome/browser/net/chrome_net_log.h" | 35 #include "chrome/browser/net/chrome_net_log.h" |
36 #include "chrome/browser/net/predictor_api.h" | 36 #include "chrome/browser/net/predictor_api.h" |
37 #include "chrome/browser/net/sdch_dictionary_fetcher.h" | 37 #include "chrome/browser/net/sdch_dictionary_fetcher.h" |
38 #include "chrome/browser/notifications/notification_ui_manager.h" | 38 #include "chrome/browser/notifications/notification_ui_manager.h" |
39 #include "chrome/browser/plugin_data_remover.h" | 39 #include "chrome/browser/plugin_data_remover.h" |
40 #include "chrome/browser/plugin_service.h" | 40 #include "chrome/browser/plugin_service.h" |
41 #include "chrome/browser/plugin_updater.h" | 41 #include "chrome/browser/plugin_updater.h" |
42 #include "chrome/browser/policy/configuration_policy_provider_keeper.h" | 42 #include "chrome/browser/policy/browser_policy_context.h" |
43 #include "chrome/browser/prefs/pref_service.h" | 43 #include "chrome/browser/prefs/pref_service.h" |
44 #include "chrome/browser/printing/print_job_manager.h" | 44 #include "chrome/browser/printing/print_job_manager.h" |
45 #include "chrome/browser/printing/print_preview_tab_controller.h" | 45 #include "chrome/browser/printing/print_preview_tab_controller.h" |
46 #include "chrome/browser/profiles/profile_manager.h" | 46 #include "chrome/browser/profiles/profile_manager.h" |
47 #include "chrome/browser/renderer_host/render_process_host.h" | 47 #include "chrome/browser/renderer_host/render_process_host.h" |
48 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 48 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
49 #include "chrome/browser/safe_browsing/client_side_detection_service.h" | 49 #include "chrome/browser/safe_browsing/client_side_detection_service.h" |
50 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 50 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
51 #include "chrome/browser/shell_integration.h" | 51 #include "chrome/browser/shell_integration.h" |
52 #include "chrome/browser/sidebar/sidebar_manager.h" | 52 #include "chrome/browser/sidebar/sidebar_manager.h" |
53 #include "chrome/browser/tab_closeable_state_watcher.h" | 53 #include "chrome/browser/tab_closeable_state_watcher.h" |
54 #include "chrome/common/chrome_constants.h" | 54 #include "chrome/common/chrome_constants.h" |
55 #include "chrome/common/chrome_paths.h" | 55 #include "chrome/common/chrome_paths.h" |
56 #include "chrome/common/chrome_switches.h" | 56 #include "chrome/common/chrome_switches.h" |
57 #include "chrome/common/extensions/extension_l10n_util.h" | |
57 #include "chrome/common/extensions/extension_resource.h" | 58 #include "chrome/common/extensions/extension_resource.h" |
58 #include "chrome/common/extensions/extension_l10n_util.h" | |
59 #include "chrome/common/json_pref_store.h" | 59 #include "chrome/common/json_pref_store.h" |
60 #include "chrome/common/notification_service.h" | 60 #include "chrome/common/notification_service.h" |
61 #include "chrome/common/pref_names.h" | 61 #include "chrome/common/pref_names.h" |
62 #include "chrome/common/switch_utils.h" | |
62 #include "chrome/common/url_constants.h" | 63 #include "chrome/common/url_constants.h" |
63 #include "chrome/common/switch_utils.h" | |
64 #include "chrome/installer/util/google_update_constants.h" | 64 #include "chrome/installer/util/google_update_constants.h" |
65 #include "ipc/ipc_logging.h" | 65 #include "ipc/ipc_logging.h" |
66 #include "ui/base/clipboard/clipboard.h" | 66 #include "ui/base/clipboard/clipboard.h" |
67 #include "ui/base/l10n/l10n_util.h" | 67 #include "ui/base/l10n/l10n_util.h" |
68 #include "webkit/database/database_tracker.h" | 68 #include "webkit/database/database_tracker.h" |
69 | 69 |
70 #if defined(OS_WIN) | 70 #if defined(OS_WIN) |
71 #include "views/focus/view_storage.h" | 71 #include "views/focus/view_storage.h" |
72 #endif | 72 #endif |
73 | 73 |
(...skipping 20 matching lines...) Expand all Loading... | |
94 created_metrics_service_(false), | 94 created_metrics_service_(false), |
95 created_io_thread_(false), | 95 created_io_thread_(false), |
96 created_file_thread_(false), | 96 created_file_thread_(false), |
97 created_db_thread_(false), | 97 created_db_thread_(false), |
98 created_process_launcher_thread_(false), | 98 created_process_launcher_thread_(false), |
99 created_cache_thread_(false), | 99 created_cache_thread_(false), |
100 created_profile_manager_(false), | 100 created_profile_manager_(false), |
101 created_local_state_(false), | 101 created_local_state_(false), |
102 created_icon_manager_(false), | 102 created_icon_manager_(false), |
103 created_devtools_manager_(false), | 103 created_devtools_manager_(false), |
104 created_sidebar_manager_(false), | 104 created_sidebar_manager_(false), |
Jakob Kummerow
2011/02/07 16:00:09
+ created_browser_policy_context_(false),
Jakob Kummerow
2011/02/14 13:50:34
Done.
| |
105 created_configuration_policy_provider_keeper_(false), | |
106 created_notification_ui_manager_(false), | 105 created_notification_ui_manager_(false), |
107 created_safe_browsing_detection_service_(false), | 106 created_safe_browsing_detection_service_(false), |
108 module_ref_count_(0), | 107 module_ref_count_(0), |
109 did_start_(false), | 108 did_start_(false), |
110 checked_for_new_frames_(false), | 109 checked_for_new_frames_(false), |
111 using_new_frames_(false), | 110 using_new_frames_(false), |
112 have_inspector_files_(true) { | 111 have_inspector_files_(true) { |
113 g_browser_process = this; | 112 g_browser_process = this; |
114 clipboard_.reset(new ui::Clipboard); | 113 clipboard_.reset(new ui::Clipboard); |
115 main_notification_service_.reset(new NotificationService); | 114 main_notification_service_.reset(new NotificationService); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
180 if (resource_dispatcher_host_.get()) { | 179 if (resource_dispatcher_host_.get()) { |
181 // Need to tell Safe Browsing Service that the IO thread is going away | 180 // Need to tell Safe Browsing Service that the IO thread is going away |
182 // since it cached a pointer to it. | 181 // since it cached a pointer to it. |
183 if (resource_dispatcher_host()->safe_browsing_service()) | 182 if (resource_dispatcher_host()->safe_browsing_service()) |
184 resource_dispatcher_host()->safe_browsing_service()->ShutDown(); | 183 resource_dispatcher_host()->safe_browsing_service()->ShutDown(); |
185 | 184 |
186 // Cancel pending requests and prevent new requests. | 185 // Cancel pending requests and prevent new requests. |
187 resource_dispatcher_host()->Shutdown(); | 186 resource_dispatcher_host()->Shutdown(); |
188 } | 187 } |
189 | 188 |
190 // The policy providers managed by |configuration_policy_provider_keeper_| | 189 // The policy providers managed by |browser_policy_context_| need to shut down |
191 // need to shut down while the file thread is still alive. | 190 // while the IO and FILE threads are still alive. |
192 configuration_policy_provider_keeper_.reset(); | 191 browser_policy_context_.reset(); |
193 | 192 |
194 #if defined(USE_X11) | 193 #if defined(USE_X11) |
195 // The IO thread must outlive the BACKGROUND_X11 thread. | 194 // The IO thread must outlive the BACKGROUND_X11 thread. |
196 background_x11_thread_.reset(); | 195 background_x11_thread_.reset(); |
197 #endif | 196 #endif |
198 | 197 |
199 // Wait for removing plugin data to finish before shutting down the IO thread. | 198 // Wait for removing plugin data to finish before shutting down the IO thread. |
200 WaitForPluginDataRemoverToFinish(); | 199 WaitForPluginDataRemoverToFinish(); |
201 | 200 |
202 // Need to stop io_thread_ before resource_dispatcher_host_, since | 201 // Need to stop io_thread_ before resource_dispatcher_host_, since |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
423 return clipboard_.get(); | 422 return clipboard_.get(); |
424 } | 423 } |
425 | 424 |
426 NotificationUIManager* BrowserProcessImpl::notification_ui_manager() { | 425 NotificationUIManager* BrowserProcessImpl::notification_ui_manager() { |
427 DCHECK(CalledOnValidThread()); | 426 DCHECK(CalledOnValidThread()); |
428 if (!created_notification_ui_manager_) | 427 if (!created_notification_ui_manager_) |
429 CreateNotificationUIManager(); | 428 CreateNotificationUIManager(); |
430 return notification_ui_manager_.get(); | 429 return notification_ui_manager_.get(); |
431 } | 430 } |
432 | 431 |
433 policy::ConfigurationPolicyProviderKeeper* | 432 policy::BrowserPolicyContext* BrowserProcessImpl::browser_policy_context() { |
434 BrowserProcessImpl::configuration_policy_provider_keeper() { | |
435 DCHECK(CalledOnValidThread()); | 433 DCHECK(CalledOnValidThread()); |
436 if (!created_configuration_policy_provider_keeper_) { | 434 if (!created_browser_policy_context_) { |
437 DCHECK(configuration_policy_provider_keeper_.get() == NULL); | 435 DCHECK(browser_policy_context_.get() == NULL); |
438 created_configuration_policy_provider_keeper_ = true; | 436 created_browser_policy_context_ = true; |
439 configuration_policy_provider_keeper_.reset( | 437 browser_policy_context_.reset(new policy::BrowserPolicyContext()); |
440 new policy::ConfigurationPolicyProviderKeeper()); | |
441 } | 438 } |
442 return configuration_policy_provider_keeper_.get(); | 439 return browser_policy_context_.get(); |
443 } | 440 } |
444 | 441 |
445 IconManager* BrowserProcessImpl::icon_manager() { | 442 IconManager* BrowserProcessImpl::icon_manager() { |
446 DCHECK(CalledOnValidThread()); | 443 DCHECK(CalledOnValidThread()); |
447 if (!created_icon_manager_) | 444 if (!created_icon_manager_) |
448 CreateIconManager(); | 445 CreateIconManager(); |
449 return icon_manager_.get(); | 446 return icon_manager_.get(); |
450 } | 447 } |
451 | 448 |
452 ThumbnailGenerator* BrowserProcessImpl::GetThumbnailGenerator() { | 449 ThumbnailGenerator* BrowserProcessImpl::GetThumbnailGenerator() { |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
941 } | 938 } |
942 | 939 |
943 void BrowserProcessImpl::OnAutoupdateTimer() { | 940 void BrowserProcessImpl::OnAutoupdateTimer() { |
944 if (CanAutorestartForUpdate()) { | 941 if (CanAutorestartForUpdate()) { |
945 DLOG(WARNING) << "Detected update. Restarting browser."; | 942 DLOG(WARNING) << "Detected update. Restarting browser."; |
946 RestartPersistentInstance(); | 943 RestartPersistentInstance(); |
947 } | 944 } |
948 } | 945 } |
949 | 946 |
950 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 947 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
OLD | NEW |