| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ash/test/ash_test_environment.h" |
| 6 |
| 7 #include "ash/test/ash_test_views_delegate.h" |
| 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" |
| 11 #include "base/test/sequenced_worker_pool_owner.h" |
| 12 #include "base/threading/sequenced_worker_pool.h" |
| 13 |
| 14 namespace ash { |
| 15 namespace test { |
| 16 namespace { |
| 17 |
| 18 class AshTestEnvironmentDefault : public AshTestEnvironment { |
| 19 public: |
| 20 AshTestEnvironmentDefault() {} |
| 21 |
| 22 ~AshTestEnvironmentDefault() override { |
| 23 base::RunLoop().RunUntilIdle(); |
| 24 blocking_pool_owner_.reset(); |
| 25 base::RunLoop().RunUntilIdle(); |
| 26 } |
| 27 |
| 28 // AshTestEnvironment: |
| 29 base::SequencedWorkerPool* GetBlockingPool() override { |
| 30 if (!blocking_pool_owner_) { |
| 31 const size_t kMaxNumberThreads = 3u; // Matches that of content. |
| 32 const char kThreadNamePrefix[] = "AshBlocking"; |
| 33 blocking_pool_owner_ = base::MakeUnique<base::SequencedWorkerPoolOwner>( |
| 34 kMaxNumberThreads, kThreadNamePrefix); |
| 35 } |
| 36 return blocking_pool_owner_->pool().get(); |
| 37 } |
| 38 std::unique_ptr<views::ViewsDelegate> CreateViewsDelegate() override { |
| 39 return base::MakeUnique<AshTestViewsDelegate>(); |
| 40 } |
| 41 |
| 42 private: |
| 43 base::MessageLoopForUI message_loop_; |
| 44 std::unique_ptr<base::SequencedWorkerPoolOwner> blocking_pool_owner_; |
| 45 |
| 46 DISALLOW_COPY_AND_ASSIGN(AshTestEnvironmentDefault); |
| 47 }; |
| 48 |
| 49 } // namespace |
| 50 |
| 51 // static |
| 52 std::unique_ptr<AshTestEnvironment> AshTestEnvironment::Create() { |
| 53 return base::MakeUnique<AshTestEnvironmentDefault>(); |
| 54 } |
| 55 |
| 56 } // namespace test |
| 57 } // namespace ash |
| OLD | NEW |