| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/embedder/test_embedder.h" | 5 #include "mojo/embedder/test_embedder.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "mojo/system/core_impl.h" | 9 #include "mojo/system/core.h" |
| 10 #include "mojo/system/entrypoints.h" |
| 10 #include "mojo/system/handle_table.h" | 11 #include "mojo/system/handle_table.h" |
| 11 | 12 |
| 12 namespace mojo { | 13 namespace mojo { |
| 13 | 14 |
| 14 namespace system { | 15 namespace system { |
| 15 namespace internal { | 16 namespace internal { |
| 16 | 17 |
| 17 bool ShutdownCheckNoLeaks(CoreImpl* core_impl) { | 18 bool ShutdownCheckNoLeaks(Core* core_impl) { |
| 18 // No point in taking the lock. | 19 // No point in taking the lock. |
| 19 const HandleTable::HandleToEntryMap& handle_to_entry_map = | 20 const HandleTable::HandleToEntryMap& handle_to_entry_map = |
| 20 core_impl->handle_table_.handle_to_entry_map_; | 21 core_impl->handle_table_.handle_to_entry_map_; |
| 21 | 22 |
| 22 if (handle_to_entry_map.empty()) | 23 if (handle_to_entry_map.empty()) |
| 23 return true; | 24 return true; |
| 24 | 25 |
| 25 for (HandleTable::HandleToEntryMap::const_iterator it = | 26 for (HandleTable::HandleToEntryMap::const_iterator it = |
| 26 handle_to_entry_map.begin(); | 27 handle_to_entry_map.begin(); |
| 27 it != handle_to_entry_map.end(); | 28 it != handle_to_entry_map.end(); |
| 28 ++it) { | 29 ++it) { |
| 29 LOG(ERROR) << "Mojo embedder shutdown: Leaking handle " << (*it).first; | 30 LOG(ERROR) << "Mojo embedder shutdown: Leaking handle " << (*it).first; |
| 30 } | 31 } |
| 31 return false; | 32 return false; |
| 32 } | 33 } |
| 33 | 34 |
| 34 } // namespace internal | 35 } // namespace internal |
| 35 } // namespace system | 36 } // namespace system |
| 36 | 37 |
| 37 namespace embedder { | 38 namespace embedder { |
| 38 namespace test { | 39 namespace test { |
| 39 | 40 |
| 40 bool Shutdown() { | 41 bool Shutdown() { |
| 41 system::CoreImpl* core_impl = static_cast<system::CoreImpl*>(Core::Get()); | 42 system::Core* core = system::entrypoints::GetCore(); |
| 42 CHECK(core_impl); | 43 CHECK(core); |
| 43 Core::Reset(); | 44 system::entrypoints::SetCore(NULL); |
| 44 | 45 |
| 45 bool rv = system::internal::ShutdownCheckNoLeaks(core_impl); | 46 bool rv = system::internal::ShutdownCheckNoLeaks(core); |
| 46 delete core_impl; | 47 delete core; |
| 47 return rv; | 48 return rv; |
| 48 } | 49 } |
| 49 | 50 |
| 50 } // namespace test | 51 } // namespace test |
| 51 } // namespace embedder | 52 } // namespace embedder |
| 52 | 53 |
| 53 } // namespace mojo | 54 } // namespace mojo |
| OLD | NEW |