Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / content / public / renderer / render_thread.h
blob929dd09786e82365cdcb898f0975e975dc7cb073
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.
5 #ifndef CONTENT_PUBLIC_RENDERER_RENDER_THREAD_H_
6 #define CONTENT_PUBLIC_RENDERER_RENDER_THREAD_H_
8 #include "base/basictypes.h"
9 #include "base/callback.h"
10 #include "base/memory/shared_memory.h"
11 #include "base/metrics/user_metrics_action.h"
12 #include "content/common/content_export.h"
13 #include "content/public/child/child_thread.h"
14 #include "ipc/ipc_channel_proxy.h"
16 class GURL;
18 namespace base {
19 class MessageLoop;
20 class WaitableEvent;
23 namespace cc {
24 class SharedBitmapManager;
27 namespace IPC {
28 class MessageFilter;
29 class SyncChannel;
30 class SyncMessageFilter;
33 namespace v8 {
34 class Extension;
37 namespace content {
39 class RenderProcessObserver;
40 class ResourceDispatcherDelegate;
41 class ServiceRegistry;
43 class CONTENT_EXPORT RenderThread : virtual public ChildThread {
44 public:
45 // Returns the one render thread for this process. Note that this can only
46 // be accessed when running on the render thread itself.
47 static RenderThread* Get();
49 RenderThread();
50 ~RenderThread() override;
52 virtual IPC::SyncChannel* GetChannel() = 0;
53 virtual std::string GetLocale() = 0;
54 virtual IPC::SyncMessageFilter* GetSyncMessageFilter() = 0;
55 virtual scoped_refptr<base::SingleThreadTaskRunner>
56 GetIOMessageLoopProxy() = 0;
58 // Called to add or remove a listener for a particular message routing ID.
59 // These methods normally get delegated to a MessageRouter.
60 virtual void AddRoute(int32 routing_id, IPC::Listener* listener) = 0;
61 virtual void RemoveRoute(int32 routing_id) = 0;
62 virtual int GenerateRoutingID() = 0;
64 // These map to IPC::ChannelProxy methods.
65 virtual void AddFilter(IPC::MessageFilter* filter) = 0;
66 virtual void RemoveFilter(IPC::MessageFilter* filter) = 0;
68 // Add/remove observers for the process.
69 virtual void AddObserver(RenderProcessObserver* observer) = 0;
70 virtual void RemoveObserver(RenderProcessObserver* observer) = 0;
72 // Set the ResourceDispatcher delegate object for this process.
73 virtual void SetResourceDispatcherDelegate(
74 ResourceDispatcherDelegate* delegate) = 0;
76 // We initialize WebKit as late as possible. Call this to force
77 // initialization.
78 virtual void EnsureWebKitInitialized() = 0;
80 // Sends over a base::UserMetricsAction to be recorded by user metrics as
81 // an action. Once a new user metric is added, run
82 // tools/metrics/actions/extract_actions.py
83 // to add the metric to actions.xml, then update the <owner>s and
84 // <description> sections. Make sure to include the actions.xml file when you
85 // upload your code for review!
87 // WARNING: When using base::UserMetricsAction, base::UserMetricsAction
88 // and a string literal parameter must be on the same line, e.g.
89 // RenderThread::Get()->RecordAction(
90 // base::UserMetricsAction("my extremely long action name"));
91 // because otherwise our processing scripts won't pick up on new actions.
92 virtual void RecordAction(const base::UserMetricsAction& action) = 0;
94 // Sends over a string to be recorded by user metrics as a computed action.
95 // When you use this you need to also update the rules for extracting known
96 // actions in chrome/tools/extract_actions.py.
97 virtual void RecordComputedAction(const std::string& action) = 0;
99 // Asks the host to create a block of shared memory for the renderer.
100 // The shared memory allocated by the host is returned back.
101 virtual scoped_ptr<base::SharedMemory> HostAllocateSharedMemoryBuffer(
102 size_t buffer_size) = 0;
104 virtual cc::SharedBitmapManager* GetSharedBitmapManager() = 0;
106 // Registers the given V8 extension with WebKit.
107 virtual void RegisterExtension(v8::Extension* extension) = 0;
109 // Schedule a call to IdleHandler with the given initial delay.
110 virtual void ScheduleIdleHandler(int64 initial_delay_ms) = 0;
112 // A task we invoke periodically to assist with idle cleanup.
113 virtual void IdleHandler() = 0;
115 // Get/Set the delay for how often the idle handler is called.
116 virtual int64 GetIdleNotificationDelayInMs() const = 0;
117 virtual void SetIdleNotificationDelayInMs(
118 int64 idle_notification_delay_in_ms) = 0;
120 virtual void UpdateHistograms(int sequence_number) = 0;
122 // Post task to all worker threads. Returns number of workers.
123 virtual int PostTaskToAllWebWorkers(const base::Closure& closure) = 0;
125 // Resolve the proxy servers to use for a given url. On success true is
126 // returned and |proxy_list| is set to a PAC string containing a list of
127 // proxy servers.
128 virtual bool ResolveProxy(const GURL& url, std::string* proxy_list) = 0;
130 // Gets the shutdown event for the process.
131 virtual base::WaitableEvent* GetShutdownEvent() = 0;
133 // Returns the ServiceRegistry for this thread.
134 virtual ServiceRegistry* GetServiceRegistry() = 0;
137 } // namespace content
139 #endif // CONTENT_PUBLIC_RENDERER_RENDER_THREAD_H_