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/edk/embedder/test_embedder.h"
      6 
      7 #include <memory>
      8 
      9 #include "base/logging.h"
     10 #include "mojo/edk/embedder/embedder.h"
     11 #include "mojo/edk/embedder/embedder_internal.h"
     12 #include "mojo/edk/system/core.h"
     13 #include "mojo/edk/system/handle_table.h"
     14 
     15 namespace mojo {
     16 
     17 namespace edk {
     18 namespace internal {
     19 
     20 bool ShutdownCheckNoLeaks(Core* core) {
     21   std::vector<MojoHandle> leaked_handles;
     22   core->GetActiveHandlesForTest(&leaked_handles);
     23   if (leaked_handles.empty())
     24     return true;
     25   for (auto handle : leaked_handles)
     26     LOG(ERROR) << "Mojo embedder shutdown: Leaking handle " << handle;
     27   return false;
     28 }
     29 
     30 }  // namespace internal
     31 
     32 namespace test {
     33 
     34 bool Shutdown() {
     35   CHECK(internal::g_core);
     36   bool rv = internal::ShutdownCheckNoLeaks(internal::g_core);
     37   delete internal::g_core;
     38   internal::g_core = nullptr;
     39 
     40   return rv;
     41 }
     42 
     43 }  // namespace test
     44 }  // namespace edk
     45 
     46 }  // namespace mojo
     47