| 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/test/test_browser_thread.h" | 5 #include "content/test/test_browser_thread.h" | 
| 6 | 6 | 
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" | 
| 8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" | 
| 9 #include "content/browser/browser_thread_impl.h" | 9 #include "content/browser/browser_thread_impl.h" | 
|  | 10 #include "content/browser/notification_service_impl.h" | 
| 10 | 11 | 
| 11 namespace content { | 12 namespace content { | 
| 12 | 13 | 
| 13 // This gives access to set_message_loop(). | 14 // This gives access to set_message_loop(). | 
| 14 class TestBrowserThreadImpl : public BrowserThreadImpl { | 15 class TestBrowserThreadImpl : public BrowserThreadImpl { | 
| 15  public: | 16  public: | 
| 16   explicit TestBrowserThreadImpl(BrowserThread::ID identifier) | 17   explicit TestBrowserThreadImpl(BrowserThread::ID identifier) | 
| 17       : BrowserThreadImpl(identifier) { | 18       : BrowserThreadImpl(identifier), | 
|  | 19         notification_service_(NULL) { | 
| 18   } | 20   } | 
| 19 | 21 | 
| 20   TestBrowserThreadImpl(BrowserThread::ID identifier, | 22   TestBrowserThreadImpl(BrowserThread::ID identifier, | 
| 21                         MessageLoop* message_loop) | 23                         MessageLoop* message_loop) | 
| 22       : BrowserThreadImpl(identifier, message_loop) { | 24       : BrowserThreadImpl(identifier, message_loop), | 
|  | 25         notification_service_(NULL) { | 
| 23   } | 26   } | 
| 24 | 27 | 
| 25   virtual ~TestBrowserThreadImpl() { | 28   virtual ~TestBrowserThreadImpl() { | 
| 26     Stop(); | 29     Stop(); | 
| 27   } | 30   } | 
| 28 | 31 | 
| 29   void set_message_loop(MessageLoop* loop) { | 32   void set_message_loop(MessageLoop* loop) { | 
| 30     Thread::set_message_loop(loop); | 33     Thread::set_message_loop(loop); | 
| 31   } | 34   } | 
| 32 | 35 | 
|  | 36   virtual void Init() OVERRIDE { | 
|  | 37     notification_service_ = new NotificationServiceImpl; | 
|  | 38     BrowserThreadImpl::Init(); | 
|  | 39   } | 
|  | 40 | 
|  | 41   virtual void CleanUp() OVERRIDE { | 
|  | 42     delete notification_service_; | 
|  | 43     notification_service_ = NULL; | 
|  | 44     BrowserThreadImpl::CleanUp(); | 
|  | 45   } | 
|  | 46 | 
| 33  private: | 47  private: | 
|  | 48   NotificationService* notification_service_; | 
| 34   DISALLOW_COPY_AND_ASSIGN(TestBrowserThreadImpl); | 49   DISALLOW_COPY_AND_ASSIGN(TestBrowserThreadImpl); | 
| 35 }; | 50 }; | 
| 36 | 51 | 
| 37 TestBrowserThread::TestBrowserThread(BrowserThread::ID identifier) | 52 TestBrowserThread::TestBrowserThread(BrowserThread::ID identifier) | 
| 38     : impl_(new TestBrowserThreadImpl(identifier)) { | 53     : impl_(new TestBrowserThreadImpl(identifier)) { | 
| 39 } | 54 } | 
| 40 | 55 | 
| 41 TestBrowserThread::TestBrowserThread(BrowserThread::ID identifier, | 56 TestBrowserThread::TestBrowserThread(BrowserThread::ID identifier, | 
| 42                                      MessageLoop* message_loop) | 57                                      MessageLoop* message_loop) | 
| 43     : impl_(new TestBrowserThreadImpl(identifier, message_loop)) { | 58     : impl_(new TestBrowserThreadImpl(identifier, message_loop)) { | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
| 67 | 82 | 
| 68 base::Thread* TestBrowserThread::DeprecatedGetThreadObject() { | 83 base::Thread* TestBrowserThread::DeprecatedGetThreadObject() { | 
| 69   return impl_.get(); | 84   return impl_.get(); | 
| 70 } | 85 } | 
| 71 | 86 | 
| 72 void TestBrowserThread::DeprecatedSetMessageLoop(MessageLoop* loop) { | 87 void TestBrowserThread::DeprecatedSetMessageLoop(MessageLoop* loop) { | 
| 73   impl_->set_message_loop(loop); | 88   impl_->set_message_loop(loop); | 
| 74 } | 89 } | 
| 75 | 90 | 
| 76 }  // namespace content | 91 }  // namespace content | 
| OLD | NEW | 
|---|