summaryrefslogtreecommitdiff
path: root/chromium/content/browser/browser_process_sub_thread.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-08-24 12:15:48 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-08-28 13:30:04 +0000
commitb014812705fc80bff0a5c120dfcef88f349816dc (patch)
tree25a2e2d9fa285f1add86aa333389a839f81a39ae /chromium/content/browser/browser_process_sub_thread.cc
parent9f4560b1027ae06fdb497023cdcaf91b8511fa74 (diff)
downloadqtwebengine-chromium-b014812705fc80bff0a5c120dfcef88f349816dc.tar.gz
BASELINE: Update Chromium to 68.0.3440.125
Change-Id: I23f19369e01f688e496f5bf179abb521ad73874f Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/content/browser/browser_process_sub_thread.cc')
-rw-r--r--chromium/content/browser/browser_process_sub_thread.cc57
1 files changed, 57 insertions, 0 deletions
diff --git a/chromium/content/browser/browser_process_sub_thread.cc b/chromium/content/browser/browser_process_sub_thread.cc
index 0902fb6bfd0..6f33cee4d65 100644
--- a/chromium/content/browser/browser_process_sub_thread.cc
+++ b/chromium/content/browser/browser_process_sub_thread.cc
@@ -6,13 +6,18 @@
#include "base/compiler_specific.h"
#include "base/debug/alias.h"
+#include "base/metrics/histogram_macros.h"
#include "base/threading/thread_restrictions.h"
#include "base/trace_event/memory_dump_manager.h"
#include "content/browser/browser_child_process_host_impl.h"
#include "content/browser/browser_thread_impl.h"
#include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
#include "content/browser/notification_service_impl.h"
+#include "content/browser/utility_process_host.h"
+#include "content/common/child_process_host_impl.h"
+#include "content/public/browser/browser_child_process_host_iterator.h"
#include "content/public/browser/browser_thread_delegate.h"
+#include "content/public/common/process_type.h"
#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_request.h"
@@ -70,6 +75,24 @@ void BrowserProcessSubThread::AllowBlockingForTesting() {
is_blocking_allowed_for_testing_ = true;
}
+// static
+std::unique_ptr<BrowserProcessSubThread>
+BrowserProcessSubThread::CreateIOThread() {
+ TRACE_EVENT0("startup", "BrowserProcessSubThread::CreateIOThread");
+ base::Thread::Options options;
+ options.message_loop_type = base::MessageLoop::TYPE_IO;
+#if defined(OS_ANDROID) || defined(OS_CHROMEOS)
+ // Up the priority of the |io_thread_| as some of its IPCs relate to
+ // display tasks.
+ options.priority = base::ThreadPriority::DISPLAY;
+#endif
+ std::unique_ptr<BrowserProcessSubThread> io_thread(
+ new BrowserProcessSubThread(BrowserThread::IO));
+ if (!io_thread->StartWithOptions(options))
+ LOG(FATAL) << "Failed to start BrowserThread:IO";
+ return io_thread;
+}
+
void BrowserProcessSubThread::Init() {
DCHECK_CALLED_ON_VALID_THREAD(browser_thread_checker_);
@@ -168,6 +191,40 @@ void BrowserProcessSubThread::IOThreadCleanUp() {
// Destroy all URLRequests started by URLFetchers.
net::URLFetcher::CancelAll();
+ for (BrowserChildProcessHostIterator it(PROCESS_TYPE_UTILITY); !it.Done();
+ ++it) {
+ UtilityProcessHost* utility_process =
+ static_cast<UtilityProcessHost*>(it.GetDelegate());
+ if (utility_process->sandbox_type() ==
+ service_manager::SANDBOX_TYPE_NETWORK) {
+ // Even though the TerminateAll call above tries to kill all child
+ // processes, that will fail sometimes (e.g. on Windows if there's pending
+ // I/O). Once the network service is sandboxed this will be taken care of,
+ // since the sandbox ensures child processes are terminated. Until then,
+ // wait on the network process for a bit. This is done so that:
+ // 1) when Chrome quits, we ensure that cookies & cache are flushed
+ // 2) tests aren't killed by swarming because of child processes that
+ // outlive the parent process.
+ // https://crbug.com/841001
+ const int kMaxSecondsToWaitForNetworkProcess = 10;
+ ChildProcessHostImpl* child_process =
+ static_cast<ChildProcessHostImpl*>(it.GetHost());
+ auto& process = child_process->peer_process();
+ if (!process.IsValid())
+ continue;
+ base::ScopedAllowBaseSyncPrimitives scoped_allow_base_sync_primitives;
+ const base::TimeTicks start_time = base::TimeTicks::Now();
+ process.WaitForExitWithTimeout(
+ base::TimeDelta::FromSeconds(kMaxSecondsToWaitForNetworkProcess),
+ nullptr);
+ // Record time spent for the method call.
+ base::TimeDelta network_wait_time = base::TimeTicks::Now() - start_time;
+ UMA_HISTOGRAM_TIMES("NetworkService.ShutdownTime", network_wait_time);
+ LOG(ERROR) << "Waited " << network_wait_time.InMilliseconds()
+ << " ms for network service";
+ }
+ }
+
// If any child processes are still running, terminate them and
// and delete the BrowserChildProcessHost instances to release whatever
// IO thread only resources they are referencing.