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