| Index: chrome/browser/browser_process_impl.cc
|
| ===================================================================
|
| --- chrome/browser/browser_process_impl.cc (revision 117096)
|
| +++ chrome/browser/browser_process_impl.cc (working copy)
|
| @@ -68,10 +68,8 @@
|
| #include "chrome/installer/util/google_update_constants.h"
|
| #include "content/browser/browser_child_process_host.h"
|
| #include "content/browser/child_process_security_policy.h"
|
| -#include "content/browser/download/download_file_manager.h"
|
| #include "content/browser/download/download_status_updater.h"
|
| #include "content/browser/download/mhtml_generation_manager.h"
|
| -#include "content/browser/download/save_file_manager.h"
|
| #include "content/browser/gpu/gpu_process_host_ui_shim.h"
|
| #include "content/browser/net/browser_online_state_observer.h"
|
| #include "content/browser/renderer_host/resource_dispatcher_host.h"
|
| @@ -121,8 +119,7 @@
|
| using content::PluginService;
|
|
|
| BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line)
|
| - : created_resource_dispatcher_host_(false),
|
| - created_metrics_service_(false),
|
| + : created_metrics_service_(false),
|
| created_watchdog_thread_(false),
|
| created_profile_manager_(false),
|
| created_local_state_(false),
|
| @@ -155,10 +152,6 @@
|
| }
|
|
|
| BrowserProcessImpl::~BrowserProcessImpl() {
|
| - // See StartTearDown and PreStopThread functions below, this is where
|
| - // most destruction happens so that it can be interleaved with threads
|
| - // going away.
|
| -
|
| // Wait for the pending print jobs to finish.
|
| print_job_manager_->OnQuit();
|
| print_job_manager_.reset();
|
| @@ -219,11 +212,6 @@
|
| // Debugger must be cleaned up before IO thread and NotificationService.
|
| remote_debugging_server_.reset();
|
|
|
| - if (resource_dispatcher_host_.get()) {
|
| - // Cancel pending requests and prevent new requests.
|
| - resource_dispatcher_host()->Shutdown();
|
| - }
|
| -
|
| ExtensionTabIdMap::GetInstance()->Shutdown();
|
|
|
| // The policy providers managed by |browser_policy_connector_| need to shut
|
| @@ -240,62 +228,20 @@
|
| watchdog_thread_.reset();
|
| }
|
|
|
| -void BrowserProcessImpl::PreStartThread(BrowserThread::ID thread_id) {
|
| - switch (thread_id) {
|
| - case BrowserThread::IO:
|
| - CreateIOThreadState();
|
| - break;
|
| +void BrowserProcessImpl::PostDestroyThreads() {
|
| + // With the file_thread_ flushed, we can release any icon resources.
|
| + icon_manager_.reset();
|
|
|
| - default:
|
| - break;
|
| - }
|
| + // Reset associated state right after actual thread is stopped,
|
| + // as io_thread_.global_ cleanup happens in CleanUp on the IO
|
| + // thread, i.e. as the thread exits its message loop.
|
| + //
|
| + // This is important also because in various places, the
|
| + // IOThread object being NULL is considered synonymous with the
|
| + // IO thread having stopped.
|
| + io_thread_.reset();
|
| }
|
|
|
| -void BrowserProcessImpl::PostStartThread(BrowserThread::ID thread_id) {
|
| -}
|
| -
|
| -void BrowserProcessImpl::PreStopThread(BrowserThread::ID thread_id) {
|
| - switch (thread_id) {
|
| - case BrowserThread::FILE:
|
| - // Clean up state that lives on or uses the file_thread_ before
|
| - // it goes away.
|
| - if (resource_dispatcher_host_.get()) {
|
| - resource_dispatcher_host()->download_file_manager()->Shutdown();
|
| - resource_dispatcher_host()->save_file_manager()->Shutdown();
|
| - }
|
| - break;
|
| - case BrowserThread::WEBKIT_DEPRECATED:
|
| - // Need to destroy ResourceDispatcherHost before PluginService
|
| - // and SafeBrowsingService, since it caches a pointer to
|
| - // it.
|
| - resource_dispatcher_host_.reset();
|
| - break;
|
| - default:
|
| - break;
|
| - }
|
| -}
|
| -
|
| -void BrowserProcessImpl::PostStopThread(BrowserThread::ID thread_id) {
|
| - switch (thread_id) {
|
| - case BrowserThread::FILE:
|
| - // With the file_thread_ flushed, we can release any icon resources.
|
| - icon_manager_.reset();
|
| - break;
|
| - case BrowserThread::IO:
|
| - // Reset associated state right after actual thread is stopped,
|
| - // as io_thread_.global_ cleanup happens in CleanUp on the IO
|
| - // thread, i.e. as the thread exits its message loop.
|
| - //
|
| - // This is important also because in various places, the
|
| - // IOThread object being NULL is considered synonymous with the
|
| - // IO thread having stopped.
|
| - io_thread_.reset();
|
| - break;
|
| - default:
|
| - break;
|
| - }
|
| -}
|
| -
|
| #if defined(OS_WIN)
|
| // Send a QuitTask to the given MessageLoop when the (file) thread has processed
|
| // our (other) recent requests (to save preferences).
|
| @@ -392,13 +338,6 @@
|
| #endif
|
| }
|
|
|
| -ResourceDispatcherHost* BrowserProcessImpl::resource_dispatcher_host() {
|
| - DCHECK(CalledOnValidThread());
|
| - if (!created_resource_dispatcher_host_)
|
| - CreateResourceDispatcherHost();
|
| - return resource_dispatcher_host_.get();
|
| -}
|
| -
|
| MetricsService* BrowserProcessImpl::metrics_service() {
|
| DCHECK(CalledOnValidThread());
|
| if (!created_metrics_service_)
|
| @@ -697,25 +636,15 @@
|
| return audio_manager_;
|
| }
|
|
|
| -void BrowserProcessImpl::CreateResourceDispatcherHost() {
|
| - DCHECK(!created_resource_dispatcher_host_ &&
|
| - resource_dispatcher_host_.get() == NULL);
|
| - created_resource_dispatcher_host_ = true;
|
| -
|
| +void BrowserProcessImpl::ResourceDispatcherHostCreated() {
|
| // UserScriptListener and NetworkDelayListener will delete themselves.
|
| - ResourceQueue::DelegateSet resource_queue_delegates;
|
| - resource_queue_delegates.insert(new UserScriptListener());
|
| - resource_queue_delegates.insert(new NetworkDelayListener());
|
| + ResourceDispatcherHost* rdh = ResourceDispatcherHost::Get();
|
| + rdh->AddResourceQueueDelegate(new UserScriptListener());
|
| + rdh->AddResourceQueueDelegate(new NetworkDelayListener());
|
|
|
| - resource_dispatcher_host_.reset(
|
| - new ResourceDispatcherHost(resource_queue_delegates));
|
| - resource_dispatcher_host_->Initialize();
|
| -
|
| resource_dispatcher_host_delegate_.reset(
|
| - new ChromeResourceDispatcherHostDelegate(resource_dispatcher_host_.get(),
|
| - prerender_tracker()));
|
| - resource_dispatcher_host_->set_delegate(
|
| - resource_dispatcher_host_delegate_.get());
|
| + new ChromeResourceDispatcherHostDelegate(rdh, prerender_tracker()));
|
| + rdh->set_delegate(resource_dispatcher_host_delegate_.get());
|
|
|
| pref_change_registrar_.Add(prefs::kAllowCrossOriginAuthPrompt, this);
|
| ApplyAllowCrossOriginAuthPromptPolicy();
|
| @@ -728,38 +657,6 @@
|
| metrics_service_.reset(new MetricsService);
|
| }
|
|
|
| -void BrowserProcessImpl::CreateIOThreadState() {
|
| - // Prior to any processing happening on the io thread, we create the
|
| - // plugin service as it is predominantly used from the io thread,
|
| - // but must be created on the main thread. The service ctor is
|
| - // inexpensive and does not invoke the io_thread() accessor.
|
| - PluginService* plugin_service = PluginService::GetInstance();
|
| - plugin_service->Init();
|
| - plugin_service->SetFilter(ChromePluginServiceFilter::GetInstance());
|
| - plugin_service->StartWatchingPlugins();
|
| -
|
| - // Register the internal Flash if available.
|
| - FilePath path;
|
| - if (!CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kDisableInternalFlash) &&
|
| - PathService::Get(chrome::FILE_FLASH_PLUGIN, &path)) {
|
| - plugin_service->AddExtraPluginPath(path);
|
| - }
|
| -
|
| -#if defined(OS_POSIX)
|
| - // Also find plugins in a user-specific plugins dir,
|
| - // e.g. ~/.config/chromium/Plugins.
|
| - FilePath user_data_dir;
|
| - if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) {
|
| - plugin_service->AddExtraPluginPath(user_data_dir.Append("Plugins"));
|
| - }
|
| -#endif
|
| -
|
| - scoped_ptr<IOThread> thread(new IOThread(
|
| - local_state(), net_log_.get(), extension_event_router_forwarder_.get()));
|
| - io_thread_.swap(thread);
|
| -}
|
| -
|
| void BrowserProcessImpl::CreateWatchdogThread() {
|
| DCHECK(!created_watchdog_thread_ && watchdog_thread_.get() == NULL);
|
| created_watchdog_thread_ = true;
|
| @@ -826,7 +723,33 @@
|
| local_state_->RegisterBooleanPref(prefs::kAllowCrossOriginAuthPrompt, false);
|
| }
|
|
|
| +void BrowserProcessImpl::PreCreateThreads() {
|
| + io_thread_.reset(new IOThread(
|
| + local_state(), net_log_.get(), extension_event_router_forwarder_.get()));
|
| +}
|
| +
|
| void BrowserProcessImpl::PreMainMessageLoopRun() {
|
| + PluginService* plugin_service = PluginService::GetInstance();
|
| + plugin_service->SetFilter(ChromePluginServiceFilter::GetInstance());
|
| + plugin_service->StartWatchingPlugins();
|
| +
|
| + // Register the internal Flash if available.
|
| + FilePath path;
|
| + if (!CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kDisableInternalFlash) &&
|
| + PathService::Get(chrome::FILE_FLASH_PLUGIN, &path)) {
|
| + plugin_service->AddExtraPluginPath(path);
|
| + }
|
| +
|
| +#if defined(OS_POSIX)
|
| + // Also find plugins in a user-specific plugins dir,
|
| + // e.g. ~/.config/chromium/Plugins.
|
| + FilePath user_data_dir;
|
| + if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) {
|
| + plugin_service->AddExtraPluginPath(user_data_dir.Append("Plugins"));
|
| + }
|
| +#endif
|
| +
|
| if (local_state_->IsManagedPreference(prefs::kDefaultBrowserSettingEnabled))
|
| ApplyDefaultBrowserPolicy();
|
| }
|
| @@ -916,7 +839,7 @@
|
|
|
| void BrowserProcessImpl::ApplyAllowCrossOriginAuthPromptPolicy() {
|
| bool value = local_state()->GetBoolean(prefs::kAllowCrossOriginAuthPrompt);
|
| - resource_dispatcher_host()->set_allow_cross_origin_auth_prompt(value);
|
| + ResourceDispatcherHost::Get()->set_allow_cross_origin_auth_prompt(value);
|
| }
|
|
|
| // Mac is currently not supported.
|
|
|