diff options
34 files changed, 586 insertions, 379 deletions
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index c19c8e2..b029ec4 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -44,6 +44,7 @@ 'theme_resources', '../base/base.gyp:test_support_base', '../content/content.gyp:content_gpu', + '../content/content.gyp:content_renderer', '../content/content.gyp:test_support_content', '../ipc/ipc.gyp:test_support_ipc', '../media/media.gyp:media_test_support', diff --git a/chrome/renderer/blocked_plugin.cc b/chrome/renderer/blocked_plugin.cc index 4582c8e..7d8fac8 100644 --- a/chrome/renderer/blocked_plugin.cc +++ b/chrome/renderer/blocked_plugin.cc @@ -11,7 +11,7 @@ #include "chrome/common/render_messages.h" #include "chrome/renderer/plugin_uma.h" #include "content/common/view_messages.h" -#include "content/renderer/render_thread.h" +#include "content/public/renderer/render_thread.h" #include "content/renderer/render_view.h" #include "grit/generated_resources.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" @@ -44,6 +44,7 @@ using WebKit::WebPoint; using WebKit::WebRegularExpression; using WebKit::WebString; using WebKit::WebVector; +using content::RenderThread; static const char* const kBlockedPluginDataURL = "chrome://blockedplugindata/"; // TODO(cevans) - move these to a shared header file so that there are no @@ -165,16 +166,16 @@ void BlockedPlugin::ContextMenuAction(unsigned id) { if (g_last_active_menu != this) return; if (id == kMenuActionLoad) { - RenderThread::RecordUserMetrics("Plugin_Load_Menu"); + RenderThread::Get()->RecordUserMetrics("Plugin_Load_Menu"); LoadPlugin(); } else if (id == kMenuActionRemove) { - RenderThread::RecordUserMetrics("Plugin_Hide_Menu"); + RenderThread::Get()->RecordUserMetrics("Plugin_Hide_Menu"); HidePlugin(); } } void BlockedPlugin::OnLoadBlockedPlugins() { - RenderThread::RecordUserMetrics("Plugin_Load_UI"); + RenderThread::Get()->RecordUserMetrics("Plugin_Load_UI"); LoadPlugin(); } @@ -212,12 +213,12 @@ void BlockedPlugin::LoadPlugin() { } void BlockedPlugin::Load(const CppArgumentList& args, CppVariant* result) { - RenderThread::RecordUserMetrics("Plugin_Load_Click"); + RenderThread::Get()->RecordUserMetrics("Plugin_Load_Click"); LoadPlugin(); } void BlockedPlugin::Hide(const CppArgumentList& args, CppVariant* result) { - RenderThread::RecordUserMetrics("Plugin_Hide_Click"); + RenderThread::Get()->RecordUserMetrics("Plugin_Hide_Click"); HidePlugin(); } diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc index 06033bf..68da99d 100644 --- a/chrome/renderer/chrome_content_renderer_client.cc +++ b/chrome/renderer/chrome_content_renderer_client.cc @@ -58,7 +58,7 @@ #include "chrome/renderer/spellchecker/spellcheck_provider.h" #include "chrome/renderer/translate_helper.h" #include "chrome/renderer/visitedlink_slave.h" -#include "content/renderer/render_thread.h" +#include "content/public/renderer/render_thread.h" #include "content/renderer/render_view.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" @@ -80,8 +80,6 @@ #include "webkit/plugins/npapi/plugin_list.h" #include "webkit/plugins/ppapi/plugin_module.h" -using autofill::AutofillAgent; -using autofill::PasswordAutofillManager; using WebKit::WebCache; using WebKit::WebDataSource; using WebKit::WebFrame; @@ -95,6 +93,9 @@ using WebKit::WebURLError; using WebKit::WebURLRequest; using WebKit::WebURLResponse; using WebKit::WebVector; +using autofill::AutofillAgent; +using autofill::PasswordAutofillManager; +using content::RenderThread; namespace { @@ -160,7 +161,7 @@ void ChromeContentRendererClient::RenderThreadStarted() { phishing_classifier_.reset(safe_browsing::PhishingClassifierFilter::Create()); #endif - RenderThread* thread = RenderThread::current(); + RenderThread* thread = RenderThread::Get(); thread->AddObserver(chrome_observer_.get()); thread->AddObserver(extension_dispatcher_.get()); @@ -191,7 +192,7 @@ void ChromeContentRendererClient::RenderThreadStarted() { if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableIPCFuzzing)) { - thread->channel()->set_outgoing_message_filter(LoadExternalIPCFuzzer()); + thread->GetChannel()->set_outgoing_message_filter(LoadExternalIPCFuzzer()); } // chrome:, chrome-devtools:, and chrome-internal: pages should not be // accessible by normal content, and should also be unable to script @@ -482,12 +483,12 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin( observer->DidBlockContentType(content_type, resource); if (plugin_setting == CONTENT_SETTING_ASK) { - RenderThread::RecordUserMetrics("Plugin_ClickToPlay"); + RenderThread::Get()->RecordUserMetrics("Plugin_ClickToPlay"); return CreatePluginPlaceholder( render_view, frame, params, group.get(), IDR_CLICK_TO_PLAY_PLUGIN_HTML, IDS_PLUGIN_LOAD, false, true); } else { - RenderThread::RecordUserMetrics("Plugin_Blocked"); + RenderThread::Get()->RecordUserMetrics("Plugin_Blocked"); return CreatePluginPlaceholder( render_view, frame, params, group.get(), IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_BLOCKED, false, true); @@ -779,7 +780,7 @@ bool ChromeContentRendererClient::CrossesExtensionExtents( void ChromeContentRendererClient::OnPurgeMemory() { DVLOG(1) << "Resetting spellcheck in renderer client"; - RenderThread* thread = RenderThread::current(); + RenderThread* thread = RenderThread::Get(); if (spellcheck_.get()) thread->RemoveObserver(spellcheck_.get()); SpellCheck* new_spellcheck = new SpellCheck(); diff --git a/chrome/renderer/chrome_ppapi_interfaces.cc b/chrome/renderer/chrome_ppapi_interfaces.cc index 818b1d9..8fcdc71 100644 --- a/chrome/renderer/chrome_ppapi_interfaces.cc +++ b/chrome/renderer/chrome_ppapi_interfaces.cc @@ -11,7 +11,7 @@ #include "chrome/common/render_messages.h" #include "chrome/renderer/chrome_ppb_pdf_impl.h" #include "content/common/content_switches.h" -#include "content/renderer/render_thread.h" +#include "content/public/renderer/render_thread.h" #include "ppapi/c/private/ppb_nacl_private.h" #include "ppapi/c/private/ppb_pdf.h" #include "webkit/plugins/ppapi/ppapi_interface_factory.h" @@ -21,6 +21,8 @@ #include "ppapi/native_client/src/trusted/plugin/nacl_entry_points.h" #endif +using content::RenderThread; + namespace chrome { // Launch NaCl's sel_ldr process. @@ -30,13 +32,13 @@ bool LaunchSelLdr(const char* alleged_url, int socket_count, #if !defined(DISABLE_NACL) std::vector<nacl::FileDescriptor> sockets; base::ProcessHandle nacl_process; - if (!RenderThread::current()->Send( - new ChromeViewHostMsg_LaunchNaCl( - ASCIIToWide(alleged_url), - socket_count, - &sockets, - &nacl_process, - reinterpret_cast<base::ProcessId*>(nacl_process_id)))) { + if (!RenderThread::Get()->Send( + new ChromeViewHostMsg_LaunchNaCl( + ASCIIToWide(alleged_url), + socket_count, + &sockets, + &nacl_process, + reinterpret_cast<base::ProcessId*>(nacl_process_id)))) { return false; } CHECK(static_cast<int>(sockets.size()) == socket_count); diff --git a/chrome/renderer/chrome_ppb_pdf_impl.cc b/chrome/renderer/chrome_ppb_pdf_impl.cc index 67f1d94..7df306b 100644 --- a/chrome/renderer/chrome_ppb_pdf_impl.cc +++ b/chrome/renderer/chrome_ppb_pdf_impl.cc @@ -9,7 +9,7 @@ #include "build/build_config.h" #include "chrome/common/render_messages.h" #include "content/common/child_process_sandbox_support_linux.h" -#include "content/renderer/render_thread.h" +#include "content/public/renderer/render_thread.h" #include "content/renderer/render_view.h" #include "grit/webkit_resources.h" #include "grit/webkit_strings.h" @@ -36,6 +36,7 @@ #include "webkit/plugins/ppapi/resource_tracker.h" using WebKit::WebView; +using content::RenderThread; namespace chrome { @@ -240,7 +241,7 @@ void SearchString(PP_Instance instance, UErrorCode status = U_ZERO_ERROR; UStringSearch* searcher = usearch_open( - term, -1, string, -1, RenderThread::GetLocale().c_str(), 0, + term, -1, string, -1, RenderThread::Get()->GetLocale().c_str(), 0, &status); DCHECK(status == U_ZERO_ERROR || status == U_USING_FALLBACK_WARNING || status == U_USING_DEFAULT_WARNING); @@ -310,9 +311,8 @@ void HistogramPDFPageCount(int count) { void UserMetricsRecordAction(PP_Var action) { scoped_refptr<ppapi::StringVar> action_str( ppapi::StringVar::FromPPVar(action)); - if (action_str) { - RenderThread::RecordUserMetrics(action_str->value()); - } + if (action_str) + RenderThread::Get()->RecordUserMetrics(action_str->value()); } void HasUnsupportedFeature(PP_Instance instance_id) { diff --git a/chrome/renderer/chrome_render_process_observer.cc b/chrome/renderer/chrome_render_process_observer.cc index 6617b0b..7ef53d5 100644 --- a/chrome/renderer/chrome_render_process_observer.cc +++ b/chrome/renderer/chrome_render_process_observer.cc @@ -23,8 +23,8 @@ #include "content/common/resource_dispatcher.h" #include "content/common/resource_dispatcher_delegate.h" #include "content/common/view_messages.h" +#include "content/public/renderer/render_thread.h" #include "content/public/renderer/render_view_visitor.h" -#include "content/renderer/render_thread.h" #include "content/renderer/render_view.h" #include "crypto/nss_util.h" #include "media/base/media.h" @@ -51,6 +51,7 @@ using WebKit::WebCache; using WebKit::WebCrossOriginPreflightResultCache; using WebKit::WebFontCache; using WebKit::WebRuntimeFeatures; +using content::RenderThread; namespace { @@ -91,15 +92,14 @@ class RendererResourceDelegate : public ResourceDispatcherDelegate { const std::string& mime_type, const GURL& url) { return ExtensionLocalizationPeer::CreateExtensionLocalizationPeer( - current_peer, RenderThread::current(), mime_type, url); + current_peer, RenderThread::Get(), mime_type, url); } private: void InformHostOfCacheStats() { WebCache::UsageStats stats; WebCache::getUsageStats(&stats); - RenderThread::current()->Send(new ChromeViewHostMsg_UpdatedCacheStats( - stats)); + RenderThread::Get()->Send(new ChromeViewHostMsg_UpdatedCacheStats(stats)); } ScopedRunnableMethodFactory<RendererResourceDelegate> method_factory_; @@ -158,9 +158,9 @@ DWORD WINAPI GetFontDataPatch(HDC hdc, LOGFONT logfont; if (GetObject(font, sizeof(LOGFONT), &logfont)) { std::vector<char> font_data; - if (RenderThread::PreCacheFont(logfont)) - rv = GetFontData(hdc, table, offset, buffer, length); - RenderThread::ReleaseCachedFonts(); + RenderThread::Get()->PreCacheFont(logfont); + rv = GetFontData(hdc, table, offset, buffer, length); + RenderThread::Get()->ReleaseCachedFonts(); } } return rv; @@ -207,9 +207,9 @@ ChromeRenderProcessObserver::ChromeRenderProcessObserver( base::StatisticsRecorder::set_dump_on_exit(true); } - RenderThread* thread = RenderThread::current(); + RenderThread* thread = RenderThread::Get(); resource_delegate_.reset(new RendererResourceDelegate()); - thread->resource_dispatcher()->set_delegate(resource_delegate_.get()); + thread->GetResourceDispatcher()->set_delegate(resource_delegate_.get()); #if defined(OS_POSIX) thread->AddFilter(new SuicideOnChannelErrorFilter()); @@ -326,7 +326,7 @@ void ChromeRenderProcessObserver::OnClearCache(bool on_navigation) { void ChromeRenderProcessObserver::OnGetCacheResourceStats() { WebCache::ResourceTypeStats stats; WebCache::getResourceTypeStats(&stats); - RenderThread::current()->Send(new ChromeViewHostMsg_ResourceTypeStats(stats)); + RenderThread::Get()->Send(new ChromeViewHostMsg_ResourceTypeStats(stats)); } #if defined(USE_TCMALLOC) @@ -335,7 +335,7 @@ void ChromeRenderProcessObserver::OnGetRendererTcmalloc() { char buffer[1024 * 32]; MallocExtension::instance()->GetStats(buffer, sizeof(buffer)); result.append(buffer); - RenderThread::current()->Send(new ChromeViewHostMsg_RendererTcmalloc(result)); + RenderThread::Get()->Send(new ChromeViewHostMsg_RendererTcmalloc(result)); } void ChromeRenderProcessObserver::OnSetTcmallocHeapProfiling( @@ -364,7 +364,7 @@ void ChromeRenderProcessObserver::OnWriteTcmallocHeapProfile( // a string and pass it to the handler (which runs on the browser host). std::string result(profile); delete profile; - RenderThread::current()->Send( + RenderThread::Get()->Send( new ChromeViewHostMsg_WriteTcmallocHeapProfile_ACK(filename, result)); #endif } @@ -380,7 +380,7 @@ void ChromeRenderProcessObserver::OnSetFieldTrialGroup( void ChromeRenderProcessObserver::OnGetV8HeapStats() { v8::HeapStatistics heap_stats; v8::V8::GetHeapStatistics(&heap_stats); - RenderThread::current()->Send(new ChromeViewHostMsg_V8HeapStats( + RenderThread::Get()->Send(new ChromeViewHostMsg_V8HeapStats( heap_stats.total_heap_size(), heap_stats.used_heap_size())); } diff --git a/chrome/renderer/extensions/chrome_v8_context_set.cc b/chrome/renderer/extensions/chrome_v8_context_set.cc index e518b21..fee6ca5 100644 --- a/chrome/renderer/extensions/chrome_v8_context_set.cc +++ b/chrome/renderer/extensions/chrome_v8_context_set.cc @@ -7,10 +7,11 @@ #include "base/logging.h" #include "base/message_loop.h" #include "base/tracked_objects.h" +#include "base/values.h" #include "chrome/renderer/extensions/chrome_v8_context.h" #include "content/common/url_constants.h" +#include "content/public/renderer/render_thread.h" #include "content/public/renderer/v8_value_converter.h" -#include "content/renderer/render_thread.h" #include "content/renderer/render_view.h" #include "v8/include/v8.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" @@ -19,6 +20,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" +using content::RenderThread; using content::V8ValueConverter; namespace { @@ -79,7 +81,7 @@ void ChromeV8ContextSet::Remove(ChromeV8Context* context) { context->clear_web_frame(); MessageLoop* loop = delete_loop_ ? delete_loop_ : - RenderThread::current()->message_loop(); + RenderThread::Get()->GetMessageLoop(); loop->DeleteSoon(FROM_HERE, context); } } diff --git a/chrome/renderer/extensions/event_bindings.cc b/chrome/renderer/extensions/event_bindings.cc index 988c6fd..03cc664 100644 --- a/chrome/renderer/extensions/event_bindings.cc +++ b/chrome/renderer/extensions/event_bindings.cc @@ -19,7 +19,7 @@ #include "chrome/renderer/extensions/extension_dispatcher.h" #include "chrome/renderer/extensions/extension_process_bindings.h" #include "chrome/renderer/extensions/user_script_slave.h" -#include "content/renderer/render_thread.h" +#include "content/public/renderer/render_thread.h" #include "content/renderer/render_view.h" #include "googleurl/src/gurl.h" #include "grit/renderer_resources.h" @@ -34,11 +34,12 @@ using WebKit::WebFrame; using WebKit::WebSecurityOrigin; using WebKit::WebURL; +using content::RenderThread; namespace { // Keep a local cache of RenderThread so that we can mock it out for unit tests. -static RenderThreadBase* render_thread = NULL; +static RenderThread* render_thread = NULL; // A map of event names to the number of listeners for that event. We notify // the browser about event listeners when we transition between 0 and 1. @@ -173,11 +174,11 @@ v8::Extension* EventBindings::Get(ExtensionDispatcher* dispatcher) { } // static -void EventBindings::SetRenderThread(RenderThreadBase* thread) { +void EventBindings::SetRenderThread(RenderThread* thread) { render_thread = thread; } // static -RenderThreadBase* EventBindings::GetRenderThread() { - return render_thread ? render_thread : RenderThread::current(); +RenderThread* EventBindings::GetRenderThread() { + return render_thread ? render_thread : RenderThread::Get(); } diff --git a/chrome/renderer/extensions/event_bindings.h b/chrome/renderer/extensions/event_bindings.h index 42c9450..b983684 100644 --- a/chrome/renderer/extensions/event_bindings.h +++ b/chrome/renderer/extensions/event_bindings.h @@ -7,7 +7,10 @@ #pragma once class ExtensionDispatcher; -class RenderThreadBase; + +namespace content { +class RenderThread; +} namespace v8 { class Extension; @@ -20,8 +23,8 @@ class EventBindings { // Allow RenderThread to be mocked out. It would be better if // RenderView::current() worked inside tests. See crbug.com/98375. - static void SetRenderThread(RenderThreadBase* thread); - static RenderThreadBase* GetRenderThread(); + static void SetRenderThread(content::RenderThread* thread); + static content::RenderThread* GetRenderThread(); }; #endif // CHROME_RENDERER_EXTENSIONS_EVENT_BINDINGS_H_ diff --git a/chrome/renderer/extensions/extension_dispatcher.cc b/chrome/renderer/extensions/extension_dispatcher.cc index 3adcd77..792496c 100644 --- a/chrome/renderer/extensions/extension_dispatcher.cc +++ b/chrome/renderer/extensions/extension_dispatcher.cc @@ -21,7 +21,7 @@ #include "chrome/renderer/extensions/extension_process_bindings.h" #include "chrome/renderer/extensions/renderer_extension_bindings.h" #include "chrome/renderer/extensions/user_script_slave.h" -#include "content/renderer/render_thread.h" +#include "content/public/renderer/render_thread.h" #include "grit/renderer_resources.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" @@ -39,6 +39,7 @@ using WebKit::WebDataSource; using WebKit::WebFrame; using WebKit::WebSecurityPolicy; using WebKit::WebString; +using content::RenderThread; ExtensionDispatcher::ExtensionDispatcher() : is_webkit_initialized_(false) { @@ -48,7 +49,7 @@ ExtensionDispatcher::ExtensionDispatcher() command_line.HasSwitch(switches::kSingleProcess); if (is_extension_process_) { - RenderThread::current()->set_idle_notification_delay_in_s( + RenderThread::Get()->SetIdleNotificationDelayInS( kInitialExtensionIdleHandlerDelayS); } @@ -85,7 +86,7 @@ void ExtensionDispatcher::WebKitInitialized() { if (is_extension_process_) { forced_idle_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(kMaxExtensionIdleHandlerDelayS), - RenderThread::current(), &RenderThread::IdleHandler); + RenderThread::Get(), &RenderThread::IdleHandler); } RegisterExtension(extensions_v8::ChromeAppExtension::Get(this), false); @@ -117,12 +118,12 @@ void ExtensionDispatcher::IdleNotification() { // Dampen the forced delay as well if the extension stays idle for long // periods of time. int64 forced_delay_s = std::max(static_cast<int64>( - RenderThread::current()->idle_notification_delay_in_s()), + RenderThread::Get()->GetIdleNotificationDelayInS()), kMaxExtensionIdleHandlerDelayS); forced_idle_timer_.Stop(); forced_idle_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(forced_delay_s), - RenderThread::current(), &RenderThread::IdleHandler); + RenderThread::Get(), &RenderThread::IdleHandler); } } @@ -143,7 +144,7 @@ void ExtensionDispatcher::OnMessageInvoke(const std::string& extension_id, // Reset the idle handler each time there's any activity like event or message // dispatch, for which Invoke is the chokepoint. if (is_extension_process_) { - RenderThread::current()->ScheduleIdleHandler( + RenderThread::Get()->ScheduleIdleHandler( kInitialExtensionIdleHandlerDelayS); } } @@ -200,11 +201,11 @@ bool ExtensionDispatcher::AllowScriptExtension( const std::string& v8_extension_name, int extension_group) { // NULL in unit tests. - if (!RenderThread::current()) + if (!RenderThread::Get()) return true; // If we don't know about it, it was added by WebCore, so we should allow it. - if (!RenderThread::current()->IsRegisteredExtension(v8_extension_name)) + if (!RenderThread::Get()->IsRegisteredExtension(v8_extension_name)) return true; // If the V8 extension is not restricted, allow it to run anywhere. @@ -271,8 +272,7 @@ void ExtensionDispatcher::OnActivateExtension( // This is called when starting a new extension page, so start the idle // handler ticking. - RenderThread::current()->ScheduleIdleHandler( - kInitialExtensionIdleHandlerDelayS); + RenderThread::Get()->ScheduleIdleHandler(kInitialExtensionIdleHandlerDelayS); UpdateActiveExtensions(); @@ -378,5 +378,5 @@ void ExtensionDispatcher::RegisterExtension(v8::Extension* extension, if (restrict_to_extensions) restricted_v8_extensions_.insert(extension->name()); - RenderThread::current()->RegisterExtension(extension); + RenderThread::Get()->RegisterExtension(extension); } diff --git a/chrome/renderer/extensions/extension_dispatcher.h b/chrome/renderer/extensions/extension_dispatcher.h index b76c8ad..5b6f4b5 100644 --- a/chrome/renderer/extensions/extension_dispatcher.h +++ b/chrome/renderer/extensions/extension_dispatcher.h @@ -18,18 +18,21 @@ #include "v8/include/v8.h" class GURL; -class RenderThread; class URLPattern; class UserScriptSlave; struct ExtensionMsg_Loaded_Params; struct ExtensionMsg_UpdatePermissions_Params; +namespace WebKit { +class WebFrame; +} + namespace base { class ListValue; } -namespace WebKit { -class WebFrame; +namespace content { +class RenderThread; } // Dispatches extension control messages sent to the renderer and stores @@ -125,7 +128,7 @@ class ExtensionDispatcher : public content::RenderProcessObserver { // Same as above, but on a longer timer and will run even if the process is // not idle, to ensure that IdleHandle gets called eventually. - base::RepeatingTimer<RenderThread> forced_idle_timer_; + base::RepeatingTimer<content::RenderThread> forced_idle_timer_; // The v8 extensions which are restricted to extension-related contexts. std::set<std::string> restricted_v8_extensions_; diff --git a/chrome/renderer/extensions/renderer_extension_bindings.cc b/chrome/renderer/extensions/renderer_extension_bindings.cc index 33b8fa6..0571c77 100644 --- a/chrome/renderer/extensions/renderer_extension_bindings.cc +++ b/chrome/renderer/extensions/renderer_extension_bindings.cc @@ -17,7 +17,7 @@ #include "chrome/renderer/extensions/chrome_v8_extension.h" #include "chrome/renderer/extensions/event_bindings.h" #include "chrome/renderer/extensions/extension_dispatcher.h" -#include "content/renderer/render_thread.h" +#include "content/public/renderer/render_thread.h" #include "content/renderer/render_view.h" #include "grit/renderer_resources.h" #include "v8/include/v8.h" @@ -32,6 +32,8 @@ // port.postMessage('I got your reponse'); // }); +using content::RenderThread; + namespace { struct ExtensionData { diff --git a/chrome/renderer/extensions/user_script_slave.cc b/chrome/renderer/extensions/user_script_slave.cc index 8cc9703..c53789e 100644 --- a/chrome/renderer/extensions/user_script_slave.cc +++ b/chrome/renderer/extensions/user_script_slave.cc @@ -19,7 +19,7 @@ #include "chrome/renderer/chrome_render_process_observer.h" #include "chrome/renderer/extensions/extension_dispatcher.h" #include "chrome/renderer/extensions/extension_groups.h" -#include "content/renderer/render_thread.h" +#include "content/public/renderer/render_thread.h" #include "googleurl/src/gurl.h" #include "grit/renderer_resources.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" @@ -38,6 +38,7 @@ using WebKit::WebSecurityPolicy; using WebKit::WebString; using WebKit::WebVector; using WebKit::WebView; +using content::RenderThread; // These two strings are injected before and after the Greasemonkey API and // user script to wrap it in an anonymous scope. @@ -192,7 +193,7 @@ bool UserScriptSlave::UpdateScripts(base::SharedMemoryHandle shared_memory) { } // Push user styles down into WebCore - RenderThread::current()->EnsureWebKitInitialized(); + RenderThread::Get()->EnsureWebKitInitialized(); WebView::removeAllUserContent(); for (size_t i = 0; i < scripts_.size(); ++i) { UserScript* script = scripts_[i]; diff --git a/chrome/renderer/localized_error.cc b/chrome/renderer/localized_error.cc index b238b1d..681d783 100644 --- a/chrome/renderer/localized_error.cc +++ b/chrome/renderer/localized_error.cc @@ -11,7 +11,7 @@ #include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/common/extensions/extension_set.h" -#include "content/renderer/render_thread.h" +#include "content/public/renderer/render_thread.h" #include "googleurl/src/gurl.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" @@ -26,6 +26,7 @@ #endif using WebKit::WebURLError; +using content::RenderThread; namespace { @@ -614,7 +615,7 @@ void LocalizedError::GetStrings(const WebKit::WebURLError& error, if (learn_more_url.is_valid()) { // Add the language parameter to the URL. std::string query = learn_more_url.query() + "&hl=" + - RenderThread::GetLocale(); + RenderThread::Get()->GetLocale(); GURL::Replacements repl; repl.SetQueryStr(query); diff --git a/chrome/renderer/mock_render_thread.cc b/chrome/renderer/mock_render_thread.cc index 0e074d6..e20e7cc 100644 --- a/chrome/renderer/mock_render_thread.cc +++ b/chrome/renderer/mock_render_thread.cc @@ -33,35 +33,6 @@ MockRenderThread::MockRenderThread() MockRenderThread::~MockRenderThread() { } -// Called by the Widget. The routing_id must match the routing id assigned -// to the Widget in reply to ViewHostMsg_CreateWidget message. -void MockRenderThread::AddRoute(int32 routing_id, - IPC::Channel::Listener* listener) { - EXPECT_EQ(routing_id_, routing_id); - widget_ = listener; -} - -// Called by the Widget. The routing id must match the routing id of AddRoute. -void MockRenderThread::RemoveRoute(int32 routing_id) { - EXPECT_EQ(routing_id_, routing_id); - widget_ = NULL; -} - -// Called by, for example, RenderView::Init(), when adding a new message filter. -void MockRenderThread::AddFilter(IPC::ChannelProxy::MessageFilter* filter) { - filter->OnFilterAdded(&sink()); -} - -// Called when the filter is removed. -void MockRenderThread::RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) { - filter->OnFilterRemoved(); -} - - -bool MockRenderThread::IsIncognitoProcess() const { - return false; -} - // Called by the Widget. Used to send messages to the browser. // We short-circuit the mechanism and handle the messages right here on this // class. @@ -87,6 +58,95 @@ bool MockRenderThread::Send(IPC::Message* msg) { return true; } +MessageLoop* MockRenderThread::GetMessageLoop() { + return NULL; +} + +IPC::SyncChannel* MockRenderThread::GetChannel() { + return NULL; +} + +ResourceDispatcher* MockRenderThread::GetResourceDispatcher() { + return NULL; +} + +std::string MockRenderThread::GetLocale() { + return std::string(); +} + +void MockRenderThread::AddRoute(int32 routing_id, + IPC::Channel::Listener* listener) { + EXPECT_EQ(routing_id_, routing_id); + widget_ = listener; +} + +void MockRenderThread::RemoveRoute(int32 routing_id) { + EXPECT_EQ(routing_id_, routing_id); + widget_ = NULL; +} + +void MockRenderThread::AddFilter(IPC::ChannelProxy::MessageFilter* filter) { + filter->OnFilterAdded(&sink()); +} + +void MockRenderThread::RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) { + filter->OnFilterRemoved(); +} + +void MockRenderThread::SetOutgoingMessageFilter( + IPC::ChannelProxy::OutgoingMessageFilter* filter) { +} + +void MockRenderThread::AddObserver(content::RenderProcessObserver* observer) { +} + +void MockRenderThread::RemoveObserver( + content::RenderProcessObserver* observer) { +} + +void MockRenderThread::WidgetHidden() { +} + +void MockRenderThread::WidgetRestored() { +} + +void MockRenderThread::EnsureWebKitInitialized() { +} + +void MockRenderThread::RecordUserMetrics(const std::string& action) { +} + +void MockRenderThread::RegisterExtension(v8::Extension* extension) { +} + +bool MockRenderThread::IsRegisteredExtension( + const std::string& v8_extension_name) const { + return false; +} + +void MockRenderThread::ScheduleIdleHandler(double initial_delay_s) { +} + +void MockRenderThread::IdleHandler() { +} + +double MockRenderThread::GetIdleNotificationDelayInS() const { + return 0.0; +} + +void MockRenderThread::SetIdleNotificationDelayInS( + double idle_notification_delay_in_s) { +} + +#if defined(OS_WIN) +void MockRenderThread::PreCacheFont(const LOGFONT& log_font) { +} + +void MockRenderThread::ReleaseCachedFonts() { +} + +#endif // OS_WIN + void MockRenderThread::SendCloseMessage() { ViewMsg_Close msg(routing_id_); widget_->OnMessageReceived(msg); @@ -234,7 +294,7 @@ void MockRenderThread::OnCheckForCancel(const std::string& preview_ui_addr, void MockRenderThread::OnUpdatePrintSettings( int document_cookie, - const DictionaryValue& job_settings, + const base::DictionaryValue& job_settings, PrintMsg_PrintPages_Params* params) { // Check and make sure the required settings are all there. // We don't actually care about the values. @@ -258,7 +318,7 @@ void MockRenderThread::OnUpdatePrintSettings( printing::PageRanges new_ranges; if (job_settings.GetList(printing::kSettingPageRange, &page_range_array)) { for (size_t index = 0; index < page_range_array->GetSize(); ++index) { - DictionaryValue* dict; + base::DictionaryValue* dict; if (!page_range_array->GetDictionary(index, &dict)) continue; printing::PageRange range; diff --git a/chrome/renderer/mock_render_thread.h b/chrome/renderer/mock_render_thread.h index d0344b8..b697f2b 100644 --- a/chrome/renderer/mock_render_thread.h +++ b/chrome/renderer/mock_render_thread.h @@ -8,9 +8,11 @@ #include <string> +#include "base/compiler_specific.h" +#include "base/shared_memory.h" #include "chrome/common/extensions/extension_set.h" #include "chrome/renderer/mock_printer.h" -#include "content/renderer/render_thread.h" +#include "content/public/renderer/render_thread.h" #include "ipc/ipc_test_sink.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h" @@ -18,6 +20,10 @@ namespace IPC { class MessageReplyDeserializer; } +namespace base { +class DictionaryValue; +} + struct PrintHostMsg_DidGetPreviewPageCount_Params; struct PrintHostMsg_DidPreviewPage_Params; struct PrintHostMsg_ScriptedPrint_Params; @@ -28,7 +34,7 @@ struct PrintMsg_Print_Params; // which supports only two messages: // ViewHostMsg_CreateWidget : sync message sent by the Widget. // ViewMsg_Close : async, send to the Widget. -class MockRenderThread : public RenderThreadBase { +class MockRenderThread : public content::RenderThread { public: MockRenderThread(); virtual ~MockRenderThread(); @@ -36,27 +42,38 @@ class MockRenderThread : public RenderThreadBase { // Provides access to the messages that have been received by this thread. IPC::TestSink& sink() { return sink_; } - // Called by the Widget. The routing_id must match the routing id assigned - // to the Widget in reply to ViewHostMsg_CreateWidget message. - virtual void AddRoute(int32 routing_id, IPC::Channel::Listener* listener); - - // Called by the Widget. The routing id must match the routing id of AddRoute. - virtual void RemoveRoute(int32 routing_id); - - // Called by the Widget. Used to send messages to the browser. - // We short-circuit the mechanim and handle the messages right here on this - // class. - virtual bool Send(IPC::Message* msg); - - // Filtering support. - virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter); - virtual void RemoveFilter(IPC::ChannelProxy::MessageFilter* filter); - - // Our mock thread doesn't deal with hidden and restored tabs. - virtual void WidgetHidden() { } - virtual void WidgetRestored() { } - - virtual bool IsIncognitoProcess() const; + // content::RenderThread implementation: + virtual bool Send(IPC::Message* msg) OVERRIDE; + virtual MessageLoop* GetMessageLoop() OVERRIDE; + virtual IPC::SyncChannel* GetChannel() OVERRIDE; + virtual ResourceDispatcher* GetResourceDispatcher() OVERRIDE; + virtual std::string GetLocale() OVERRIDE; + virtual void AddRoute(int32 routing_id, + IPC::Channel::Listener* listener) OVERRIDE; + virtual void RemoveRoute(int32 routing_id) OVERRIDE; + virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter) OVERRIDE; + virtual void RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) OVERRIDE; + virtual void SetOutgoingMessageFilter( + IPC::ChannelProxy::OutgoingMessageFilter* filter) OVERRIDE; + virtual void AddObserver(content::RenderProcessObserver* observer) OVERRIDE; + virtual void RemoveObserver( + content::RenderProcessObserver* observer) OVERRIDE; + virtual void WidgetHidden() OVERRIDE; + virtual void WidgetRestored() OVERRIDE; + virtual void EnsureWebKitInitialized() OVERRIDE; + virtual void RecordUserMetrics(const std::string& action) OVERRIDE; + virtual void RegisterExtension(v8::Extension* extension) OVERRIDE; + virtual bool IsRegisteredExtension( + const std::string& v8_extension_name) const OVERRIDE; + virtual void ScheduleIdleHandler(double initial_delay_s) OVERRIDE; + virtual void IdleHandler() OVERRIDE; + virtual double GetIdleNotificationDelayInS() const OVERRIDE; + virtual void SetIdleNotificationDelayInS( + double idle_notification_delay_in_s) OVERRIDE; +#if defined(OS_WIN) + virtual void PreCacheFont(const LOGFONT& log_font) OVERRIDE; + virtual void ReleaseCachedFonts() OVERRIDE; +#endif ////////////////////////////////////////////////////////////////////////// // The following functions are called by the test itself. @@ -139,7 +156,7 @@ class MockRenderThread : public RenderThreadBase { // For print preview, PrintWebViewHelper will update settings. void OnUpdatePrintSettings(int document_cookie, - const DictionaryValue& job_settings, + const base::DictionaryValue& job_settings, PrintMsg_PrintPages_Params* params); IPC::TestSink sink_; diff --git a/chrome/renderer/net/renderer_net_predictor.cc b/chrome/renderer/net/renderer_net_predictor.cc index 16cc665..5037ec4 100644 --- a/chrome/renderer/net/renderer_net_predictor.cc +++ b/chrome/renderer/net/renderer_net_predictor.cc @@ -4,7 +4,6 @@ // See header file for description of RendererNetPredictor class - #include "chrome/renderer/net/renderer_net_predictor.h" #include <ctype.h> @@ -14,7 +13,9 @@ #include "chrome/common/net/predictor_common.h" #include "chrome/common/render_messages.h" #include "chrome/renderer/net/predictor_queue.h" -#include "content/renderer/render_thread.h" +#include "content/public/renderer/render_thread.h" + +using content::RenderThread; // The number of hostnames submitted to Browser DNS resolver per call to // SubmitHostsnames() (which reads names from our queue). @@ -52,7 +53,7 @@ void RendererNetPredictor::Resolve(const char* name, size_t length) { if (0 != old_size) return; // Overkill safety net: Don't send too many InvokeLater's. renderer_predictor_factory_.RevokeAll(); - RenderThread::current()->message_loop()->PostDelayedTask(FROM_HERE, + RenderThread::Get()->GetMessageLoop()->PostDelayedTask(FROM_HERE, renderer_predictor_factory_.NewRunnableMethod( &RendererNetPredictor::SubmitHostnames), 10); } @@ -86,7 +87,7 @@ void RendererNetPredictor::SubmitHostnames() { DnsPrefetchNames(kMAX_SUBMISSION_PER_TASK); if (new_name_count_ > 0 || 0 < c_string_queue_.Size()) { renderer_predictor_factory_.RevokeAll(); - RenderThread::current()->message_loop()->PostDelayedTask(FROM_HERE, + RenderThread::Get()->GetMessageLoop()->PostDelayedTask(FROM_HERE, renderer_predictor_factory_.NewRunnableMethod( &RendererNetPredictor::SubmitHostnames), 10); } else { @@ -142,7 +143,7 @@ void RendererNetPredictor::DnsPrefetchNames(size_t max_count) { DCHECK_GE(new_name_count_, names.size()); new_name_count_ -= names.size(); - RenderThread::current()->Send(new ChromeViewHostMsg_DnsPrefetch(names)); + RenderThread::Get()->Send(new ChromeViewHostMsg_DnsPrefetch(names)); } // is_numeric_ip() checks to see if all characters in name are either numeric, diff --git a/chrome/renderer/renderer_histogram_snapshots.cc b/chrome/renderer/renderer_histogram_snapshots.cc index 8cf4082..c72a8c2 100644 --- a/chrome/renderer/renderer_histogram_snapshots.cc +++ b/chrome/renderer/renderer_histogram_snapshots.cc @@ -10,12 +10,13 @@ #include "base/message_loop.h" #include "base/metrics/histogram.h" #include "chrome/common/render_messages.h" -#include "content/renderer/render_thread.h" +#include "content/public/renderer/render_thread.h" // TODO(raman): Before renderer shuts down send final snapshot lists. using base::Histogram; using base::StatisticsRecorder; +using content::RenderThread; RendererHistogramSnapshots::RendererHistogramSnapshots() : ALLOW_THIS_IN_INITIALIZER_LIST( @@ -27,7 +28,7 @@ RendererHistogramSnapshots::~RendererHistogramSnapshots() { // Send data quickly! void RendererHistogramSnapshots::SendHistograms(int sequence_number) { - RenderThread::current()->message_loop()->PostTask(FROM_HERE, + RenderThread::Get()->GetMessageLoop()->PostTask(FROM_HERE, renderer_histogram_snapshots_factory_.NewRunnableMethod( &RendererHistogramSnapshots::UploadAllHistrograms, sequence_number)); } @@ -55,9 +56,8 @@ void RendererHistogramSnapshots::UploadAllHistrograms(int sequence_number) { // Send the sequence number and list of pickled histograms over synchronous // IPC, so we can clear pickled_histograms_ afterwards. - RenderThread::current()->Send( - new ChromeViewHostMsg_RendererHistograms( - sequence_number, pickled_histograms_)); + RenderThread::Get()->Send(new ChromeViewHostMsg_RendererHistograms( + sequence_number, pickled_histograms_)); pickled_histograms_.clear(); } diff --git a/chrome/renderer/safe_browsing/phishing_classifier_delegate.cc b/chrome/renderer/safe_browsing/phishing_classifier_delegate.cc index 8b43c5f..5d0068f 100644 --- a/chrome/renderer/safe_browsing/phishing_classifier_delegate.cc +++ b/chrome/renderer/safe_browsing/phishing_classifier_delegate.cc @@ -17,7 +17,7 @@ #include "chrome/renderer/safe_browsing/phishing_classifier.h" #include "chrome/renderer/safe_browsing/scorer.h" #include "content/public/renderer/navigation_state.h" -#include "content/renderer/render_thread.h" +#include "content/public/renderer/render_thread.h" #include "content/renderer/render_view.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" @@ -25,6 +25,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" using content::NavigationState; +using content::RenderThread; namespace safe_browsing { @@ -203,7 +204,7 @@ void PhishingClassifierDelegate::ClassificationDone( << " score = " << verdict.client_score(); if (verdict.client_score() != PhishingClassifier::kInvalidScore) { DCHECK_EQ(last_url_sent_to_classifier_.spec(), verdict.url()); - RenderThread::current()->Send(new SafeBrowsingHostMsg_PhishingDetectionDone( + RenderThread::Get()->Send(new SafeBrowsingHostMsg_PhishingDetectionDone( routing_id(), verdict.SerializeAsString())); } } diff --git a/chrome/renderer/spellchecker/spellcheck.cc b/chrome/renderer/spellchecker/spellcheck.cc index d16ac0c..fb87366 100644 --- a/chrome/renderer/spellchecker/spellcheck.cc +++ b/chrome/renderer/spellchecker/spellcheck.cc @@ -11,10 +11,11 @@ #include "chrome/common/render_messages.h" #include "chrome/common/spellcheck_common.h" #include "chrome/common/spellcheck_messages.h" -#include "content/renderer/render_thread.h" +#include "content/public/renderer/render_thread.h" #include "third_party/hunspell/src/hunspell/hunspell.hxx" using base::TimeTicks; +using content::RenderThread; SpellCheck::SpellCheck() : file_(base::kInvalidPlatformFileValue), @@ -222,7 +223,7 @@ bool SpellCheck::InitializeIfNeeded() { return false; if (!initialized_) { - RenderThread::current()->Send(new SpellCheckHostMsg_RequestDictionary); + RenderThread::Get()->Send(new SpellCheckHostMsg_RequestDictionary); initialized_ = true; return true; } @@ -240,7 +241,7 @@ bool SpellCheck::CheckSpelling(const string16& word_to_check, int tag) { bool word_correct = false; if (is_using_platform_spelling_engine_) { - RenderThread::current()->Send(new SpellCheckHostMsg_PlatformCheckSpelling( + RenderThread::Get()->Send(new SpellCheckHostMsg_PlatformCheckSpelling( word_to_check, tag, &word_correct)); } else { std::string word_to_check_utf8(UTF16ToUTF8(word_to_check)); @@ -265,9 +266,8 @@ void SpellCheck::FillSuggestionList( const string16& wrong_word, std::vector<string16>* optional_suggestions) { if (is_using_platform_spelling_engine_) { - RenderThread::current()->Send( - new SpellCheckHostMsg_PlatformFillSuggestionList( - wrong_word, optional_suggestions)); + RenderThread::Get()->Send(new SpellCheckHostMsg_PlatformFillSuggestionList( + wrong_word, optional_suggestions)); return; } diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi index bc68a41..e460e85 100644 --- a/content/content_renderer.gypi +++ b/content/content_renderer.gypi @@ -28,6 +28,8 @@ 'public/renderer/navigation_state.h', 'public/renderer/render_process_observer.cc', 'public/renderer/render_process_observer.h', + 'public/renderer/render_thread.cc', + 'public/renderer/render_thread.h', 'public/renderer/render_view_observer.cc', 'public/renderer/render_view_observer.h', 'public/renderer/render_view_observer_tracker.h', diff --git a/content/public/renderer/render_thread.cc b/content/public/renderer/render_thread.cc new file mode 100644 index 0000000..3dc536f --- /dev/null +++ b/content/public/renderer/render_thread.cc @@ -0,0 +1,8 @@ +// Copyright (c) 2011 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. + +#include "content/public/renderer/render_thread.h" + +#include "base/lazy_instance.h" + diff --git a/content/public/renderer/render_thread.h b/content/public/renderer/render_thread.h new file mode 100644 index 0000000..3f1e964 --- /dev/null +++ b/content/public/renderer/render_thread.h @@ -0,0 +1,101 @@ +// Copyright (c) 2011 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 CONTENT_PUBLIC_RENDERER_RENDER_THREAD_H_ +#define CONTENT_PUBLIC_RENDERER_RENDER_THREAD_H_ + +#include "base/basictypes.h" +#include "content/common/content_export.h" +#include "ipc/ipc_channel_proxy.h" + +#if defined(OS_WIN) +#include <windows.h> +#endif + +class MessageLoop; +class ResourceDispatcher; + +namespace IPC { +class SyncChannel; +} + +namespace v8 { +class Extension; +} + +namespace content { + +class RenderProcessObserver; + +class CONTENT_EXPORT RenderThread : public IPC::Message::Sender { + public: + // Returns the one render thread for this process. Note that this can only + // be accessed when running on the render thread itself. + static RenderThread* Get(); + + RenderThread(); + virtual ~RenderThread(); + + virtual MessageLoop* GetMessageLoop() = 0; + virtual IPC::SyncChannel* GetChannel() = 0; + virtual ResourceDispatcher* GetResourceDispatcher() = 0; + virtual std::string GetLocale() = 0; + + // Called to add or remove a listener for a particular message routing ID. + // These methods normally get delegated to a MessageRouter. + virtual void AddRoute(int32 routing_id, IPC::Channel::Listener* listener) = 0; + virtual void RemoveRoute(int32 routing_id) = 0; + + // These map to IPC::ChannelProxy methods. + virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter) = 0; + virtual void RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) = 0; + virtual void SetOutgoingMessageFilter( + IPC::ChannelProxy::OutgoingMessageFilter* filter) = 0; + + // Add/remove observers for the process. + virtual void AddObserver(content::RenderProcessObserver* observer) = 0; + virtual void RemoveObserver(content::RenderProcessObserver* observer) = 0; + + // Called by a RenderWidget when it is hidden or restored. + virtual void WidgetHidden() = 0; + virtual void WidgetRestored() = 0; + + // We initialize WebKit as late as possible. Call this to force + // initialization. + virtual void EnsureWebKitInitialized() = 0; + + // Helper function to send over a string to be recorded by user metrics + virtual void RecordUserMetrics(const std::string& action) = 0; + + // Registers the given V8 extension with WebKit. + virtual void RegisterExtension(v8::Extension* extension) = 0; + + // Returns true iff the extension is registered. + virtual bool IsRegisteredExtension( + const std::string& v8_extension_name) const = 0; + + // Schedule a call to IdleHandler with the given initial delay. + virtual void ScheduleIdleHandler(double initial_delay_s) = 0; + + // A task we invoke periodically to assist with idle cleanup. + virtual void IdleHandler() = 0; + + // Get/Set the delay for how often the idle handler is called. + virtual double GetIdleNotificationDelayInS() const = 0; + virtual void SetIdleNotificationDelayInS( + double idle_notification_delay_in_s) = 0; + +#if defined(OS_WIN) + // Request that the given font be loaded by the browser so it's cached by the + // OS. Please see ChildProcessHost::PreCacheFont for details. + virtual void PreCacheFont(const LOGFONT& log_font) = 0; + + // Release cached font. + virtual void ReleaseCachedFonts() = 0; +#endif +}; + +} // namespace content + +#endif // CONTENT_PUBLIC_RENDERER_RENDER_THREAD_H_ diff --git a/content/renderer/render_thread.cc b/content/renderer/render_thread.cc index efd9d98..207236a 100644 --- a/content/renderer/render_thread.cc +++ b/content/renderer/render_thread.cc @@ -140,6 +140,29 @@ class RenderViewZoomer : public content::RenderViewVisitor { } // namespace +// TODO(jam): move this to content/public/renderer/render_thread.cc once this file is renamed +namespace content { + +// Keep the global RenderThread in a TLS slot so it is impossible to access +// incorrectly from the wrong thread. +static base::LazyInstance<base::ThreadLocalPointer<RenderThread> > lazy_tls( + base::LINKER_INITIALIZED); + +RenderThread* RenderThread::Get() { + return lazy_tls.Pointer()->Get(); +} + +RenderThread::RenderThread() { + lazy_tls.Pointer()->Set(this); +} + +RenderThread::~RenderThread() { + lazy_tls.Pointer()->Set(NULL); +} + +} // namespace content + + static void* CreateHistogram( const char *name, int min, int max, size_t buckets) { if (min <= 0) @@ -154,6 +177,10 @@ static void AddHistogramSample(void* hist, int sample) { histogram->Add(sample); } +RenderThread* RenderThread::current() { + return lazy_tls.Pointer()->Get(); +} + // When we run plugins in process, we actually run them on the render thread, // which means that we need to make the render thread pump UI events. RenderThread::RenderThread() { @@ -190,7 +217,7 @@ void RenderThread::Init() { idle_notification_delay_in_s_ = kInitialIdleHandlerDelayS; task_factory_.reset(new ScopedRunnableMethodFactory<RenderThread>(this)); - appcache_dispatcher_.reset(new AppCacheDispatcher(this)); + appcache_dispatcher_.reset(new AppCacheDispatcher(Get())); indexed_db_dispatcher_.reset(new IndexedDBDispatcher()); db_message_filter_ = new DBMessageFilter(); @@ -260,38 +287,6 @@ RenderThread::~RenderThread() { #endif } -RenderThread* RenderThread::current() { - return lazy_tls.Pointer()->Get(); -} - -std::string RenderThread::GetLocale() { - // The browser process should have passed the locale to the renderer via the - // --lang command line flag. In single process mode, this will return the - // wrong value. TODO(tc): Fix this for single process mode. - const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); - const std::string& lang = - parsed_command_line.GetSwitchValueASCII(switches::kLang); - DCHECK(!lang.empty() || - (!parsed_command_line.HasSwitch(switches::kRendererProcess) && - !parsed_command_line.HasSwitch(switches::kPluginProcess))); - return lang; -} - -int32 RenderThread::RoutingIDForCurrentContext() { - int32 routing_id = MSG_ROUTING_CONTROL; - if (v8::Context::InContext()) { - WebFrame* frame = WebFrame::frameForCurrentContext(); - if (frame) { - RenderView* view = RenderView::FromWebView(frame->view()); - if (view) - routing_id = view->routing_id(); - } - } else { - DLOG(WARNING) << "Not called within a script context!"; - } - return routing_id; -} - bool RenderThread::Send(IPC::Message* msg) { // Certain synchronous messages cannot always be processed synchronously by // the browser, e.g., Chrome frame communicating with the embedding browser. @@ -360,6 +355,31 @@ bool RenderThread::Send(IPC::Message* msg) { return rv; } +MessageLoop* RenderThread::GetMessageLoop() { + return message_loop(); +} + +IPC::SyncChannel* RenderThread::GetChannel() { + return channel(); +} + +ResourceDispatcher* RenderThread::GetResourceDispatcher() { + return resource_dispatcher(); +} + +std::string RenderThread::GetLocale() { + // The browser process should have passed the locale to the renderer via the + // --lang command line flag. In single process mode, this will return the + // wrong value. TODO(tc): Fix this for single process mode. + const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); + const std::string& lang = + parsed_command_line.GetSwitchValueASCII(switches::kLang); + DCHECK(!lang.empty() || + (!parsed_command_line.HasSwitch(switches::kRendererProcess) && + !parsed_command_line.HasSwitch(switches::kPluginProcess))); + return lang; +} + void RenderThread::AddRoute(int32 routing_id, IPC::Channel::Listener* listener) { widget_count_++; @@ -379,6 +399,18 @@ void RenderThread::RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) { channel()->RemoveFilter(filter); } +void RenderThread::SetOutgoingMessageFilter( + IPC::ChannelProxy::OutgoingMessageFilter* filter) { +} + +void RenderThread::AddObserver(content::RenderProcessObserver* observer) { + observers_.AddObserver(observer); +} + +void RenderThread::RemoveObserver(content::RenderProcessObserver* observer) { + observers_.RemoveObserver(observer); +} + void RenderThread::WidgetHidden() { DCHECK(hidden_widget_count_ < widget_count_); hidden_widget_count_++; @@ -403,37 +435,6 @@ void RenderThread::WidgetRestored() { idle_timer_.Stop(); } -void RenderThread::AddObserver(RenderProcessObserver* observer) { - observers_.AddObserver(observer); -} - -void RenderThread::RemoveObserver(RenderProcessObserver* observer) { - observers_.RemoveObserver(observer); -} - -void RenderThread::DoNotSuspendWebKitSharedTimer() { - suspend_webkit_shared_timer_ = false; -} - -void RenderThread::DoNotNotifyWebKitOfModalLoop() { - notify_webkit_of_modal_loop_ = false; -} - -void RenderThread::OnSetZoomLevelForCurrentURL(const GURL& url, - double zoom_level) { - RenderViewZoomer zoomer(url, zoom_level); - RenderView::ForEach(&zoomer); -} - -void RenderThread::OnDOMStorageEvent( - const DOMStorageMsg_Event_Params& params) { - if (!dom_storage_event_dispatcher_.get()) - dom_storage_event_dispatcher_.reset(WebStorageEventDispatcher::create()); - dom_storage_event_dispatcher_->dispatchStorageEvent(params.key, - params.old_value, params.new_value, params.origin, params.url, - params.storage_type == DOM_STORAGE_LOCAL); -} - void RenderThread::EnsureWebKitInitialized() { if (webkit_platform_support_.get()) return; @@ -461,7 +462,7 @@ void RenderThread::EnsureWebKitInitialized() { RegisterExtension(extensions_v8::PlaybackExtension::Get()); } - web_database_observer_impl_.reset(new WebDatabaseObserverImpl(this)); + web_database_observer_impl_.reset(new WebDatabaseObserverImpl(Get())); WebKit::WebDatabase::setObserver(web_database_observer_impl_.get()); WebRuntimeFeatures::enableSockets( @@ -534,26 +535,106 @@ void RenderThread::EnsureWebKitInitialized() { FOR_EACH_OBSERVER(RenderProcessObserver, observers_, WebKitInitialized()); } -// static void RenderThread::RecordUserMetrics(const std::string& action) { - RenderThread::current()->Send( - new ViewHostMsg_UserMetricsRecordAction(action)); + Send(new ViewHostMsg_UserMetricsRecordAction(action)); +} + +void RenderThread::RegisterExtension(v8::Extension* extension) { + WebScriptController::registerExtension(extension); + v8_extensions_.insert(extension->name()); +} + +bool RenderThread::IsRegisteredExtension( + const std::string& v8_extension_name) const { + return v8_extensions_.find(v8_extension_name) != v8_extensions_.end(); +} + +void RenderThread::ScheduleIdleHandler(double initial_delay_s) { + idle_notification_delay_in_s_ = initial_delay_s; + idle_timer_.Stop(); + idle_timer_.Start(FROM_HERE, + base::TimeDelta::FromSeconds(static_cast<int64>(initial_delay_s)), + this, &RenderThread::IdleHandler); +} + +void RenderThread::IdleHandler() { + #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) + MallocExtension::instance()->ReleaseFreeMemory(); +#endif + + v8::V8::IdleNotification(); + + // Schedule next invocation. + // Dampen the delay using the algorithm: + // delay = delay + 1 / (delay + 2) + // Using floor(delay) has a dampening effect such as: + // 1s, 1, 1, 2, 2, 2, 2, 3, 3, ... + // Note that idle_notification_delay_in_s_ would be reset to + // kInitialIdleHandlerDelayS in RenderThread::WidgetHidden. + ScheduleIdleHandler(idle_notification_delay_in_s_ + + 1.0 / (idle_notification_delay_in_s_ + 2.0)); + + FOR_EACH_OBSERVER(RenderProcessObserver, observers_, IdleNotification()); +} + +double RenderThread::GetIdleNotificationDelayInS() const { + return idle_notification_delay_in_s_; +} + +void RenderThread::SetIdleNotificationDelayInS( + double idle_notification_delay_in_s) { + idle_notification_delay_in_s_ = idle_notification_delay_in_s; } #if defined(OS_WIN) -// static -bool RenderThread::PreCacheFont(const LOGFONT& log_font) { - return RenderThread::current()->Send( - new ChildProcessHostMsg_PreCacheFont(log_font)); +void RenderThread::PreCacheFont(const LOGFONT& log_font) { + Send(new ChildProcessHostMsg_PreCacheFont(log_font)); } -// static -bool RenderThread::ReleaseCachedFonts() { - return RenderThread::current()->Send( - new ChildProcessHostMsg_ReleaseCachedFonts()); +void RenderThread::ReleaseCachedFonts() { + Send(new ChildProcessHostMsg_ReleaseCachedFonts()); } + #endif // OS_WIN +int32 RenderThread::RoutingIDForCurrentContext() { + int32 routing_id = MSG_ROUTING_CONTROL; + if (v8::Context::InContext()) { + WebFrame* frame = WebFrame::frameForCurrentContext(); + if (frame) { + RenderView* view = RenderView::FromWebView(frame->view()); + if (view) + routing_id = view->routing_id(); + } + } else { + DLOG(WARNING) << "Not called within a script context!"; + } + return routing_id; +} + +void RenderThread::DoNotSuspendWebKitSharedTimer() { + suspend_webkit_shared_timer_ = false; +} + +void RenderThread::DoNotNotifyWebKitOfModalLoop() { + notify_webkit_of_modal_loop_ = false; +} + +void RenderThread::OnSetZoomLevelForCurrentURL(const GURL& url, + double zoom_level) { + RenderViewZoomer zoomer(url, zoom_level); + RenderView::ForEach(&zoomer); +} + +void RenderThread::OnDOMStorageEvent( + const DOMStorageMsg_Event_Params& params) { + if (!dom_storage_event_dispatcher_.get()) + dom_storage_event_dispatcher_.reset(WebStorageEventDispatcher::create()); + dom_storage_event_dispatcher_->dispatchStorageEvent(params.key, + params.old_value, params.new_value, params.origin, params.url, + params.storage_type == DOM_STORAGE_LOCAL); +} + bool RenderThread::OnControlMessageReceived(const IPC::Message& msg) { ObserverListBase<RenderProcessObserver>::Iterator it(observers_); RenderProcessObserver* observer; @@ -678,34 +759,6 @@ GpuChannelHost* RenderThread::GetGpuChannel() { return gpu_channel_.get(); } -void RenderThread::IdleHandler() { -#if !defined(OS_MACOSX) && defined(USE_TCMALLOC) - MallocExtension::instance()->ReleaseFreeMemory(); -#endif - - v8::V8::IdleNotification(); - - // Schedule next invocation. - // Dampen the delay using the algorithm: - // delay = delay + 1 / (delay + 2) - // Using floor(delay) has a dampening effect such as: - // 1s, 1, 1, 2, 2, 2, 2, 3, 3, ... - // Note that idle_notification_delay_in_s_ would be reset to - // kInitialIdleHandlerDelayS in RenderThread::WidgetHidden. - ScheduleIdleHandler(idle_notification_delay_in_s_ + - 1.0 / (idle_notification_delay_in_s_ + 2.0)); - - FOR_EACH_OBSERVER(RenderProcessObserver, observers_, IdleNotification()); -} - -void RenderThread::ScheduleIdleHandler(double initial_delay_s) { - idle_notification_delay_in_s_ = initial_delay_s; - idle_timer_.Stop(); - idle_timer_.Start(FROM_HERE, - base::TimeDelta::FromSeconds(static_cast<int64>(initial_delay_s)), - this, &RenderThread::IdleHandler); -} - void RenderThread::OnPurgePluginListCache(bool reload_pages) { EnsureWebKitInitialized(); // The call below will cause a GetPlugins call with refresh=true, but at this @@ -731,13 +784,3 @@ RenderThread::GetFileThreadMessageLoopProxy() { } return file_thread_->message_loop_proxy(); } - -void RenderThread::RegisterExtension(v8::Extension* extension) { - WebScriptController::registerExtension(extension); - v8_extensions_.insert(extension->name()); -} - -bool RenderThread::IsRegisteredExtension( - const std::string& v8_extension_name) const { - return v8_extensions_.find(v8_extension_name) != v8_extensions_.end(); -} diff --git a/content/renderer/render_thread.h b/content/renderer/render_thread.h index 4520490..16ffc87 100644 --- a/content/renderer/render_thread.h +++ b/content/renderer/render_thread.h @@ -19,6 +19,7 @@ #include "content/common/content_export.h" #include "content/common/css_colors.h" #include "content/common/gpu/gpu_process_launch_causes.h" +#include "content/public/renderer/render_thread.h" #include "ipc/ipc_channel_proxy.h" #include "ui/gfx/native_widget_types.h" @@ -66,36 +67,6 @@ namespace v8 { class Extension; } -// The RenderThreadBase is the minimal interface that a RenderView/Widget -// expects from a render thread. The interface basically abstracts a way to send -// and receive messages. -// -// TODO(brettw): This has two different and opposing usage patterns which -// make it confusing. It can be accessed through RenderThread::current(), which -// can be NULL during tests, or it can be passed as RenderThreadBase, which is -// mocked during tests. It should be changed to RenderThread::current() -// everywhere. -// -// See crbug.com/98375 for more details. -class CONTENT_EXPORT RenderThreadBase { - public: - virtual ~RenderThreadBase() {} - - virtual bool Send(IPC::Message* msg) = 0; - - // Called to add or remove a listener for a particular message routing ID. - // These methods normally get delegated to a MessageRouter. - virtual void AddRoute(int32 routing_id, IPC::Channel::Listener* listener) = 0; - virtual void RemoveRoute(int32 routing_id) = 0; - - virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter) = 0; - virtual void RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) = 0; - - // Called by a RenderWidget when it is hidden or restored. - virtual void WidgetHidden() = 0; - virtual void WidgetRestored() = 0; -}; - // The RenderThread class represents a background thread where RenderView // instances live. The RenderThread supports an API that is used by its // consumer to talk indirectly to the RenderViews and supporting objects. @@ -105,40 +76,52 @@ class CONTENT_EXPORT RenderThreadBase { // Most of the communication occurs in the form of IPC messages. They are // routed to the RenderThread according to the routing IDs of the messages. // The routing IDs correspond to RenderView instances. -class CONTENT_EXPORT RenderThread : public RenderThreadBase, +class CONTENT_EXPORT RenderThread : public content::RenderThread, public ChildThread { public: - // Grabs the IPC channel name from the command line. + static RenderThread* current(); + RenderThread(); // Constructor that's used when running in single process mode. explicit RenderThread(const std::string& channel_name); virtual ~RenderThread(); - // Returns the one render thread for this process. Note that this should only - // be accessed when running on the render thread itself - // - // TODO(brettw) this should be on the abstract base class instead of here, - // and return the base class' interface instead. See crbug.com/98375. - static RenderThread* current(); - // Returns the routing ID of the RenderWidget containing the current script // execution context (corresponding to WebFrame::frameForCurrentContext). static int32 RoutingIDForCurrentContext(); - // Returns the locale string to be used in WebKit. - static std::string GetLocale(); - - // Overridden from RenderThreadBase. - virtual bool Send(IPC::Message* msg); - virtual void AddRoute(int32 routing_id, IPC::Channel::Listener* listener); - virtual void RemoveRoute(int32 routing_id); - virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter); - virtual void RemoveFilter(IPC::ChannelProxy::MessageFilter* filter); - virtual void WidgetHidden(); - virtual void WidgetRestored(); - - void AddObserver(content::RenderProcessObserver* observer); - void RemoveObserver(content::RenderProcessObserver* observer); + // content::RenderThread implementation: + virtual bool Send(IPC::Message* msg) OVERRIDE; + virtual MessageLoop* GetMessageLoop() OVERRIDE; + virtual IPC::SyncChannel* GetChannel() OVERRIDE; + virtual ResourceDispatcher* GetResourceDispatcher() OVERRIDE; + virtual std::string GetLocale() OVERRIDE; + virtual void AddRoute(int32 routing_id, + IPC::Channel::Listener* listener) OVERRIDE; + virtual void RemoveRoute(int32 routing_id) OVERRIDE; + virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter) OVERRIDE; + virtual void RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) OVERRIDE; + virtual void SetOutgoingMessageFilter( + IPC::ChannelProxy::OutgoingMessageFilter* filter) OVERRIDE; + virtual void AddObserver(content::RenderProcessObserver* observer) OVERRIDE; + virtual void RemoveObserver( + content::RenderProcessObserver* observer) OVERRIDE; + virtual void WidgetHidden() OVERRIDE; + virtual void WidgetRestored() OVERRIDE; + virtual void EnsureWebKitInitialized() OVERRIDE; + virtual void RecordUserMetrics(const std::string& action) OVERRIDE; + virtual void RegisterExtension(v8::Extension* extension) OVERRIDE; + virtual bool IsRegisteredExtension( + const std::string& v8_extension_name) const OVERRIDE; + virtual void ScheduleIdleHandler(double initial_delay_s) OVERRIDE; + virtual void IdleHandler() OVERRIDE; + virtual double GetIdleNotificationDelayInS() const OVERRIDE; + virtual void SetIdleNotificationDelayInS( + double idle_notification_delay_in_s) OVERRIDE; +#if defined(OS_WIN) + virtual void PreCacheFont(const LOGFONT& log_font) OVERRIDE; + virtual void ReleaseCachedFonts() OVERRIDE; +#endif // These methods modify how the next message is sent. Normally, when sending // a synchronous message that runs a nested message loop, we need to suspend @@ -174,13 +157,6 @@ class CONTENT_EXPORT RenderThread : public RenderThreadBase, bool plugin_refresh_allowed() const { return plugin_refresh_allowed_; } - double idle_notification_delay_in_s() const { - return idle_notification_delay_in_s_; - } - void set_idle_notification_delay_in_s(double idle_notification_delay_in_s) { - idle_notification_delay_in_s_ = idle_notification_delay_in_s; - } - // Synchronously establish a channel to the GPU plugin if not previously // established or if it has been lost (for example if the GPU plugin crashed). // If there is a pending asynchronous request, it will be completed by the @@ -196,33 +172,6 @@ class CONTENT_EXPORT RenderThread : public RenderThreadBase, // on the renderer's main thread. scoped_refptr<base::MessageLoopProxy> GetFileThreadMessageLoopProxy(); - // Schedule a call to IdleHandler with the given initial delay. - void ScheduleIdleHandler(double initial_delay_s); - - // A task we invoke periodically to assist with idle cleanup. - void IdleHandler(); - - // Registers the given V8 extension with WebKit. - void RegisterExtension(v8::Extension* extension); - - // Returns true iff the extension is registered. - bool IsRegisteredExtension(const std::string& v8_extension_name) const; - - // We initialize WebKit as late as possible. - void EnsureWebKitInitialized(); - - // Helper function to send over a string to be recorded by user metrics - static void RecordUserMetrics(const std::string& action); - -#if defined(OS_WIN) - // Request that the given font be loaded by the browser so it's cached by the - // OS. Please see ChildProcessHost::PreCacheFont for details. - static bool PreCacheFont(const LOGFONT& log_font); - - // Release cached font. - static bool ReleaseCachedFonts(); -#endif // OS_WIN - private: virtual bool OnControlMessageReceived(const IPC::Message& msg); diff --git a/content/renderer/render_view.cc b/content/renderer/render_view.cc index c79c567..10ba01f 100644 --- a/content/renderer/render_view.cc +++ b/content/renderer/render_view.cc @@ -300,7 +300,7 @@ struct RenderView::PendingFileChooser { WebFileChooserCompletion* completion; // MAY BE NULL to skip callback. }; -RenderView::RenderView(RenderThreadBase* render_thread, +RenderView::RenderView(content::RenderThread* render_thread, gfx::NativeViewId parent_hwnd, int32 opener_id, const RendererPreferences& renderer_prefs, @@ -459,7 +459,7 @@ RenderView* RenderView::FromWebView(WebView* webview) { /*static*/ RenderView* RenderView::Create( - RenderThreadBase* render_thread, + content::RenderThread* render_thread, gfx::NativeViewId parent_hwnd, int32 opener_id, const RendererPreferences& renderer_prefs, @@ -1530,7 +1530,7 @@ void RenderView::didExecuteCommand(const WebString& command_name) { StartsWithASCII(name, "Insert", true) || StartsWithASCII(name, "Delete", true)) return; - RenderThread::RecordUserMetrics(name); + RenderThread::current()->RecordUserMetrics(name); } bool RenderView::handleCurrentKeyboardEvent() { diff --git a/content/renderer/render_view.h b/content/renderer/render_view.h index 2c16ac6..91d03ca 100644 --- a/content/renderer/render_view.h +++ b/content/renderer/render_view.h @@ -87,6 +87,7 @@ class WaitableEvent; namespace content { class NavigationState; class P2PSocketDispatcher; +class RenderThread; class RenderViewObserver; class RenderViewVisitor; } // namespace content @@ -179,7 +180,7 @@ class RenderView : public RenderWidget, // |counter| is either a currently initialized counter, or NULL (in which case // we treat this RenderView as a top level window). CONTENT_EXPORT static RenderView* Create( - RenderThreadBase* render_thread, + content::RenderThread* render_thread, gfx::NativeViewId parent_hwnd, int32 opener_id, const RendererPreferences& renderer_prefs, @@ -697,7 +698,7 @@ class RenderView : public RenderWidget, CONNECTION_ERROR, }; - RenderView(RenderThreadBase* render_thread, + RenderView(content::RenderThread* render_thread, gfx::NativeViewId parent_hwnd, int32 opener_id, const RendererPreferences& renderer_prefs, diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc index 1378a8a..71e0a84 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc @@ -62,7 +62,7 @@ using WebKit::WebTouchEvent; using WebKit::WebVector; using WebKit::WebWidget; -RenderWidget::RenderWidget(RenderThreadBase* render_thread, +RenderWidget::RenderWidget(content::RenderThread* render_thread, WebKit::WebPopupType popup_type) : routing_id_(MSG_ROUTING_NONE), webwidget_(NULL), @@ -111,7 +111,7 @@ RenderWidget::~RenderWidget() { // static RenderWidget* RenderWidget::Create(int32 opener_id, - RenderThreadBase* render_thread, + content::RenderThread* render_thread, WebKit::WebPopupType popup_type) { DCHECK(opener_id != MSG_ROUTING_NONE); scoped_refptr<RenderWidget> widget(new RenderWidget(render_thread, diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h index 17db0c2..fdd89ea 100644 --- a/content/renderer/render_widget.h +++ b/content/renderer/render_widget.h @@ -29,20 +29,10 @@ #include "ui/gfx/surface/transport_dib.h" #include "webkit/glue/webcursor.h" -class RenderThreadBase; - -namespace gfx { -class Point; -} - namespace IPC { class SyncMessage; } -namespace skia { -class PlatformCanvas; -} - namespace WebKit { class WebInputEvent; class WebMouseEvent; @@ -51,6 +41,18 @@ class WebWidget; struct WebPopupMenuInfo; } +namespace content { +class RenderThread; +} + +namespace gfx { +class Point; +} + +namespace skia { +class PlatformCanvas; +} + namespace webkit { namespace npapi { struct WebPluginGeometry; @@ -71,9 +73,10 @@ class CONTENT_EXPORT RenderWidget public: // Creates a new RenderWidget. The opener_id is the routing ID of the // RenderView that this widget lives inside. The render_thread is any - // RenderThreadBase implementation, mostly commonly RenderThread::current(). + // content::RenderThread implementation, mostly commonly + // RenderThread::current(). static RenderWidget* Create(int32 opener_id, - RenderThreadBase* render_thread, + content::RenderThread* render_thread, WebKit::WebPopupType popup_type); // Creates a WebWidget based on the popup type. @@ -145,7 +148,7 @@ class CONTENT_EXPORT RenderWidget // For unit tests. friend class RenderWidgetTest; - RenderWidget(RenderThreadBase* render_thread, + RenderWidget(content::RenderThread* render_thread, WebKit::WebPopupType popup_type); virtual ~RenderWidget(); @@ -337,7 +340,7 @@ class CONTENT_EXPORT RenderWidget int32 opener_id_; // The thread that does our IPC. - RenderThreadBase* render_thread_; + content::RenderThread* render_thread_; // The position where this view should be initially shown. gfx::Rect initial_pos_; diff --git a/content/renderer/render_widget_fullscreen.cc b/content/renderer/render_widget_fullscreen.cc index c5e1b29..5a8ace6 100644 --- a/content/renderer/render_widget_fullscreen.cc +++ b/content/renderer/render_widget_fullscreen.cc @@ -12,7 +12,7 @@ using WebKit::WebWidget; // static RenderWidgetFullscreen* RenderWidgetFullscreen::Create( - int32 opener_id, RenderThreadBase* render_thread) { + int32 opener_id, content::RenderThread* render_thread) { DCHECK_NE(MSG_ROUTING_NONE, opener_id); scoped_refptr<RenderWidgetFullscreen> widget( new RenderWidgetFullscreen(render_thread)); @@ -46,6 +46,7 @@ void RenderWidgetFullscreen::show(WebKit::WebNavigationPolicy) { } } -RenderWidgetFullscreen::RenderWidgetFullscreen(RenderThreadBase* render_thread) +RenderWidgetFullscreen::RenderWidgetFullscreen( + content::RenderThread* render_thread) : RenderWidget(render_thread, WebKit::WebPopupTypeNone) { } diff --git a/content/renderer/render_widget_fullscreen.h b/content/renderer/render_widget_fullscreen.h index 7e18037..1b2c382 100644 --- a/content/renderer/render_widget_fullscreen.h +++ b/content/renderer/render_widget_fullscreen.h @@ -14,15 +14,16 @@ class RenderWidgetFullscreen : public RenderWidget { public: // Creates a new RenderWidget. The opener_id is the routing ID of the // RenderView that this widget lives inside. The render_thread is any - // RenderThreadBase implementation, mostly commonly RenderThread::current(). + // content::RenderThread implementation, mostly commonly + // RenderThread::current(). static RenderWidgetFullscreen* Create(int32 opener_id, - RenderThreadBase* render_thread); + content::RenderThread* render_thread); virtual void show(WebKit::WebNavigationPolicy); protected: virtual WebKit::WebWidget* CreateWebWidget(); - RenderWidgetFullscreen(RenderThreadBase* render_thread); + RenderWidgetFullscreen(content::RenderThread* render_thread); void Init(int32 opener_id); }; diff --git a/content/renderer/render_widget_fullscreen_pepper.cc b/content/renderer/render_widget_fullscreen_pepper.cc index ece64b3..ed8a853 100644 --- a/content/renderer/render_widget_fullscreen_pepper.cc +++ b/content/renderer/render_widget_fullscreen_pepper.cc @@ -203,7 +203,7 @@ void DestroyContext(RendererGLContext* context, GLuint program, GLuint buffer) { // static RenderWidgetFullscreenPepper* RenderWidgetFullscreenPepper::Create( - int32 opener_id, RenderThreadBase* render_thread, + int32 opener_id, content::RenderThread* render_thread, webkit::ppapi::PluginInstance* plugin, const GURL& active_url) { DCHECK_NE(MSG_ROUTING_NONE, opener_id); @@ -214,7 +214,7 @@ RenderWidgetFullscreenPepper* RenderWidgetFullscreenPepper::Create( } RenderWidgetFullscreenPepper::RenderWidgetFullscreenPepper( - RenderThreadBase* render_thread, + content::RenderThread* render_thread, webkit::ppapi::PluginInstance* plugin, const GURL& active_url) : RenderWidgetFullscreen(render_thread), diff --git a/content/renderer/render_widget_fullscreen_pepper.h b/content/renderer/render_widget_fullscreen_pepper.h index d804f85..e6d4d18 100644 --- a/content/renderer/render_widget_fullscreen_pepper.h +++ b/content/renderer/render_widget_fullscreen_pepper.h @@ -27,7 +27,7 @@ class RenderWidgetFullscreenPepper : public RenderWidgetFullscreen, public: static RenderWidgetFullscreenPepper* Create( int32 opener_id, - RenderThreadBase* render_thread, + content::RenderThread* render_thread, webkit::ppapi::PluginInstance* plugin, const GURL& active_url); @@ -43,7 +43,7 @@ class RenderWidgetFullscreenPepper : public RenderWidgetFullscreen, void SwapBuffers(); protected: - RenderWidgetFullscreenPepper(RenderThreadBase* render_thread, + RenderWidgetFullscreenPepper(content::RenderThread* render_thread, webkit::ppapi::PluginInstance* plugin, const GURL& active_url); virtual ~RenderWidgetFullscreenPepper(); diff --git a/content/renderer/renderer_webkitplatformsupport_impl.cc b/content/renderer/renderer_webkitplatformsupport_impl.cc index 7800c08..24863e4 100644 --- a/content/renderer/renderer_webkitplatformsupport_impl.cc +++ b/content/renderer/renderer_webkitplatformsupport_impl.cc @@ -258,7 +258,7 @@ void RendererWebKitPlatformSupportImpl::cacheMetadata( } WebString RendererWebKitPlatformSupportImpl::defaultLocale() { - return ASCIIToUTF16(RenderThread::GetLocale()); + return ASCIIToUTF16(RenderThread::Get()->GetLocale()); } void RendererWebKitPlatformSupportImpl::suddenTerminationChanged(bool enabled) { @@ -444,8 +444,8 @@ bool RendererWebKitPlatformSupportImpl::SandboxSupport::ensureFontLoaded( HFONT font) { LOGFONT logfont; GetObject(font, sizeof(LOGFONT), &logfont); - return RenderThread::current()->Send( - new ChildProcessHostMsg_PreCacheFont(logfont)); + RenderThread::current()->PreCacheFont(logfont); + return true; } #elif defined(OS_MACOSX) @@ -604,7 +604,8 @@ RendererWebKitPlatformSupportImpl::signedPublicKeyAndChallengeString( WebBlobRegistry* RendererWebKitPlatformSupportImpl::blobRegistry() { // RenderThread::current can be NULL when running some tests. - if (!blob_registry_.get() && RenderThread::current()) - blob_registry_.reset(new WebBlobRegistryImpl(RenderThread::current())); + if (!blob_registry_.get() && RenderThread::current()) { + blob_registry_.reset(new WebBlobRegistryImpl(RenderThread::Get())); + } return blob_registry_.get(); } |