cef/libcef/task_impl.cc
Marshall Greenblatt a3e0935ce3 Update to Chromium revision 119867.
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@504 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-02-17 14:51:20 +00:00

49 lines
1.3 KiB
C++

// Copyright (c) 2011 The Chromium Embedded Framework 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 "include/cef_task.h"
#include "libcef/cef_thread.h"
#include "base/bind.h"
namespace {
int GetThreadId(CefThreadId threadId) {
switch (threadId) {
case TID_UI: return CefThread::UI;
case TID_IO: return CefThread::IO;
case TID_FILE: return CefThread::FILE;
};
NOTREACHED();
return -1;
}
} // namespace
bool CefCurrentlyOn(CefThreadId threadId) {
int id = GetThreadId(threadId);
if (id < 0)
return false;
return CefThread::CurrentlyOn(static_cast<CefThread::ID>(id));
}
bool CefPostTask(CefThreadId threadId, CefRefPtr<CefTask> task) {
int id = GetThreadId(threadId);
if (id < 0)
return false;
return CefThread::PostTask(static_cast<CefThread::ID>(id), FROM_HERE,
base::Bind(&CefTask::Execute, task, threadId));
}
bool CefPostDelayedTask(CefThreadId threadId, CefRefPtr<CefTask> task,
int64 delay_ms) {
int id = GetThreadId(threadId);
if (id < 0)
return false;
return CefThread::PostDelayedTask(static_cast<CefThread::ID>(id), FROM_HERE,
base::Bind(&CefTask::Execute, task, threadId), delay_ms);
}