| Index: ios/chrome/browser/ios_chrome_io_thread.mm
|
| diff --git a/ios/chrome/browser/ios_chrome_io_thread.mm b/ios/chrome/browser/ios_chrome_io_thread.mm
|
| index 22fc9c5d63ea76b7f38680d87d3bf72ead16e01d..3668e0aeb0a616b28e42d6067c22f382ed0cce40 100644
|
| --- a/ios/chrome/browser/ios_chrome_io_thread.mm
|
| +++ b/ios/chrome/browser/ios_chrome_io_thread.mm
|
| @@ -205,12 +205,14 @@ class SystemURLRequestContextGetter : public net::URLRequestContextGetter {
|
| scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner()
|
| const override;
|
|
|
| + // Tells the getter that the URLRequestContext is about to be shut down.
|
| + void Shutdown();
|
| +
|
| protected:
|
| ~SystemURLRequestContextGetter() override;
|
|
|
| private:
|
| - IOSChromeIOThread* const
|
| - io_thread_; // Weak pointer, owned by ApplicationContext.
|
| + IOSChromeIOThread* io_thread_; // Weak pointer, owned by ApplicationContext.
|
| scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
|
|
|
| base::debug::LeakTracker<SystemURLRequestContextGetter> leak_tracker_;
|
| @@ -226,6 +228,8 @@ SystemURLRequestContextGetter::~SystemURLRequestContextGetter() {}
|
|
|
| net::URLRequestContext* SystemURLRequestContextGetter::GetURLRequestContext() {
|
| DCHECK_CURRENTLY_ON(web::WebThread::IO);
|
| + if (!io_thread_)
|
| + return nullptr;
|
| DCHECK(io_thread_->globals()->system_request_context.get());
|
|
|
| return io_thread_->globals()->system_request_context.get();
|
| @@ -236,6 +240,12 @@ SystemURLRequestContextGetter::GetNetworkTaskRunner() const {
|
| return network_task_runner_;
|
| }
|
|
|
| +void SystemURLRequestContextGetter::Shutdown() {
|
| + DCHECK_CURRENTLY_ON(web::WebThread::IO);
|
| + io_thread_ = nullptr;
|
| + NotifyContextShuttingDown();
|
| +}
|
| +
|
| IOSChromeIOThread::Globals::SystemRequestContextLeakChecker::
|
| SystemRequestContextLeakChecker(Globals* globals)
|
| : globals_(globals) {
|
| @@ -423,6 +433,7 @@ void IOSChromeIOThread::Init() {
|
| }
|
|
|
| void IOSChromeIOThread::CleanUp() {
|
| + system_url_request_context_getter_->Shutdown();
|
| system_url_request_context_getter_ = nullptr;
|
|
|
| // Release objects that the net::URLRequestContext could have been pointing
|
|
|