blob: 5a7f39a39675f802161ef59d35a3ab50b684281f [file] [log] [blame]
Rohit Raoecad2002018-11-16 19:42:051// Copyright 2018 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "ios/web/web_sub_thread.h"
6
7#include "base/threading/thread_restrictions.h"
8#include "ios/web/public/web_thread.h"
9#include "ios/web/web_thread_impl.h"
10#include "net/url_request/url_fetcher.h"
11
12namespace web {
13
14WebSubThread::WebSubThread(WebThread::ID identifier)
15 : WebThreadImpl(identifier) {}
16
17WebSubThread::WebSubThread(WebThread::ID identifier,
18 base::MessageLoop* message_loop)
19 : WebThreadImpl(identifier, message_loop) {}
20
21WebSubThread::~WebSubThread() {
22 Stop();
23}
24
25void WebSubThread::Init() {
26 WebThreadImpl::Init();
27
28 if (WebThread::CurrentlyOn(WebThread::IO)) {
29 // Though this thread is called the "IO" thread, it actually just routes
30 // messages around; it shouldn't be allowed to perform any blocking disk
31 // I/O.
32 base::DisallowUnresponsiveTasks();
33 }
34}
35
36void WebSubThread::CleanUp() {
37 if (WebThread::CurrentlyOn(WebThread::IO))
38 IOThreadPreCleanUp();
39
40 WebThreadImpl::CleanUp();
41}
42
43void WebSubThread::IOThreadPreCleanUp() {
44 // Kill all things that might be holding onto
45 // net::URLRequest/net::URLRequestContexts.
46
47 // Destroy all URLRequests started by URLFetchers.
48 net::URLFetcher::CancelAll();
49}
50
51} // namespace web