summaryrefslogtreecommitdiff
path: root/chromium/content/public/browser/browser_thread.cc
blob: 9d33097ada7b54a64b9fe7a2b94344593772624b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/public/browser/browser_thread.h"

#include <utility>

#include "base/callback.h"
#include "base/location.h"
#include "base/task/post_task.h"
#include "content/public/browser/browser_task_traits.h"

namespace content {

void RunOrPostTaskOnThread(const base::Location& location,
                           BrowserThread::ID thread_id,
                           base::OnceClosure task) {
  if (BrowserThread::CurrentlyOn(thread_id)) {
    std::move(task).Run();
    return;
  }
  base::PostTask(location, {thread_id}, std::move(task));
}

}  // namespace content