cef/cef1/libcef/task_impl.cc
Marshall Greenblatt 3b8ebef27b Update to Chromium revision 149431.
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@731 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
2012-08-07 13:58:35 +00:00

50 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),
base::TimeDelta::FromMilliseconds(delay_ms));
}