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