Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Side by Side Diff: mojo/edk/embedder/test_embedder.cc

Issue 1585493002: [mojo] Ports EDK (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "mojo/edk/embedder/embedder.h" 9 #include "mojo/edk/embedder/embedder.h"
10 #include "mojo/edk/embedder/embedder_internal.h" 10 #include "mojo/edk/embedder/embedder_internal.h"
11 #include "mojo/edk/embedder/platform_support.h" 11 #include "mojo/edk/embedder/platform_support.h"
12 #include "mojo/edk/system/broker.h" 12 #include "mojo/edk/system/broker.h"
13 #include "mojo/edk/system/core.h" 13 #include "mojo/edk/system/core.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 edk { 18 namespace edk {
19 namespace internal { 19 namespace internal {
20 20
21 bool ShutdownCheckNoLeaks(Core* core) { 21 bool ShutdownCheckNoLeaks(Core* core) {
22 // No point in taking the lock. 22 std::vector<MojoHandle> leaked_handles;
23 const HandleTable::HandleToEntryMap& handle_to_entry_map = 23 core->GetActiveHandlesForTest(&leaked_handles);
24 core->handle_table_.handle_to_entry_map_; 24 if (leaked_handles.empty())
25
26 if (handle_to_entry_map.empty())
27 return true; 25 return true;
28 26 for (auto handle : leaked_handles)
29 for (HandleTable::HandleToEntryMap::const_iterator it = 27 LOG(ERROR) << "Mojo embedder shutdown: Leaking handle " << handle;
30 handle_to_entry_map.begin();
31 it != handle_to_entry_map.end(); ++it) {
32 LOG(ERROR) << "Mojo embedder shutdown: Leaking handle " << (*it).first;
33 }
34 return false; 28 return false;
35 } 29 }
36 30
37 } // namespace internal 31 } // namespace internal
38 32
39 namespace test { 33 namespace test {
40 34
41 bool Shutdown() { 35 bool Shutdown() {
42 CHECK(internal::g_core); 36 CHECK(internal::g_core);
43 bool rv = internal::ShutdownCheckNoLeaks(internal::g_core); 37 bool rv = internal::ShutdownCheckNoLeaks(internal::g_core);
44 delete internal::g_core; 38 delete internal::g_core;
45 internal::g_core = nullptr; 39 internal::g_core = nullptr;
46 40
47 CHECK(internal::g_platform_support); 41 CHECK(internal::g_platform_support);
48 delete internal::g_platform_support; 42 delete internal::g_platform_support;
49 internal::g_platform_support = nullptr; 43 internal::g_platform_support = nullptr;
50 44
51 CHECK(internal::g_broker);
52 delete internal::g_broker;
53 internal::g_broker = nullptr;
54
55 return rv; 45 return rv;
56 } 46 }
57 47
58 } // namespace test 48 } // namespace test
59 } // namespace edk 49 } // namespace edk
60 50
61 } // namespace mojo 51 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698