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

Side by Side Diff: content/public/test/mock_render_process_host.cc

Issue 2921063003: Fix process reuse for dedicated processes when over process limit. (Closed)
Patch Set: Cleanup Created 3 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include "content/public/test/mock_render_process_host.h" 5 #include "content/public/test/mock_render_process_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 28 matching lines...) Expand all
39 : bad_msg_count_(0), 39 : bad_msg_count_(0),
40 factory_(NULL), 40 factory_(NULL),
41 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), 41 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()),
42 has_connection_(false), 42 has_connection_(false),
43 browser_context_(browser_context), 43 browser_context_(browser_context),
44 prev_routing_id_(0), 44 prev_routing_id_(0),
45 fast_shutdown_started_(false), 45 fast_shutdown_started_(false),
46 deletion_callback_called_(false), 46 deletion_callback_called_(false),
47 is_for_guests_only_(false), 47 is_for_guests_only_(false),
48 is_process_backgrounded_(false), 48 is_process_backgrounded_(false),
49 can_become_dedicated_process_(true),
49 worker_ref_count_(0) { 50 worker_ref_count_(0) {
50 // Child process security operations can't be unit tested unless we add 51 // Child process security operations can't be unit tested unless we add
51 // ourselves as an existing child process. 52 // ourselves as an existing child process.
52 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID()); 53 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID());
53 54
54 RenderProcessHostImpl::RegisterHost(GetID(), this); 55 RenderProcessHostImpl::RegisterHost(GetID(), this);
55 } 56 }
56 57
57 MockRenderProcessHost::~MockRenderProcessHost() { 58 MockRenderProcessHost::~MockRenderProcessHost() {
58 ChildProcessSecurityPolicyImpl::GetInstance()->Remove(GetID()); 59 ChildProcessSecurityPolicyImpl::GetInstance()->Remove(GetID());
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 bool MockRenderProcessHost::IsProcessBackgrounded() const { 290 bool MockRenderProcessHost::IsProcessBackgrounded() const {
290 return is_process_backgrounded_; 291 return is_process_backgrounded_;
291 } 292 }
292 293
293 size_t MockRenderProcessHost::GetWorkerRefCount() const { 294 size_t MockRenderProcessHost::GetWorkerRefCount() const {
294 return worker_ref_count_; 295 return worker_ref_count_;
295 } 296 }
296 297
297 void MockRenderProcessHost::IncrementServiceWorkerRefCount() { 298 void MockRenderProcessHost::IncrementServiceWorkerRefCount() {
298 ++worker_ref_count_; 299 ++worker_ref_count_;
300 UnsetCanBecomeDedicatedProcess();
Charlie Reis 2017/06/12 23:08:17 It's not obvious why these need to be here in Mock
alexmos 2017/06/14 22:39:05 Ah, good catch. These shouldn't be here, I just f
299 } 301 }
300 302
301 void MockRenderProcessHost::DecrementServiceWorkerRefCount() { 303 void MockRenderProcessHost::DecrementServiceWorkerRefCount() {
302 --worker_ref_count_; 304 --worker_ref_count_;
303 } 305 }
304 306
305 void MockRenderProcessHost::IncrementSharedWorkerRefCount() { 307 void MockRenderProcessHost::IncrementSharedWorkerRefCount() {
306 ++worker_ref_count_; 308 ++worker_ref_count_;
309 UnsetCanBecomeDedicatedProcess();
307 } 310 }
308 311
309 void MockRenderProcessHost::DecrementSharedWorkerRefCount() { 312 void MockRenderProcessHost::DecrementSharedWorkerRefCount() {
310 --worker_ref_count_; 313 --worker_ref_count_;
311 } 314 }
312 315
313 void MockRenderProcessHost::ForceReleaseWorkerRefCounts() { 316 void MockRenderProcessHost::ForceReleaseWorkerRefCounts() {
314 worker_ref_count_ = 0; 317 worker_ref_count_ = 0;
315 } 318 }
316 319
(...skipping 14 matching lines...) Expand all
331 } 334 }
332 335
333 void MockRenderProcessHost::SetIsNeverSuitableForReuse() { 336 void MockRenderProcessHost::SetIsNeverSuitableForReuse() {
334 NOTREACHED(); 337 NOTREACHED();
335 } 338 }
336 339
337 bool MockRenderProcessHost::MayReuseHost() { 340 bool MockRenderProcessHost::MayReuseHost() {
338 return true; 341 return true;
339 } 342 }
340 343
344 bool MockRenderProcessHost::CanBecomeDedicatedProcess() {
345 return can_become_dedicated_process_;
346 }
347
348 void MockRenderProcessHost::UnsetCanBecomeDedicatedProcess() {
349 can_become_dedicated_process_ = false;
350 }
351
341 void MockRenderProcessHost::FilterURL(bool empty_allowed, GURL* url) { 352 void MockRenderProcessHost::FilterURL(bool empty_allowed, GURL* url) {
342 RenderProcessHostImpl::FilterURL(this, empty_allowed, url); 353 RenderProcessHostImpl::FilterURL(this, empty_allowed, url);
343 } 354 }
344 355
345 #if BUILDFLAG(ENABLE_WEBRTC) 356 #if BUILDFLAG(ENABLE_WEBRTC)
346 void MockRenderProcessHost::EnableAudioDebugRecordings( 357 void MockRenderProcessHost::EnableAudioDebugRecordings(
347 const base::FilePath& file) { 358 const base::FilePath& file) {
348 } 359 }
349 360
350 void MockRenderProcessHost::DisableAudioDebugRecordings() {} 361 void MockRenderProcessHost::DisableAudioDebugRecordings() {}
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 for (auto it = processes_.begin(); it != processes_.end(); ++it) { 426 for (auto it = processes_.begin(); it != processes_.end(); ++it) {
416 if (it->get() == host) { 427 if (it->get() == host) {
417 it->release(); 428 it->release();
418 processes_.erase(it); 429 processes_.erase(it);
419 break; 430 break;
420 } 431 }
421 } 432 }
422 } 433 }
423 434
424 } // namespace content 435 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698