OLD | NEW |
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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 LAZY_INSTANCE_INITIALIZER; | 328 LAZY_INSTANCE_INITIALIZER; |
329 | 329 |
330 // Map of site to process, to ensure we only have one RenderProcessHost per | 330 // Map of site to process, to ensure we only have one RenderProcessHost per |
331 // site in process-per-site mode. Each map is specific to a BrowserContext. | 331 // site in process-per-site mode. Each map is specific to a BrowserContext. |
332 class SiteProcessMap : public base::SupportsUserData::Data { | 332 class SiteProcessMap : public base::SupportsUserData::Data { |
333 public: | 333 public: |
334 typedef base::hash_map<std::string, RenderProcessHost*> SiteToProcessMap; | 334 typedef base::hash_map<std::string, RenderProcessHost*> SiteToProcessMap; |
335 SiteProcessMap() {} | 335 SiteProcessMap() {} |
336 | 336 |
337 void RegisterProcess(const std::string& site, RenderProcessHost* process) { | 337 void RegisterProcess(const std::string& site, RenderProcessHost* process) { |
338 map_[site] = process; | 338 // There could already exist a site to process mapping due to races between |
| 339 // two WebContents with blank SiteInstances. If that occurs, keeping the |
| 340 // exising entry and not overwriting it is a predictable behavior that is |
| 341 // safe. |
| 342 SiteToProcessMap::iterator i = map_.find(site); |
| 343 if (i == map_.end()) |
| 344 map_[site] = process; |
339 } | 345 } |
340 | 346 |
341 RenderProcessHost* FindProcess(const std::string& site) { | 347 RenderProcessHost* FindProcess(const std::string& site) { |
342 SiteToProcessMap::iterator i = map_.find(site); | 348 SiteToProcessMap::iterator i = map_.find(site); |
343 if (i != map_.end()) | 349 if (i != map_.end()) |
344 return i->second; | 350 return i->second; |
345 return NULL; | 351 return NULL; |
346 } | 352 } |
347 | 353 |
348 void RemoveProcess(RenderProcessHost* host) { | 354 void RemoveProcess(RenderProcessHost* host) { |
(...skipping 2737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3086 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 3092 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
3087 | 3093 |
3088 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. | 3094 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. |
3089 // Capture the error message in a crash key value. | 3095 // Capture the error message in a crash key value. |
3090 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); | 3096 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); |
3091 bad_message::ReceivedBadMessage(render_process_id, | 3097 bad_message::ReceivedBadMessage(render_process_id, |
3092 bad_message::RPH_MOJO_PROCESS_ERROR); | 3098 bad_message::RPH_MOJO_PROCESS_ERROR); |
3093 } | 3099 } |
3094 | 3100 |
3095 } // namespace content | 3101 } // namespace content |
OLD | NEW |