mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-20 14:10:40 +01:00
Merge revision 482 changes:
- Mac: Fix the "no autorelease pool in place" error by initializing an NSAutoreleasePool on every thread (issue #502). git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/963@629 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
266f4e7a27
commit
a63833acfd
@ -31,10 +31,7 @@ CefProcessIOThread::~CefProcessIOThread() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CefProcessIOThread::Init() {
|
void CefProcessIOThread::Init() {
|
||||||
#if defined(OS_WIN)
|
CefThread::Init();
|
||||||
// Initializes the COM library on the current thread.
|
|
||||||
CoInitialize(NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
FilePath cache_path(_Context->cache_path());
|
FilePath cache_path(_Context->cache_path());
|
||||||
request_context_ = new BrowserRequestContext(cache_path,
|
request_context_ = new BrowserRequestContext(cache_path,
|
||||||
@ -63,9 +60,5 @@ void CefProcessIOThread::CleanUp() {
|
|||||||
_Context->set_request_context(NULL);
|
_Context->set_request_context(NULL);
|
||||||
request_context_ = NULL;
|
request_context_ = NULL;
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
CefThread::Cleanup();
|
||||||
// Closes the COM library on the current thread. CoInitialize must
|
|
||||||
// be balanced by a corresponding call to CoUninitialize.
|
|
||||||
CoUninitialize();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
@ -25,12 +25,13 @@ class CefProcessIOThread : public CefThread {
|
|||||||
CefProcessIOThread(MessageLoop* message_loop);
|
CefProcessIOThread(MessageLoop* message_loop);
|
||||||
virtual ~CefProcessIOThread();
|
virtual ~CefProcessIOThread();
|
||||||
|
|
||||||
virtual void Init();
|
|
||||||
virtual void CleanUp();
|
|
||||||
|
|
||||||
scoped_refptr<BrowserRequestContext> request_context()
|
scoped_refptr<BrowserRequestContext> request_context()
|
||||||
{ return request_context_; }
|
{ return request_context_; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void Init();
|
||||||
|
virtual void CleanUp();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
scoped_refptr<BrowserRequestContext> request_context_;
|
scoped_refptr<BrowserRequestContext> request_context_;
|
||||||
|
|
||||||
|
@ -6,10 +6,6 @@
|
|||||||
#include "cef_process_sub_thread.h"
|
#include "cef_process_sub_thread.h"
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
|
||||||
#include <Objbase.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
CefProcessSubThread::CefProcessSubThread(CefThread::ID identifier)
|
CefProcessSubThread::CefProcessSubThread(CefThread::ID identifier)
|
||||||
: CefThread(identifier) {}
|
: CefThread(identifier) {}
|
||||||
|
|
||||||
@ -23,22 +19,11 @@ CefProcessSubThread::~CefProcessSubThread() {
|
|||||||
Stop();
|
Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefProcessSubThread::Init() {
|
|
||||||
#if defined(OS_WIN)
|
|
||||||
// Initializes the COM library on the current thread.
|
|
||||||
CoInitialize(NULL);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefProcessSubThread::CleanUp() {
|
void CefProcessSubThread::CleanUp() {
|
||||||
// Flush any remaining messages. This ensures that any accumulated
|
// Flush any remaining messages. This ensures that any accumulated
|
||||||
// Task objects get destroyed before we exit, which avoids noise in
|
// Task objects get destroyed before we exit, which avoids noise in
|
||||||
// purify leak-test results.
|
// purify leak-test results.
|
||||||
MessageLoop::current()->RunAllPending();
|
MessageLoop::current()->RunAllPending();
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
CefThread::Cleanup();
|
||||||
// Closes the COM library on the current thread. CoInitialize must
|
|
||||||
// be balanced by a corresponding call to CoUninitialize.
|
|
||||||
CoUninitialize();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ class CefProcessSubThread : public CefThread {
|
|||||||
virtual ~CefProcessSubThread();
|
virtual ~CefProcessSubThread();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Init();
|
|
||||||
virtual void CleanUp();
|
virtual void CleanUp();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -9,6 +9,10 @@
|
|||||||
#include "base/message_loop.h"
|
#include "base/message_loop.h"
|
||||||
#include "base/message_loop_proxy.h"
|
#include "base/message_loop_proxy.h"
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
#include <Objbase.h> // NOLINT(build/include_order)
|
||||||
|
#endif
|
||||||
|
|
||||||
using base::MessageLoopProxy;
|
using base::MessageLoopProxy;
|
||||||
|
|
||||||
// Friendly names for the well-known threads.
|
// Friendly names for the well-known threads.
|
||||||
@ -102,6 +106,29 @@ CefThread::CefThread(ID identifier, MessageLoop* message_loop)
|
|||||||
Initialize();
|
Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CefThread::Init() {
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
// Initializes the COM library on the current thread.
|
||||||
|
CoInitialize(NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(OS_MACOSX)
|
||||||
|
autorelease_pool_.reset(new base::mac::ScopedNSAutoreleasePool);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefThread::Cleanup() {
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
// Closes the COM library on the current thread. CoInitialize must
|
||||||
|
// be balanced by a corresponding call to CoUninitialize.
|
||||||
|
CoUninitialize();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(OS_MACOSX)
|
||||||
|
autorelease_pool_.reset(NULL);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void CefThread::Initialize() {
|
void CefThread::Initialize() {
|
||||||
base::AutoLock lock(lock_);
|
base::AutoLock lock(lock_);
|
||||||
DCHECK(identifier_ >= 0 && identifier_ < ID_COUNT);
|
DCHECK(identifier_ >= 0 && identifier_ < ID_COUNT);
|
||||||
|
@ -6,10 +6,15 @@
|
|||||||
#ifndef _CEF_THREAD_H
|
#ifndef _CEF_THREAD_H
|
||||||
#define _CEF_THREAD_H
|
#define _CEF_THREAD_H
|
||||||
|
|
||||||
|
#include "base/memory/scoped_ptr.h"
|
||||||
#include "base/synchronization/lock.h"
|
#include "base/synchronization/lock.h"
|
||||||
#include "base/task.h"
|
#include "base/task.h"
|
||||||
#include "base/threading/thread.h"
|
#include "base/threading/thread.h"
|
||||||
|
|
||||||
|
#if defined(OS_MACOSX)
|
||||||
|
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
class MessageLoopProxy;
|
class MessageLoopProxy;
|
||||||
}
|
}
|
||||||
@ -179,6 +184,10 @@ class CefThread : public base::Thread {
|
|||||||
struct DeleteOnIOThread : public DeleteOnThread<IO> { };
|
struct DeleteOnIOThread : public DeleteOnThread<IO> { };
|
||||||
struct DeleteOnFileThread : public DeleteOnThread<FILE> { };
|
struct DeleteOnFileThread : public DeleteOnThread<FILE> { };
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void Init();
|
||||||
|
virtual void Cleanup();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Common initialization code for the constructors.
|
// Common initialization code for the constructors.
|
||||||
void Initialize();
|
void Initialize();
|
||||||
@ -210,6 +219,10 @@ class CefThread : public base::Thread {
|
|||||||
// on the UI thread by the g_browser_process object. CefThreads remove
|
// on the UI thread by the g_browser_process object. CefThreads remove
|
||||||
// themselves from this array upon destruction.
|
// themselves from this array upon destruction.
|
||||||
static CefThread* cef_threads_[ID_COUNT];
|
static CefThread* cef_threads_[ID_COUNT];
|
||||||
|
|
||||||
|
#if defined(OS_MACOSX)
|
||||||
|
scoped_ptr<base::mac::ScopedNSAutoreleasePool> autorelease_pool_;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#define REQUIRE_UIT() DCHECK(CefThread::CurrentlyOn(CefThread::UI))
|
#define REQUIRE_UIT() DCHECK(CefThread::CurrentlyOn(CefThread::UI))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user