render_thread.h revision c2e0dbddbe15c98d52c4786dac06cb8952a8ae6d
1// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef CONTENT_PUBLIC_RENDERER_RENDER_THREAD_H_ 6#define CONTENT_PUBLIC_RENDERER_RENDER_THREAD_H_ 7 8#include "base/basictypes.h" 9#include "base/shared_memory.h" 10#include "content/common/content_export.h" 11#include "ipc/ipc_channel_proxy.h" 12#include "ipc/ipc_sender.h" 13 14#if defined(OS_WIN) 15#include <windows.h> 16#endif 17 18class GURL; 19 20namespace base { 21class MessageLoop; 22class MessageLoopProxy; 23} 24 25namespace IPC { 26class SyncChannel; 27class SyncMessageFilter; 28} 29 30namespace v8 { 31class Extension; 32} 33 34namespace content { 35 36class RenderProcessObserver; 37class ResourceDispatcherDelegate; 38 39class CONTENT_EXPORT RenderThread : public IPC::Sender { 40 public: 41 // Returns the one render thread for this process. Note that this can only 42 // be accessed when running on the render thread itself. 43 static RenderThread* Get(); 44 45 RenderThread(); 46 virtual ~RenderThread(); 47 48 virtual base::MessageLoop* GetMessageLoop() = 0; 49 virtual IPC::SyncChannel* GetChannel() = 0; 50 virtual std::string GetLocale() = 0; 51 virtual IPC::SyncMessageFilter* GetSyncMessageFilter() = 0; 52 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() = 0; 53 54 // Called to add or remove a listener for a particular message routing ID. 55 // These methods normally get delegated to a MessageRouter. 56 virtual void AddRoute(int32 routing_id, IPC::Listener* listener) = 0; 57 virtual void RemoveRoute(int32 routing_id) = 0; 58 virtual int GenerateRoutingID() = 0; 59 60 // These map to IPC::ChannelProxy methods. 61 virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter) = 0; 62 virtual void RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) = 0; 63 virtual void SetOutgoingMessageFilter( 64 IPC::ChannelProxy::OutgoingMessageFilter* filter) = 0; 65 66 // Add/remove observers for the process. 67 virtual void AddObserver(RenderProcessObserver* observer) = 0; 68 virtual void RemoveObserver(RenderProcessObserver* observer) = 0; 69 70 // Set the ResourceDispatcher delegate object for this process. 71 virtual void SetResourceDispatcherDelegate( 72 ResourceDispatcherDelegate* delegate) = 0; 73 74 // Called by a RenderWidget when it is hidden or restored. 75 virtual void WidgetHidden() = 0; 76 virtual void WidgetRestored() = 0; 77 78 // We initialize WebKit as late as possible. Call this to force 79 // initialization. 80 virtual void EnsureWebKitInitialized() = 0; 81 82 // Helper function to send over a string to be recorded by user metrics 83 virtual void RecordUserMetrics(const std::string& action) = 0; 84 85 // Asks the host to create a block of shared memory for the renderer. 86 // The shared memory allocated by the host is returned back. 87 virtual scoped_ptr<base::SharedMemory> HostAllocateSharedMemoryBuffer( 88 size_t buffer_size) = 0; 89 90 // Registers the given V8 extension with WebKit. 91 virtual void RegisterExtension(v8::Extension* extension) = 0; 92 93 // Schedule a call to IdleHandler with the given initial delay. 94 virtual void ScheduleIdleHandler(int64 initial_delay_ms) = 0; 95 96 // A task we invoke periodically to assist with idle cleanup. 97 virtual void IdleHandler() = 0; 98 99 // Get/Set the delay for how often the idle handler is called. 100 virtual int64 GetIdleNotificationDelayInMs() const = 0; 101 virtual void SetIdleNotificationDelayInMs( 102 int64 idle_notification_delay_in_ms) = 0; 103 104 // Suspend/resume the webkit timer for this renderer. 105 virtual void ToggleWebKitSharedTimer(bool suspend) = 0; 106 107 virtual void UpdateHistograms(int sequence_number) = 0; 108 109 // Resolve the proxy servers to use for a given url. On success true is 110 // returned and |proxy_list| is set to a PAC string containing a list of 111 // proxy servers. 112 virtual bool ResolveProxy(const GURL& url, std::string* proxy_list) = 0; 113 114#if defined(OS_WIN) 115 // Request that the given font be loaded by the browser so it's cached by the 116 // OS. Please see ChildProcessHost::PreCacheFont for details. 117 virtual void PreCacheFont(const LOGFONT& log_font) = 0; 118 119 // Release cached font. 120 virtual void ReleaseCachedFonts() = 0; 121#endif 122}; 123 124} // namespace content 125 126#endif // CONTENT_PUBLIC_RENDERER_RENDER_THREAD_H_ 127