Remove requirement that mojo::Environment be instantiated.

In fact, make it not instantiatable.

Arguably, the class should be removed and its static methods replaced
with free functions. But I'll leave that for another day.

R=vardhan@google.com

Review URL: https://codereview.chromium.org/1997473005 .
diff --git a/mojo/environment/environment.cc b/mojo/environment/environment.cc
index 8867dd0..aa7ab98 100644
--- a/mojo/environment/environment.cc
+++ b/mojo/environment/environment.cc
@@ -10,32 +10,33 @@
 
 namespace mojo {
 
-// These methods are intentionally not implemented so that there is a link
-// error if someone uses them in a Chromium-environment.
-#if 0
-Environment::Environment() {
-}
+// TODO(vtl): Probably we should share the following async waiter and logger
+// code with the "standalone" implementation. (The only difference is what the
+// |internal::kDefault...| are.)
 
-Environment::Environment(const MojoAsyncWaiter* default_async_waiter,
-                         const MojoLogger* default_logger) {
-}
-
-Environment::~Environment() {
-}
-#endif
+const MojoAsyncWaiter* g_default_async_waiter = &internal::kDefaultAsyncWaiter;
+const MojoLogger* g_default_logger = &internal::kDefaultLogger;
 
 // static
 const MojoAsyncWaiter* Environment::GetDefaultAsyncWaiter() {
-  return &internal::kDefaultAsyncWaiter;
+  return g_default_async_waiter;
+}
+
+// static
+void Environment::SetDefaultAsyncWaiter(const MojoAsyncWaiter* async_waiter) {
+  g_default_async_waiter =
+      async_waiter ? async_waiter : &internal::kDefaultAsyncWaiter;
 }
 
 // static
 const MojoLogger* Environment::GetDefaultLogger() {
-  return &internal::kDefaultLogger;
+  return g_default_logger;
 }
 
 // static
-void Environment::SetDefaultLogger(const MojoLogger* logger) {}
+void Environment::SetDefaultLogger(const MojoLogger* logger) {
+  g_default_logger = logger ? logger : &internal::kDefaultLogger;
+}
 
 // static
 void Environment::InstantiateDefaultRunLoop() {
diff --git a/mojo/public/cpp/application/lib/application_runner.cc b/mojo/public/cpp/application/lib/application_runner.cc
index c4577c0..7a87e42 100644
--- a/mojo/public/cpp/application/lib/application_runner.cc
+++ b/mojo/public/cpp/application/lib/application_runner.cc
@@ -7,7 +7,6 @@
 #include "mojo/public/cpp/application/application_delegate.h"
 #include "mojo/public/cpp/application/application_impl.h"
 #include "mojo/public/cpp/application/application_impl_base.h"
-#include "mojo/public/cpp/environment/environment.h"
 #include "mojo/public/cpp/utility/run_loop.h"
 
 namespace mojo {
@@ -33,7 +32,6 @@
       << "Another ApplicationRunner::Run() is already running!";
 
   g_running = true;
-  Environment env;
   {
     RunLoop loop;
     ApplicationImpl app(delegate_.get(),
diff --git a/mojo/public/cpp/application/lib/application_test_main.cc b/mojo/public/cpp/application/lib/application_test_main.cc
index 128d8ae..93057e4 100644
--- a/mojo/public/cpp/application/lib/application_test_main.cc
+++ b/mojo/public/cpp/application/lib/application_test_main.cc
@@ -4,11 +4,7 @@
 
 #include "mojo/public/c/system/main.h"
 #include "mojo/public/cpp/application/application_test_base.h"
-#include "mojo/public/cpp/environment/environment.h"
 
 MojoResult MojoMain(MojoHandle handle) {
-  // An Environment instance is needed to construct run loops.
-  mojo::Environment environment;
-
   return mojo::test::RunAllTests(handle);
 }
diff --git a/mojo/public/cpp/application/tests/service_provider_impl_unittest.cc b/mojo/public/cpp/application/tests/service_provider_impl_unittest.cc
index f676767..fb42758 100644
--- a/mojo/public/cpp/application/tests/service_provider_impl_unittest.cc
+++ b/mojo/public/cpp/application/tests/service_provider_impl_unittest.cc
@@ -8,7 +8,6 @@
 
 #include "mojo/public/cpp/application/connect.h"
 #include "mojo/public/cpp/bindings/strong_binding.h"
-#include "mojo/public/cpp/environment/environment.h"
 #include "mojo/public/cpp/system/macros.h"
 #include "mojo/public/cpp/utility/run_loop.h"
 #include "mojo/public/interfaces/application/service_provider.mojom.h"
@@ -32,7 +31,6 @@
   }
 
  private:
-  Environment env_;
   RunLoop loop_;
 
   MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceProviderImplTest);
diff --git a/mojo/public/cpp/bindings/tests/array_unittest.cc b/mojo/public/cpp/bindings/tests/array_unittest.cc
index e81b5ee..820331c 100644
--- a/mojo/public/cpp/bindings/tests/array_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/array_unittest.cc
@@ -8,7 +8,6 @@
 #include "mojo/public/cpp/bindings/lib/fixed_buffer.h"
 #include "mojo/public/cpp/bindings/tests/container_test_util.h"
 #include "mojo/public/cpp/bindings/tests/iterator_test_util.h"
-#include "mojo/public/cpp/environment/environment.h"
 #include "mojo/public/interfaces/bindings/tests/test_arrays.mojom.h"
 #include "mojo/public/interfaces/bindings/tests/test_structs.mojom.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -22,16 +21,8 @@
 using mojo::internal::FixedBufferForTesting;
 using mojo::internal::String_Data;
 
-class ArrayTest : public testing::Test {
- public:
-  ~ArrayTest() override {}
-
- private:
-  Environment env_;
-};
-
 // Tests that basic Array operations work.
-TEST_F(ArrayTest, Basic) {
+TEST(ArrayTest, Basic) {
   auto array = Array<uint8_t>::New(8);
   for (size_t i = 0u; i < array.size(); ++i) {
     uint8_t val = static_cast<uint8_t>(i * 2);
@@ -44,7 +35,7 @@
   EXPECT_EQ(4u, *(array.data() + 2));
 }
 
-TEST_F(ArrayTest, Testability) {
+TEST(ArrayTest, Testability) {
   Array<int32_t> array;
   EXPECT_FALSE(array);
   EXPECT_TRUE(array.is_null());
@@ -60,7 +51,7 @@
   EXPECT_EQ(0u, array.size());
 }
 
-TEST_F(ArrayTest, NullptrConstructor) {
+TEST(ArrayTest, NullptrConstructor) {
   Array<int32_t> array(nullptr);
   EXPECT_FALSE(array);
   EXPECT_TRUE(array.is_null());
@@ -77,7 +68,7 @@
 }
 
 // Tests that basic Array<bool> operations work.
-TEST_F(ArrayTest, Bool) {
+TEST(ArrayTest, Bool) {
   auto array = Array<bool>::New(64);
   for (size_t i = 0; i < array.size(); ++i) {
     bool val = i % 3 == 0;
@@ -87,7 +78,7 @@
 }
 
 // Tests that Array<ScopedMessagePipeHandle> supports transferring handles.
-TEST_F(ArrayTest, Handle) {
+TEST(ArrayTest, Handle) {
   MessagePipe pipe;
   auto handles = Array<ScopedMessagePipeHandle>::New(2);
   handles[0] = pipe.handle0.Pass();
@@ -106,7 +97,7 @@
 }
 
 // Tests that Array<ScopedMessagePipeHandle> supports closing handles.
-TEST_F(ArrayTest, HandlesAreClosed) {
+TEST(ArrayTest, HandlesAreClosed) {
   MessagePipe pipe;
   MojoHandle pipe0_value = pipe.handle0.get().value();
   MojoHandle pipe1_value = pipe.handle0.get().value();
@@ -122,7 +113,7 @@
   EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, MojoClose(pipe1_value));
 }
 
-TEST_F(ArrayTest, Clone) {
+TEST(ArrayTest, Clone) {
   {
     // Test POD.
     auto array = Array<int32_t>::New(3);
@@ -187,7 +178,7 @@
   }
 }
 
-TEST_F(ArrayTest, Serialization_ArrayOfPOD) {
+TEST(ArrayTest, Serialization_ArrayOfPOD) {
   auto array = Array<int32_t>::New(4);
   for (size_t i = 0; i < array.size(); ++i)
     array[i] = static_cast<int32_t>(i);
@@ -209,7 +200,7 @@
     EXPECT_EQ(static_cast<int32_t>(i), array2[i]);
 }
 
-TEST_F(ArrayTest, Serialization_EmptyArrayOfPOD) {
+TEST(ArrayTest, Serialization_EmptyArrayOfPOD) {
   auto array = Array<int32_t>::New(0);
   size_t size = GetSerializedSize_(array);
   EXPECT_EQ(8U, size);
@@ -225,7 +216,7 @@
   EXPECT_EQ(0U, array2.size());
 }
 
-TEST_F(ArrayTest, Serialization_ArrayOfArrayOfPOD) {
+TEST(ArrayTest, Serialization_ArrayOfArrayOfPOD) {
   auto array = Array<Array<int32_t>>::New(2);
   for (size_t j = 0; j < array.size(); ++j) {
     auto inner = Array<int32_t>::New(4);
@@ -256,7 +247,7 @@
   }
 }
 
-TEST_F(ArrayTest, Serialization_ArrayOfScopedEnum) {
+TEST(ArrayTest, Serialization_ArrayOfScopedEnum) {
   enum class TestEnum : int32_t {
     E0,
     E1,
@@ -288,7 +279,7 @@
     EXPECT_EQ(TEST_VALS[i], array2[i]);
 }
 
-TEST_F(ArrayTest, Serialization_ArrayOfBool) {
+TEST(ArrayTest, Serialization_ArrayOfBool) {
   auto array = Array<bool>::New(10);
   for (size_t i = 0; i < array.size(); ++i)
     array[i] = i % 2 ? true : false;
@@ -310,7 +301,7 @@
     EXPECT_EQ(i % 2 ? true : false, array2[i]);
 }
 
-TEST_F(ArrayTest, Serialization_ArrayOfString) {
+TEST(ArrayTest, Serialization_ArrayOfString) {
   auto array = Array<String>::New(10);
   for (size_t i = 0; i < array.size(); ++i) {
     char c = 'A' + static_cast<char>(i);
@@ -342,7 +333,7 @@
 }
 
 // Tests serializing and deserializing an Array<Handle>.
-TEST_F(ArrayTest, Serialization_ArrayOfHandle) {
+TEST(ArrayTest, Serialization_ArrayOfHandle) {
   auto array = Array<ScopedHandleBase<MessagePipeHandle>>::New(4);
   MessagePipe p0;
   MessagePipe p1;
@@ -388,13 +379,13 @@
   EXPECT_TRUE(array[3].is_valid());
 }
 
-TEST_F(ArrayTest, Serialization_StructWithArraysOfHandles) {
+TEST(ArrayTest, Serialization_StructWithArraysOfHandles) {
   StructWithHandles handles_struct;
   MessagePipe handle_pair_0;
 }
 
 // Test serializing and deserializing an Array<InterfacePtr>.
-TEST_F(ArrayTest, Serialization_ArrayOfInterfacePtr) {
+TEST(ArrayTest, Serialization_ArrayOfInterfacePtr) {
   auto iface_array = Array<mojo::InterfaceHandle<TestInterface>>::New(1);
   size_t size = GetSerializedSize_(iface_array);
   EXPECT_EQ(8U               // array header
@@ -435,7 +426,7 @@
 
 // Test serializing and deserializing a struct with an Array<> of another struct
 // which has an InterfacePtr.
-TEST_F(ArrayTest, Serialization_StructWithArrayOfInterfacePtr) {
+TEST(ArrayTest, Serialization_StructWithArrayOfInterfacePtr) {
   StructWithInterfaceArray struct_arr_iface;
   struct_arr_iface.structs_array = Array<StructWithInterfacePtr>::New(1);
   struct_arr_iface.nullable_structs_array =
@@ -480,7 +471,7 @@
 
 // Test serializing and deserializing a struct with an Array<> of interface
 // requests.
-TEST_F(ArrayTest, Serialization_StructWithArrayOfIntefaceRequest) {
+TEST(ArrayTest, Serialization_StructWithArrayOfIntefaceRequest) {
   StructWithInterfaceRequests struct_arr_iface_req;
   struct_arr_iface_req.req_array =
       Array<InterfaceRequest<TestInterface>>::New(1);
@@ -524,7 +515,7 @@
   EXPECT_TRUE(struct_arr_iface_req.req_array[0].is_pending());
 }
 
-TEST_F(ArrayTest, Resize_Copyable) {
+TEST(ArrayTest, Resize_Copyable) {
   ASSERT_EQ(0u, CopyableType::num_instances());
   auto array = mojo::Array<CopyableType>::New(3);
   std::vector<CopyableType*> value_ptrs;
@@ -576,7 +567,7 @@
   EXPECT_TRUE(array);
 }
 
-TEST_F(ArrayTest, Resize_MoveOnly) {
+TEST(ArrayTest, Resize_MoveOnly) {
   ASSERT_EQ(0u, MoveOnlyType::num_instances());
   auto array = mojo::Array<MoveOnlyType>::New(3);
   std::vector<MoveOnlyType*> value_ptrs;
@@ -628,7 +619,7 @@
   EXPECT_TRUE(array);
 }
 
-TEST_F(ArrayTest, PushBack_Copyable) {
+TEST(ArrayTest, PushBack_Copyable) {
   ASSERT_EQ(0u, CopyableType::num_instances());
   auto array = mojo::Array<CopyableType>::New(2);
   array.reset();
@@ -663,7 +654,7 @@
   EXPECT_EQ(0u, CopyableType::num_instances());
 }
 
-TEST_F(ArrayTest, PushBack_MoveOnly) {
+TEST(ArrayTest, PushBack_MoveOnly) {
   ASSERT_EQ(0u, MoveOnlyType::num_instances());
   auto array = mojo::Array<MoveOnlyType>::New(2);
   array.reset();
@@ -698,7 +689,7 @@
   EXPECT_EQ(0u, MoveOnlyType::num_instances());
 }
 
-TEST_F(ArrayTest, Iterator) {
+TEST(ArrayTest, Iterator) {
   std::vector<int> values;
   values.push_back(0);
   values.push_back(1);
@@ -748,7 +739,7 @@
 }
 
 // Test serializing and deserializing of an array with null elements.
-TEST_F(ArrayTest, Serialization_ArrayOfStructPtr) {
+TEST(ArrayTest, Serialization_ArrayOfStructPtr) {
   ArrayValidateParams validate_nullable(2, true, nullptr);
   ArrayValidateParams validate_non_nullable(2, false, nullptr);
 
diff --git a/mojo/public/cpp/bindings/tests/binding_callback_unittest.cc b/mojo/public/cpp/bindings/tests/binding_callback_unittest.cc
index 2d57683..44a8150 100644
--- a/mojo/public/cpp/bindings/tests/binding_callback_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/binding_callback_unittest.cc
@@ -6,7 +6,6 @@
 #include "mojo/public/cpp/bindings/binding.h"
 #include "mojo/public/cpp/bindings/interface_ptr.h"
 #include "mojo/public/cpp/bindings/string.h"
-#include "mojo/public/cpp/environment/environment.h"
 #include "mojo/public/cpp/system/message_pipe.h"
 #include "mojo/public/cpp/utility/run_loop.h"
 #include "mojo/public/interfaces/bindings/tests/sample_interfaces.mojom.h"
@@ -120,7 +119,6 @@
   void PumpMessages() { loop_.RunUntilIdle(); }
 
  private:
-  Environment env_;
   RunLoop loop_;
 };
 
diff --git a/mojo/public/cpp/bindings/tests/binding_unittest.cc b/mojo/public/cpp/bindings/tests/binding_unittest.cc
index 7524900..f47e70a 100644
--- a/mojo/public/cpp/bindings/tests/binding_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/binding_unittest.cc
@@ -7,7 +7,6 @@
 
 #include "mojo/public/cpp/bindings/binding.h"
 #include "mojo/public/cpp/bindings/strong_binding.h"
-#include "mojo/public/cpp/environment/environment.h"
 #include "mojo/public/cpp/system/macros.h"
 #include "mojo/public/cpp/utility/run_loop.h"
 #include "mojo/public/interfaces/bindings/tests/sample_interfaces.mojom.h"
@@ -25,7 +24,6 @@
   RunLoop& loop() { return loop_; }
 
  private:
-  Environment env_;
   RunLoop loop_;
 
   MOJO_DISALLOW_COPY_AND_ASSIGN(BindingTestBase);
diff --git a/mojo/public/cpp/bindings/tests/bindings_perftest.cc b/mojo/public/cpp/bindings/tests/bindings_perftest.cc
index d4d838a..3655498 100644
--- a/mojo/public/cpp/bindings/tests/bindings_perftest.cc
+++ b/mojo/public/cpp/bindings/tests/bindings_perftest.cc
@@ -83,7 +83,6 @@
 
 class MojoBindingsPerftest : public testing::Test {
  protected:
-  Environment env_;
   RunLoop run_loop_;
 };
 
diff --git a/mojo/public/cpp/bindings/tests/connector_unittest.cc b/mojo/public/cpp/bindings/tests/connector_unittest.cc
index a0fafd4..7d49d73 100644
--- a/mojo/public/cpp/bindings/tests/connector_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/connector_unittest.cc
@@ -10,7 +10,6 @@
 #include "mojo/public/cpp/bindings/lib/connector.h"
 #include "mojo/public/cpp/bindings/lib/message_builder.h"
 #include "mojo/public/cpp/bindings/tests/message_queue.h"
-#include "mojo/public/cpp/environment/environment.h"
 #include "mojo/public/cpp/environment/logging.h"
 #include "mojo/public/cpp/system/macros.h"
 #include "mojo/public/cpp/utility/run_loop.h"
@@ -45,7 +44,6 @@
   ScopedMessagePipeHandle handle1_;
 
  private:
-  Environment env_;
   RunLoop loop_;
 
   MOJO_DISALLOW_COPY_AND_ASSIGN(ConnectorTest);
diff --git a/mojo/public/cpp/bindings/tests/equals_unittest.cc b/mojo/public/cpp/bindings/tests/equals_unittest.cc
index 4b70af0..efac86b 100644
--- a/mojo/public/cpp/bindings/tests/equals_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/equals_unittest.cc
@@ -2,7 +2,6 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "mojo/public/cpp/environment/environment.h"
 #include "mojo/public/interfaces/bindings/tests/test_structs.mojom.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -20,16 +19,9 @@
   return r;
 }
 
-class EqualsTest : public testing::Test {
- public:
-  ~EqualsTest() override {}
+}  // namespace
 
- private:
-  Environment env_;
-};
-}
-
-TEST_F(EqualsTest, Null) {
+TEST(EqualsTest, Null) {
   RectPtr r1;
   RectPtr r2;
   EXPECT_TRUE(r1.Equals(r2));
@@ -40,7 +32,7 @@
   EXPECT_FALSE(r2.Equals(r1));
 }
 
-TEST_F(EqualsTest, EqualsStruct) {
+TEST(EqualsTest, EqualsStruct) {
   RectPtr r1(CreateRect());
   RectPtr r2(r1.Clone());
   EXPECT_TRUE(r1.Equals(r2));
@@ -50,7 +42,7 @@
   EXPECT_FALSE(r1.Equals(r2));
 }
 
-TEST_F(EqualsTest, EqualsStructNested) {
+TEST(EqualsTest, EqualsStructNested) {
   RectPairPtr p1(RectPair::New());
   p1->first = CreateRect();
   p1->second = CreateRect();
@@ -62,7 +54,7 @@
   EXPECT_FALSE(p1.Equals(p2));
 }
 
-TEST_F(EqualsTest, EqualsArray) {
+TEST(EqualsTest, EqualsArray) {
   NamedRegionPtr n1(NamedRegion::New());
   n1->name = "n1";
   n1->rects.push_back(CreateRect());
@@ -86,7 +78,7 @@
   EXPECT_TRUE(n1.Equals(n2));
 }
 
-TEST_F(EqualsTest, EqualsMap) {
+TEST(EqualsTest, EqualsMap) {
   auto n1(NamedRegion::New());
   n1->name = "foo";
   n1->rects.push_back(CreateRect());
diff --git a/mojo/public/cpp/bindings/tests/handle_passing_unittest.cc b/mojo/public/cpp/bindings/tests/handle_passing_unittest.cc
index 3af49e4..ca11052 100644
--- a/mojo/public/cpp/bindings/tests/handle_passing_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/handle_passing_unittest.cc
@@ -6,7 +6,6 @@
 
 #include "mojo/public/cpp/bindings/binding.h"
 #include "mojo/public/cpp/bindings/strong_binding.h"
-#include "mojo/public/cpp/environment/environment.h"
 #include "mojo/public/cpp/test_support/test_utils.h"
 #include "mojo/public/cpp/utility/run_loop.h"
 #include "mojo/public/interfaces/bindings/tests/sample_factory.mojom.h"
@@ -145,7 +144,6 @@
   void PumpMessages() { loop_.RunUntilIdle(); }
 
  private:
-  Environment env_;
   RunLoop loop_;
 };
 
diff --git a/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc b/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc
index dc8e290..dbe5f29 100644
--- a/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc
@@ -6,7 +6,6 @@
 
 #include "mojo/public/cpp/bindings/binding.h"
 #include "mojo/public/cpp/bindings/strong_binding.h"
-#include "mojo/public/cpp/environment/environment.h"
 #include "mojo/public/cpp/utility/run_loop.h"
 #include "mojo/public/interfaces/bindings/tests/math_calculator.mojom.h"
 #include "mojo/public/interfaces/bindings/tests/sample_interfaces.mojom.h"
@@ -195,7 +194,6 @@
   void PumpMessages() { loop_.RunUntilIdle(); }
 
  private:
-  Environment env_;
   RunLoop loop_;
 };
 
@@ -486,7 +484,6 @@
 };
 
 TEST(StrongConnectorTest, Math) {
-  Environment env;
   RunLoop loop;
 
   bool error_received = false;
@@ -555,7 +552,6 @@
 };
 
 TEST(WeakConnectorTest, Math) {
-  Environment env;
   RunLoop loop;
 
   bool error_received = false;
diff --git a/mojo/public/cpp/bindings/tests/map_unittest.cc b/mojo/public/cpp/bindings/tests/map_unittest.cc
index 3df89d3..5488c95 100644
--- a/mojo/public/cpp/bindings/tests/map_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/map_unittest.cc
@@ -11,7 +11,6 @@
 #include "mojo/public/cpp/bindings/map.h"
 #include "mojo/public/cpp/bindings/string.h"
 #include "mojo/public/cpp/bindings/tests/container_test_util.h"
-#include "mojo/public/cpp/environment/environment.h"
 #include "mojo/public/interfaces/bindings/tests/rect.mojom.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -39,15 +38,7 @@
 
 const size_t kStringIntDataSize = 4;
 
-class MapTest : public testing::Test {
- public:
-  ~MapTest() override {}
-
- private:
-  Environment env_;
-};
-
-TEST_F(MapTest, Testability) {
+TEST(MapTest, Testability) {
   Map<int32_t, int32_t> map;
   EXPECT_FALSE(map);
   EXPECT_TRUE(map.is_null());
@@ -58,7 +49,7 @@
 }
 
 // Tests that basic Map operations work.
-TEST_F(MapTest, InsertWorks) {
+TEST(MapTest, InsertWorks) {
   Map<String, int> map;
   for (size_t i = 0; i < kStringIntDataSize; ++i)
     map.insert(kStringIntData[i].string_data, kStringIntData[i].int_data);
@@ -69,7 +60,7 @@
   }
 }
 
-TEST_F(MapTest, TestIndexOperator) {
+TEST(MapTest, TestIndexOperator) {
   Map<String, int> map;
   for (size_t i = 0; i < kStringIntDataSize; ++i)
     map[kStringIntData[i].string_data] = kStringIntData[i].int_data;
@@ -80,7 +71,7 @@
   }
 }
 
-TEST_F(MapTest, TestIndexOperatorAsRValue) {
+TEST(MapTest, TestIndexOperatorAsRValue) {
   Map<String, int> map;
   for (size_t i = 0; i < kStringIntDataSize; ++i)
     map.insert(kStringIntData[i].string_data, kStringIntData[i].int_data);
@@ -90,7 +81,7 @@
   }
 }
 
-TEST_F(MapTest, TestIndexOperatorMoveOnly) {
+TEST(MapTest, TestIndexOperatorMoveOnly) {
   ASSERT_EQ(0u, MoveOnlyType::num_instances());
   mojo::Map<mojo::String, mojo::Array<int32_t>> map;
   std::vector<MoveOnlyType*> value_ptrs;
@@ -112,7 +103,7 @@
   }
 }
 
-TEST_F(MapTest, ConstructedFromArray) {
+TEST(MapTest, ConstructedFromArray) {
   auto keys = Array<String>::New(kStringIntDataSize);
   auto values = Array<int>::New(kStringIntDataSize);
   for (size_t i = 0; i < kStringIntDataSize; ++i) {
@@ -128,7 +119,7 @@
   }
 }
 
-TEST_F(MapTest, Insert_Copyable) {
+TEST(MapTest, Insert_Copyable) {
   ASSERT_EQ(0u, CopyableType::num_instances());
   mojo::Map<mojo::String, CopyableType> map;
   std::vector<CopyableType*> value_ptrs;
@@ -154,7 +145,7 @@
   EXPECT_EQ(0u, CopyableType::num_instances());
 }
 
-TEST_F(MapTest, Insert_MoveOnly) {
+TEST(MapTest, Insert_MoveOnly) {
   ASSERT_EQ(0u, MoveOnlyType::num_instances());
   mojo::Map<mojo::String, MoveOnlyType> map;
   std::vector<MoveOnlyType*> value_ptrs;
@@ -180,7 +171,7 @@
   EXPECT_EQ(0u, MoveOnlyType::num_instances());
 }
 
-TEST_F(MapTest, IndexOperator_MoveOnly) {
+TEST(MapTest, IndexOperator_MoveOnly) {
   ASSERT_EQ(0u, MoveOnlyType::num_instances());
   mojo::Map<mojo::String, MoveOnlyType> map;
   std::vector<MoveOnlyType*> value_ptrs;
@@ -206,7 +197,7 @@
   EXPECT_EQ(0u, MoveOnlyType::num_instances());
 }
 
-TEST_F(MapTest, STLToMojo) {
+TEST(MapTest, STLToMojo) {
   std::map<std::string, int> stl_data;
   for (size_t i = 0; i < kStringIntDataSize; ++i)
     stl_data[kStringIntData[i].string_data] = kStringIntData[i].int_data;
@@ -218,7 +209,7 @@
   }
 }
 
-TEST_F(MapTest, MojoToSTL) {
+TEST(MapTest, MojoToSTL) {
   Map<String, int32_t> mojo_map;
   for (size_t i = 0; i < kStringIntDataSize; ++i)
     mojo_map.insert(kStringIntData[i].string_data, kStringIntData[i].int_data);
@@ -232,7 +223,7 @@
   }
 }
 
-TEST_F(MapTest, MapArrayClone) {
+TEST(MapTest, MapArrayClone) {
   Map<String, Array<String>> m;
   for (size_t i = 0; i < kStringIntDataSize; ++i) {
     Array<String> s;
@@ -248,7 +239,7 @@
   }
 }
 
-TEST_F(MapTest, ArrayOfMap) {
+TEST(MapTest, ArrayOfMap) {
   {
     auto array = Array<Map<int32_t, int8_t>>::New(1);
     array[0].insert(1, 42);
@@ -295,7 +286,7 @@
   }
 }
 
-TEST_F(MapTest, Serialization_MapWithScopedEnumKeys) {
+TEST(MapTest, Serialization_MapWithScopedEnumKeys) {
   enum class TestEnum : int32_t {
     E0,
     E1,
@@ -337,7 +328,7 @@
   }
 }
 
-TEST_F(MapTest, Serialization_MapWithScopedEnumVals) {
+TEST(MapTest, Serialization_MapWithScopedEnumVals) {
   enum class TestEnum : int32_t {
     E0,
     E1,
@@ -380,7 +371,7 @@
 }
 
 // Test serialization/deserialization of a map with null elements.
-TEST_F(MapTest, Serialization_MapOfNullableStructs) {
+TEST(MapTest, Serialization_MapOfNullableStructs) {
   ArrayValidateParams validate_nullable(2, true, nullptr);
   ArrayValidateParams validate_non_nullable(2, false, nullptr);
 
diff --git a/mojo/public/cpp/bindings/tests/request_response_unittest.cc b/mojo/public/cpp/bindings/tests/request_response_unittest.cc
index 705f747..0a003d1 100644
--- a/mojo/public/cpp/bindings/tests/request_response_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/request_response_unittest.cc
@@ -3,7 +3,6 @@
 // found in the LICENSE file.
 
 #include "mojo/public/cpp/bindings/binding.h"
-#include "mojo/public/cpp/environment/environment.h"
 #include "mojo/public/cpp/test_support/test_utils.h"
 #include "mojo/public/cpp/utility/run_loop.h"
 #include "mojo/public/interfaces/bindings/tests/sample_import.mojom.h"
@@ -90,7 +89,6 @@
   void PumpMessages() { loop_.RunUntilIdle(); }
 
  private:
-  Environment env_;
   RunLoop loop_;
 };
 
diff --git a/mojo/public/cpp/bindings/tests/router_unittest.cc b/mojo/public/cpp/bindings/tests/router_unittest.cc
index e05293b..c5ea103 100644
--- a/mojo/public/cpp/bindings/tests/router_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/router_unittest.cc
@@ -8,7 +8,6 @@
 #include "mojo/public/cpp/bindings/lib/message_builder.h"
 #include "mojo/public/cpp/bindings/lib/router.h"
 #include "mojo/public/cpp/bindings/tests/message_queue.h"
-#include "mojo/public/cpp/environment/environment.h"
 #include "mojo/public/cpp/system/macros.h"
 #include "mojo/public/cpp/utility/run_loop.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -140,7 +139,6 @@
   ScopedMessagePipeHandle handle1_;
 
  private:
-  Environment env_;
   RunLoop loop_;
 };
 
diff --git a/mojo/public/cpp/bindings/tests/sample_service_unittest.cc b/mojo/public/cpp/bindings/tests/sample_service_unittest.cc
index 2ef710b..31d829e 100644
--- a/mojo/public/cpp/bindings/tests/sample_service_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/sample_service_unittest.cc
@@ -7,7 +7,6 @@
 #include <string>
 #include <utility>
 
-#include "mojo/public/cpp/environment/environment.h"
 #include "mojo/public/cpp/system/macros.h"
 #include "mojo/public/interfaces/bindings/tests/sample_service.mojom.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -315,18 +314,7 @@
   }
 };
 
-class BindingsSampleTest : public testing::Test {
- public:
-  BindingsSampleTest() {}
-  ~BindingsSampleTest() override {}
-
- private:
-  mojo::Environment env_;
-
-  MOJO_DISALLOW_COPY_AND_ASSIGN(BindingsSampleTest);
-};
-
-TEST_F(BindingsSampleTest, Basic) {
+TEST(BindingsSampleTest, Basic) {
   SimpleMessageReceiver receiver;
 
   // User has a proxy to a Service somehow.
@@ -348,7 +336,7 @@
   delete service;
 }
 
-TEST_F(BindingsSampleTest, DefaultValues) {
+TEST(BindingsSampleTest, DefaultValues) {
   DefaultsTestPtr defaults(DefaultsTest::New());
   EXPECT_EQ(-12, defaults->a0);
   EXPECT_EQ(kTwelve, defaults->a1);
diff --git a/mojo/public/cpp/bindings/tests/serialization_api_unittest.cc b/mojo/public/cpp/bindings/tests/serialization_api_unittest.cc
index cd711dc..754f68f 100644
--- a/mojo/public/cpp/bindings/tests/serialization_api_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/serialization_api_unittest.cc
@@ -47,9 +47,6 @@
     EXPECT_EQ(actual_validation_error == mojo::internal::ValidationError::NONE,
               deserialize_ret);
   }
-
- private:
-  Environment env_;
 };
 
 TEST_F(StructSerializationAPITest, GetSerializedSize) {
diff --git a/mojo/public/cpp/bindings/tests/serialization_warning_unittest.cc b/mojo/public/cpp/bindings/tests/serialization_warning_unittest.cc
index 2a7bae5..fe5d393 100644
--- a/mojo/public/cpp/bindings/tests/serialization_warning_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/serialization_warning_unittest.cc
@@ -11,7 +11,6 @@
 #include "mojo/public/cpp/bindings/lib/fixed_buffer.h"
 #include "mojo/public/cpp/bindings/lib/validation_errors.h"
 #include "mojo/public/cpp/bindings/string.h"
-#include "mojo/public/cpp/environment/environment.h"
 #include "mojo/public/cpp/system/message_pipe.h"
 #include "mojo/public/interfaces/bindings/tests/serialization_test_structs.mojom.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -71,8 +70,6 @@
     EXPECT_EQ(expected_warning,
               SerializeArray_(&obj, &buf, &data, validate_params));
   }
-
-  Environment env_;
 };
 
 TEST_F(SerializationWarningTest, HandleInStruct) {
diff --git a/mojo/public/cpp/bindings/tests/struct_unittest.cc b/mojo/public/cpp/bindings/tests/struct_unittest.cc
index 1c98a5e..68782b8 100644
--- a/mojo/public/cpp/bindings/tests/struct_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/struct_unittest.cc
@@ -7,7 +7,6 @@
 
 #include "mojo/public/cpp/bindings/lib/fixed_buffer.h"
 #include "mojo/public/cpp/bindings/lib/validation_errors.h"
-#include "mojo/public/cpp/environment/environment.h"
 #include "mojo/public/cpp/system/message_pipe.h"
 #include "mojo/public/interfaces/bindings/tests/test_structs.mojom.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -80,17 +79,9 @@
   return output;
 }
 
-class StructTest : public testing::Test {
- public:
-  ~StructTest() override {}
-
- private:
-  Environment env_;
-};
-
 }  // namespace
 
-TEST_F(StructTest, Rect) {
+TEST(StructTest, Rect) {
   RectPtr rect;
   EXPECT_FALSE(rect);
   EXPECT_TRUE(rect.is_null());
@@ -118,7 +109,7 @@
   CheckRect(*rect);
 }
 
-TEST_F(StructTest, Clone) {
+TEST(StructTest, Clone) {
   NamedRegionPtr region;
 
   NamedRegionPtr clone_region = region.Clone();
@@ -147,7 +138,7 @@
 }
 
 // Serialization test of a struct with no pointer or handle members.
-TEST_F(StructTest, Serialization_Basic) {
+TEST(StructTest, Serialization_Basic) {
   RectPtr rect(MakeRect());
 
   size_t size = GetSerializedSize_(*rect);
@@ -165,7 +156,7 @@
 }
 
 // Construction of a struct with struct pointers from null.
-TEST_F(StructTest, Construction_StructPointers) {
+TEST(StructTest, Construction_StructPointers) {
   RectPairPtr pair;
   EXPECT_TRUE(pair.is_null());
 
@@ -179,7 +170,7 @@
 }
 
 // Serialization test of a struct with struct pointers.
-TEST_F(StructTest, Serialization_StructPointers) {
+TEST(StructTest, Serialization_StructPointers) {
   RectPairPtr pair(RectPair::New());
   pair->first = MakeRect();
   pair->second = MakeRect();
@@ -200,7 +191,7 @@
 }
 
 // Serialization test of a struct with an array member.
-TEST_F(StructTest, Serialization_ArrayPointers) {
+TEST(StructTest, Serialization_ArrayPointers) {
   NamedRegionPtr region(NamedRegion::New());
   region->name = "region";
   region->rects = Array<RectPtr>::New(4);
@@ -235,7 +226,7 @@
 }
 
 // Serialization test of a struct with null array pointers.
-TEST_F(StructTest, Serialization_NullArrayPointers) {
+TEST(StructTest, Serialization_NullArrayPointers) {
   NamedRegionPtr region(NamedRegion::New());
   EXPECT_TRUE(region->name.is_null());
   EXPECT_TRUE(region->rects.is_null());
@@ -258,7 +249,7 @@
   EXPECT_TRUE(region2->rects.is_null());
 }
 
-TEST_F(StructTest, Serialization_InterfaceRequest) {
+TEST(StructTest, Serialization_InterfaceRequest) {
   ContainsInterfaceRequest iface_req_struct;
 
   auto size = GetSerializedSize_(iface_req_struct);
@@ -287,7 +278,7 @@
 }
 
 // Tests deserializing structs as a newer version.
-TEST_F(StructTest, Versioning_OldToNew) {
+TEST(StructTest, Versioning_OldToNew) {
   {
     MultiVersionStructV0Ptr input(MultiVersionStructV0::New());
     input->f_int32 = 123;
@@ -387,7 +378,7 @@
 }
 
 // Tests deserializing structs as an older version.
-TEST_F(StructTest, Versioning_NewToOld) {
+TEST(StructTest, Versioning_NewToOld) {
   {
     MultiVersionStructPtr input = MakeMultiVersionStruct();
     MultiVersionStructV7Ptr expected_output(MultiVersionStructV7::New());
diff --git a/mojo/public/cpp/bindings/tests/synchronous_connector_unittest.cc b/mojo/public/cpp/bindings/tests/synchronous_connector_unittest.cc
index 7d0bc63..4ef1ca9 100644
--- a/mojo/public/cpp/bindings/tests/synchronous_connector_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/synchronous_connector_unittest.cc
@@ -46,7 +46,6 @@
 
 // Writing to a closed pipe should fail.
 TEST(SynchronousConnectorTest, WriteToClosedPipe) {
-  Environment env;
   MessagePipe pipe;
   internal::SynchronousConnector connector0(std::move(pipe.handle0));
 
@@ -59,7 +58,6 @@
 
 // Reading from a closed pipe should fail (while waiting on it).
 TEST(SynchronousConnectorTest, ReadFromClosedPipe) {
-  Environment env;
   MessagePipe pipe;
   internal::SynchronousConnector connector0(std::move(pipe.handle0));
 
diff --git a/mojo/public/cpp/bindings/tests/synchronous_interface_ptr_unittest.cc b/mojo/public/cpp/bindings/tests/synchronous_interface_ptr_unittest.cc
index a2b0c19..db59a6f 100644
--- a/mojo/public/cpp/bindings/tests/synchronous_interface_ptr_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/synchronous_interface_ptr_unittest.cc
@@ -11,7 +11,6 @@
 #include "mojo/public/cpp/bindings/interface_request.h"
 #include "mojo/public/cpp/bindings/strong_binding.h"
 #include "mojo/public/cpp/bindings/synchronous_interface_ptr.h"
-#include "mojo/public/cpp/environment/environment.h"
 #include "mojo/public/cpp/utility/run_loop.h"
 #include "mojo/public/interfaces/bindings/tests/math_calculator.mojom-sync.h"
 #include "mojo/public/interfaces/bindings/tests/math_calculator.mojom.h"
@@ -69,7 +68,6 @@
   }
 
  private:
-  Environment env_;
   RunLoop loop_;
 };
 
diff --git a/mojo/public/cpp/bindings/tests/union_unittest.cc b/mojo/public/cpp/bindings/tests/union_unittest.cc
index 13f3b5e..6f14a1a 100644
--- a/mojo/public/cpp/bindings/tests/union_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/union_unittest.cc
@@ -13,7 +13,6 @@
 #include "mojo/public/cpp/bindings/lib/fixed_buffer.h"
 #include "mojo/public/cpp/bindings/lib/map_serialization.h"
 #include "mojo/public/cpp/bindings/string.h"
-#include "mojo/public/cpp/environment/environment.h"
 #include "mojo/public/cpp/test_support/test_utils.h"
 #include "mojo/public/cpp/utility/run_loop.h"
 #include "mojo/public/interfaces/bindings/tests/test_structs.mojom.h"
@@ -228,7 +227,6 @@
 }
 
 TEST(UnionTest, OutOfAlignmentValidation) {
-  Environment environment;
   size_t size = sizeof(internal::PodUnion_Data);
   // Get an aligned object and shift the alignment.
   mojo::internal::FixedBufferForTesting aligned_buf(size + 1);
@@ -246,7 +244,6 @@
 }
 
 TEST(UnionTest, OOBValidation) {
-  Environment environment;
   size_t size = sizeof(internal::PodUnion_Data) - 1;
   mojo::internal::FixedBufferForTesting buf(size);
   internal::PodUnion_Data* data = internal::PodUnion_Data::New(&buf);
@@ -260,7 +257,6 @@
 }
 
 TEST(UnionTest, UnknownTagDeserialization) {
-  Environment environment;
   size_t size = sizeof(internal::PodUnion_Data);
   mojo::internal::FixedBufferForTesting buf(size);
   internal::PodUnion_Data* data = internal::PodUnion_Data::New(&buf);
@@ -274,7 +270,6 @@
 }
 
 TEST(UnionTest, UnknownTagValidation) {
-  Environment environment;
   size_t size = sizeof(internal::PodUnion_Data);
   mojo::internal::FixedBufferForTesting buf(size);
   internal::PodUnion_Data* data = internal::PodUnion_Data::New(&buf);
@@ -345,7 +340,6 @@
 }
 
 TEST(UnionTest, NullStringValidation) {
-  Environment environment;
   size_t size = sizeof(internal::ObjectUnion_Data);
   mojo::internal::FixedBufferForTesting buf(size);
   internal::ObjectUnion_Data* data = internal::ObjectUnion_Data::New(&buf);
@@ -362,7 +356,6 @@
 }
 
 TEST(UnionTest, StringPointerOverflowValidation) {
-  Environment environment;
   size_t size = sizeof(internal::ObjectUnion_Data);
   mojo::internal::FixedBufferForTesting buf(size);
   internal::ObjectUnion_Data* data = internal::ObjectUnion_Data::New(&buf);
@@ -379,7 +372,6 @@
 }
 
 TEST(UnionTest, StringValidateOOB) {
-  Environment environment;
   size_t size = 32;
   mojo::internal::FixedBufferForTesting buf(size);
   internal::ObjectUnion_Data* data = internal::ObjectUnion_Data::New(&buf);
@@ -416,7 +408,6 @@
 }
 
 TEST(UnionTest, PodUnionInArraySerialization) {
-  Environment environment;
   auto array = Array<PodUnionPtr>::New(2);
   array[0] = PodUnion::New();
   array[1] = PodUnion::New();
@@ -443,7 +434,6 @@
 }
 
 TEST(UnionTest, PodUnionInArrayValidation) {
-  Environment environment;
   auto array = Array<PodUnionPtr>::New(2);
   array[0] = PodUnion::New();
   array[1] = PodUnion::New();
@@ -472,7 +462,6 @@
   free(raw_buf);
 }
 TEST(UnionTest, PodUnionInArraySerializationWithNull) {
-  Environment environment;
   auto array = Array<PodUnionPtr>::New(2);
   array[0] = PodUnion::New();
 
@@ -499,7 +488,6 @@
 // TODO(azani): Move back in struct_unittest.cc when possible.
 // Struct tests
 TEST(UnionTest, Clone_Union) {
-  Environment environment;
   SmallStructPtr small_struct(SmallStruct::New());
   small_struct->pod_union = PodUnion::New();
   small_struct->pod_union->set_f_int8(10);
@@ -510,7 +498,6 @@
 
 // Serialization test of a struct with a union of plain old data.
 TEST(UnionTest, Serialization_UnionOfPods) {
-  Environment environment;
   SmallStructPtr small_struct(SmallStruct::New());
   small_struct->pod_union = PodUnion::New();
   small_struct->pod_union->set_f_int32(10);
@@ -530,7 +517,6 @@
 
 // Serialization test of a struct with a union of structs.
 TEST(UnionTest, Serialization_UnionOfObjects) {
-  Environment environment;
   SmallObjStructPtr obj_struct(SmallObjStruct::New());
   obj_struct->obj_union = ObjectUnion::New();
   String hello("hello world");
@@ -555,7 +541,6 @@
 
 // Validation test of a struct with a union.
 TEST(UnionTest, Validation_UnionsInStruct) {
-  Environment environment;
   SmallStructPtr small_struct(SmallStruct::New());
   small_struct->pod_union = PodUnion::New();
   small_struct->pod_union->set_f_int32(10);
@@ -582,7 +567,6 @@
 
 // Validation test of a struct union fails due to unknown union tag.
 TEST(UnionTest, Validation_PodUnionInStruct_Failure) {
-  Environment environment;
   SmallStructPtr small_struct(SmallStruct::New());
   small_struct->pod_union = PodUnion::New();
   small_struct->pod_union->set_f_int32(10);
@@ -610,7 +594,6 @@
 
 // Validation fails due to non-nullable null union in struct.
 TEST(UnionTest, Validation_NullUnion_Failure) {
-  Environment environment;
   SmallStructNonNullableUnionPtr small_struct(
       SmallStructNonNullableUnion::New());
 
@@ -631,7 +614,6 @@
 
 // Validation passes with nullable null union.
 TEST(UnionTest, Validation_NullableUnion) {
-  Environment environment;
   SmallStructPtr small_struct(SmallStruct::New());
 
   size_t size = GetSerializedSize_(*small_struct);
@@ -669,7 +651,6 @@
 
 // Validation passes with nullable null union containing non-nullable objects.
 TEST(UnionTest, Validation_NullableObjectUnion) {
-  Environment environment;
   StructNullObjectUnionPtr small_struct(StructNullObjectUnion::New());
 
   size_t size = GetSerializedSize_(*small_struct);
@@ -708,7 +689,6 @@
 }
 
 TEST(UnionTest, PodUnionInMapSerialization) {
-  Environment environment;
   Map<String, PodUnionPtr> map;
   map.insert("one", PodUnion::New());
   map.insert("two", PodUnion::New());
@@ -734,7 +714,6 @@
 }
 
 TEST(UnionTest, PodUnionInMapSerializationWithNull) {
-  Environment environment;
   Map<String, PodUnionPtr> map;
   map.insert("one", PodUnion::New());
   map.insert("two", nullptr);
@@ -769,7 +748,6 @@
 }
 
 TEST(UnionTest, StructInUnionSerialization) {
-  Environment environment;
   DummyStructPtr dummy(DummyStruct::New());
   dummy->f_int8 = 8;
 
@@ -793,7 +771,6 @@
 }
 
 TEST(UnionTest, StructInUnionValidation) {
-  Environment environment;
   DummyStructPtr dummy(DummyStruct::New());
   dummy->f_int8 = 8;
 
@@ -820,7 +797,6 @@
 }
 
 TEST(UnionTest, StructInUnionValidationNonNullable) {
-  Environment environment;
   DummyStructPtr dummy(nullptr);
 
   ObjectUnionPtr obj(ObjectUnion::New());
@@ -846,7 +822,6 @@
 }
 
 TEST(UnionTest, StructInUnionValidationNullable) {
-  Environment environment;
   DummyStructPtr dummy(nullptr);
 
   ObjectUnionPtr obj(ObjectUnion::New());
@@ -872,8 +847,6 @@
 }
 
 TEST(UnionTest, ArrayInUnionGetterSetter) {
-  Environment environment;
-
   auto array = Array<int8_t>::New(2);
   array[0] = 8;
   array[1] = 9;
@@ -886,8 +859,6 @@
 }
 
 TEST(UnionTest, ArrayInUnionSerialization) {
-  Environment environment;
-
   auto array = Array<int8_t>::New(2);
   array[0] = 8;
   array[1] = 9;
@@ -914,8 +885,6 @@
 }
 
 TEST(UnionTest, ArrayInUnionValidation) {
-  Environment environment;
-
   auto array = Array<int8_t>::New(2);
   array[0] = 8;
   array[1] = 9;
@@ -943,7 +912,6 @@
 }
 
 TEST(UnionTest, MapInUnionGetterSetter) {
-  Environment environment;
   Map<String, int8_t> map;
   map.insert("one", 1);
   map.insert("two", 2);
@@ -956,7 +924,6 @@
 }
 
 TEST(UnionTest, MapInUnionSerialization) {
-  Environment environment;
   Map<String, int8_t> map;
   map.insert("one", 1);
   map.insert("two", 2);
@@ -983,7 +950,6 @@
 }
 
 TEST(UnionTest, MapInUnionValidation) {
-  Environment environment;
   Map<String, int8_t> map;
   map.insert("one", 1);
   map.insert("two", 2);
@@ -1023,7 +989,6 @@
 }
 
 TEST(UnionTest, UnionInUnionSerialization) {
-  Environment environment;
   PodUnionPtr pod(PodUnion::New());
   pod->set_f_int8(10);
 
@@ -1047,7 +1012,6 @@
 }
 
 TEST(UnionTest, UnionInUnionValidation) {
-  Environment environment;
   PodUnionPtr pod(PodUnion::New());
   pod->set_f_int8(10);
 
@@ -1074,7 +1038,6 @@
 }
 
 TEST(UnionTest, UnionInUnionValidationNonNullable) {
-  Environment environment;
   PodUnionPtr pod(nullptr);
 
   ObjectUnionPtr obj(ObjectUnion::New());
@@ -1149,7 +1112,6 @@
 }
 
 TEST(UnionTest, HandleInUnionValidation) {
-  Environment environment;
   ScopedMessagePipeHandle pipe0;
   ScopedMessagePipeHandle pipe1;
 
@@ -1178,7 +1140,6 @@
 }
 
 TEST(UnionTest, HandleInUnionValidationNull) {
-  Environment environment;
   ScopedMessagePipeHandle pipe;
   HandleUnionPtr handle(HandleUnion::New());
   handle->set_f_message_pipe(pipe.Pass());
@@ -1218,7 +1179,6 @@
 };
 
 TEST(UnionTest, InterfaceInUnion) {
-  Environment env;
   RunLoop run_loop;
   SmallCacheImpl impl;
   SmallCachePtr ptr;
@@ -1235,7 +1195,6 @@
 }
 
 TEST(UnionTest, InterfaceInUnionSerialization) {
-  Environment env;
   RunLoop run_loop;
   SmallCacheImpl impl;
   SmallCachePtr ptr;
@@ -1277,7 +1236,6 @@
 };
 
 TEST(UnionTest, UnionInInterface) {
-  Environment env;
   RunLoop run_loop;
   UnionInterfaceImpl impl;
   UnionInterfacePtr ptr;
diff --git a/mojo/public/cpp/bindings/tests/validation_unittest.cc b/mojo/public/cpp/bindings/tests/validation_unittest.cc
index 70bd75b..e5d097d 100644
--- a/mojo/public/cpp/bindings/tests/validation_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/validation_unittest.cc
@@ -17,7 +17,6 @@
 #include "mojo/public/cpp/bindings/lib/validation_errors.h"
 #include "mojo/public/cpp/bindings/message.h"
 #include "mojo/public/cpp/bindings/tests/validation_test_input_parser.h"
-#include "mojo/public/cpp/environment/environment.h"
 #include "mojo/public/cpp/system/macros.h"
 #include "mojo/public/cpp/system/message_pipe.h"
 #include "mojo/public/cpp/test_support/test_support.h"
@@ -193,15 +192,7 @@
   }
 };
 
-class ValidationTest : public testing::Test {
- public:
-  ~ValidationTest() override {}
-
- private:
-  Environment env_;
-};
-
-class ValidationIntegrationTest : public ValidationTest {
+class ValidationIntegrationTest : public testing::Test {
  public:
   ValidationIntegrationTest() : test_message_receiver_(nullptr) {}
 
@@ -277,7 +268,7 @@
   ValidationError err_;
 };
 
-TEST_F(ValidationTest, InputParser) {
+TEST(ValidationTest, InputParser) {
   {
     // The parser, as well as Append() defined above, assumes that this code is
     // running on a little-endian platform. Test whether that is true.
@@ -381,7 +372,7 @@
   }
 }
 
-TEST_F(ValidationTest, Conformance) {
+TEST(ValidationTest, Conformance) {
   DummyMessageReceiver dummy_receiver;
   MessageValidatorList validators;
   validators.push_back(std::unique_ptr<MessageValidator>(
@@ -395,7 +386,7 @@
 // This test is similar to Conformance test but its goal is specifically
 // do bounds-check testing of message validation. For example we test the
 // detection of off-by-one errors in method ordinals.
-TEST_F(ValidationTest, BoundsCheck) {
+TEST(ValidationTest, BoundsCheck) {
   DummyMessageReceiver dummy_receiver;
   MessageValidatorList validators;
   validators.push_back(std::unique_ptr<MessageValidator>(
@@ -407,7 +398,7 @@
 }
 
 // This test is similar to the Conformance test but for responses.
-TEST_F(ValidationTest, ResponseConformance) {
+TEST(ValidationTest, ResponseConformance) {
   DummyMessageReceiver dummy_receiver;
   MessageValidatorList validators;
   validators.push_back(std::unique_ptr<MessageValidator>(
@@ -419,7 +410,7 @@
 }
 
 // This test is similar to the BoundsCheck test but for responses.
-TEST_F(ValidationTest, ResponseBoundsCheck) {
+TEST(ValidationTest, ResponseBoundsCheck) {
   DummyMessageReceiver dummy_receiver;
   MessageValidatorList validators;
   validators.push_back(std::unique_ptr<MessageValidator>(
@@ -474,7 +465,7 @@
 }
 
 // Test pointer validation (specifically, that the encoded offset is 32-bit)
-TEST_F(ValidationTest, ValidateEncodedPointer) {
+TEST(ValidationTest, ValidateEncodedPointer) {
   uint64_t offset;
 
   offset = 0ULL;
@@ -488,7 +479,7 @@
   EXPECT_FALSE(mojo::internal::ValidateEncodedPointer(&offset));
 }
 
-TEST_F(ValidationTest, RunValidatorsOnMessageTest) {
+TEST(ValidationTest, RunValidatorsOnMessageTest) {
   Message msg;
   mojo::internal::MessageValidatorList validators;
 
diff --git a/mojo/public/cpp/environment/environment.h b/mojo/public/cpp/environment/environment.h
index 85d1799..6c544ee 100644
--- a/mojo/public/cpp/environment/environment.h
+++ b/mojo/public/cpp/environment/environment.h
@@ -12,27 +12,19 @@
 
 namespace mojo {
 
-// Other parts of the Mojo C++ APIs use the *static* methods of this class.
-//
-// The "standalone" implementation of this class requires that this class (in
-// the lib/ subdirectory) be instantiated (and remain so) while using the Mojo
-// C++ APIs. I.e., the static methods depend on things set up by the constructor
-// and torn down by the destructor.
-//
-// Other implementations may not have this requirement.
+// This class just acts as a "namespace": it only has static methods (whose
+// implementation may be varied). Note that some implementations may require
+// their own explicit initialization/shut down functions to be called.
 class Environment {
  public:
-  Environment();
-  // This constructor allows the standard implementations to be overridden (set
-  // a parameter to null to get the standard implementation).
-  Environment(const MojoAsyncWaiter* default_async_waiter,
-              const MojoLogger* default_logger);
-  ~Environment();
-
   static const MojoAsyncWaiter* GetDefaultAsyncWaiter();
+  // Setting the default async waiter to null will use the original default
+  // implementation.
+  static void SetDefaultAsyncWaiter(const MojoAsyncWaiter* async_waiter);
 
   static const MojoLogger* GetDefaultLogger();
-  // Setting the logger to null will use the standard implementation.
+  // Setting the logger to null will use the will use the original default
+  // implementation.
   static void SetDefaultLogger(const MojoLogger* logger);
 
   // These instantiate and destroy an environment-specific run loop for the
@@ -44,7 +36,8 @@
   static void DestroyDefaultRunLoop();
 
  private:
-  MOJO_DISALLOW_COPY_AND_ASSIGN(Environment);
+  Environment() = delete;
+  ~Environment() = delete;
 };
 
 }  // namespace mojo
diff --git a/mojo/public/cpp/environment/lib/environment.cc b/mojo/public/cpp/environment/lib/environment.cc
index 8224970..73f8668 100644
--- a/mojo/public/cpp/environment/lib/environment.cc
+++ b/mojo/public/cpp/environment/lib/environment.cc
@@ -13,53 +13,27 @@
 
 namespace mojo {
 
-namespace {
-
-const MojoAsyncWaiter* g_default_async_waiter = nullptr;
-const MojoLogger* g_default_logger = nullptr;
-
-void Init(const MojoAsyncWaiter* default_async_waiter,
-          const MojoLogger* default_logger) {
-  g_default_async_waiter = default_async_waiter
-                               ? default_async_waiter
-                               : &internal::kDefaultAsyncWaiter;
-  g_default_logger =
-      default_logger ? default_logger : &internal::kDefaultLogger;
-}
-
-}  // namespace
-
-Environment::Environment() {
-  Init(nullptr, nullptr);
-}
-
-Environment::Environment(const MojoAsyncWaiter* default_async_waiter,
-                         const MojoLogger* default_logger) {
-  Init(default_async_waiter, default_logger);
-}
-
-Environment::~Environment() {
-  // TODO(vtl): Maybe we should allow nesting, and restore previous default
-  // async waiters and loggers?
-  g_default_async_waiter = nullptr;
-  g_default_logger = nullptr;
-}
+const MojoAsyncWaiter* g_default_async_waiter = &internal::kDefaultAsyncWaiter;
+const MojoLogger* g_default_logger = &internal::kDefaultLogger;
 
 // static
 const MojoAsyncWaiter* Environment::GetDefaultAsyncWaiter() {
-  assert(g_default_async_waiter);  // Fails if not "inside" |Environment|.
   return g_default_async_waiter;
 }
 
 // static
+void Environment::SetDefaultAsyncWaiter(const MojoAsyncWaiter* async_waiter) {
+  g_default_async_waiter =
+      async_waiter ? async_waiter : &internal::kDefaultAsyncWaiter;
+}
+
+// static
 const MojoLogger* Environment::GetDefaultLogger() {
-  assert(g_default_logger);  // Fails if not "inside" |Environment|.
   return g_default_logger;
 }
 
 // static
 void Environment::SetDefaultLogger(const MojoLogger* logger) {
-  assert(g_default_logger);  // Fails if not "inside" |Environment|.
   g_default_logger = logger ? logger : &internal::kDefaultLogger;
 }
 
diff --git a/mojo/public/cpp/environment/lib/logging_only_environment.cc b/mojo/public/cpp/environment/lib/logging_only_environment.cc
index 42c33ff..38b15b8 100644
--- a/mojo/public/cpp/environment/lib/logging_only_environment.cc
+++ b/mojo/public/cpp/environment/lib/logging_only_environment.cc
@@ -12,13 +12,6 @@
 
 namespace mojo {
 
-Environment::Environment() {}
-
-Environment::Environment(const MojoAsyncWaiter* default_async_waiter,
-                         const MojoLogger* default_logger) {}
-
-Environment::~Environment() {}
-
 // static
 const MojoLogger* Environment::GetDefaultLogger() {
   return &internal::kDefaultLogger;
diff --git a/mojo/public/cpp/environment/tests/async_wait_unittest.cc b/mojo/public/cpp/environment/tests/async_wait_unittest.cc
index 8d9750f..0fba423 100644
--- a/mojo/public/cpp/environment/tests/async_wait_unittest.cc
+++ b/mojo/public/cpp/environment/tests/async_wait_unittest.cc
@@ -61,7 +61,6 @@
   AsyncWaitTest() {}
 
  private:
-  Environment environment_;
   RunLoop run_loop_;
 
   MOJO_DISALLOW_COPY_AND_ASSIGN(AsyncWaitTest);
diff --git a/mojo/public/cpp/environment/tests/async_waiter_unittest.cc b/mojo/public/cpp/environment/tests/async_waiter_unittest.cc
index 1c1c2bf..9347450 100644
--- a/mojo/public/cpp/environment/tests/async_waiter_unittest.cc
+++ b/mojo/public/cpp/environment/tests/async_waiter_unittest.cc
@@ -49,7 +49,6 @@
   AsyncWaiterTest() {}
 
  private:
-  Environment environment_;
   RunLoop run_loop_;
 
   MOJO_DISALLOW_COPY_AND_ASSIGN(AsyncWaiterTest);
diff --git a/mojo/public/cpp/environment/tests/logger_unittest.cc b/mojo/public/cpp/environment/tests/logger_unittest.cc
index cf0e1c0..fcbc3ea 100644
--- a/mojo/public/cpp/environment/tests/logger_unittest.cc
+++ b/mojo/public/cpp/environment/tests/logger_unittest.cc
@@ -20,7 +20,6 @@
 TEST(LoggerTest, Basic) {
   const char kPath[] = "/fake/path/to/file.cc";
 
-  Environment environment;
   const MojoLogger* const logger = Environment::GetDefaultLogger();
 
   logger->LogMessage(MOJO_LOG_LEVEL_VERBOSE - 1, kPath, 123,
@@ -42,7 +41,6 @@
 TEST(LoggerTest, LogLevels) {
   const char kPath[] = "/fake/path/to/file.cc";
 
-  Environment environment;
   const MojoLogger* const logger = Environment::GetDefaultLogger();
 
   for (MojoLogLevel log_level = MOJO_LOG_LEVEL_VERBOSE - 1;
@@ -74,7 +72,6 @@
 }
 
 TEST(LoggerTest, NoFile) {
-  Environment environment;
   const MojoLogger* const logger = Environment::GetDefaultLogger();
 
   logger->LogMessage(MOJO_LOG_LEVEL_VERBOSE - 1, nullptr, 0,
@@ -94,7 +91,6 @@
 }
 
 TEST(LoggerTest, SetDefaultLogger) {
-  Environment environment;
   Environment::SetDefaultLogger(&kTestLogger);
 
   std::vector<std::string> expected_msgs;
diff --git a/mojo/public/cpp/environment/tests/logging_unittest.cc b/mojo/public/cpp/environment/tests/logging_unittest.cc
index ab1de64..e3af7aa 100644
--- a/mojo/public/cpp/environment/tests/logging_unittest.cc
+++ b/mojo/public/cpp/environment/tests/logging_unittest.cc
@@ -30,7 +30,8 @@
 
 class LoggingTest : public testing::Test {
  public:
-  LoggingTest() : environment_(nullptr, &kMockLogger) {
+  LoggingTest() {
+    Environment::SetDefaultLogger(&kMockLogger);
     minimum_log_level_ = MOJO_LOG_LEVEL_INFO;
     ResetMockLogger();
   }
@@ -82,8 +83,6 @@
     minimum_log_level_ = minimum_log_level;
   }
 
-  Environment environment_;
-
   static const MojoLogger kMockLogger;
   static MojoLogLevel minimum_log_level_;
   static bool log_message_was_called_;
diff --git a/mojo/public/python/c_environment.pxd b/mojo/public/python/c_environment.pxd
index c1b37d6..950dc04 100644
--- a/mojo/public/python/c_environment.pxd
+++ b/mojo/public/python/c_environment.pxd
@@ -28,8 +28,3 @@
     void Quit()
     void PostDelayedTask(CClosure&, int64_t)
   cdef CRunLoop CRunLoopCurrent "mojo::RunLoop::current"()
-
-
-cdef extern from "mojo/public/cpp/environment/environment.h" nogil:
-  cdef cppclass CEnvironment "mojo::Environment":
-    CEnvironment()
diff --git a/mojo/public/python/mojo_system_impl.pyx b/mojo/public/python/mojo_system_impl.pyx
index 3e299c1..3b7cfeb 100644
--- a/mojo/public/python/mojo_system_impl.pyx
+++ b/mojo/public/python/mojo_system_impl.pyx
@@ -57,16 +57,13 @@
 # We use a wrapping class to be able to call the C++ class PythonAsyncWaiter
 # across module boundaries.
 cdef class AsyncWaiter(object):
-  cdef c_environment.CEnvironment* _cenvironment
   cdef c_async_waiter.PythonAsyncWaiter* _c_async_waiter
 
   def __init__(self):
-    self._cenvironment = new c_environment.CEnvironment()
     self._c_async_waiter = c_environment.NewAsyncWaiter()
 
   def __dealloc__(self):
     del self._c_async_waiter
-    del self._cenvironment
 
   def AsyncWait(self, handle, signals, deadline, callback):
     return self._c_async_waiter.AsyncWait(handle, signals, deadline, callback)