Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / mojo / embedder / test_embedder.cc
blob7f50abb9de9d9b81d0be538f59081467930f0bac
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.
5 #include "mojo/embedder/test_embedder.h"
7 #include "base/logging.h"
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "mojo/embedder/embedder.h"
11 #include "mojo/embedder/simple_platform_support.h"
12 #include "mojo/system/core.h"
13 #include "mojo/system/entrypoints.h"
14 #include "mojo/system/handle_table.h"
16 namespace mojo {
18 namespace system {
19 namespace internal {
21 bool ShutdownCheckNoLeaks(Core* core_impl) {
22 // No point in taking the lock.
23 const HandleTable::HandleToEntryMap& handle_to_entry_map =
24 core_impl->handle_table_.handle_to_entry_map_;
26 if (handle_to_entry_map.empty())
27 return true;
29 for (HandleTable::HandleToEntryMap::const_iterator it =
30 handle_to_entry_map.begin();
31 it != handle_to_entry_map.end();
32 ++it) {
33 LOG(ERROR) << "Mojo embedder shutdown: Leaking handle " << (*it).first;
35 return false;
38 } // namespace internal
39 } // namespace system
41 namespace embedder {
42 namespace test {
44 void InitWithSimplePlatformSupport() {
45 Init(scoped_ptr<PlatformSupport>(new SimplePlatformSupport()));
48 bool Shutdown() {
49 system::Core* core = system::entrypoints::GetCore();
50 CHECK(core);
51 system::entrypoints::SetCore(NULL);
53 bool rv = system::internal::ShutdownCheckNoLeaks(core);
54 delete core;
55 return rv;
58 } // namespace test
59 } // namespace embedder
61 } // namespace mojo