mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Initial commit of libcef and cefclient projects.
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@2 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
67
libcef/context.h
Normal file
67
libcef/context.h
Normal file
@@ -0,0 +1,67 @@
|
||||
// Copyright (c) 2008 The Chromium Embedded Framework Authors.
|
||||
// Portions copyright (c) 2006-2008 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.
|
||||
|
||||
#ifndef _CONTEXT_H
|
||||
#define _CONTEXT_H
|
||||
|
||||
#include "../include/cef.h"
|
||||
#include "base/message_loop.h"
|
||||
#include "base/gfx/native_widget_types.h"
|
||||
#include "webkit/glue/webpreferences.h"
|
||||
|
||||
class CefBrowserImpl;
|
||||
|
||||
class CefContext : public CefThreadSafeBase<CefBase>
|
||||
{
|
||||
public:
|
||||
typedef std::list<CefRefPtr<CefBrowserImpl> > BrowserList;
|
||||
|
||||
CefContext();
|
||||
~CefContext();
|
||||
|
||||
bool Initialize();
|
||||
void Shutdown();
|
||||
|
||||
MessageLoopForUI* GetMessageLoopForUI() { return messageloopui_; }
|
||||
|
||||
HMODULE GetInstanceHandle() { return hinstance_; }
|
||||
HANDLE GetUIThreadHandle() { return hthreadui_; }
|
||||
DWORD GetUIThreadId() { return idthreadui_; }
|
||||
WebPreferences* GetWebPreferences() { return webprefs_; }
|
||||
|
||||
bool AddBrowser(CefRefPtr<CefBrowserImpl> browser);
|
||||
bool RemoveBrowser(CefRefPtr<CefBrowserImpl> browser);
|
||||
BrowserList* GetBrowserList() { return &browserlist_; }
|
||||
|
||||
// Returns true if the calling thread is the same as the UI thread
|
||||
bool RunningOnUIThread() { return (GetCurrentThreadId() == idthreadui_); }
|
||||
|
||||
private:
|
||||
void SetMessageLoopForUI(MessageLoopForUI* loop);
|
||||
void NotifyEvent();
|
||||
|
||||
protected:
|
||||
HMODULE hinstance_;
|
||||
DWORD idthreadui_;
|
||||
HANDLE hthreadui_;
|
||||
HANDLE heventui_;
|
||||
MessageLoopForUI* messageloopui_;
|
||||
bool in_transition_;
|
||||
BrowserList browserlist_;
|
||||
WebPreferences* webprefs_;
|
||||
|
||||
friend DWORD WINAPI ThreadHandlerUI(LPVOID lpParam);
|
||||
};
|
||||
|
||||
// Post a task to the UI message loop
|
||||
void PostTask(const tracked_objects::Location& from_here, Task* task);
|
||||
|
||||
// Global context object pointer
|
||||
extern CefRefPtr<CefContext> _Context;
|
||||
|
||||
// Macro for requiring that a function be called on the UI thread
|
||||
#define REQUIRE_UIT() DCHECK(_Context->RunningOnUIThread())
|
||||
|
||||
#endif // _CONTEXT_H
|
Reference in New Issue
Block a user