| OLD | NEW | 
|    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/test_utils.h" |    5 #include "content/public/test/test_utils.h" | 
|    6  |    6  | 
|    7 #include <utility> |    7 #include <utility> | 
|    8  |    8  | 
|    9 #include "base/bind.h" |    9 #include "base/bind.h" | 
|   10 #include "base/command_line.h" |   10 #include "base/command_line.h" | 
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  308 InProcessUtilityThreadHelper::InProcessUtilityThreadHelper() |  308 InProcessUtilityThreadHelper::InProcessUtilityThreadHelper() | 
|  309     : child_thread_count_(0), shell_context_(new TestServiceManagerContext) { |  309     : child_thread_count_(0), shell_context_(new TestServiceManagerContext) { | 
|  310   RenderProcessHost::SetRunRendererInProcess(true); |  310   RenderProcessHost::SetRunRendererInProcess(true); | 
|  311   BrowserChildProcessObserver::Add(this); |  311   BrowserChildProcessObserver::Add(this); | 
|  312 } |  312 } | 
|  313  |  313  | 
|  314 InProcessUtilityThreadHelper::~InProcessUtilityThreadHelper() { |  314 InProcessUtilityThreadHelper::~InProcessUtilityThreadHelper() { | 
|  315   if (child_thread_count_) { |  315   if (child_thread_count_) { | 
|  316     DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::UI)); |  316     DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::UI)); | 
|  317     DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::IO)); |  317     DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::IO)); | 
|  318     runner_ = new MessageLoopRunner; |  318     run_loop_.reset(new base::RunLoop); | 
|  319     runner_->Run(); |  319     run_loop_->Run(); | 
|  320   } |  320   } | 
|  321   BrowserChildProcessObserver::Remove(this); |  321   BrowserChildProcessObserver::Remove(this); | 
|  322   RenderProcessHost::SetRunRendererInProcess(false); |  322   RenderProcessHost::SetRunRendererInProcess(false); | 
|  323 } |  323 } | 
|  324  |  324  | 
|  325 void InProcessUtilityThreadHelper::BrowserChildProcessHostConnected( |  325 void InProcessUtilityThreadHelper::BrowserChildProcessHostConnected( | 
|  326     const ChildProcessData& data) { |  326     const ChildProcessData& data) { | 
|  327   child_thread_count_++; |  327   child_thread_count_++; | 
|  328 } |  328 } | 
|  329  |  329  | 
|  330 void InProcessUtilityThreadHelper::BrowserChildProcessHostDisconnected( |  330 void InProcessUtilityThreadHelper::BrowserChildProcessHostDisconnected( | 
|  331     const ChildProcessData& data) { |  331     const ChildProcessData& data) { | 
|  332   if (--child_thread_count_) |  332   if (--child_thread_count_) | 
|  333     return; |  333     return; | 
|  334  |  334  | 
|  335   if (runner_.get()) |  335   if (run_loop_) | 
|  336     runner_->Quit(); |  336     run_loop_->Quit(); | 
|  337 } |  337 } | 
|  338  |  338  | 
|  339 RenderFrameDeletedObserver::RenderFrameDeletedObserver(RenderFrameHost* rfh) |  339 RenderFrameDeletedObserver::RenderFrameDeletedObserver(RenderFrameHost* rfh) | 
|  340     : WebContentsObserver(WebContents::FromRenderFrameHost(rfh)), |  340     : WebContentsObserver(WebContents::FromRenderFrameHost(rfh)), | 
|  341       process_id_(rfh->GetProcess()->GetID()), |  341       process_id_(rfh->GetProcess()->GetID()), | 
|  342       routing_id_(rfh->GetRoutingID()), |  342       routing_id_(rfh->GetRoutingID()), | 
|  343       deleted_(false) {} |  343       deleted_(false) {} | 
|  344  |  344  | 
|  345 RenderFrameDeletedObserver::~RenderFrameDeletedObserver() {} |  345 RenderFrameDeletedObserver::~RenderFrameDeletedObserver() {} | 
|  346  |  346  | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
|  363   if (deleted_) |  363   if (deleted_) | 
|  364     return; |  364     return; | 
|  365  |  365  | 
|  366   runner_.reset(new base::RunLoop()); |  366   runner_.reset(new base::RunLoop()); | 
|  367   runner_->Run(); |  367   runner_->Run(); | 
|  368   runner_.reset(); |  368   runner_.reset(); | 
|  369 } |  369 } | 
|  370  |  370  | 
|  371 WebContentsDestroyedWatcher::WebContentsDestroyedWatcher( |  371 WebContentsDestroyedWatcher::WebContentsDestroyedWatcher( | 
|  372     WebContents* web_contents) |  372     WebContents* web_contents) | 
|  373     : WebContentsObserver(web_contents), |  373     : WebContentsObserver(web_contents) { | 
|  374       message_loop_runner_(new MessageLoopRunner) { |  | 
|  375   EXPECT_TRUE(web_contents != NULL); |  374   EXPECT_TRUE(web_contents != NULL); | 
|  376 } |  375 } | 
|  377  |  376  | 
|  378 WebContentsDestroyedWatcher::~WebContentsDestroyedWatcher() {} |  377 WebContentsDestroyedWatcher::~WebContentsDestroyedWatcher() { | 
 |  378 } | 
|  379  |  379  | 
|  380 void WebContentsDestroyedWatcher::Wait() { |  380 void WebContentsDestroyedWatcher::Wait() { | 
|  381   message_loop_runner_->Run(); |  381   run_loop_.Run(); | 
|  382 } |  382 } | 
|  383  |  383  | 
|  384 void WebContentsDestroyedWatcher::WebContentsDestroyed() { |  384 void WebContentsDestroyedWatcher::WebContentsDestroyed() { | 
|  385   message_loop_runner_->Quit(); |  385   run_loop_.Quit(); | 
|  386 } |  386 } | 
|  387  |  387  | 
|  388 }  // namespace content |  388 }  // namespace content | 
| OLD | NEW |