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