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/edk/embedder/test_embedder.h" | 5 #include "mojo/edk/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 "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "mojo/edk/embedder/embedder.h" | 10 #include "mojo/edk/embedder/embedder.h" |
| 11 #include "mojo/edk/embedder/embedder_internal.h" |
11 #include "mojo/edk/embedder/simple_platform_support.h" | 12 #include "mojo/edk/embedder/simple_platform_support.h" |
12 #include "mojo/edk/system/core.h" | 13 #include "mojo/edk/system/core.h" |
13 #include "mojo/edk/system/entrypoints.h" | |
14 #include "mojo/edk/system/handle_table.h" | 14 #include "mojo/edk/system/handle_table.h" |
15 | 15 |
16 namespace mojo { | 16 namespace mojo { |
17 | 17 |
18 namespace system { | 18 namespace system { |
19 namespace internal { | 19 namespace internal { |
20 | 20 |
21 bool ShutdownCheckNoLeaks(Core* core_impl) { | 21 bool ShutdownCheckNoLeaks(Core* core) { |
22 // No point in taking the lock. | 22 // No point in taking the lock. |
23 const HandleTable::HandleToEntryMap& handle_to_entry_map = | 23 const HandleTable::HandleToEntryMap& handle_to_entry_map = |
24 core_impl->handle_table_.handle_to_entry_map_; | 24 core->handle_table_.handle_to_entry_map_; |
25 | 25 |
26 if (handle_to_entry_map.empty()) | 26 if (handle_to_entry_map.empty()) |
27 return true; | 27 return true; |
28 | 28 |
29 for (HandleTable::HandleToEntryMap::const_iterator it = | 29 for (HandleTable::HandleToEntryMap::const_iterator it = |
30 handle_to_entry_map.begin(); | 30 handle_to_entry_map.begin(); |
31 it != handle_to_entry_map.end(); | 31 it != handle_to_entry_map.end(); ++it) { |
32 ++it) { | |
33 LOG(ERROR) << "Mojo embedder shutdown: Leaking handle " << (*it).first; | 32 LOG(ERROR) << "Mojo embedder shutdown: Leaking handle " << (*it).first; |
34 } | 33 } |
35 return false; | 34 return false; |
36 } | 35 } |
37 | 36 |
38 } // namespace internal | 37 } // namespace internal |
39 } // namespace system | 38 } // namespace system |
40 | 39 |
41 namespace embedder { | 40 namespace embedder { |
42 namespace test { | 41 namespace test { |
43 | 42 |
44 void InitWithSimplePlatformSupport() { | 43 void InitWithSimplePlatformSupport() { |
45 Init(make_scoped_ptr(new SimplePlatformSupport())); | 44 Init(make_scoped_ptr(new SimplePlatformSupport())); |
46 } | 45 } |
47 | 46 |
48 bool Shutdown() { | 47 bool Shutdown() { |
49 system::Core* core = system::entrypoints::GetCore(); | 48 system::Core* core = internal::g_core; |
50 CHECK(core); | 49 CHECK(core); |
51 system::entrypoints::SetCore(nullptr); | 50 internal::g_core = nullptr; |
52 | 51 |
53 bool rv = system::internal::ShutdownCheckNoLeaks(core); | 52 bool rv = system::internal::ShutdownCheckNoLeaks(core); |
54 delete core; | 53 delete core; |
55 return rv; | 54 return rv; |
56 } | 55 } |
57 | 56 |
58 } // namespace test | 57 } // namespace test |
59 } // namespace embedder | 58 } // namespace embedder |
60 | 59 |
61 } // namespace mojo | 60 } // namespace mojo |
OLD | NEW |