diff --git a/libcef/browser/browser_urlrequest_impl.cc b/libcef/browser/browser_urlrequest_impl.cc index e16ae7c70..c6366fcdf 100644 --- a/libcef/browser/browser_urlrequest_impl.cc +++ b/libcef/browser/browser_urlrequest_impl.cc @@ -14,6 +14,7 @@ #include "libcef/browser/thread_util.h" #include "libcef/common/request_impl.h" #include "libcef/common/response_impl.h" +#include "libcef/common/task_runner_impl.h" #include "base/logging.h" #include "base/message_loop/message_loop.h" @@ -75,7 +76,7 @@ class CefURLFetcherResponseWriter : public net::URLFetcherResponseWriter { base::Bind(&CefURLFetcherResponseWriter::WriteOnClientThread, url_request_, scoped_refptr(buffer), num_bytes, callback, - base::MessageLoop::current()->task_runner())); + CefTaskRunnerImpl::GetCurrentTaskRunner())); return net::ERR_IO_PENDING; } return num_bytes; @@ -135,7 +136,7 @@ class CefBrowserURLRequest::Context request_(request), client_(client), request_context_(request_context), - task_runner_(base::MessageLoop::current()->task_runner()), + task_runner_(CefTaskRunnerImpl::GetCurrentTaskRunner()), status_(UR_IO_PENDING), error_code_(ERR_NONE), upload_data_size_(0), @@ -391,7 +392,7 @@ CefURLFetcherDelegate::~CefURLFetcherDelegate() {} void CefURLFetcherDelegate::OnURLFetchComplete(const net::URLFetcher* source) { // Complete asynchronously so as not to delete the URLFetcher while it's still // in the call stack. - base::MessageLoop::current()->task_runner()->PostTask( + CefTaskRunnerImpl::GetCurrentTaskRunner()->PostTask( FROM_HERE, base::Bind(&CefBrowserURLRequest::Context::OnComplete, context_)); } diff --git a/libcef/browser/cookie_manager_impl.cc b/libcef/browser/cookie_manager_impl.cc index 56d764f8d..3f6572a7c 100644 --- a/libcef/browser/cookie_manager_impl.cc +++ b/libcef/browser/cookie_manager_impl.cc @@ -11,6 +11,7 @@ #include "libcef/browser/content_browser_client.h" #include "libcef/browser/context.h" #include "libcef/browser/net/network_delegate.h" +#include "libcef/common/task_runner_impl.h" #include "libcef/common/time_util.h" #include "base/bind.h" @@ -144,7 +145,7 @@ void CefCookieManagerImpl::GetCookieStore( scoped_refptr task_runner, const CookieStoreCallback& callback) { if (!task_runner.get()) - task_runner = base::MessageLoop::current()->task_runner(); + task_runner = CefTaskRunnerImpl::GetCurrentTaskRunner(); if (!CEF_CURRENTLY_ON_IOT()) { CEF_POST_TASK(CEF_IOT, base::Bind(&CefCookieManagerImpl::GetCookieStore, diff --git a/libcef/browser/menu_model_impl.cc b/libcef/browser/menu_model_impl.cc index 4b8d741d7..66b11c148 100644 --- a/libcef/browser/menu_model_impl.cc +++ b/libcef/browser/menu_model_impl.cc @@ -8,6 +8,7 @@ #include #include "libcef/browser/thread_util.h" +#include "libcef/common/task_runner_impl.h" #include "base/bind.h" #include "base/logging.h" @@ -793,7 +794,7 @@ void CefMenuModelImpl::MouseOutsideMenu(const gfx::Point& screen_point) { // Allow the callstack to unwind before notifying the delegate since it may // result in the menu being destroyed. - base::MessageLoop::current()->task_runner()->PostTask( + CefTaskRunnerImpl::GetCurrentTaskRunner()->PostTask( FROM_HERE, base::Bind(&CefMenuModelImpl::OnMouseOutsideMenu, this, screen_point)); } @@ -804,7 +805,7 @@ void CefMenuModelImpl::UnhandledOpenSubmenu(bool is_rtl) { // Allow the callstack to unwind before notifying the delegate since it may // result in the menu being destroyed. - base::MessageLoop::current()->task_runner()->PostTask( + CefTaskRunnerImpl::GetCurrentTaskRunner()->PostTask( FROM_HERE, base::Bind(&CefMenuModelImpl::OnUnhandledOpenSubmenu, this, is_rtl)); } @@ -815,7 +816,7 @@ void CefMenuModelImpl::UnhandledCloseSubmenu(bool is_rtl) { // Allow the callstack to unwind before notifying the delegate since it may // result in the menu being destroyed. - base::MessageLoop::current()->task_runner()->PostTask( + CefTaskRunnerImpl::GetCurrentTaskRunner()->PostTask( FROM_HERE, base::Bind(&CefMenuModelImpl::OnUnhandledCloseSubmenu, this, is_rtl)); } @@ -891,7 +892,7 @@ void CefMenuModelImpl::MenuWillClose() { // Due to how menus work on the different platforms, ActivatedAt will be // called after this. It's more convenient for the delegate to be called // afterwards, though, so post a task. - base::MessageLoop::current()->task_runner()->PostTask( + CefTaskRunnerImpl::GetCurrentTaskRunner()->PostTask( FROM_HERE, base::Bind(&CefMenuModelImpl::OnMenuClosed, this)); } diff --git a/libcef/browser/request_context_impl.cc b/libcef/browser/request_context_impl.cc index 25c126079..c3d2bd3f9 100644 --- a/libcef/browser/request_context_impl.cc +++ b/libcef/browser/request_context_impl.cc @@ -9,6 +9,7 @@ #include "libcef/browser/context.h" #include "libcef/browser/cookie_manager_impl.h" #include "libcef/browser/thread_util.h" +#include "libcef/common/task_runner_impl.h" #include "libcef/common/values_impl.h" #include "base/atomic_sequence_num.h" @@ -180,7 +181,7 @@ void CefRequestContextImpl::GetBrowserContext( scoped_refptr task_runner, const BrowserContextCallback& callback) { if (!task_runner.get()) - task_runner = base::MessageLoop::current()->task_runner(); + task_runner = CefTaskRunnerImpl::GetCurrentTaskRunner(); GetBrowserContextOnUIThread(task_runner, callback); } @@ -188,7 +189,7 @@ void CefRequestContextImpl::GetRequestContextImpl( scoped_refptr task_runner, const RequestContextCallback& callback) { if (!task_runner.get()) - task_runner = base::MessageLoop::current()->task_runner(); + task_runner = CefTaskRunnerImpl::GetCurrentTaskRunner(); if (request_context_getter_impl_) { // The browser context already exists. DCHECK(browser_context()); diff --git a/libcef/common/task_runner_impl.cc b/libcef/common/task_runner_impl.cc index b054a744b..5009d8cca 100644 --- a/libcef/common/task_runner_impl.cc +++ b/libcef/common/task_runner_impl.cc @@ -19,7 +19,7 @@ using content::BrowserThread; // static CefRefPtr CefTaskRunner::GetForCurrentThread() { - scoped_refptr task_runner = + scoped_refptr task_runner = CefTaskRunnerImpl::GetCurrentTaskRunner(); if (task_runner.get()) return new CefTaskRunnerImpl(task_runner); @@ -28,7 +28,7 @@ CefRefPtr CefTaskRunner::GetForCurrentThread() { // static CefRefPtr CefTaskRunner::GetForThread(CefThreadId threadId) { - scoped_refptr task_runner = + scoped_refptr task_runner = CefTaskRunnerImpl::GetTaskRunner(threadId); if (task_runner.get()) return new CefTaskRunnerImpl(task_runner); @@ -40,13 +40,13 @@ CefRefPtr CefTaskRunner::GetForThread(CefThreadId threadId) { // CefTaskRunnerImpl CefTaskRunnerImpl::CefTaskRunnerImpl( - scoped_refptr task_runner) + scoped_refptr task_runner) : task_runner_(task_runner) { DCHECK(task_runner_.get()); } // static -scoped_refptr CefTaskRunnerImpl::GetTaskRunner( +scoped_refptr CefTaskRunnerImpl::GetTaskRunner( CefThreadId threadId) { // Render process. if (threadId == TID_RENDERER) { @@ -95,9 +95,9 @@ scoped_refptr CefTaskRunnerImpl::GetTaskRunner( } // static -scoped_refptr +scoped_refptr CefTaskRunnerImpl::GetCurrentTaskRunner() { - scoped_refptr task_runner; + scoped_refptr task_runner; // For named browser process threads return the same TaskRunner as // GetTaskRunner(). Otherwise BelongsToThread() will return incorrect results. @@ -133,7 +133,7 @@ bool CefTaskRunnerImpl::BelongsToCurrentThread() { } bool CefTaskRunnerImpl::BelongsToThread(CefThreadId threadId) { - scoped_refptr task_runner = + scoped_refptr task_runner = GetTaskRunner(threadId); return (task_runner_ == task_runner); } diff --git a/libcef/common/task_runner_impl.h b/libcef/common/task_runner_impl.h index 0f2aeec9a..899171882 100644 --- a/libcef/common/task_runner_impl.h +++ b/libcef/common/task_runner_impl.h @@ -8,18 +8,18 @@ #include "include/cef_task.h" -#include "base/sequenced_task_runner.h" +#include "base/single_thread_task_runner.h" class CefTaskRunnerImpl : public CefTaskRunner { public: explicit CefTaskRunnerImpl( - scoped_refptr task_runner); + scoped_refptr task_runner); // Returns the task runner associated with |threadId|. - static scoped_refptr GetTaskRunner( + static scoped_refptr GetTaskRunner( CefThreadId threadId); // Returns the current task runner. - static scoped_refptr GetCurrentTaskRunner(); + static scoped_refptr GetCurrentTaskRunner(); // CefTaskRunner methods: bool IsSame(CefRefPtr that) override; @@ -29,7 +29,7 @@ class CefTaskRunnerImpl : public CefTaskRunner { bool PostDelayedTask(CefRefPtr task, int64 delay_ms) override; private: - scoped_refptr task_runner_; + scoped_refptr task_runner_; IMPLEMENT_REFCOUNTING(CefTaskRunnerImpl); DISALLOW_COPY_AND_ASSIGN(CefTaskRunnerImpl); diff --git a/libcef/common/urlrequest_impl.cc b/libcef/common/urlrequest_impl.cc index 45f1a05ac..b0a2f3ca0 100644 --- a/libcef/common/urlrequest_impl.cc +++ b/libcef/common/urlrequest_impl.cc @@ -5,6 +5,7 @@ #include "include/cef_urlrequest.h" #include "libcef/browser/browser_urlrequest_impl.h" #include "libcef/common/content_client.h" +#include "libcef/common/task_runner_impl.h" #include "libcef/renderer/render_urlrequest_impl.h" #include "base/logging.h" @@ -21,7 +22,7 @@ CefRefPtr CefURLRequest::Create( return NULL; } - if (!base::MessageLoop::current()) { + if (!CefTaskRunnerImpl::GetCurrentTaskRunner()) { NOTREACHED() << "called on invalid thread"; return NULL; } diff --git a/libcef/renderer/content_renderer_client.cc b/libcef/renderer/content_renderer_client.cc index f28a0a367..983a9d1b1 100644 --- a/libcef/renderer/content_renderer_client.cc +++ b/libcef/renderer/content_renderer_client.cc @@ -342,7 +342,7 @@ void CefContentRendererClient::DevToolsAgentDetached() { } } -scoped_refptr +scoped_refptr CefContentRendererClient::GetCurrentTaskRunner() { // Check if currently on the render thread. if (CEF_CURRENTLY_ON_RT()) diff --git a/libcef/renderer/content_renderer_client.h b/libcef/renderer/content_renderer_client.h index a95f87c3c..213810bcf 100644 --- a/libcef/renderer/content_renderer_client.h +++ b/libcef/renderer/content_renderer_client.h @@ -66,7 +66,7 @@ class CefContentRendererClient : public content::ContentRendererClient, void OnGuestViewDestroyed(CefGuestView* guest_view); // Render thread task runner. - base::SequencedTaskRunner* render_task_runner() const { + base::SingleThreadTaskRunner* render_task_runner() const { return render_task_runner_.get(); } @@ -82,7 +82,7 @@ class CefContentRendererClient : public content::ContentRendererClient, // Returns the task runner for the current thread. Returns NULL if the current // thread is not the main render process thread. - scoped_refptr GetCurrentTaskRunner(); + scoped_refptr GetCurrentTaskRunner(); // Perform cleanup work that needs to occur before shutdown when running in // single-process mode. Blocks until cleanup is complete. @@ -145,7 +145,7 @@ class CefContentRendererClient : public content::ContentRendererClient, // Perform cleanup work for single-process mode. void RunSingleProcessCleanupOnUIThread(); - scoped_refptr render_task_runner_; + scoped_refptr render_task_runner_; std::unique_ptr observer_; std::unique_ptr web_cache_impl_; std::unique_ptr spellcheck_; diff --git a/libcef/renderer/render_urlrequest_impl.cc b/libcef/renderer/render_urlrequest_impl.cc index b9757c11b..8498f0b42 100644 --- a/libcef/renderer/render_urlrequest_impl.cc +++ b/libcef/renderer/render_urlrequest_impl.cc @@ -8,6 +8,7 @@ #include "libcef/common/request_impl.h" #include "libcef/common/response_impl.h" +#include "libcef/common/task_runner_impl.h" #include "base/logging.h" #include "base/message_loop/message_loop.h" @@ -72,7 +73,7 @@ class CefRenderURLRequest::Context : url_request_(url_request), request_(request), client_(client), - task_runner_(base::MessageLoop::current()->task_runner()), + task_runner_(CefTaskRunnerImpl::GetCurrentTaskRunner()), status_(UR_IO_PENDING), error_code_(ERR_NONE), upload_data_size_(0), diff --git a/libcef/renderer/v8_impl.cc b/libcef/renderer/v8_impl.cc index 3eedd5375..bd07360f1 100644 --- a/libcef/renderer/v8_impl.cc +++ b/libcef/renderer/v8_impl.cc @@ -152,7 +152,7 @@ class CefV8IsolateManager { } v8::Isolate* isolate() const { return isolate_; } - scoped_refptr task_runner() const { + scoped_refptr task_runner() const { return task_runner_; } @@ -162,7 +162,7 @@ class CefV8IsolateManager { private: v8::Isolate* isolate_; - scoped_refptr task_runner_; + scoped_refptr task_runner_; typedef std::map> ContextMap; ContextMap context_map_; diff --git a/libcef/renderer/v8_impl.h b/libcef/renderer/v8_impl.h index 796902e73..1c5a60738 100644 --- a/libcef/renderer/v8_impl.h +++ b/libcef/renderer/v8_impl.h @@ -14,7 +14,7 @@ #include "base/location.h" #include "base/logging.h" #include "base/memory/ref_counted.h" -#include "base/sequenced_task_runner.h" +#include "base/single_thread_task_runner.h" #include "v8/include/v8.h" class CefTrackNode; @@ -103,7 +103,7 @@ class CefV8HandleBase bool BelongsToCurrentThread() const; v8::Isolate* isolate() const { return isolate_; } - scoped_refptr task_runner() const { + scoped_refptr task_runner() const { return task_runner_; } @@ -120,7 +120,7 @@ class CefV8HandleBase protected: v8::Isolate* isolate_; - scoped_refptr task_runner_; + scoped_refptr task_runner_; scoped_refptr context_state_; };