From 7e7592b298783435934c66963ebd646c9ece6a7f Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Tue, 3 Nov 2009 01:39:16 +0000 Subject: [PATCH] libcef: Update due to underlying chromium changes. - WebKit API changes. - Delay OnClose actions in WebSocketStreamHandleBridgeImpl. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@63 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- CHROMIUM_BUILD_COMPATIBILITY.txt | 1 + cef.gyp | 4 +- libcef/browser_socket_stream_bridge.cc | 55 ++++++++++++++++---------- libcef/browser_webkit_glue.cc | 4 +- libcef/browser_webkit_init.h | 16 +++++--- libcef/browser_webview_delegate.cc | 3 ++ libcef/browser_webview_delegate.h | 1 + 7 files changed, 54 insertions(+), 30 deletions(-) diff --git a/CHROMIUM_BUILD_COMPATIBILITY.txt b/CHROMIUM_BUILD_COMPATIBILITY.txt index d700465cb..e137b7009 100644 --- a/CHROMIUM_BUILD_COMPATIBILITY.txt +++ b/CHROMIUM_BUILD_COMPATIBILITY.txt @@ -45,3 +45,4 @@ Date | CEF Revision | Chromium Revision 2009-10-18 | /trunk@58 | /trunk@29378 2009-10-21 | /trunk@60 | /trunk@29687 2009-10-25 | /trunk@61 | /trunk@30028 +2009-11-02 | /trunk@63 | /trunk@30778 diff --git a/cef.gyp b/cef.gyp index 6052c1034..af94fe9dc 100644 --- a/cef.gyp +++ b/cef.gyp @@ -146,10 +146,10 @@ '../third_party/WebKit/JavaScriptCore/JavaScriptCore.gyp/JavaScriptCore.gyp:wtf', '../third_party/WebKit/WebCore/WebCore.gyp/WebCore.gyp:webcore', '../third_party/zlib/zlib.gyp:zlib', + '../webkit/api/WebKit.gyp:webkit', '../webkit/webkit.gyp:appcache', '../webkit/webkit.gyp:database', '../webkit/webkit.gyp:glue', - '../webkit/webkit.gyp:webkit', '../webkit/webkit.gyp:webkit_resources', '../webkit/webkit.gyp:webkit_strings', '../webkit/default_plugin/default_plugin.gyp:default_plugin', @@ -308,10 +308,10 @@ '../third_party/WebKit/JavaScriptCore/JavaScriptCore.gyp/JavaScriptCore.gyp:wtf', '../third_party/WebKit/WebCore/WebCore.gyp/WebCore.gyp:webcore', '../third_party/zlib/zlib.gyp:zlib', + '../webkit/api/WebKit.gyp:webkit', '../webkit/webkit.gyp:appcache', '../webkit/webkit.gyp:database', '../webkit/webkit.gyp:glue', - '../webkit/webkit.gyp:webkit', '../webkit/webkit.gyp:webkit_resources', '../webkit/webkit.gyp:webkit_strings', '../webkit/default_plugin/default_plugin.gyp:default_plugin', diff --git a/libcef/browser_socket_stream_bridge.cc b/libcef/browser_socket_stream_bridge.cc index 83a6c49c5..d987ccd6c 100644 --- a/libcef/browser_socket_stream_bridge.cc +++ b/libcef/browser_socket_stream_bridge.cc @@ -59,7 +59,7 @@ class WebSocketStreamHandleBridgeImpl void DoOnConnected(int max_amount_send_allowed); void DoOnSentData(int amount_sent); void DoOnReceivedData(std::vector* data); - void DoOnClose(webkit_glue::WebSocketStreamHandleDelegate* delegate); + void DoOnClose(); int socket_id_; MessageLoop* message_loop_; @@ -67,6 +67,8 @@ class WebSocketStreamHandleBridgeImpl webkit_glue::WebSocketStreamHandleDelegate* delegate_; scoped_refptr socket_; + // Number of pending tasks to handle net::SocketStream::Delegate methods. + int num_pending_tasks_; DISALLOW_COPY_AND_ASSIGN(WebSocketStreamHandleBridgeImpl); }; @@ -77,15 +79,16 @@ WebSocketStreamHandleBridgeImpl::WebSocketStreamHandleBridgeImpl( : socket_id_(kNoSocketId), message_loop_(MessageLoop::current()), handle_(handle), - delegate_(delegate) { + delegate_(delegate), + num_pending_tasks_(0) { } WebSocketStreamHandleBridgeImpl::~WebSocketStreamHandleBridgeImpl() { - CHECK(socket_id_ == kNoSocketId); + DCHECK_EQ(socket_id_, kNoSocketId); } void WebSocketStreamHandleBridgeImpl::Connect(const GURL& url) { - CHECK(g_io_thread); + DCHECK(g_io_thread); AddRef(); // Released in DoOnClose(). g_io_thread->PostTask( FROM_HERE, @@ -97,7 +100,7 @@ void WebSocketStreamHandleBridgeImpl::Connect(const GURL& url) { bool WebSocketStreamHandleBridgeImpl::Send( const std::vector& data) { - CHECK(g_io_thread); + DCHECK(g_io_thread); g_io_thread->PostTask( FROM_HERE, NewRunnableMethod(this, &WebSocketStreamHandleBridgeImpl::DoSend, @@ -106,7 +109,7 @@ bool WebSocketStreamHandleBridgeImpl::Send( } void WebSocketStreamHandleBridgeImpl::Close() { - CHECK(g_io_thread); + DCHECK(g_io_thread); g_io_thread->PostTask( FROM_HERE, NewRunnableMethod(this, &WebSocketStreamHandleBridgeImpl::DoClose)); @@ -114,6 +117,7 @@ void WebSocketStreamHandleBridgeImpl::Close() { void WebSocketStreamHandleBridgeImpl::OnConnected( net::SocketStream* socket, int max_pending_send_allowed) { + ++num_pending_tasks_; message_loop_->PostTask( FROM_HERE, NewRunnableMethod(this, &WebSocketStreamHandleBridgeImpl::DoOnConnected, @@ -122,6 +126,7 @@ void WebSocketStreamHandleBridgeImpl::OnConnected( void WebSocketStreamHandleBridgeImpl::OnSentData( net::SocketStream* socket, int amount_sent) { + ++num_pending_tasks_; message_loop_->PostTask( FROM_HERE, NewRunnableMethod(this, &WebSocketStreamHandleBridgeImpl::DoOnSentData, @@ -130,6 +135,7 @@ void WebSocketStreamHandleBridgeImpl::OnSentData( void WebSocketStreamHandleBridgeImpl::OnReceivedData( net::SocketStream* socket, const char* data, int len) { + ++num_pending_tasks_; message_loop_->PostTask( FROM_HERE, NewRunnableMethod(this, @@ -138,25 +144,24 @@ void WebSocketStreamHandleBridgeImpl::OnReceivedData( } void WebSocketStreamHandleBridgeImpl::OnClose(net::SocketStream* socket) { - webkit_glue::WebSocketStreamHandleDelegate* delegate = delegate_; - delegate_ = NULL; - socket_ = 0; + ++num_pending_tasks_; + // Release socket_ on IO thread. + socket_ = NULL; socket_id_ = kNoSocketId; message_loop_->PostTask( FROM_HERE, - NewRunnableMethod(this, &WebSocketStreamHandleBridgeImpl::DoOnClose, - delegate)); + NewRunnableMethod(this, &WebSocketStreamHandleBridgeImpl::DoOnClose)); } void WebSocketStreamHandleBridgeImpl::DoConnect(const GURL& url) { - CHECK(MessageLoop::current() == g_io_thread); + DCHECK(MessageLoop::current() == g_io_thread); socket_ = new net::SocketStream(url, this); socket_->set_context(g_request_context); socket_->Connect(); } void WebSocketStreamHandleBridgeImpl::DoSend(std::vector* data) { - CHECK(MessageLoop::current() == g_io_thread); + DCHECK(MessageLoop::current() == g_io_thread); scoped_ptr > scoped_data(data); if (!socket_) return; @@ -165,7 +170,7 @@ void WebSocketStreamHandleBridgeImpl::DoSend(std::vector* data) { } void WebSocketStreamHandleBridgeImpl::DoClose() { - CHECK(MessageLoop::current() == g_io_thread); + DCHECK(MessageLoop::current() == g_io_thread); if (!socket_) return; socket_->Close(); @@ -173,29 +178,37 @@ void WebSocketStreamHandleBridgeImpl::DoClose() { void WebSocketStreamHandleBridgeImpl::DoOnConnected( int max_pending_send_allowed) { - CHECK(MessageLoop::current() == message_loop_); + DCHECK(MessageLoop::current() == message_loop_); + --num_pending_tasks_; if (delegate_) delegate_->DidOpenStream(handle_, max_pending_send_allowed); } void WebSocketStreamHandleBridgeImpl::DoOnSentData(int amount_sent) { - CHECK(MessageLoop::current() == message_loop_); + DCHECK(MessageLoop::current() == message_loop_); + --num_pending_tasks_; if (delegate_) delegate_->DidSendData(handle_, amount_sent); } void WebSocketStreamHandleBridgeImpl::DoOnReceivedData( std::vector* data) { - CHECK(MessageLoop::current() == message_loop_); + DCHECK(MessageLoop::current() == message_loop_); + --num_pending_tasks_; scoped_ptr > scoped_data(data); if (delegate_) delegate_->DidReceiveData(handle_, &(data->at(0)), data->size()); } -void WebSocketStreamHandleBridgeImpl::DoOnClose( - webkit_glue::WebSocketStreamHandleDelegate* delegate) { - CHECK(MessageLoop::current() == message_loop_); - CHECK(!socket_); +void WebSocketStreamHandleBridgeImpl::DoOnClose() { + DCHECK(MessageLoop::current() == message_loop_); + --num_pending_tasks_; + // Don't handle OnClose if there are pending tasks. + DCHECK_EQ(num_pending_tasks_, 0); + DCHECK(!socket_); + DCHECK_EQ(socket_id_, kNoSocketId); + webkit_glue::WebSocketStreamHandleDelegate* delegate = delegate_; + delegate_ = NULL; if (delegate) delegate->DidClose(handle_); Release(); diff --git a/libcef/browser_webkit_glue.cc b/libcef/browser_webkit_glue.cc index b7367fa69..4f2f250e6 100644 --- a/libcef/browser_webkit_glue.cc +++ b/libcef/browser_webkit_glue.cc @@ -9,7 +9,7 @@ MSVC_PUSH_WARNING_LEVEL(0); #include "Cache.h" #include "TextEncoding.h" -#include "webkit/glue/webframe_impl.h" +#include "webkit/api/src/WebFrameImpl.h" MSVC_POP_WARNING(); #include "browser_webkit_glue.h" @@ -29,6 +29,8 @@ MSVC_POP_WARNING(); // Generated by GRIT #include "grit/webkit_resources.h" +using WebKit::WebFrameImpl; + namespace webkit_glue { bool IsMediaPlayerAvailable() { diff --git a/libcef/browser_webkit_init.h b/libcef/browser_webkit_init.h index cd7e400a4..4eaba1c81 100644 --- a/libcef/browser_webkit_init.h +++ b/libcef/browser_webkit_init.h @@ -18,6 +18,7 @@ #include "webkit/extensions/v8/interval_extension.h" #include "webkit/api/public/WebCString.h" #include "webkit/api/public/WebData.h" +#include "webkit/api/public/WebRuntimeFeatures.h" #include "webkit/api/public/WebKit.h" #include "webkit/api/public/WebScriptController.h" #include "webkit/api/public/WebSecurityPolicy.h" @@ -50,14 +51,13 @@ class BrowserWebKitInit : public webkit_glue::WebKitClientImpl { extensions_v8::GearsExtension::Get()); WebKit::WebScriptController::registerExtension( extensions_v8::IntervalExtension::Get()); - WebKit::enableWebSockets(); + WebKit::WebRuntimeFeatures::enableSockets(true); // Load libraries for media and enable the media player. FilePath module_path; - if (PathService::Get(base::DIR_MODULE, &module_path) && - media::InitializeMediaLibrary(module_path)) { - WebKit::enableMediaPlayer(); - } + WebKit::WebRuntimeFeatures::enableMediaPlayer( + PathService::Get(base::DIR_MODULE, &module_path) && + media::InitializeMediaLibrary(module_path)); // Construct and initialize an appcache system for this scope. // A new empty temp directory is created to house any cached @@ -200,7 +200,11 @@ class BrowserWebKitInit : public webkit_glue::WebKitClientImpl { return BrowserAppCacheSystem::CreateApplicationCacheHost(client); } - private: + virtual WebKit::WebSharedWorkerRepository* sharedWorkerRepository() { + return NULL; + } + +private: webkit_glue::SimpleWebMimeRegistryImpl mime_registry_; webkit_glue::WebClipboardImpl clipboard_; ScopedTempDir appcache_dir_; diff --git a/libcef/browser_webview_delegate.cc b/libcef/browser_webview_delegate.cc index 30cc1e01d..c5734dea5 100644 --- a/libcef/browser_webview_delegate.cc +++ b/libcef/browser_webview_delegate.cc @@ -341,6 +341,9 @@ void BrowserWebViewDelegate::setStatusText(const WebString& text) { void BrowserWebViewDelegate::setMouseOverURL(const WebURL& url) { } +void BrowserWebViewDelegate::setKeyboardFocusURL(const WebKit::WebURL& url) { +} + void BrowserWebViewDelegate::setToolTipText( const WebString& text, WebTextDirection hint) { } diff --git a/libcef/browser_webview_delegate.h b/libcef/browser_webview_delegate.h index 4c55a204d..d13903c6a 100644 --- a/libcef/browser_webview_delegate.h +++ b/libcef/browser_webview_delegate.h @@ -103,6 +103,7 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient, WebKit::WebFrame* frame, const WebKit::WebContextMenuData& data); virtual void setStatusText(const WebKit::WebString& text); virtual void setMouseOverURL(const WebKit::WebURL& url); + virtual void setKeyboardFocusURL(const WebKit::WebURL& url); virtual void setToolTipText( const WebKit::WebString& text, WebKit::WebTextDirection hint); virtual void startDragging(