| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/renderer_host/mock_render_process_host.h" | 5 #include "content/browser/renderer_host/mock_render_process_host.h" |
| 6 | 6 |
| 7 #include "content/browser/child_process_security_policy.h" | 7 #include "content/browser/child_process_security_policy.h" |
| 8 | 8 |
| 9 MockRenderProcessHost::MockRenderProcessHost(Profile* profile) | 9 MockRenderProcessHost::MockRenderProcessHost(content::BrowserContext* context) |
| 10 : RenderProcessHost(profile), | 10 : RenderProcessHost(context), |
| 11 transport_dib_(NULL), | 11 transport_dib_(NULL), |
| 12 bad_msg_count_(0), | 12 bad_msg_count_(0), |
| 13 factory_(NULL) { | 13 factory_(NULL) { |
| 14 // Child process security operations can't be unit tested unless we add | 14 // Child process security operations can't be unit tested unless we add |
| 15 // ourselves as an existing child process. | 15 // ourselves as an existing child process. |
| 16 ChildProcessSecurityPolicy::GetInstance()->Add(id()); | 16 ChildProcessSecurityPolicy::GetInstance()->Add(id()); |
| 17 } | 17 } |
| 18 | 18 |
| 19 MockRenderProcessHost::~MockRenderProcessHost() { | 19 MockRenderProcessHost::~MockRenderProcessHost() { |
| 20 ChildProcessSecurityPolicy::GetInstance()->Remove(id()); | 20 ChildProcessSecurityPolicy::GetInstance()->Remove(id()); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 MockRenderProcessHostFactory::~MockRenderProcessHostFactory() { | 120 MockRenderProcessHostFactory::~MockRenderProcessHostFactory() { |
| 121 // Detach this object from MockRenderProcesses to prevent STLDeleteElements() | 121 // Detach this object from MockRenderProcesses to prevent STLDeleteElements() |
| 122 // from calling MockRenderProcessHostFactory::Remove(). | 122 // from calling MockRenderProcessHostFactory::Remove(). |
| 123 for (ScopedVector<MockRenderProcessHost>::iterator it = processes_.begin(); | 123 for (ScopedVector<MockRenderProcessHost>::iterator it = processes_.begin(); |
| 124 it != processes_.end(); ++it) { | 124 it != processes_.end(); ++it) { |
| 125 (*it)->SetFactory(NULL); | 125 (*it)->SetFactory(NULL); |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 | 128 |
| 129 RenderProcessHost* MockRenderProcessHostFactory::CreateRenderProcessHost( | 129 RenderProcessHost* MockRenderProcessHostFactory::CreateRenderProcessHost( |
| 130 Profile* profile) const { | 130 content::BrowserContext* context) const { |
| 131 MockRenderProcessHost* host = new MockRenderProcessHost(profile); | 131 MockRenderProcessHost* host = new MockRenderProcessHost(context); |
| 132 if (host) { | 132 if (host) { |
| 133 processes_.push_back(host); | 133 processes_.push_back(host); |
| 134 host->SetFactory(this); | 134 host->SetFactory(this); |
| 135 } | 135 } |
| 136 return host; | 136 return host; |
| 137 } | 137 } |
| 138 | 138 |
| 139 void MockRenderProcessHostFactory::Remove(MockRenderProcessHost* host) const { | 139 void MockRenderProcessHostFactory::Remove(MockRenderProcessHost* host) const { |
| 140 for (ScopedVector<MockRenderProcessHost>::iterator it = processes_.begin(); | 140 for (ScopedVector<MockRenderProcessHost>::iterator it = processes_.begin(); |
| 141 it != processes_.end(); ++it) { | 141 it != processes_.end(); ++it) { |
| 142 if (*it == host) { | 142 if (*it == host) { |
| 143 processes_.weak_erase(it); | 143 processes_.weak_erase(it); |
| 144 break; | 144 break; |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 } | 147 } |
| OLD | NEW |