1 // Copyright 2019 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 "content/public/browser/browser_thread.h" 6 7 #include <utility> 8 9 #include "base/callback.h" 10 #include "base/location.h" 11 #include "base/task/post_task.h" 12 #include "content/public/browser/browser_task_traits.h" 13 14 namespace content { 15 RunOrPostTaskOnThread(const base::Location & location,BrowserThread::ID thread_id,base::OnceClosure task)16void RunOrPostTaskOnThread(const base::Location& location, 17 BrowserThread::ID thread_id, 18 base::OnceClosure task) { 19 if (BrowserThread::CurrentlyOn(thread_id)) { 20 std::move(task).Run(); 21 return; 22 } 23 base::PostTask(location, {thread_id}, std::move(task)); 24 } 25 26 } // namespace content 27