blob: 7d048ee0430ca089795ad119affe7a9fb1781759 (
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
27
28
29
|
// Copyright (c) 2012 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 "chrome/browser/google_apis/task_util.h"
#include "base/location.h"
#include "content/public/browser/browser_thread.h"
using content::BrowserThread;
namespace google_apis {
void RunTaskOnThread(scoped_refptr<base::MessageLoopProxy> relay_proxy,
const base::Closure& task) {
if (relay_proxy->BelongsToCurrentThread()) {
task.Run();
} else {
const bool posted = relay_proxy->PostTask(FROM_HERE, task);
DCHECK(posted);
}
}
void RunTaskOnUIThread(const base::Closure& task) {
RunTaskOnThread(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), task);
}
} // namespace google_apis
|