From a46069c097661074cd9e9e7f2983463f9d6a045a Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Thu, 11 Feb 2010 18:33:33 +0000 Subject: [PATCH] libcef: Update due to underlying chromium changes. - Database and AppCache changes. - New cookie policy class. - Add StdStringToWebString and WebStringToStdString to browser_webkit_glue.{h,cc} because webkit/glue/glue_util.{h,cc} have been deleted. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@71 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- CHROMIUM_BUILD_COMPATIBILITY.txt | 1 + libcef/browser_appcache_system.cc | 14 ++++++++++++- libcef/browser_appcache_system.h | 2 +- libcef/browser_database_system.cc | 23 +++++++++++++++++++--- libcef/browser_database_system.h | 3 +++ libcef/browser_impl.cc | 2 +- libcef/browser_request_context.cc | 11 +++++++---- libcef/browser_resource_loader_bridge.cc | 13 +++++++----- libcef/browser_resource_loader_bridge.h | 4 ++-- libcef/browser_webkit_glue.cc | 14 ++++++++++++- libcef/browser_webkit_glue.h | 5 +++++ libcef/browser_webkit_init.h | 25 ++++++++---------------- libcef/browser_webview_delegate.cc | 15 +++++++++++--- libcef/browser_webview_delegate.h | 1 + libcef/request_impl.cc | 2 +- libcef/simple_clipboard_impl.cc | 2 -- 16 files changed, 96 insertions(+), 41 deletions(-) diff --git a/CHROMIUM_BUILD_COMPATIBILITY.txt b/CHROMIUM_BUILD_COMPATIBILITY.txt index 456f35e8d..ce9b4069b 100644 --- a/CHROMIUM_BUILD_COMPATIBILITY.txt +++ b/CHROMIUM_BUILD_COMPATIBILITY.txt @@ -48,3 +48,4 @@ Date | CEF Revision | Chromium Revision 2009-11-02 | /trunk@63 | /trunk@30778 2009-11-04 | /trunk@64 | /trunk@31062 2010-01-11 | /trunk@65 | /trunk@35902 +2010-02-11 | /trunk@71 | /trunk@38776 diff --git a/libcef/browser_appcache_system.cc b/libcef/browser_appcache_system.cc index 378aa1515..6d7fba375 100644 --- a/libcef/browser_appcache_system.cc +++ b/libcef/browser_appcache_system.cc @@ -280,16 +280,28 @@ BrowserAppCacheSystem::BrowserAppCacheSystem() instance_ = this; } +static void SignalEvent(base::WaitableEvent* event) { + event->Signal(); +} + BrowserAppCacheSystem::~BrowserAppCacheSystem() { DCHECK(!io_message_loop_ && !backend_impl_ && !service_); frontend_proxy_->clear_appcache_system(); // in case a task is in transit instance_ = NULL; + + if (db_thread_.IsRunning()) { + // We pump a task thru the db thread to ensure any tasks previously + // scheduled on that thread have been performed prior to return. + base::WaitableEvent event(false, false); + db_thread_.message_loop()->PostTask(FROM_HERE, + NewRunnableFunction(&SignalEvent, &event)); + event.Wait(); + } } void BrowserAppCacheSystem::InitOnUIThread( const FilePath& cache_directory) { DCHECK(!ui_message_loop_); - DCHECK(!cache_directory.empty()); AppCacheThread::InitIDs(DB_THREAD_ID, IO_THREAD_ID); ui_message_loop_ = MessageLoop::current(); cache_directory_ = cache_directory; diff --git a/libcef/browser_appcache_system.h b/libcef/browser_appcache_system.h index ec8a5d6b8..5896eaa8c 100644 --- a/libcef/browser_appcache_system.h +++ b/libcef/browser_appcache_system.h @@ -126,7 +126,7 @@ class BrowserAppCacheSystem : public MessageLoop::DestructionObserver { return io_message_loop_ && is_initailized_on_ui_thread(); } bool is_initailized_on_ui_thread() { - return ui_message_loop_ && !cache_directory_.empty(); + return ui_message_loop_ ? true : false; } static MessageLoop* GetMessageLoop(int id) { if (instance_) { diff --git a/libcef/browser_database_system.cc b/libcef/browser_database_system.cc index af9c11851..66c8f0679 100644 --- a/libcef/browser_database_system.cc +++ b/libcef/browser_database_system.cc @@ -10,7 +10,9 @@ #include "third_party/sqlite/preprocessed/sqlite3.h" #endif +#include "base/auto_reset.h" #include "base/file_util.h" +#include "base/message_loop.h" #include "base/platform_thread.h" #include "base/process_util.h" #include "third_party/WebKit/WebKit/chromium/public/WebDatabase.h" @@ -29,14 +31,17 @@ BrowserDatabaseSystem* BrowserDatabaseSystem::GetInstance() { return instance_; } -BrowserDatabaseSystem::BrowserDatabaseSystem() { +BrowserDatabaseSystem::BrowserDatabaseSystem() + : waiting_for_dbs_to_close_(false) { temp_dir_.CreateUniqueTempDir(); db_tracker_ = new DatabaseTracker(temp_dir_.path()); + db_tracker_->AddObserver(this); DCHECK(!instance_); instance_ = this; } BrowserDatabaseSystem::~BrowserDatabaseSystem() { + db_tracker_->RemoveObserver(this); instance_ = NULL; } @@ -113,6 +118,9 @@ void BrowserDatabaseSystem::DatabaseClosed(const string16& origin_identifier, origin_identifier, database_name)); db_tracker_->DatabaseClosed(origin_identifier, database_name); database_connections_.RemoveConnection(origin_identifier, database_name); + + if (waiting_for_dbs_to_close_ && database_connections_.IsEmpty()) + MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); } void BrowserDatabaseSystem::OnDatabaseSizeChanged( @@ -144,13 +152,22 @@ void BrowserDatabaseSystem::databaseClosed(const WebKit::WebDatabase& database) } void BrowserDatabaseSystem::ClearAllDatabases() { - db_tracker_->CloseDatabases(database_connections_); - database_connections_.RemoveAllConnections(); + // Wait for all databases to be closed. + if (!database_connections_.IsEmpty()) { + AutoReset waiting_for_dbs_auto_reset(&waiting_for_dbs_to_close_, true); + MessageLoop::ScopedNestableTaskAllower nestable(MessageLoop::current()); + MessageLoop::current()->Run(); + } + db_tracker_->CloseTrackerDatabaseAndClearCaches(); file_util::Delete(db_tracker_->DatabaseDirectory(), true); file_names_.clear(); } +void BrowserDatabaseSystem::SetDatabaseQuota(int64 quota) { + db_tracker_->SetDefaultQuota(quota); +} + void BrowserDatabaseSystem::SetFullFilePathsForVfsFile( const string16& origin_identifier, const string16& database_name) { diff --git a/libcef/browser_database_system.h b/libcef/browser_database_system.h index 6748d2097..2f50a2011 100644 --- a/libcef/browser_database_system.h +++ b/libcef/browser_database_system.h @@ -53,6 +53,7 @@ class BrowserDatabaseSystem : public webkit_database::DatabaseTracker::Observer, virtual void databaseClosed(const WebKit::WebDatabase& database); void ClearAllDatabases(); + void SetDatabaseQuota(int64 quota); private: // The calls that come from the database tracker run on the main thread. @@ -68,6 +69,8 @@ class BrowserDatabaseSystem : public webkit_database::DatabaseTracker::Observer, static BrowserDatabaseSystem* instance_; + bool waiting_for_dbs_to_close_; + ScopedTempDir temp_dir_; scoped_refptr db_tracker_; diff --git a/libcef/browser_impl.cc b/libcef/browser_impl.cc index 6dbd2daf7..500630899 100644 --- a/libcef/browser_impl.cc +++ b/libcef/browser_impl.cc @@ -5,6 +5,7 @@ #include "context.h" #include "browser_impl.h" +#include "browser_webkit_glue.h" #include "request_impl.h" #include "base/string_util.h" @@ -16,7 +17,6 @@ #include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h" #include "third_party/WebKit/WebKit/chromium/public/WebView.h" #include "webkit/glue/glue_serialize.h" -#include "webkit/glue/glue_util.h" using WebKit::WebFrame; using WebKit::WebHTTPBody; diff --git a/libcef/browser_request_context.cc b/libcef/browser_request_context.cc index 775c6792d..41f961e16 100644 --- a/libcef/browser_request_context.cc +++ b/libcef/browser_request_context.cc @@ -11,6 +11,7 @@ #include "net/base/cookie_monster.h" #include "net/base/host_resolver.h" #include "net/base/ssl_config_service.h" +#include "net/base/static_cookie_policy.h" #include "net/ftp/ftp_network_layer.h" #include "net/proxy/proxy_config_service.h" #include "net/proxy/proxy_config_service_fixed.h" @@ -32,7 +33,8 @@ void BrowserRequestContext::Init( const FilePath& cache_path, net::HttpCache::Mode cache_mode, bool no_proxy) { - cookie_store_ = new net::CookieMonster(); + cookie_store_ = new net::CookieMonster(NULL); + cookie_policy_ = new net::StaticCookiePolicy(); // hard-code A-L and A-C for test shells accept_language_ = "en-us,en"; @@ -41,17 +43,17 @@ void BrowserRequestContext::Init( // Use the system proxy settings. scoped_ptr proxy_config_service( net::ProxyService::CreateSystemProxyConfigService(NULL, NULL)); - host_resolver_ = net::CreateSystemHostResolver(); + host_resolver_ = net::CreateSystemHostResolver(NULL); proxy_service_ = net::ProxyService::Create(proxy_config_service.release(), false, NULL, NULL, NULL); ssl_config_service_ = net::SSLConfigService::CreateSystemSSLConfigService(); net::HttpCache *cache; if (cache_path.empty()) { - cache = new net::HttpCache(host_resolver_, proxy_service_, + cache = new net::HttpCache(NULL, host_resolver_, proxy_service_, ssl_config_service_, 0); } else { - cache = new net::HttpCache(host_resolver_, proxy_service_, + cache = new net::HttpCache(NULL, host_resolver_, proxy_service_, ssl_config_service_, cache_path, 0); } cache->set_mode(cache_mode); @@ -63,6 +65,7 @@ void BrowserRequestContext::Init( BrowserRequestContext::~BrowserRequestContext() { delete ftp_transaction_factory_; delete http_transaction_factory_; + delete static_cast(cookie_policy_); } const std::string& BrowserRequestContext::GetUserAgent( diff --git a/libcef/browser_resource_loader_bridge.cc b/libcef/browser_resource_loader_bridge.cc index 4178ba138..c1798a056 100644 --- a/libcef/browser_resource_loader_bridge.cc +++ b/libcef/browser_resource_loader_bridge.cc @@ -50,6 +50,7 @@ #include "net/base/load_flags.h" #include "net/base/net_errors.h" #include "net/base/net_util.h" +#include "net/base/static_cookie_policy.h" #include "net/base/upload_data.h" #include "net/http/http_response_headers.h" #include "net/http/http_util.h" @@ -61,8 +62,8 @@ #include "webkit/glue/resource_loader_bridge.h" using webkit_glue::ResourceLoaderBridge; -using net::CookiePolicy; using net::HttpResponseHeaders; +using net::StaticCookiePolicy; namespace { @@ -762,7 +763,7 @@ bool FindProxyForUrl(const GURL& url, std::string* proxy_list) { //----------------------------------------------------------------------------- // static -void BrowserResourceLoaderBridge::Init(URLRequestContext* context) { +void BrowserResourceLoaderBridge::Init(BrowserRequestContext* context) { // Make sure to stop any existing IO thread since it may be using the // current request context. Shutdown(); @@ -836,7 +837,9 @@ bool BrowserResourceLoaderBridge::EnsureIOThread() { // static void BrowserResourceLoaderBridge::SetAcceptAllCookies(bool accept_all_cookies) { - CookiePolicy::Type policy_type = accept_all_cookies ? - CookiePolicy::ALLOW_ALL_COOKIES : CookiePolicy::BLOCK_THIRD_PARTY_COOKIES; - request_context->cookie_policy()->set_type(policy_type); + StaticCookiePolicy::Type policy_type = accept_all_cookies ? + StaticCookiePolicy::ALLOW_ALL_COOKIES : + StaticCookiePolicy::BLOCK_THIRD_PARTY_COOKIES; + static_cast(request_context->cookie_policy())-> + set_type(policy_type); } diff --git a/libcef/browser_resource_loader_bridge.h b/libcef/browser_resource_loader_bridge.h index d4f4ba20a..ee5c3f956 100644 --- a/libcef/browser_resource_loader_bridge.h +++ b/libcef/browser_resource_loader_bridge.h @@ -9,7 +9,7 @@ #include class GURL; -class URLRequestContext; +class BrowserRequestContext; class BrowserResourceLoaderBridge { public: @@ -23,7 +23,7 @@ class BrowserResourceLoaderBridge { // NOTE: If this function is not called, then a default request context will // be initialized lazily. // - static void Init(URLRequestContext* context); + static void Init(BrowserRequestContext* context); // Call this function to shutdown the simple resource loader bridge. static void Shutdown(); diff --git a/libcef/browser_webkit_glue.cc b/libcef/browser_webkit_glue.cc index e87711f1c..02e0c01e8 100644 --- a/libcef/browser_webkit_glue.cc +++ b/libcef/browser_webkit_glue.cc @@ -20,10 +20,11 @@ MSVC_POP_WARNING(); #include "base/resource_util.h" #include "base/scoped_ptr.h" #include "base/string16.h" +#include "base/string_util.h" #include "base/win_util.h" #include "net/base/mime_util.h" #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" -#include "webkit/glue/glue_util.h" +#include "third_party/WebKit/WebKit/chromium/public/WebString.h" #include "webkit/glue/webkit_glue.h" // Generated by GRIT @@ -204,4 +205,15 @@ void ClearCache() WebCore::cache()->setDisabled(false); } +WebKit::WebString StdStringToWebString(const std::string& str) { + return WebKit::WebString::fromUTF8(str.data(), str.size()); +} + +std::string WebStringToStdString(const WebKit::WebString& str) { + std::string ret; + if (!str.isNull()) + UTF16ToUTF8(str.data(), str.length(), &ret); + return ret; +} + } // namespace webkit_glue diff --git a/libcef/browser_webkit_glue.h b/libcef/browser_webkit_glue.h index a2b0abe88..e1e34d77a 100644 --- a/libcef/browser_webkit_glue.h +++ b/libcef/browser_webkit_glue.h @@ -12,6 +12,7 @@ namespace WebKit { class WebFrame; +class WebString; class WebView; } @@ -38,4 +39,8 @@ v8::Handle GetV8Context(WebKit::WebFrame* frame); // Clear all cached data. void ClearCache(); +WebKit::WebString StdStringToWebString(const std::string& str); + +std::string WebStringToStdString(const WebKit::WebString& str); + } // namespace webkit_glue diff --git a/libcef/browser_webkit_init.h b/libcef/browser_webkit_init.h index da095223f..5fbeb49b8 100644 --- a/libcef/browser_webkit_init.h +++ b/libcef/browser_webkit_init.h @@ -61,8 +61,13 @@ class BrowserWebKitInit : public webkit_glue::WebKitClientImpl { // Construct and initialize an appcache system for this scope. // A new empty temp directory is created to house any cached // content during the run. Upon exit that directory is deleted. - if (appcache_dir_.CreateUniqueTempDir()) - BrowserAppCacheSystem::InitializeOnUIThread(appcache_dir_.path()); + // If we can't create a tempdir, we'll use in-memory storage. + if (!appcache_dir_.CreateUniqueTempDir()) { + LOG(WARNING) << "Failed to create a temp dir for the appcache, " + "using in-memory storage."; + DCHECK(appcache_dir_.path().empty()); + } + BrowserAppCacheSystem::InitializeOnUIThread(appcache_dir_.path()); WebKit::WebDatabase::setObserver(&database_system_); } @@ -177,24 +182,11 @@ class BrowserWebKitInit : public webkit_glue::WebKitClientImpl { quota); } - virtual WebKit::WebStorageNamespace* createSessionStorageNamespace() { - return WebKit::WebStorageNamespace::createSessionStorageNamespace(); - } - void dispatchStorageEvent(const WebKit::WebString& key, const WebKit::WebString& old_value, const WebKit::WebString& new_value, const WebKit::WebString& origin, const WebKit::WebURL& url, bool is_local_storage) { - // TODO(jorlow): Implement - if (!is_local_storage) - return; - - if (!dom_storage_event_dispatcher_.get()) { - dom_storage_event_dispatcher_.reset( - WebKit::WebStorageEventDispatcher::create()); - } - dom_storage_event_dispatcher_->dispatchStorageEvent( - key, old_value, new_value, origin, url, is_local_storage); + // The event is dispatched by the proxy. } virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost( @@ -212,7 +204,6 @@ class BrowserWebKitInit : public webkit_glue::WebKitClientImpl { ScopedTempDir appcache_dir_; BrowserAppCacheSystem appcache_system_; BrowserDatabaseSystem database_system_; - scoped_ptr dom_storage_event_dispatcher_; }; #endif // _BROWSER_WEBKIT_INIT_H diff --git a/libcef/browser_webview_delegate.cc b/libcef/browser_webview_delegate.cc index 9190dd86c..3cdd24fca 100644 --- a/libcef/browser_webview_delegate.cc +++ b/libcef/browser_webview_delegate.cc @@ -37,6 +37,7 @@ #include "third_party/WebKit/WebKit/chromium/public/WebPopupMenu.h" #include "third_party/WebKit/WebKit/chromium/public/WebRange.h" #include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" +#include "third_party/WebKit/WebKit/chromium/public/WebStorageNamespace.h" #include "third_party/WebKit/WebKit/chromium/public/WebString.h" #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" #include "third_party/WebKit/WebKit/chromium/public/WebURLError.h" @@ -44,9 +45,8 @@ #include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h" #include "third_party/WebKit/WebKit/chromium/public/WebVector.h" #include "third_party/WebKit/WebKit/chromium/public/WebView.h" -#include "webkit/appcache/appcache_interfaces.h" +#include "webkit/appcache/web_application_cache_host_impl.h" #include "webkit/glue/glue_serialize.h" -#include "webkit/glue/glue_util.h" #include "webkit/glue/media/buffered_data_source.h" #include "webkit/glue/media/media_resource_loader_bridge_factory.h" #include "webkit/glue/media/simple_data_source.h" @@ -66,6 +66,7 @@ #include "browser_drop_delegate.h" #endif +using appcache::WebApplicationCacheHostImpl; using WebKit::WebConsoleMessage; using WebKit::WebContextMenuData; using WebKit::WebData; @@ -90,6 +91,7 @@ using WebKit::WebRect; using WebKit::WebScreenInfo; using WebKit::WebSecurityOrigin; using WebKit::WebSize; +using WebKit::WebStorageNamespace; using WebKit::WebString; using WebKit::WebTextAffinity; using WebKit::WebTextDirection; @@ -139,6 +141,10 @@ WebWidget* BrowserWebViewDelegate::createPopupMenu( return browser_->UIT_CreatePopupWidget(); } +WebStorageNamespace* BrowserWebViewDelegate::createSessionStorageNamespace() { + return WebKit::WebStorageNamespace::createSessionStorageNamespace(); +} + void BrowserWebViewDelegate::didAddMessageToConsole( const WebConsoleMessage& message, const WebString& source_name, unsigned source_line) { @@ -452,6 +458,9 @@ WebMediaPlayer* BrowserWebViewDelegate::createMediaPlayer( scoped_refptr factory = new media::FilterFactoryCollection(); + WebApplicationCacheHostImpl* appcache_host = + WebApplicationCacheHostImpl::FromFrame(frame); + // TODO(hclam): this is the same piece of code as in RenderView, maybe they // should be grouped together. webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory = @@ -460,7 +469,7 @@ WebMediaPlayer* BrowserWebViewDelegate::createMediaPlayer( "null", // frame origin "null", // main_frame_origin base::GetCurrentProcId(), - appcache::kNoHostId, + appcache_host ? appcache_host->host_id() : appcache::kNoHostId, 0); // A simple data source that keeps all data in memory. media::FilterFactory* simple_data_source_factory = diff --git a/libcef/browser_webview_delegate.h b/libcef/browser_webview_delegate.h index 1d85a26ae..b2238dc79 100644 --- a/libcef/browser_webview_delegate.h +++ b/libcef/browser_webview_delegate.h @@ -49,6 +49,7 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient, virtual WebKit::WebWidget* createPopupMenu(bool activatable); virtual WebKit::WebWidget* createPopupMenu( const WebKit::WebPopupMenuInfo& info); + virtual WebKit::WebStorageNamespace* createSessionStorageNamespace(); virtual void didAddMessageToConsole( const WebKit::WebConsoleMessage& message, const WebKit::WebString& source_name, unsigned source_line); diff --git a/libcef/request_impl.cc b/libcef/request_impl.cc index 39f7deea2..279cb334a 100644 --- a/libcef/request_impl.cc +++ b/libcef/request_impl.cc @@ -3,6 +3,7 @@ // can be found in the LICENSE file. #include "request_impl.h" +#include "browser_webkit_glue.h" #include "base/logging.h" #include "base/string_util.h" @@ -10,7 +11,6 @@ #include "net/http/http_util.h" #include "net/url_request/url_request.h" #include "third_party/WebKit/WebKit/chromium/public/WebHTTPHeaderVisitor.h" -#include "webkit/glue/glue_util.h" using net::HttpResponseHeaders; diff --git a/libcef/simple_clipboard_impl.cc b/libcef/simple_clipboard_impl.cc index 62b08b090..2f370d9d5 100644 --- a/libcef/simple_clipboard_impl.cc +++ b/libcef/simple_clipboard_impl.cc @@ -15,12 +15,10 @@ // Clipboard glue -#if defined(OS_WIN) void ScopedClipboardWriterGlue::WriteBitmapFromPixels( const void* pixels, const gfx::Size& size) { ScopedClipboardWriter::WriteBitmapFromPixels(pixels, size); } -#endif ScopedClipboardWriterGlue::~ScopedClipboardWriterGlue() { }