1 // Copyright 2018 The Chromium Authors
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 "partition_alloc/partition_alloc_base/threading/platform_thread.h"
6 
7 namespace partition_alloc::internal::base {
8 
9 namespace {
10 
11 // SetThreadNameHook is invoked by EnablePCScan(). EnablePCScan() will be
12 // invoked soon after running RunBrowser, RunZygote, and RunContentProcess.
13 // So g_set_thread_name_proc can be non-atomic.
14 SetThreadNameProc g_set_thread_name_proc = nullptr;
15 
16 }  // namespace
17 
SetThreadNameHook(SetThreadNameProc hook)18 void PlatformThread::SetThreadNameHook(SetThreadNameProc hook) {
19   g_set_thread_name_proc = hook;
20 }
21 
22 // static
SetName(const std::string & name)23 void PlatformThread::SetName(const std::string& name) {
24   if (!g_set_thread_name_proc) {
25     return;
26   }
27   g_set_thread_name_proc(name);
28 }
29 
30 }  // namespace partition_alloc::internal::base
31