| 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 "base/message_loop/message_loop_proxy.h" |    5 #include "base/message_loop/message_loop_proxy.h" | 
|    6  |    6  | 
|    7 #include "base/atomic_sequence_num.h" |    7 #include "base/atomic_sequence_num.h" | 
|    8 #include "base/bind.h" |    8 #include "base/bind.h" | 
|    9 #include "base/debug/leak_annotations.h" |    9 #include "base/debug/leak_annotations.h" | 
|   10 #include "base/memory/ref_counted.h" |   10 #include "base/memory/ref_counted.h" | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
|   24       : current_loop_(new MessageLoop()), |   24       : current_loop_(new MessageLoop()), | 
|   25         task_thread_("task_thread"), |   25         task_thread_("task_thread"), | 
|   26         thread_sync_(true, false) { |   26         thread_sync_(true, false) { | 
|   27   } |   27   } | 
|   28  |   28  | 
|   29   void DeleteCurrentMessageLoop() { |   29   void DeleteCurrentMessageLoop() { | 
|   30     current_loop_.reset(); |   30     current_loop_.reset(); | 
|   31   } |   31   } | 
|   32  |   32  | 
|   33  protected: |   33  protected: | 
|   34   virtual void SetUp() OVERRIDE { |   34   virtual void SetUp() override { | 
|   35     // Use SetUp() instead of the constructor to avoid posting a task to a |   35     // Use SetUp() instead of the constructor to avoid posting a task to a | 
|   36     // partialy constructed object. |   36     // partialy constructed object. | 
|   37     task_thread_.Start(); |   37     task_thread_.Start(); | 
|   38  |   38  | 
|   39     // Allow us to pause the |task_thread_|'s MessageLoop. |   39     // Allow us to pause the |task_thread_|'s MessageLoop. | 
|   40     task_thread_.message_loop()->PostTask( |   40     task_thread_.message_loop()->PostTask( | 
|   41         FROM_HERE, |   41         FROM_HERE, | 
|   42         Bind(&MessageLoopProxyTest::BlockTaskThreadHelper, Unretained(this))); |   42         Bind(&MessageLoopProxyTest::BlockTaskThreadHelper, Unretained(this))); | 
|   43   } |   43   } | 
|   44  |   44  | 
|   45   virtual void TearDown() OVERRIDE { |   45   virtual void TearDown() override { | 
|   46     // Make sure the |task_thread_| is not blocked, and stop the thread |   46     // Make sure the |task_thread_| is not blocked, and stop the thread | 
|   47     // fully before destuction because its tasks may still depend on the |   47     // fully before destuction because its tasks may still depend on the | 
|   48     // |thread_sync_| event. |   48     // |thread_sync_| event. | 
|   49     thread_sync_.Signal(); |   49     thread_sync_.Signal(); | 
|   50     task_thread_.Stop(); |   50     task_thread_.Stop(); | 
|   51     DeleteCurrentMessageLoop(); |   51     DeleteCurrentMessageLoop(); | 
|   52   } |   52   } | 
|   53  |   53  | 
|   54   // Make LoopRecorder threadsafe so that there is defined behavior even if a |   54   // Make LoopRecorder threadsafe so that there is defined behavior even if a | 
|   55   // threading mistake sneaks into the PostTaskAndReplyRelay implementation. |   55   // threading mistake sneaks into the PostTaskAndReplyRelay implementation. | 
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  257   // it, we cannot just delete it because PostTaskAndReplyRelay's destructor |  257   // it, we cannot just delete it because PostTaskAndReplyRelay's destructor | 
|  258   // checks that MessageLoop::current() is the the same as when the |  258   // checks that MessageLoop::current() is the the same as when the | 
|  259   // PostTaskAndReplyRelay object was constructed.  However, this loop must have |  259   // PostTaskAndReplyRelay object was constructed.  However, this loop must have | 
|  260   // aleady been deleted in order to perform this test.  See |  260   // aleady been deleted in order to perform this test.  See | 
|  261   // http://crbug.com/86301. |  261   // http://crbug.com/86301. | 
|  262 } |  262 } | 
|  263  |  263  | 
|  264 }  // namespace |  264 }  // namespace | 
|  265  |  265  | 
|  266 }  // namespace base |  266 }  // namespace base | 
| OLD | NEW |