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

Side by Side Diff: chrome/browser/browser_process_impl.cc

Issue 6292017: Extended: Add "system" URLRequestContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup 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
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/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"
(...skipping 16 matching lines...) Expand all
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/pref_proxy_config_service.h"
38 #include "chrome/browser/net/proxy_service_factory.h"
37 #include "chrome/browser/net/sdch_dictionary_fetcher.h" 39 #include "chrome/browser/net/sdch_dictionary_fetcher.h"
38 #include "chrome/browser/notifications/notification_ui_manager.h" 40 #include "chrome/browser/notifications/notification_ui_manager.h"
39 #include "chrome/browser/plugin_data_remover.h" 41 #include "chrome/browser/plugin_data_remover.h"
40 #include "chrome/browser/plugin_service.h" 42 #include "chrome/browser/plugin_service.h"
41 #include "chrome/browser/plugin_updater.h" 43 #include "chrome/browser/plugin_updater.h"
42 #include "chrome/browser/policy/configuration_policy_provider_keeper.h" 44 #include "chrome/browser/policy/configuration_policy_provider_keeper.h"
43 #include "chrome/browser/prefs/pref_service.h" 45 #include "chrome/browser/prefs/pref_service.h"
44 #include "chrome/browser/printing/print_job_manager.h" 46 #include "chrome/browser/printing/print_job_manager.h"
45 #include "chrome/browser/printing/print_preview_tab_controller.h" 47 #include "chrome/browser/printing/print_preview_tab_controller.h"
46 #include "chrome/browser/profiles/profile_manager.h" 48 #include "chrome/browser/profiles/profile_manager.h"
47 #include "chrome/browser/renderer_host/render_process_host.h" 49 #include "chrome/browser/renderer_host/render_process_host.h"
48 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" 50 #include "chrome/browser/renderer_host/resource_dispatcher_host.h"
49 #include "chrome/browser/safe_browsing/client_side_detection_service.h" 51 #include "chrome/browser/safe_browsing/client_side_detection_service.h"
50 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 52 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
51 #include "chrome/browser/shell_integration.h" 53 #include "chrome/browser/shell_integration.h"
52 #include "chrome/browser/sidebar/sidebar_manager.h" 54 #include "chrome/browser/sidebar/sidebar_manager.h"
53 #include "chrome/browser/tab_closeable_state_watcher.h" 55 #include "chrome/browser/tab_closeable_state_watcher.h"
54 #include "chrome/common/chrome_constants.h" 56 #include "chrome/common/chrome_constants.h"
55 #include "chrome/common/chrome_paths.h" 57 #include "chrome/common/chrome_paths.h"
56 #include "chrome/common/chrome_switches.h" 58 #include "chrome/common/chrome_switches.h"
57 #include "chrome/common/extensions/extension_resource.h" 59 #include "chrome/common/extensions/extension_resource.h"
58 #include "chrome/common/extensions/extension_l10n_util.h" 60 #include "chrome/common/extensions/extension_l10n_util.h"
59 #include "chrome/common/json_pref_store.h" 61 #include "chrome/common/json_pref_store.h"
62 #include "chrome/common/net/url_request_context_getter.h"
60 #include "chrome/common/notification_service.h" 63 #include "chrome/common/notification_service.h"
61 #include "chrome/common/pref_names.h" 64 #include "chrome/common/pref_names.h"
62 #include "chrome/common/url_constants.h" 65 #include "chrome/common/url_constants.h"
63 #include "chrome/common/switch_utils.h" 66 #include "chrome/common/switch_utils.h"
64 #include "chrome/installer/util/google_update_constants.h" 67 #include "chrome/installer/util/google_update_constants.h"
65 #include "ipc/ipc_logging.h" 68 #include "ipc/ipc_logging.h"
66 #include "ui/base/clipboard/clipboard.h" 69 #include "ui/base/clipboard/clipboard.h"
67 #include "ui/base/l10n/l10n_util.h" 70 #include "ui/base/l10n/l10n_util.h"
68 #include "webkit/database/database_tracker.h" 71 #include "webkit/database/database_tracker.h"
69 72
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 configuration_policy_provider_keeper_.reset(); 195 configuration_policy_provider_keeper_.reset();
193 196
194 #if defined(USE_X11) 197 #if defined(USE_X11)
195 // The IO thread must outlive the BACKGROUND_X11 thread. 198 // The IO thread must outlive the BACKGROUND_X11 thread.
196 background_x11_thread_.reset(); 199 background_x11_thread_.reset();
197 #endif 200 #endif
198 201
199 // Wait for removing plugin data to finish before shutting down the IO thread. 202 // Wait for removing plugin data to finish before shutting down the IO thread.
200 WaitForPluginDataRemoverToFinish(); 203 WaitForPluginDataRemoverToFinish();
201 204
205 // Give up reference before io_thread_ checks that there is no one left
206 // holding a reference.
207 system_request_context_ = NULL;
208
202 // Need to stop io_thread_ before resource_dispatcher_host_, since 209 // Need to stop io_thread_ before resource_dispatcher_host_, since
203 // io_thread_ may still deref ResourceDispatcherHost and handle resource 210 // io_thread_ may still deref ResourceDispatcherHost and handle resource
204 // request before going away. 211 // request before going away.
205 io_thread_.reset(); 212 io_thread_.reset();
206 213
207 // The IO thread was the only user of this thread. 214 // The IO thread was the only user of this thread.
208 cache_thread_.reset(); 215 cache_thread_.reset();
209 216
210 // Stop the process launcher thread after the IO thread, in case the IO thread 217 // Stop the process launcher thread after the IO thread, in case the IO thread
211 // posted a task to terminate a process on the process launcher thread. 218 // posted a task to terminate a process on the process launcher thread.
(...skipping 26 matching lines...) Expand all
238 // former registers for notifications. 245 // former registers for notifications.
239 tab_closeable_state_watcher_.reset(); 246 tab_closeable_state_watcher_.reset();
240 247
241 // Now OK to destroy NotificationService. 248 // Now OK to destroy NotificationService.
242 main_notification_service_.reset(); 249 main_notification_service_.reset();
243 250
244 // Prior to clearing local state, we want to complete tasks pending 251 // Prior to clearing local state, we want to complete tasks pending
245 // on the db thread too. 252 // on the db thread too.
246 db_thread_.reset(); 253 db_thread_.reset();
247 254
255 // Need to destroy PrefProxyConfigTracker before local state, since it
256 // caches a pointer to local state.
257 if (pref_proxy_config_tracker_)
258 pref_proxy_config_tracker_->DetachFromPrefService();
259 pref_proxy_config_tracker_ = NULL;
260
248 // At this point, no render process exist and the file, io, db, and 261 // At this point, no render process exist and the file, io, db, and
249 // webkit threads in this process have all terminated, so it's safe 262 // webkit threads in this process have all terminated, so it's safe
250 // to access local state data such as cookies, database, or local storage. 263 // to access local state data such as cookies, database, or local storage.
251 if (clear_local_state_on_exit) 264 if (clear_local_state_on_exit)
252 ClearLocalState(profile_path); 265 ClearLocalState(profile_path);
253 266
254 g_browser_process = NULL; 267 g_browser_process = NULL;
255 } 268 }
256 269
257 #if defined(OS_WIN) 270 #if defined(OS_WIN)
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 if (!created_sidebar_manager_) 429 if (!created_sidebar_manager_)
417 CreateSidebarManager(); 430 CreateSidebarManager();
418 return sidebar_manager_.get(); 431 return sidebar_manager_.get();
419 } 432 }
420 433
421 ui::Clipboard* BrowserProcessImpl::clipboard() { 434 ui::Clipboard* BrowserProcessImpl::clipboard() {
422 DCHECK(CalledOnValidThread()); 435 DCHECK(CalledOnValidThread());
423 return clipboard_.get(); 436 return clipboard_.get();
424 } 437 }
425 438
439 PrefProxyConfigTracker* BrowserProcessImpl::pref_proxy_config_tracker() {
440 DCHECK(CalledOnValidThread());
441 if (!created_pref_proxy_config_tracker_)
442 CreatePrefProxyConfigTracker();
443 return pref_proxy_config_tracker_.get();
444 }
445
446 scoped_refptr<URLRequestContextGetter>
447 BrowserProcessImpl::system_request_context() {
448 DCHECK(CalledOnValidThread());
449 if (!created_system_request_context_)
450 CreateSystemRequestContextGetter();
451 return system_request_context_.get();
452 }
453
426 NotificationUIManager* BrowserProcessImpl::notification_ui_manager() { 454 NotificationUIManager* BrowserProcessImpl::notification_ui_manager() {
427 DCHECK(CalledOnValidThread()); 455 DCHECK(CalledOnValidThread());
428 if (!created_notification_ui_manager_) 456 if (!created_notification_ui_manager_)
429 CreateNotificationUIManager(); 457 CreateNotificationUIManager();
430 return notification_ui_manager_.get(); 458 return notification_ui_manager_.get();
431 } 459 }
432 460
433 policy::ConfigurationPolicyProviderKeeper* 461 policy::ConfigurationPolicyProviderKeeper*
434 BrowserProcessImpl::configuration_policy_provider_keeper() { 462 BrowserProcessImpl::configuration_policy_provider_keeper() {
435 DCHECK(CalledOnValidThread()); 463 DCHECK(CalledOnValidThread());
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 if (IsSafeBrowsingDetectionServiceEnabled() && 854 if (IsSafeBrowsingDetectionServiceEnabled() &&
827 PathService::Get(chrome::DIR_USER_DATA, &model_file_path) && 855 PathService::Get(chrome::DIR_USER_DATA, &model_file_path) &&
828 profile && profile->GetRequestContext()) { 856 profile && profile->GetRequestContext()) {
829 safe_browsing_detection_service_.reset( 857 safe_browsing_detection_service_.reset(
830 safe_browsing::ClientSideDetectionService::Create( 858 safe_browsing::ClientSideDetectionService::Create(
831 model_file_path.Append(chrome::kSafeBrowsingPhishingModelFilename), 859 model_file_path.Append(chrome::kSafeBrowsingPhishingModelFilename),
832 profile->GetRequestContext())); 860 profile->GetRequestContext()));
833 } 861 }
834 } 862 }
835 863
864 void BrowserProcessImpl::CreatePrefProxyConfigTracker() {
865 DCHECK(pref_proxy_config_tracker_.get() == NULL);
866 created_pref_proxy_config_tracker_ = true;
867 pref_proxy_config_tracker_ = new PrefProxyConfigTracker(local_state());
868 }
869
870 void BrowserProcessImpl::CreateSystemRequestContextGetter() {
871 DCHECK(system_request_context_.get() == NULL);
872 created_system_request_context_ = true;
873
874 net::ProxyConfigService* config_service =
willchan no longer on Chromium 2011/02/16 20:02:27 There's also a SSLConfigService, so can you name t
battre 2011/02/21 17:27:57 Done.
875 ProxyServiceFactory::CreateProxyConfigService(
876 io_thread()->message_loop(), file_thread()->message_loop(),
877 pref_proxy_config_tracker());
878
879 // Takes ownership of config_service.
880 io_thread()->SetSystemProxyConfigService(config_service);
881
882 system_request_context_ = io_thread()->system_url_request_context_getter();
willchan no longer on Chromium 2011/02/16 20:02:27 Don't cache the pointer here. We want the IOThread
battre 2011/02/21 17:27:57 Done.
883 }
884
836 bool BrowserProcessImpl::IsSafeBrowsingDetectionServiceEnabled() { 885 bool BrowserProcessImpl::IsSafeBrowsingDetectionServiceEnabled() {
837 // The safe browsing client-side detection is enabled only if the switch is 886 // The safe browsing client-side detection is enabled only if the switch is
838 // enabled and when safe browsing related stats is allowed to be collected. 887 // enabled and when safe browsing related stats is allowed to be collected.
839 return CommandLine::ForCurrentProcess()->HasSwitch( 888 return CommandLine::ForCurrentProcess()->HasSwitch(
840 switches::kEnableClientSidePhishingDetection) && 889 switches::kEnableClientSidePhishingDetection) &&
841 resource_dispatcher_host()->safe_browsing_service() && 890 resource_dispatcher_host()->safe_browsing_service() &&
842 resource_dispatcher_host()->safe_browsing_service()->CanReportStats(); 891 resource_dispatcher_host()->safe_browsing_service()->CanReportStats();
843 } 892 }
844 893
845 // The BrowserProcess object must outlive the file thread so we use traits 894 // The BrowserProcess object must outlive the file thread so we use traits
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 } 996 }
948 997
949 void BrowserProcessImpl::OnAutoupdateTimer() { 998 void BrowserProcessImpl::OnAutoupdateTimer() {
950 if (CanAutorestartForUpdate()) { 999 if (CanAutorestartForUpdate()) {
951 DLOG(WARNING) << "Detected update. Restarting browser."; 1000 DLOG(WARNING) << "Detected update. Restarting browser.";
952 RestartPersistentInstance(); 1001 RestartPersistentInstance();
953 } 1002 }
954 } 1003 }
955 1004
956 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) 1005 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698