Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(449)

Side by Side Diff: chrome/browser/renderer_host/browser_render_process_host.h

Issue 18460: * Revert "POSIX: Get render_process_host to build." (Closed)
Patch Set: Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_RENDERER_HOST_BROWSER_RENDER_PROCESS_HOST_H_ 5 #ifndef CHROME_BROWSER_RENDERER_HOST_BROWSER_RENDER_PROCESS_HOST_H_
6 #define CHROME_BROWSER_RENDERER_HOST_BROWSER_RENDER_PROCESS_HOST_H_ 6 #define CHROME_BROWSER_RENDERER_HOST_BROWSER_RENDER_PROCESS_HOST_H_
7 7
8 #include "build/build_config.h"
9
10 #if defined(OS_WIN)
11 #include <windows.h>
12 #endif
13
14 #include <limits> 8 #include <limits>
15 #include <set> 9 #include <set>
16 #include <vector> 10 #include <vector>
11 #include <windows.h>
17 12
18 #include "base/id_map.h" 13 #include "base/id_map.h"
19 #include "base/process.h" 14 #include "base/object_watcher.h"
20 #include "base/rand_util.h" 15 #include "base/rand_util.h"
21 #include "base/ref_counted.h" 16 #include "base/ref_counted.h"
17 #include "base/scoped_handle.h"
22 #include "base/scoped_ptr.h" 18 #include "base/scoped_ptr.h"
23 #include "chrome/browser/renderer_host/render_process_host.h" 19 #include "chrome/browser/renderer_host/render_process_host.h"
24 #include "chrome/common/notification_service.h" 20 #include "chrome/common/notification_service.h"
25 #include "chrome/common/render_messages.h" 21 #include "chrome/common/render_messages.h"
26 22
27 class PrefService; 23 class PrefService;
28 class RenderWidgetHelper; 24 class RenderWidgetHelper;
29 class WebContents; 25 class WebContents;
30 26
31 namespace base { 27 namespace base {
32 class Thread; 28 class Thread;
33 } 29 }
34 30
35 // Implements a concrete RenderProcessHost for the browser process for talking 31 // Implements a concrete RenderProcessHost for the browser process for talking
36 // to actual renderer processes (as opposed to mocks). 32 // to actual renderer processes (as opposed to mocks).
37 // 33 //
38 // Represents the browser side of the browser <--> renderer communication 34 // Represents the browser side of the browser <--> renderer communication
39 // channel. There will be one RenderProcessHost per renderer process. 35 // channel. There will be one RenderProcessHost per renderer process.
40 // 36 //
41 // This object is refcounted so that it can release its resources when all 37 // This object is refcounted so that it can release its resources when all
42 // hosts using it go away. 38 // hosts using it go away.
43 // 39 //
44 // This object communicates back and forth with the RenderProcess object 40 // This object communicates back and forth with the RenderProcess object
45 // running in the renderer process. Each RenderProcessHost and RenderProcess 41 // running in the renderer process. Each RenderProcessHost and RenderProcess
46 // keeps a list of RenderView (renderer) and WebContents (browser) which 42 // keeps a list of RenderView (renderer) and WebContents (browser) which
47 // are correlated with IDs. This way, the Views and the corresponding ViewHosts 43 // are correlated with IDs. This way, the Views and the corresponding ViewHosts
48 // communicate through the two process objects. 44 // communicate through the two process objects.
49 class BrowserRenderProcessHost : public RenderProcessHost, 45 class BrowserRenderProcessHost : public RenderProcessHost,
46 public base::ObjectWatcher::Delegate,
50 public NotificationObserver { 47 public NotificationObserver {
51 public: 48 public:
52 explicit BrowserRenderProcessHost(Profile* profile); 49 explicit BrowserRenderProcessHost(Profile* profile);
53 ~BrowserRenderProcessHost(); 50 ~BrowserRenderProcessHost();
54 51
55 // RenderProcessHost implementation (public portion). 52 // RenderProcessHost implementation (public portion).
56 virtual bool Init(); 53 virtual bool Init();
57 virtual int GetNextRoutingID(); 54 virtual int GetNextRoutingID();
58 virtual void CancelResourceRequests(int render_widget_id); 55 virtual void CancelResourceRequests(int render_widget_id);
59 virtual void CrossSiteClosePageACK(int new_render_process_host_id, 56 virtual void CrossSiteClosePageACK(int new_render_process_host_id,
60 int new_request_id); 57 int new_request_id);
61 virtual bool WaitForPaintMsg(int render_widget_id, 58 virtual bool WaitForPaintMsg(int render_widget_id,
62 const base::TimeDelta& max_delay, 59 const base::TimeDelta& max_delay,
63 IPC::Message* msg); 60 IPC::Message* msg);
64 virtual void ReceivedBadMessage(uint16 msg_type); 61 virtual void ReceivedBadMessage(uint16 msg_type);
65 virtual void WidgetRestored(); 62 virtual void WidgetRestored();
66 virtual void WidgetHidden(); 63 virtual void WidgetHidden();
67 virtual void AddWord(const std::wstring& word); 64 virtual void AddWord(const std::wstring& word);
68 virtual bool FastShutdownIfPossible(); 65 virtual bool FastShutdownIfPossible();
69 66
70 // IPC::Channel::Sender via RenderProcessHost. 67 // IPC::Channel::Sender via RenderProcessHost.
71 virtual bool Send(IPC::Message* msg); 68 virtual bool Send(IPC::Message* msg);
72 69
73 // IPC::Channel::Listener via RenderProcessHost. 70 // IPC::Channel::Listener via RenderProcessHost.
74 virtual void OnMessageReceived(const IPC::Message& msg); 71 virtual void OnMessageReceived(const IPC::Message& msg);
75 virtual void OnChannelConnected(int32 peer_pid); 72 virtual void OnChannelConnected(int32 peer_pid);
76 virtual void OnChannelError();
77 73
78 static void RegisterPrefs(PrefService* prefs); 74 static void RegisterPrefs(PrefService* prefs);
79 75
80 // If the a process has sent a message that cannot be decoded, it is deemed 76 // If the a process has sent a message that cannot be decoded, it is deemed
81 // corrupted and thus needs to be terminated using this call. This function 77 // corrupted and thus needs to be terminated using this call. This function
82 // can be safely called from any thread. 78 // can be safely called from any thread.
83 static void BadMessageTerminateProcess(uint16 msg_type, 79 static void BadMessageTerminateProcess(uint16 msg_type, HANDLE renderer);
84 base::ProcessHandle renderer); 80
81 // ObjectWatcher::Delegate
82 virtual void OnObjectSignaled(HANDLE object);
85 83
86 // NotificationObserver implementation. 84 // NotificationObserver implementation.
87 virtual void Observe(NotificationType type, 85 virtual void Observe(NotificationType type,
88 const NotificationSource& source, 86 const NotificationSource& source,
89 const NotificationDetails& details); 87 const NotificationDetails& details);
90 88
91 private: 89 private:
92 // RenderProcessHost implementation (protected portion). 90 // RenderProcessHost implementation (protected portion).
93 virtual void Unregister(); 91 virtual void Unregister();
94 92
(...skipping 22 matching lines...) Expand all
117 void SendUserScriptsUpdate(base::SharedMemory* shared_memory); 115 void SendUserScriptsUpdate(base::SharedMemory* shared_memory);
118 116
119 // Gets a handle to the renderer process, normalizing the case where we were 117 // Gets a handle to the renderer process, normalizing the case where we were
120 // started with --single-process. 118 // started with --single-process.
121 base::ProcessHandle GetRendererProcessHandle(); 119 base::ProcessHandle GetRendererProcessHandle();
122 120
123 // Callers can reduce the RenderProcess' priority. 121 // Callers can reduce the RenderProcess' priority.
124 // Returns true if the priority is backgrounded; false otherwise. 122 // Returns true if the priority is backgrounded; false otherwise.
125 void SetBackgrounded(bool boost); 123 void SetBackgrounded(bool boost);
126 124
125 // Used to watch the renderer process handle.
126 base::ObjectWatcher watcher_;
127
127 // The count of currently visible widgets. Since the host can be a container 128 // The count of currently visible widgets. Since the host can be a container
128 // for multiple widgets, it uses this count to determine when it should be 129 // for multiple widgets, it uses this count to determine when it should be
129 // backgrounded. 130 // backgrounded.
130 int32 visible_widgets_; 131 int32 visible_widgets_;
131 132
132 // Does this process have backgrounded priority. 133 // Does this process have backgrounded priority.
133 bool backgrounded_; 134 bool backgrounded_;
134 135
135 // Used to allow a RenderWidgetHost to intercept various messages on the 136 // Used to allow a RenderWidgetHost to intercept various messages on the
136 // IO thread. 137 // IO thread.
137 scoped_refptr<RenderWidgetHelper> widget_helper_; 138 scoped_refptr<RenderWidgetHelper> widget_helper_;
138 139
139 DISALLOW_COPY_AND_ASSIGN(BrowserRenderProcessHost); 140 DISALLOW_COPY_AND_ASSIGN(BrowserRenderProcessHost);
140 }; 141 };
141 142
142 // Generates a unique channel name for a child renderer/plugin process. 143 // Generates a unique channel name for a child renderer/plugin process.
143 // The "instance" pointer value is baked into the channel id. 144 // The "instance" pointer value is baked into the channel id.
144 std::wstring GenerateRandomChannelID(void* instance); 145 inline std::wstring GenerateRandomChannelID(void* instance) {
146 // Note: the string must start with the current process id, this is how
147 // child processes determine the pid of the parent.
148 // Build the channel ID. This is composed of a unique identifier for the
149 // parent browser process, an identifier for the renderer/plugin instance,
150 // and a random component. We use a random component so that a hacked child
151 // process can't cause denial of service by causing future named pipe creation
152 // to fail.
153 return StringPrintf(L"%d.%x.%d",
154 GetCurrentProcessId(), instance,
155 base::RandInt(0, std::numeric_limits<int>::max()));
156 }
157
145 158
146 #endif // CHROME_BROWSER_RENDERER_HOST_BROWSER_RENDER_PROCESS_HOST_H_ 159 #endif // CHROME_BROWSER_RENDERER_HOST_BROWSER_RENDER_PROCESS_HOST_H_
147 160
OLDNEW
« no previous file with comments | « chrome/browser/render_widget_helper.h ('k') | chrome/browser/renderer_host/browser_render_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698