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

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: Fixes based on Devlin's review. 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
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 SiteToProcessMap::iterator i = map_.find(site);
Charlie Reis 2017/03/13 19:57:30 This should have a comment, since at first glance
nasko 2017/03/13 21:06:19 Comment added.
337 if (i == map_.end())
338 map_[site] = process;
337 } 339 }
338 340
339 RenderProcessHost* FindProcess(const std::string& site) { 341 RenderProcessHost* FindProcess(const std::string& site) {
340 SiteToProcessMap::iterator i = map_.find(site); 342 SiteToProcessMap::iterator i = map_.find(site);
341 if (i != map_.end()) 343 if (i != map_.end())
342 return i->second; 344 return i->second;
343 return NULL; 345 return NULL;
344 } 346 }
345 347
346 void RemoveProcess(RenderProcessHost* host) { 348 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; 3068 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error;
3067 3069
3068 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. 3070 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing.
3069 // Capture the error message in a crash key value. 3071 // Capture the error message in a crash key value.
3070 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); 3072 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error);
3071 bad_message::ReceivedBadMessage(render_process_id, 3073 bad_message::ReceivedBadMessage(render_process_id,
3072 bad_message::RPH_MOJO_PROCESS_ERROR); 3074 bad_message::RPH_MOJO_PROCESS_ERROR);
3073 } 3075 }
3074 3076
3075 } // namespace content 3077 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698