mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Break cef.h into multiple headers (issue #142).
- Move wrapper classes from cef_wrapper.h to wrapper/ directory. - Move C API functions/classes from cef_capi.h to capi/ directory. - Move global function implementations from cef_context.cc to *_impl.cc files. - Output auto-generated file paths in cef_paths.gypi. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@442 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
63
libcef/task_impl.cc
Normal file
63
libcef/task_impl.cc
Normal file
@ -0,0 +1,63 @@
|
||||
// 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 "cef_thread.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;
|
||||
}
|
||||
|
||||
} // anonymous
|
||||
|
||||
bool CefCurrentlyOn(CefThreadId threadId)
|
||||
{
|
||||
int id = GetThreadId(threadId);
|
||||
if(id < 0)
|
||||
return false;
|
||||
|
||||
return CefThread::CurrentlyOn(static_cast<CefThread::ID>(id));
|
||||
}
|
||||
|
||||
class CefTaskHelper : public Task
|
||||
{
|
||||
public:
|
||||
CefTaskHelper(CefRefPtr<CefTask> task, CefThreadId threadId)
|
||||
: task_(task), thread_id_(threadId) {}
|
||||
virtual void Run() { task_->Execute(thread_id_); }
|
||||
private:
|
||||
CefRefPtr<CefTask> task_;
|
||||
CefThreadId thread_id_;
|
||||
DISALLOW_COPY_AND_ASSIGN(CefTaskHelper);
|
||||
};
|
||||
|
||||
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,
|
||||
new CefTaskHelper(task, threadId));
|
||||
}
|
||||
|
||||
bool CefPostDelayedTask(CefThreadId threadId, CefRefPtr<CefTask> task,
|
||||
long delay_ms)
|
||||
{
|
||||
int id = GetThreadId(threadId);
|
||||
if(id < 0)
|
||||
return false;
|
||||
|
||||
return CefThread::PostDelayedTask(static_cast<CefThread::ID>(id), FROM_HERE,
|
||||
new CefTaskHelper(task, threadId), delay_ms);
|
||||
}
|
Reference in New Issue
Block a user