diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-22 21:24:36 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-22 21:24:36 +0000 |
commit | 23056f87ae27274aae0ce642de01c5737b7882f4 (patch) | |
tree | 09d8c93071a13f11a5f9150e7eacfbb4a883eb20 /chrome/service/service_process.cc | |
parent | 2123cbae0986af60da4159862d7ac10a417de8fd (diff) | |
download | chromium_src-23056f87ae27274aae0ce642de01c5737b7882f4.zip chromium_src-23056f87ae27274aae0ce642de01c5737b7882f4.tar.gz chromium_src-23056f87ae27274aae0ce642de01c5737b7882f4.tar.bz2 |
Make sure the service process kills all URLFetcher::Cores on shutdown.
I'm not sure this is strictly necessary, since it may be that due to how the service process uses URLFetcher, that all fetches are already canceled by the time its IO thread shuts down. But this makes absolutely sure this is the case. Good practice in any case.
This also makes it completely safe for us to have URLFetcher::Core stop using the DestructionObserver.
BUG=59630
TEST=existing
Review URL: http://codereview.chromium.org/3969006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63568 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/service/service_process.cc')
-rw-r--r-- | chrome/service/service_process.cc | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/chrome/service/service_process.cc b/chrome/service/service_process.cc index 97919cd..1ec4a83 100644 --- a/chrome/service/service_process.cc +++ b/chrome/service/service_process.cc @@ -6,6 +6,7 @@ #include <algorithm> +#include "base/basictypes.h" #include "base/command_line.h" #include "base/path_service.h" #include "base/singleton.h" @@ -43,9 +44,36 @@ ServiceProcess* g_service_process = NULL; +namespace { + // Delay in millseconds after the last service is disabled before we attempt // a shutdown. -static const int64 kShutdownDelay = 60000; +const int64 kShutdownDelay = 60000; + +class ServiceIOThread : public base::Thread { + public: + explicit ServiceIOThread(const char* name); + virtual ~ServiceIOThread(); + + protected: + virtual void CleanUp(); + + private: + DISALLOW_COPY_AND_ASSIGN(ServiceIOThread); +}; + +ServiceIOThread::ServiceIOThread(const char* name) : base::Thread(name) {} +ServiceIOThread::~ServiceIOThread() { + // We cannot rely on our base class to stop the thread since we want our + // CleanUp function to run. + Stop(); +} + +void ServiceIOThread::CleanUp() { + URLFetcher::CancelAll(); +} + +} // namespace ServiceProcess::ServiceProcess() : shutdown_event_(true, false), @@ -62,7 +90,7 @@ bool ServiceProcess::Initialize(MessageLoop* message_loop, network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); base::Thread::Options options; options.message_loop_type = MessageLoop::TYPE_IO; - io_thread_.reset(new base::Thread("ServiceProcess_IO")); + io_thread_.reset(new ServiceIOThread("ServiceProcess_IO")); file_thread_.reset(new base::Thread("ServiceProcess_File")); if (!io_thread_->StartWithOptions(options) || !file_thread_->StartWithOptions(options)) { |