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

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

Issue 2929113002: Enable spare RenderProcessHost to be preinitialized. (Closed)
Patch Set: added comments Created 3 years, 5 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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 void Release(int old_route_id) { 456 void Release(int old_route_id) {
457 session_storage_namespaces_awaiting_close_->erase(old_route_id); 457 session_storage_namespaces_awaiting_close_->erase(old_route_id);
458 } 458 }
459 459
460 private: 460 private:
461 std::unique_ptr<std::map<int, SessionStorageNamespaceMap>> 461 std::unique_ptr<std::map<int, SessionStorageNamespaceMap>>
462 session_storage_namespaces_awaiting_close_; 462 session_storage_namespaces_awaiting_close_;
463 DISALLOW_COPY_AND_ASSIGN(SessionStorageHolder); 463 DISALLOW_COPY_AND_ASSIGN(SessionStorageHolder);
464 }; 464 };
465 465
466 // This class manages spare RenderProcessHosts.
467 //
468 // There is a singleton instance of this class which manages a single spare
469 // renderer (g_spare_render_process_host_manager, below). This class
470 // encapsulates the implementation of
471 // RenderProcessHost::WarmupSpareRenderProcessHost()
472 //
473 // RenderProcessHostImpl should call
474 // SpareRenderProcessHostManager::MaybeTakeSpareRenderProcessHost when creating
475 // a new RPH. In this implementation, the spare renderer is bound to a
476 // BrowserContext and its default StoragePartition. If
477 // MaybeTakeSpareRenderProcessHost is called with a BrowserContext and
478 // StoragePartition that does not match, the spare renderer is discarded. In
479 // particular, only the default StoragePartition will be able to use a spare
480 // renderer. The spare renderer will also not be used as a guest renderer
481 // (is_for_guests_ == true).
482 //
483 // It is safe to call WarmupSpareRenderProcessHost multiple times, although if
484 // called in a context where the spare renderer is not likely to be used
485 // performance may suffer due to the unnecessary RPH creation.
486 class SpareRenderProcessHostManager : public RenderProcessHostObserver {
487 public:
488 SpareRenderProcessHostManager() {}
489
490 void WarmupSpareRenderProcessHost(BrowserContext* browser_context) {
491 StoragePartitionImpl* current_partition =
492 static_cast<StoragePartitionImpl*>(
493 BrowserContext::GetStoragePartition(browser_context, nullptr));
494
495 if (spare_render_process_host_ &&
496 matching_browser_context_ == browser_context &&
497 matching_storage_partition_ == current_partition)
498 return; // Nothing to warm up.
499
500 CleanupSpareRenderProcessHost();
501
502 // Don't create a spare renderer if we're using --single-process or if we've
503 // got too many processes. See also ShouldTryToUseExistingProcessHost in
504 // this file.
505 if (RenderProcessHost::run_renderer_in_process() ||
506 g_all_hosts.Get().size() >=
507 RenderProcessHostImpl::GetMaxRendererProcessCount())
508 return;
509
510 matching_browser_context_ = browser_context;
511 matching_storage_partition_ = current_partition;
512
513 spare_render_process_host_ = RenderProcessHostImpl::CreateRenderProcessHost(
514 browser_context, current_partition, false /* is_for_guests_only */);
515 spare_render_process_host_->AddObserver(this);
516 spare_render_process_host_->Init();
517 }
518
519 RenderProcessHost* MaybeTakeSpareRenderProcessHost(
520 const BrowserContext* browser_context,
521 const StoragePartition* partition,
522 bool is_for_guests_only) {
523 if (!spare_render_process_host_ ||
524 browser_context != matching_browser_context_ ||
525 partition != matching_storage_partition_ || is_for_guests_only) {
526 // As a new RenderProcessHost will almost certainly be created, we cleanup
527 // the non-matching one so as not to waste resources.
528 CleanupSpareRenderProcessHost();
529 return nullptr;
530 }
531
532 CHECK(static_cast<RenderProcessHostImpl*>(spare_render_process_host_)
533 ->HostHasNotBeenUsed());
534 RenderProcessHost* rph = spare_render_process_host_;
535 DropSpareRenderProcessHost(spare_render_process_host_);
536 return rph;
537 }
538
539 // Remove |host| as a possible spare renderer. Does not shut it down cleanly;
540 // the assumption is that the host was shutdown somewhere else and has
541 // notifying the SpareRenderProcessHostManager.
542 void DropSpareRenderProcessHost(RenderProcessHost* host) {
543 if (spare_render_process_host_ && spare_render_process_host_ == host) {
544 spare_render_process_host_->RemoveObserver(this);
545 spare_render_process_host_ = nullptr;
546 }
547 }
548
549 RenderProcessHost* spare_render_process_host() {
550 return spare_render_process_host_;
551 }
552
553 private:
554 // RenderProcessHostObserver
555 void RenderProcessWillExit(RenderProcessHost* host) override {
556 DropSpareRenderProcessHost(host);
557 }
558
559 void RenderProcessExited(RenderProcessHost* host,
560 base::TerminationStatus unused_status,
561 int unused_exit_code) override {
562 DropSpareRenderProcessHost(host);
563 }
564
565 void RenderProcessHostDestroyed(RenderProcessHost* host) override {
566 DropSpareRenderProcessHost(host);
567 }
568
569 void CleanupSpareRenderProcessHost() {
570 if (spare_render_process_host_) {
571 spare_render_process_host_->Cleanup();
572 DropSpareRenderProcessHost(spare_render_process_host_);
573 }
574 }
575
576 // This is a bare pointer, because RenderProcessHost manages the lifetime of
577 // all its instances; see g_all_hosts, above.
578 RenderProcessHost* spare_render_process_host_;
579
580 // Used only to check if a creation request matches the spare, and not
581 // accessed.
582 const BrowserContext* matching_browser_context_ = nullptr;
583 const StoragePartition* matching_storage_partition_ = nullptr;
584
585 DISALLOW_COPY_AND_ASSIGN(SpareRenderProcessHostManager);
586 };
587
588 base::LazyInstance<SpareRenderProcessHostManager>::Leaky
589 g_spare_render_process_host_manager = LAZY_INSTANCE_INITIALIZER;
590
466 const void* const kDefaultSubframeProcessHostHolderKey = 591 const void* const kDefaultSubframeProcessHostHolderKey =
467 &kDefaultSubframeProcessHostHolderKey; 592 &kDefaultSubframeProcessHostHolderKey;
468 593
469 class DefaultSubframeProcessHostHolder : public base::SupportsUserData::Data, 594 class DefaultSubframeProcessHostHolder : public base::SupportsUserData::Data,
470 public RenderProcessHostObserver { 595 public RenderProcessHostObserver {
471 public: 596 public:
472 explicit DefaultSubframeProcessHostHolder(BrowserContext* browser_context) 597 explicit DefaultSubframeProcessHostHolder(BrowserContext* browser_context)
473 : browser_context_(browser_context) {} 598 : browser_context_(browser_context) {}
474 ~DefaultSubframeProcessHostHolder() override {} 599 ~DefaultSubframeProcessHostHolder() override {}
475 600
476 // Gets the correct render process to use for this SiteInstance. 601 // Gets the correct render process to use for this SiteInstance.
477 RenderProcessHost* GetProcessHost(SiteInstance* site_instance, 602 RenderProcessHost* GetProcessHost(SiteInstance* site_instance,
478 bool is_for_guests_only) { 603 bool is_for_guests_only) {
479 StoragePartition* default_partition = 604 StoragePartitionImpl* default_partition =
480 BrowserContext::GetDefaultStoragePartition(browser_context_); 605 static_cast<StoragePartitionImpl*>(
481 StoragePartition* partition = 606 BrowserContext::GetDefaultStoragePartition(browser_context_));
482 BrowserContext::GetStoragePartition(browser_context_, site_instance); 607 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
608 BrowserContext::GetStoragePartition(browser_context_, site_instance));
483 609
484 // Is this the default storage partition? If it isn't, then just give it its 610 // Is this the default storage partition? If it isn't, then just give it its
485 // own non-shared process. 611 // own non-shared process.
486 if (partition != default_partition || is_for_guests_only) { 612 if (partition != default_partition || is_for_guests_only) {
487 RenderProcessHostImpl* host = new RenderProcessHostImpl( 613 RenderProcessHost* host = RenderProcessHostImpl::CreateRenderProcessHost(
488 browser_context_, static_cast<StoragePartitionImpl*>(partition), 614 browser_context_, partition, is_for_guests_only);
489 is_for_guests_only);
490 host->SetIsNeverSuitableForReuse(); 615 host->SetIsNeverSuitableForReuse();
491 return host; 616 return host;
492 } 617 }
493 618
494 // If we already have a shared host for the default storage partition, use 619 // If we already have a shared host for the default storage partition, use
495 // it. 620 // it.
496 if (host_) 621 if (host_)
497 return host_; 622 return host_;
498 623
499 host_ = new RenderProcessHostImpl( 624 host_ = RenderProcessHostImpl::CreateOrUseSpareRenderProcessHost(
500 browser_context_, static_cast<StoragePartitionImpl*>(partition), 625 browser_context_, partition, false /* is for guests only */);
501 false /* for guests only */);
502 host_->SetIsNeverSuitableForReuse(); 626 host_->SetIsNeverSuitableForReuse();
503 host_->AddObserver(this); 627 host_->AddObserver(this);
504 628
505 return host_; 629 return host_;
506 } 630 }
507 631
508 // Implementation of RenderProcessHostObserver. 632 // Implementation of RenderProcessHostObserver.
509 void RenderProcessHostDestroyed(RenderProcessHost* host) override { 633 void RenderProcessHostDestroyed(RenderProcessHost* host) override {
510 DCHECK_EQ(host_, host); 634 DCHECK_EQ(host_, host);
511 host_->RemoveObserver(this); 635 host_->RemoveObserver(this);
512 host_ = nullptr; 636 host_ = nullptr;
513 } 637 }
514 638
515 private: 639 private:
516 BrowserContext* browser_context_; 640 BrowserContext* browser_context_;
517 641
518 // The default subframe render process used for the default storage partition 642 // The default subframe render process used for the default storage partition
519 // of this BrowserContext. 643 // of this BrowserContext.
520 RenderProcessHostImpl* host_ = nullptr; 644 RenderProcessHost* host_ = nullptr;
521 }; 645 };
522 646
523 void CreateMemoryCoordinatorHandle( 647 void CreateMemoryCoordinatorHandle(
524 int render_process_id, 648 int render_process_id,
525 const service_manager::BindSourceInfo& source_info, 649 const service_manager::BindSourceInfo& source_info,
526 mojom::MemoryCoordinatorHandleRequest request) { 650 mojom::MemoryCoordinatorHandleRequest request) {
527 MemoryCoordinatorImpl::GetInstance()->CreateHandle(render_process_id, 651 MemoryCoordinatorImpl::GetInstance()->CreateHandle(render_process_id,
528 std::move(request)); 652 std::move(request));
529 } 653 }
530 654
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 base::AutoLock lock(lock_); 1089 base::AutoLock lock(lock_);
966 if (filter_) 1090 if (filter_)
967 filter_->Disable(); 1091 filter_->Disable();
968 } 1092 }
969 1093
970 base::MessageLoop* 1094 base::MessageLoop*
971 RenderProcessHostImpl::GetInProcessRendererThreadForTesting() { 1095 RenderProcessHostImpl::GetInProcessRendererThreadForTesting() {
972 return g_in_process_thread; 1096 return g_in_process_thread;
973 } 1097 }
974 1098
1099 bool RenderProcessHostImpl::HostHasNotBeenUsed() {
Charlie Reis 2017/06/30 21:42:16 nit: This should be put in the same order as in th
mattcary 2017/07/03 08:03:02 Done.
1100 return IsUnused() && listeners_.IsEmpty() && GetWorkerRefCount() == 0 &&
1101 pending_views_ == 0;
1102 }
1103
975 // static 1104 // static
976 size_t RenderProcessHost::GetMaxRendererProcessCount() { 1105 size_t RenderProcessHost::GetMaxRendererProcessCount() {
977 if (g_max_renderer_count_override) 1106 if (g_max_renderer_count_override)
978 return g_max_renderer_count_override; 1107 return g_max_renderer_count_override;
979 1108
980 #if defined(OS_ANDROID) 1109 #if defined(OS_ANDROID)
981 // On Android we don't maintain a limit of renderer process hosts - we are 1110 // On Android we don't maintain a limit of renderer process hosts - we are
982 // happy with keeping a lot of these, as long as the number of live renderer 1111 // happy with keeping a lot of these, as long as the number of live renderer
983 // processes remains reasonable, and on Android the OS takes care of that. 1112 // processes remains reasonable, and on Android the OS takes care of that.
984 // TODO(boliu): This is a short term workaround before ChildProcessLauncher 1113 // TODO(boliu): This is a short term workaround before ChildProcessLauncher
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 max_count = std::min(max_count, kMaxRendererProcessCount); 1151 max_count = std::min(max_count, kMaxRendererProcessCount);
1023 } 1152 }
1024 return max_count; 1153 return max_count;
1025 } 1154 }
1026 1155
1027 // static 1156 // static
1028 void RenderProcessHost::SetMaxRendererProcessCount(size_t count) { 1157 void RenderProcessHost::SetMaxRendererProcessCount(size_t count) {
1029 g_max_renderer_count_override = count; 1158 g_max_renderer_count_override = count;
1030 } 1159 }
1031 1160
1161 // static
1162 RenderProcessHost* RenderProcessHostImpl::CreateRenderProcessHost(
1163 BrowserContext* browser_context,
1164 StoragePartitionImpl* storage_partition_impl,
1165 bool is_for_guests_only) {
1166 if (g_render_process_host_factory_) {
1167 return g_render_process_host_factory_->CreateRenderProcessHost(
1168 browser_context);
1169 }
1170
1171 return new RenderProcessHostImpl(browser_context, storage_partition_impl,
1172 is_for_guests_only);
1173 }
1174
1175 // static
1176 RenderProcessHost* RenderProcessHostImpl::CreateOrUseSpareRenderProcessHost(
1177 BrowserContext* browser_context,
1178 StoragePartitionImpl* storage_partition_impl,
1179 bool is_for_guests_only) {
1180 RenderProcessHost* render_process_host =
1181 g_spare_render_process_host_manager.Get().MaybeTakeSpareRenderProcessHost(
1182 browser_context, storage_partition_impl, is_for_guests_only);
1183
1184 if (!render_process_host) {
1185 render_process_host = CreateRenderProcessHost(
1186 browser_context, storage_partition_impl, is_for_guests_only);
1187 }
1188
1189 DCHECK(render_process_host);
1190 return render_process_host;
1191 }
1192
1032 RenderProcessHostImpl::RenderProcessHostImpl( 1193 RenderProcessHostImpl::RenderProcessHostImpl(
1033 BrowserContext* browser_context, 1194 BrowserContext* browser_context,
1034 StoragePartitionImpl* storage_partition_impl, 1195 StoragePartitionImpl* storage_partition_impl,
1035 bool is_for_guests_only) 1196 bool is_for_guests_only)
1036 : fast_shutdown_started_(false), 1197 : fast_shutdown_started_(false),
1037 deleting_soon_(false), 1198 deleting_soon_(false),
1038 #ifndef NDEBUG 1199 #ifndef NDEBUG
1039 is_self_deleted_(false), 1200 is_self_deleted_(false),
1040 #endif 1201 #endif
1041 pending_views_(0), 1202 pending_views_(0),
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
1875 } 2036 }
1876 2037
1877 void RenderProcessHostImpl::ForceReleaseWorkerRefCounts() { 2038 void RenderProcessHostImpl::ForceReleaseWorkerRefCounts() {
1878 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2039 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1879 DCHECK(!is_worker_ref_count_disabled_); 2040 DCHECK(!is_worker_ref_count_disabled_);
1880 is_worker_ref_count_disabled_ = true; 2041 is_worker_ref_count_disabled_ = true;
1881 if (!GetWorkerRefCount()) 2042 if (!GetWorkerRefCount())
1882 return; 2043 return;
1883 service_worker_ref_count_ = 0; 2044 service_worker_ref_count_ = 0;
1884 shared_worker_ref_count_ = 0; 2045 shared_worker_ref_count_ = 0;
2046 // Cleaning up will also remove this from the SpareRenderProcessHostManager.
1885 Cleanup(); 2047 Cleanup();
1886 } 2048 }
1887 2049
1888 bool RenderProcessHostImpl::IsWorkerRefCountDisabled() { 2050 bool RenderProcessHostImpl::IsWorkerRefCountDisabled() {
1889 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2051 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1890 return is_worker_ref_count_disabled_; 2052 return is_worker_ref_count_disabled_;
1891 } 2053 }
1892 2054
1893 void RenderProcessHostImpl::PurgeAndSuspend() { 2055 void RenderProcessHostImpl::PurgeAndSuspend() {
1894 Send(new ChildProcessMsg_PurgeAndSuspend()); 2056 Send(new ChildProcessMsg_PurgeAndSuspend());
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
2106 SiteProcessCountTracker* tracker = static_cast<SiteProcessCountTracker*>( 2268 SiteProcessCountTracker* tracker = static_cast<SiteProcessCountTracker*>(
2107 browser_context->GetUserData(kPendingSiteProcessCountTrackerKey)); 2269 browser_context->GetUserData(kPendingSiteProcessCountTrackerKey));
2108 if (!tracker) { 2270 if (!tracker) {
2109 tracker = new SiteProcessCountTracker(); 2271 tracker = new SiteProcessCountTracker();
2110 browser_context->SetUserData(kPendingSiteProcessCountTrackerKey, 2272 browser_context->SetUserData(kPendingSiteProcessCountTrackerKey,
2111 base::WrapUnique(tracker)); 2273 base::WrapUnique(tracker));
2112 } 2274 }
2113 tracker->DecrementSiteProcessCount(site_url, render_process_host->GetID()); 2275 tracker->DecrementSiteProcessCount(site_url, render_process_host->GetID());
2114 } 2276 }
2115 2277
2278 // static
2279 RenderProcessHost*
2280 RenderProcessHostImpl::GetSpareRenderProcessHostForTesting() {
2281 return g_spare_render_process_host_manager.Get().spare_render_process_host();
2282 }
2283
2116 bool RenderProcessHostImpl::IsForGuestsOnly() const { 2284 bool RenderProcessHostImpl::IsForGuestsOnly() const {
2117 return is_for_guests_only_; 2285 return is_for_guests_only_;
2118 } 2286 }
2119 2287
2120 StoragePartition* RenderProcessHostImpl::GetStoragePartition() const { 2288 StoragePartition* RenderProcessHostImpl::GetStoragePartition() const {
2121 return storage_partition_impl_; 2289 return storage_partition_impl_;
2122 } 2290 }
2123 2291
2124 static void AppendCompositorCommandLineFlags(base::CommandLine* command_line) { 2292 static void AppendCompositorCommandLineFlags(base::CommandLine* command_line) {
2125 command_line->AppendSwitchASCII( 2293 command_line->AppendSwitchASCII(
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after
3060 // Otherwise, if this process has been used to host any other content, it 3228 // Otherwise, if this process has been used to host any other content, it
3061 // cannot be reused if the destination site indeed requires a dedicated 3229 // cannot be reused if the destination site indeed requires a dedicated
3062 // process and can be locked to just that site. 3230 // process and can be locked to just that site.
3063 return false; 3231 return false;
3064 } 3232 }
3065 3233
3066 return GetContentClient()->browser()->IsSuitableHost(host, site_url); 3234 return GetContentClient()->browser()->IsSuitableHost(host, site_url);
3067 } 3235 }
3068 3236
3069 // static 3237 // static
3238 void RenderProcessHost::WarmupSpareRenderProcessHost(
3239 content::BrowserContext* browser_context) {
3240 g_spare_render_process_host_manager.Get().WarmupSpareRenderProcessHost(
3241 browser_context);
3242 }
3243
3244 // static
3070 bool RenderProcessHost::run_renderer_in_process() { 3245 bool RenderProcessHost::run_renderer_in_process() {
3071 return g_run_renderer_in_process_; 3246 return g_run_renderer_in_process_;
3072 } 3247 }
3073 3248
3074 // static 3249 // static
3075 void RenderProcessHost::SetRunRendererInProcess(bool value) { 3250 void RenderProcessHost::SetRunRendererInProcess(bool value) {
3076 g_run_renderer_in_process_ = value; 3251 g_run_renderer_in_process_ = value;
3077 3252
3078 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 3253 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
3079 if (value) { 3254 if (value) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
3137 browser_context, site_url)) { 3312 browser_context, site_url)) {
3138 suitable_renderers.push_back(iter.GetCurrentValue()); 3313 suitable_renderers.push_back(iter.GetCurrentValue());
3139 } 3314 }
3140 iter.Advance(); 3315 iter.Advance();
3141 } 3316 }
3142 3317
3143 // Now pick a random suitable renderer, if we have any. 3318 // Now pick a random suitable renderer, if we have any.
3144 if (!suitable_renderers.empty()) { 3319 if (!suitable_renderers.empty()) {
3145 int suitable_count = static_cast<int>(suitable_renderers.size()); 3320 int suitable_count = static_cast<int>(suitable_renderers.size());
3146 int random_index = base::RandInt(0, suitable_count - 1); 3321 int random_index = base::RandInt(0, suitable_count - 1);
3322 // If the process chosen was the spare RenderProcessHost, ensure it won't be
3323 // used as a spare in the future.
3324 g_spare_render_process_host_manager.Get().DropSpareRenderProcessHost(
3325 suitable_renderers[random_index]);
3147 return suitable_renderers[random_index]; 3326 return suitable_renderers[random_index];
3148 } 3327 }
3149 3328
3150 return NULL; 3329 return NULL;
3151 } 3330 }
3152 3331
3153 // static 3332 // static
3154 bool RenderProcessHost::ShouldUseProcessPerSite(BrowserContext* browser_context, 3333 bool RenderProcessHost::ShouldUseProcessPerSite(BrowserContext* browser_context,
3155 const GURL& url) { 3334 const GURL& url) {
3156 // Returns true if we should use the process-per-site model. This will be 3335 // Returns true if we should use the process-per-site model. This will be
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
3263 render_process_host = UnmatchedServiceWorkerProcessTracker::MatchWithSite( 3442 render_process_host = UnmatchedServiceWorkerProcessTracker::MatchWithSite(
3264 browser_context, site_url); 3443 browser_context, site_url);
3265 } 3444 }
3266 3445
3267 // If not (or if none found), see if we should reuse an existing process. 3446 // If not (or if none found), see if we should reuse an existing process.
3268 if (!render_process_host && 3447 if (!render_process_host &&
3269 ShouldTryToUseExistingProcessHost(browser_context, site_url)) { 3448 ShouldTryToUseExistingProcessHost(browser_context, site_url)) {
3270 render_process_host = GetExistingProcessHost(browser_context, site_url); 3449 render_process_host = GetExistingProcessHost(browser_context, site_url);
3271 } 3450 }
3272 3451
3273 // Otherwise (or if that fails), create a new one.
3274 if (!render_process_host) { 3452 if (!render_process_host) {
Charlie Reis 2017/06/30 21:42:16 Let's keep a comment here, like: // Otherwise, us
mattcary 2017/07/03 08:03:02 Done.
3275 if (g_render_process_host_factory_) { 3453 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
3276 render_process_host = 3454 BrowserContext::GetStoragePartition(browser_context, site_instance));
3277 g_render_process_host_factory_->CreateRenderProcessHost( 3455 render_process_host = CreateOrUseSpareRenderProcessHost(
3278 browser_context); 3456 browser_context, partition, is_for_guests_only);
3279 } else {
3280 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
3281 BrowserContext::GetStoragePartition(browser_context, site_instance));
3282 render_process_host = new RenderProcessHostImpl(
3283 browser_context, partition, is_for_guests_only);
3284 }
3285 } 3457 }
3286 3458
3287 if (is_unmatched_service_worker) { 3459 if (is_unmatched_service_worker) {
3288 UnmatchedServiceWorkerProcessTracker::Register( 3460 UnmatchedServiceWorkerProcessTracker::Register(
3289 browser_context, render_process_host, site_url); 3461 browser_context, render_process_host, site_url);
3290 } 3462 }
3291 return render_process_host; 3463 return render_process_host;
3292 } 3464 }
3293 3465
3294 void RenderProcessHostImpl::CreateSharedRendererHistogramAllocator() { 3466 void RenderProcessHostImpl::CreateSharedRendererHistogramAllocator() {
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
3787 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; 3959 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error;
3788 3960
3789 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. 3961 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing.
3790 // Capture the error message in a crash key value. 3962 // Capture the error message in a crash key value.
3791 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); 3963 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error);
3792 bad_message::ReceivedBadMessage(render_process_id, 3964 bad_message::ReceivedBadMessage(render_process_id,
3793 bad_message::RPH_MOJO_PROCESS_ERROR); 3965 bad_message::RPH_MOJO_PROCESS_ERROR);
3794 } 3966 }
3795 3967
3796 } // namespace content 3968 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698