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

Side by Side Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 2739193004: Check for already existing entry when adding to SiteProcessMap. (Closed)
Patch Set: Add extra comment. Created 3 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
« no previous file with comments | « content/browser/frame_host/navigator_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 // Represents the browser side of the browser <--> renderer communication 5 // Represents the browser side of the browser <--> renderer communication
6 // channel. There will be one RenderProcessHost per renderer process. 6 // channel. There will be one RenderProcessHost per renderer process.
7 7
8 #include "content/browser/renderer_host/render_process_host_impl.h" 8 #include "content/browser/renderer_host/render_process_host_impl.h"
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 LAZY_INSTANCE_INITIALIZER; 326 LAZY_INSTANCE_INITIALIZER;
327 327
328 // Map of site to process, to ensure we only have one RenderProcessHost per 328 // Map of site to process, to ensure we only have one RenderProcessHost per
329 // site in process-per-site mode. Each map is specific to a BrowserContext. 329 // site in process-per-site mode. Each map is specific to a BrowserContext.
330 class SiteProcessMap : public base::SupportsUserData::Data { 330 class SiteProcessMap : public base::SupportsUserData::Data {
331 public: 331 public:
332 typedef base::hash_map<std::string, RenderProcessHost*> SiteToProcessMap; 332 typedef base::hash_map<std::string, RenderProcessHost*> SiteToProcessMap;
333 SiteProcessMap() {} 333 SiteProcessMap() {}
334 334
335 void RegisterProcess(const std::string& site, RenderProcessHost* process) { 335 void RegisterProcess(const std::string& site, RenderProcessHost* process) {
336 map_[site] = process; 336 // There could already exist a site to process mapping due to races between
337 // two WebContents with blank SiteInstances. If that occurs, keeping the
338 // exising entry and not overwriting it is a predictable behavior that is
339 // safe.
340 SiteToProcessMap::iterator i = map_.find(site);
341 if (i == map_.end())
342 map_[site] = process;
337 } 343 }
338 344
339 RenderProcessHost* FindProcess(const std::string& site) { 345 RenderProcessHost* FindProcess(const std::string& site) {
340 SiteToProcessMap::iterator i = map_.find(site); 346 SiteToProcessMap::iterator i = map_.find(site);
341 if (i != map_.end()) 347 if (i != map_.end())
342 return i->second; 348 return i->second;
343 return NULL; 349 return NULL;
344 } 350 }
345 351
346 void RemoveProcess(RenderProcessHost* host) { 352 void RemoveProcess(RenderProcessHost* host) {
(...skipping 2719 matching lines...) Expand 10 before | Expand all | Expand 10 after
3066 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; 3072 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error;
3067 3073
3068 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. 3074 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing.
3069 // Capture the error message in a crash key value. 3075 // Capture the error message in a crash key value.
3070 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); 3076 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error);
3071 bad_message::ReceivedBadMessage(render_process_id, 3077 bad_message::ReceivedBadMessage(render_process_id,
3072 bad_message::RPH_MOJO_PROCESS_ERROR); 3078 bad_message::RPH_MOJO_PROCESS_ERROR);
3073 } 3079 }
3074 3080
3075 } // namespace content 3081 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigator_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698