diff options
author | gregoryd@google.com <gregoryd@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-05 17:50:43 +0000 |
---|---|---|
committer | gregoryd@google.com <gregoryd@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-05 17:50:43 +0000 |
commit | 0784bb9f201896bc333aef39e3f0a29621fe03bc (patch) | |
tree | a2017eddab0bbb8713ddfd9c1473dd81e557ec4f /chrome/browser/nacl_host | |
parent | c891d223b30349e9b4c475effd329e1e74e681ce (diff) | |
download | chromium_src-0784bb9f201896bc333aef39e3f0a29621fe03bc.zip chromium_src-0784bb9f201896bc333aef39e3f0a29621fe03bc.tar.gz chromium_src-0784bb9f201896bc333aef39e3f0a29621fe03bc.tar.bz2 |
Revert 40744 - Terminate NaCl broker process when no loader processes are running
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/669019
TBR=gregoryd@google.com
Review URL: http://codereview.chromium.org/668165
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40746 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/nacl_host')
-rw-r--r-- | chrome/browser/nacl_host/nacl_broker_host.cc | 18 | ||||
-rw-r--r-- | chrome/browser/nacl_host/nacl_broker_host.h | 8 | ||||
-rw-r--r-- | chrome/browser/nacl_host/nacl_broker_service.cc | 38 | ||||
-rw-r--r-- | chrome/browser/nacl_host/nacl_broker_service.h | 7 | ||||
-rw-r--r-- | chrome/browser/nacl_host/nacl_process_host.cc | 9 | ||||
-rw-r--r-- | chrome/browser/nacl_host/nacl_process_host.h | 1 |
6 files changed, 11 insertions, 70 deletions
diff --git a/chrome/browser/nacl_host/nacl_broker_host.cc b/chrome/browser/nacl_host/nacl_broker_host.cc index ec8aafd..92ed181 100644 --- a/chrome/browser/nacl_host/nacl_broker_host.cc +++ b/chrome/browser/nacl_host/nacl_broker_host.cc @@ -16,8 +16,7 @@ NaClBrokerHost::NaClBrokerHost( ResourceDispatcherHost* resource_dispatcher_host) - : ChildProcessHost(NACL_BROKER_PROCESS, resource_dispatcher_host), - stopping_(false) { + : ChildProcessHost(NACL_BROKER_PROCESS, resource_dispatcher_host) { } NaClBrokerHost::~NaClBrokerHost() { @@ -73,18 +72,3 @@ void NaClBrokerHost::OnLoaderLaunched(const std::wstring& loader_channel_id, base::ProcessHandle handle) { NaClBrokerService::GetInstance()->OnLoaderLaunched(loader_channel_id, handle); } - -void NaClBrokerHost::StopBroker() { - stopping_ = true; - Send(new NaClProcessMsg_StopBroker()); -} - -void NaClBrokerHost::OnChildDied() { - if (!stopping_) { - // If the broker stops unexpectedly (and not when asked by the broker - // service), we need to notify the broker service. In any other case - // the broker service may have a new broker host pointer by this time. - NaClBrokerService::GetInstance()->OnBrokerDied(); - } - ChildProcessHost::OnChildDied(); -} diff --git a/chrome/browser/nacl_host/nacl_broker_host.h b/chrome/browser/nacl_host/nacl_broker_host.h index 47c3e95..15dd18b 100644 --- a/chrome/browser/nacl_host/nacl_broker_host.h +++ b/chrome/browser/nacl_host/nacl_broker_host.h @@ -23,12 +23,6 @@ class NaClBrokerHost : public ChildProcessHost { // a Native Client loader process. bool LaunchLoader(const std::wstring& loader_channel_id); - // Stop the broker process. - void StopBroker(); - - protected: - virtual void OnChildDied(); - private: // ResourceDispatcherHost::Receiver implementation: virtual URLRequestContext* GetRequestContext( @@ -46,8 +40,6 @@ class NaClBrokerHost : public ChildProcessHost { // IPC::Channel::Listener virtual void OnMessageReceived(const IPC::Message& msg); - bool stopping_; - DISALLOW_COPY_AND_ASSIGN(NaClBrokerHost); }; diff --git a/chrome/browser/nacl_host/nacl_broker_service.cc b/chrome/browser/nacl_host/nacl_broker_service.cc index 69c919b..6a58c2f 100644 --- a/chrome/browser/nacl_host/nacl_broker_service.cc +++ b/chrome/browser/nacl_host/nacl_broker_service.cc @@ -15,18 +15,16 @@ NaClBrokerService* NaClBrokerService::GetInstance() { NaClBrokerService::NaClBrokerService() : broker_started_(false), broker_host_(NULL), - loaders_running_(0), resource_dispatcher_host_(NULL), initialized_(false) { } void NaClBrokerService::Init(ResourceDispatcherHost* resource_dispatcher_host) { - if (!initialized_) - resource_dispatcher_host_ = resource_dispatcher_host; - - if (broker_host_ == NULL) - StartBroker(); - + if (initialized_) { + return; + } + resource_dispatcher_host_ = resource_dispatcher_host; + StartBroker(); initialized_ = true; } @@ -53,9 +51,9 @@ bool NaClBrokerService::LaunchLoader(NaClProcessHost* nacl_process_host, void NaClBrokerService::OnBrokerStarted() { PendingLaunchesMap::iterator it; - for (it = pending_launches_.begin(); it != pending_launches_.end(); it++) + for (it = pending_launches_.begin(); it != pending_launches_.end(); it++) { broker_host_->LaunchLoader(it->first); - + } broker_started_ = true; } @@ -63,28 +61,10 @@ void NaClBrokerService::OnLoaderLaunched(const std::wstring& channel_id, base::ProcessHandle handle) { NaClProcessHost* client; PendingLaunchesMap::iterator it = pending_launches_.find(channel_id); - if (pending_launches_.end() == it) + if (pending_launches_.end() == it) { NOTREACHED(); - + } client = it->second; client->OnProcessLaunchedByBroker(handle); pending_launches_.erase(it); - ++loaders_running_; -} - -void NaClBrokerService::OnLoaderDied() { - --loaders_running_; - // Stop the broker only if there are no loaders running or being launched. - if (loaders_running_ + pending_launches_.size() == 0 && - broker_host_ != NULL) { - broker_host_->StopBroker(); - // Reset the pointer to the broker host. - OnBrokerDied(); - } -} - -void NaClBrokerService::OnBrokerDied() { - // NaClBrokerHost object will be destructed by ChildProcessHost - broker_started_ = false; - broker_host_.release(); } diff --git a/chrome/browser/nacl_host/nacl_broker_service.h b/chrome/browser/nacl_host/nacl_broker_service.h index 8518cd4..75e089d 100644 --- a/chrome/browser/nacl_host/nacl_broker_service.h +++ b/chrome/browser/nacl_host/nacl_broker_service.h @@ -36,12 +36,6 @@ class NaClBrokerService { void OnLoaderLaunched(const std::wstring& channel_id, base::ProcessHandle handle); - // Called by NaClProcessHost when a loader process is terminated - void OnLoaderDied(); - - // Called by NaClBrokerHost when the broker process is terminated. - void OnBrokerDied(); - private: typedef std::map<std::wstring, NaClProcessHost*> PendingLaunchesMap; @@ -53,7 +47,6 @@ class NaClBrokerService { bool broker_started_; scoped_ptr<NaClBrokerHost> broker_host_; - int loaders_running_; bool initialized_; ResourceDispatcherHost* resource_dispatcher_host_; PendingLaunchesMap pending_launches_; diff --git a/chrome/browser/nacl_host/nacl_process_host.cc b/chrome/browser/nacl_host/nacl_process_host.cc index 1114cb7..9a08d54 100644 --- a/chrome/browser/nacl_host/nacl_process_host.cc +++ b/chrome/browser/nacl_host/nacl_process_host.cc @@ -125,17 +125,10 @@ bool NaClProcessHost::DidChildCrash() { return ChildProcessHost::DidChildCrash(); } -void NaClProcessHost::OnChildDied() { -#if defined(OS_WIN) - NaClBrokerService::GetInstance()->OnLoaderDied(); -#endif - ChildProcessHost::OnChildDied(); -} - void NaClProcessHost::OnProcessLaunched() { nacl::FileDescriptor imc_handle; base::ProcessHandle nacl_process_handle; -#if defined(OS_WIN) +#if NACL_WINDOWS // Duplicate the IMC handle // We assume the size of imc_handle has the same size as HANDLE, so the cast // below is safe. diff --git a/chrome/browser/nacl_host/nacl_process_host.h b/chrome/browser/nacl_host/nacl_process_host.h index 28893fc..a89b2da 100644 --- a/chrome/browser/nacl_host/nacl_process_host.h +++ b/chrome/browser/nacl_host/nacl_process_host.h @@ -37,7 +37,6 @@ class NaClProcessHost : public ChildProcessHost { protected: virtual bool DidChildCrash(); - virtual void OnChildDied(); private: bool LaunchSelLdr(); |