| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/test_web_contents_factory.h" | 5 #include "content/public/test/test_web_contents_factory.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" |
| 7 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 8 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
| 9 #include "content/public/test/test_renderer_host.h" | 10 #include "content/public/test/test_renderer_host.h" |
| 10 #include "content/public/test/web_contents_tester.h" | 11 #include "content/public/test/web_contents_tester.h" |
| 11 | 12 |
| 12 namespace content { | 13 namespace content { |
| 13 | 14 |
| 14 TestWebContentsFactory::TestWebContentsFactory() | 15 TestWebContentsFactory::TestWebContentsFactory() |
| 15 : rvh_enabler_(new content::RenderViewHostTestEnabler()) { | 16 : rvh_enabler_(new content::RenderViewHostTestEnabler()) { |
| 16 } | 17 } |
| 17 | 18 |
| 18 TestWebContentsFactory::~TestWebContentsFactory() { | 19 TestWebContentsFactory::~TestWebContentsFactory() { |
| 19 // We explicitly clear the vector to force destruction of any created web | 20 // We explicitly clear the vector to force destruction of any created web |
| 20 // contents so that we can properly handle their cleanup (running posted | 21 // contents so that we can properly handle their cleanup (running posted |
| 21 // tasks, etc). | 22 // tasks, etc). |
| 22 web_contents_.clear(); | 23 web_contents_.clear(); |
| 23 // Let any posted tasks for web contents deletion run. | 24 // Let any posted tasks for web contents deletion run. |
| 24 base::RunLoop().RunUntilIdle(); | 25 base::RunLoop().RunUntilIdle(); |
| 25 rvh_enabler_.reset(); | 26 rvh_enabler_.reset(); |
| 26 // Let any posted tasks for RenderProcess/ViewHost deletion run. | 27 // Let any posted tasks for RenderProcess/ViewHost deletion run. |
| 27 base::RunLoop().RunUntilIdle(); | 28 base::RunLoop().RunUntilIdle(); |
| 28 } | 29 } |
| 29 | 30 |
| 30 WebContents* TestWebContentsFactory::CreateWebContents( | 31 WebContents* TestWebContentsFactory::CreateWebContents( |
| 31 BrowserContext* context) { | 32 BrowserContext* context) { |
| 32 web_contents_.push_back( | 33 web_contents_.push_back(base::WrapUnique( |
| 33 WebContentsTester::CreateTestWebContents(context, nullptr)); | 34 WebContentsTester::CreateTestWebContents(context, nullptr))); |
| 34 DCHECK(web_contents_.back()); | 35 DCHECK(web_contents_.back()); |
| 35 return web_contents_.back(); | 36 return web_contents_.back().get(); |
| 36 } | 37 } |
| 37 | 38 |
| 38 } // namespace content | 39 } // namespace content |
| OLD | NEW |