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

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

Issue 42054: Stop using renderer specific host ids in ResourceDispatcher. This allows it ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_RENDER_PROCESS_HOST_H_ 5 #ifndef CHROME_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_H_
6 #define CHROME_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_H_ 6 #define CHROME_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/id_map.h" 10 #include "base/id_map.h"
(...skipping 15 matching lines...) Expand all
26 public IPC::Channel::Listener { 26 public IPC::Channel::Listener {
27 public: 27 public:
28 typedef IDMap<RenderProcessHost>::const_iterator iterator; 28 typedef IDMap<RenderProcessHost>::const_iterator iterator;
29 29
30 RenderProcessHost(Profile* profile); 30 RenderProcessHost(Profile* profile);
31 virtual ~RenderProcessHost(); 31 virtual ~RenderProcessHost();
32 32
33 // Returns the user profile associated with this renderer process. 33 // Returns the user profile associated with this renderer process.
34 Profile* profile() const { return profile_; } 34 Profile* profile() const { return profile_; }
35 35
36 // Returns the unique identifier for this host. This can be used later in 36 // Returns the process id for this host. This can be used later in
37 // a call to FromID() to get back to this object (this is used to avoid 37 // a call to FromID() to get back to this object (this is used to avoid
38 // sending non-threadsafe pointers to other threads). 38 // sending non-threadsafe pointers to other threads).
39 int host_id() const { return host_id_; } 39 int pid() const { return pid_; }
40 40
41 // Returns the process object associated with the child process. In certain 41 // Returns the process object associated with the child process. In certain
42 // tests or single-process mode, this will actually represent the current 42 // tests or single-process mode, this will actually represent the current
43 // process. 43 // process.
44 const base::Process& process() const { return process_; } 44 const base::Process& process() const { return process_; }
45 45
46 // May return NULL if there is no connection. 46 // May return NULL if there is no connection.
47 IPC::SyncChannel* channel() { return channel_.get(); } 47 IPC::SyncChannel* channel() { return channel_.get(); }
48 48
49 // Used for refcounting, each holder of this object must Attach and Release 49 // Used for refcounting, each holder of this object must Attach and Release
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // RenderProcessHost rather than creating a new one. 165 // RenderProcessHost rather than creating a new one.
166 static bool ShouldTryToUseExistingProcessHost(); 166 static bool ShouldTryToUseExistingProcessHost();
167 167
168 // Get an existing RenderProcessHost associated with the given profile, if 168 // Get an existing RenderProcessHost associated with the given profile, if
169 // possible. The renderer process is chosen randomly from the 169 // possible. The renderer process is chosen randomly from the
170 // processes associated with the given profile. 170 // processes associated with the given profile.
171 // Returns NULL if no suitable renderer process is available. 171 // Returns NULL if no suitable renderer process is available.
172 static RenderProcessHost* GetExistingProcessHost(Profile* profile); 172 static RenderProcessHost* GetExistingProcessHost(Profile* profile);
173 173
174 protected: 174 protected:
175 // Unregister this object from all globals that reference it. 175 // Sets the process of this object, so that others access it using FromID.
176 // This would naturally be part of the destructor, but we destruct 176 void SetProcessID(int pid);
177 // asynchronously.
178 //
179 // This can be overridden by derived classes to add their own unregister code,
180 // but you should be sure to always call this one AT THE END of your own.
181 virtual void Unregister();
182 177
183 base::Process process_; 178 base::Process process_;
184 179
185 // A proxy for our IPC::Channel that lives on the IO thread (see 180 // A proxy for our IPC::Channel that lives on the IO thread (see
186 // browser_process.h) 181 // browser_process.h)
187 scoped_ptr<IPC::SyncChannel> channel_; 182 scoped_ptr<IPC::SyncChannel> channel_;
188 183
189 // the registered listeners. When this list is empty or all NULL, we should 184 // the registered listeners. When this list is empty or all NULL, we should
190 // delete ourselves 185 // delete ourselves
191 IDMap<IPC::Channel::Listener> listeners_; 186 IDMap<IPC::Channel::Listener> listeners_;
192 187
193 // The maximum page ID we've ever seen from the renderer process. 188 // The maximum page ID we've ever seen from the renderer process.
194 int32 max_page_id_; 189 int32 max_page_id_;
195 190
196 // Indicates whether we have notified that the process has terminated. We 191 // Indicates whether we have notified that the process has terminated. We
197 // only want to send this out once. 192 // only want to send this out once.
198 bool notified_termination_; 193 bool notified_termination_;
199 194
200 private: 195 private:
201 int host_id_; 196 int pid_;
202 197
203 Profile* profile_; 198 Profile* profile_;
204 199
205 // set of listeners that expect the renderer process to close 200 // set of listeners that expect the renderer process to close
206 std::set<int> listeners_expecting_close_; 201 std::set<int> listeners_expecting_close_;
207 202
208 // See getter above. 203 // See getter above.
209 static bool run_renderer_in_process_; 204 static bool run_renderer_in_process_;
210 205
211 DISALLOW_COPY_AND_ASSIGN(RenderProcessHost); 206 DISALLOW_COPY_AND_ASSIGN(RenderProcessHost);
212 }; 207 };
213 208
214 // Factory object for RenderProcessHosts. Using this factory allows tests to 209 // Factory object for RenderProcessHosts. Using this factory allows tests to
215 // swap out a different one to use a TestRenderProcessHost. 210 // swap out a different one to use a TestRenderProcessHost.
216 class RenderProcessHostFactory { 211 class RenderProcessHostFactory {
217 public: 212 public:
218 virtual ~RenderProcessHostFactory() {} 213 virtual ~RenderProcessHostFactory() {}
219 virtual RenderProcessHost* CreateRenderProcessHost( 214 virtual RenderProcessHost* CreateRenderProcessHost(
220 Profile* profile) const = 0; 215 Profile* profile) const = 0;
221 }; 216 };
222 217
223 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_H_ 218 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_H_
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/browser_render_process_host.cc ('k') | chrome/browser/renderer_host/render_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698