Make //mojo/common less of a dumping ground

This splits most of the loosely coupled code in //mojo/common out into
topical locations thusly:

data_pipe_utils                              -> //mojo/data_pipe_utils
message_pump_mojo & handle_watcher           -> //mojo/message_pump
mojo::Array <-> std::string converters       -> //mojo/converters/array_string
base type converters (string16/stringpiece)  -> //mojo/converters/base
url type converters                          -> //mojo/converters/url

and updates many references to only depend on the bit they are actually
using. The unit tests are moved to live next to their code (in
source_sets) but are still linked into mojo_common_unittests. This
patch doesn't change the namespace of anything to minimize actual code churn.

binding_set, interface_ptr_set and task_tracker are still in the
//mojo/common target and some other files in random targets are still
in the //mojo/common directory. Some (or possibly all) of these will
likely move to other locations in future patches.

R=viettrungluu@chromium.org

Review URL: https://codereview.chromium.org/1306923003 .
diff --git a/mojo/android/BUILD.gn b/mojo/android/BUILD.gn
index 8e0aacd..746a156 100644
--- a/mojo/android/BUILD.gn
+++ b/mojo/android/BUILD.gn
@@ -45,10 +45,10 @@
   deps = [
     ":system_java_jni_headers",
     "//base",
-    "//mojo/public/cpp/environment",
-    "//mojo/common:common",
+    "//mojo/message_pump",
     "//mojo/public/c/system:system",
     "//mojo/public/cpp/bindings:callback",
+    "//mojo/public/cpp/environment",
   ]
 }
 
@@ -125,13 +125,12 @@
     ":system_java_jni_headers",
     "//base",
     "//base/test/:test_support",
-    "//mojo/common",
-    "//mojo/edk/system",
-    "//mojo/public/cpp/bindings/tests:mojo_public_bindings_test_utils",
-    "//mojo/public/cpp/test_support:test_utils",
-    "//mojo/public/cpp/environment",
     "//mojo/edk/system",
     "//mojo/environment:chromium",
+    "//mojo/message_pump",
+    "//mojo/public/cpp/bindings/tests:mojo_public_bindings_test_utils",
+    "//mojo/public/cpp/environment",
+    "//mojo/public/cpp/test_support:test_utils",
   ]
   defines = [ "UNIT_TEST" ]
 }
diff --git a/mojo/android/javatests/mojo_test_case.cc b/mojo/android/javatests/mojo_test_case.cc
index 419d14d..2df0bc7 100644
--- a/mojo/android/javatests/mojo_test_case.cc
+++ b/mojo/android/javatests/mojo_test_case.cc
@@ -13,7 +13,7 @@
 #include "base/run_loop.h"
 #include "base/test/test_support_android.h"
 #include "jni/MojoTestCase_jni.h"
-#include "mojo/common/message_pump_mojo.h"
+#include "mojo/message_pump/message_pump_mojo.h"
 
 #include "mojo/public/cpp/environment/environment.h"
 
diff --git a/mojo/android/system/base_run_loop.cc b/mojo/android/system/base_run_loop.cc
index 3d05e30..f361a94 100644
--- a/mojo/android/system/base_run_loop.cc
+++ b/mojo/android/system/base_run_loop.cc
@@ -12,7 +12,7 @@
 #include "base/bind.h"
 #include "base/message_loop/message_loop.h"
 #include "jni/BaseRunLoop_jni.h"
-#include "mojo/common/message_pump_mojo.h"
+#include "mojo/message_pump/message_pump_mojo.h"
 
 namespace mojo {
 namespace android {
diff --git a/mojo/application/BUILD.gn b/mojo/application/BUILD.gn
index f28c13b..35cb345 100644
--- a/mojo/application/BUILD.gn
+++ b/mojo/application/BUILD.gn
@@ -13,7 +13,7 @@
   ]
   deps = [
     "//base",
-    "//mojo/common",
+    "//mojo/message_pump",
     "//mojo/public/cpp/system",
     "//mojo/environment:chromium",
   ]
@@ -27,8 +27,8 @@
   deps = [
     ":application",
     "//base",
-    "//mojo/common",
     "//mojo/environment:chromium",
+    "//mojo/message_pump",
     "//mojo/public/interfaces/application",
     "//mojo/services/content_handler/public/interfaces",
     "//mojo/services/network/public/interfaces",
diff --git a/mojo/application/application_runner_chromium.cc b/mojo/application/application_runner_chromium.cc
index 451d448..d54f4b2 100644
--- a/mojo/application/application_runner_chromium.cc
+++ b/mojo/application/application_runner_chromium.cc
@@ -9,7 +9,7 @@
 #include "base/debug/stack_trace.h"
 #include "base/memory/scoped_ptr.h"
 #include "base/message_loop/message_loop.h"
-#include "mojo/common/message_pump_mojo.h"
+#include "mojo/message_pump/message_pump_mojo.h"
 #include "mojo/public/cpp/application/application_delegate.h"
 #include "mojo/public/cpp/application/application_impl.h"
 
diff --git a/mojo/application/content_handler_factory.cc b/mojo/application/content_handler_factory.cc
index 1231001..9594fdb 100644
--- a/mojo/application/content_handler_factory.cc
+++ b/mojo/application/content_handler_factory.cc
@@ -13,7 +13,7 @@
 #include "base/threading/platform_thread.h"
 #include "base/trace_event/trace_event.h"
 #include "mojo/application/application_runner_chromium.h"
-#include "mojo/common/message_pump_mojo.h"
+#include "mojo/message_pump/message_pump_mojo.h"
 #include "mojo/public/cpp/application/application_connection.h"
 #include "mojo/public/cpp/application/application_delegate.h"
 #include "mojo/public/cpp/application/application_impl.h"
diff --git a/mojo/common/BUILD.gn b/mojo/common/BUILD.gn
index 748eb4f..2420060 100644
--- a/mojo/common/BUILD.gn
+++ b/mojo/common/BUILD.gn
@@ -5,54 +5,25 @@
 import("//mojo/public/tools/bindings/mojom.gni")
 import("//testing/test.gni")
 
-component("common") {
-  output_name = "mojo_common_lib"
-
+source_set("common") {
   sources = [
     "binding_set.h",
-    "common_type_converters.cc",
-    "common_type_converters.h",
-    "data_pipe_drainer.cc",
-    "data_pipe_drainer.h",
-    "data_pipe_file_utils.cc",
-    "data_pipe_utils.cc",
-    "data_pipe_utils.h",
-    "data_pipe_utils_internal.h",
-    "handle_watcher.cc",
-    "handle_watcher.h",
     "interface_ptr_set.h",
-    "message_pump_mojo.cc",
-    "message_pump_mojo.h",
-    "message_pump_mojo_handler.h",
     "task_tracker.cc",
     "task_tracker.h",
-    "time_helper.cc",
-    "time_helper.h",
   ]
 
-  if (is_nacl) {
-    sources -= [ "data_pipe_file_utils.cc" ]
-  }
-
   deps = [
     "//base",
-    "//base/third_party/dynamic_annotations",
-    "//mojo/public/c/system",
     "//mojo/public/cpp/bindings",
-    "//mojo/public/cpp/environment:environment",
-    "//mojo/public/cpp/system",
-    "//url",
   ]
 }
 
 test("mojo_common_unittests") {
   sources = [
     "binding_set_unittest.cc",
-    "common_type_converters_unittest.cc",
-    "data_pipe_utils_unittest.cc",
-    "handle_watcher_unittest.cc",
+    "callback_binding_unittest.cc",
     "interface_ptr_set_unittest.cc",
-    "message_pump_mojo_unittest.cc",
     "task_tracker_unittest.cc",
   ]
 
@@ -61,10 +32,15 @@
     ":test_interfaces",
     "//base",
     "//base/test:test_support",
-    "//base:message_loop_tests",
+    "//mojo/converters/array_string:tests",
+    "//mojo/converters/base:tests",
+    "//mojo/converters/url:tests",
+    "//mojo/data_pipe_utils:tests",
     "//mojo/edk/test:run_all_unittests",
     "//mojo/edk/test:test_support",
     "//mojo/environment:chromium",
+    "//mojo/message_pump",
+    "//mojo/message_pump:tests",
     "//mojo/public/cpp/bindings",
     "//mojo/public/cpp/bindings:callback",
     "//mojo/public/cpp/system",
diff --git a/mojo/common/binding_set_unittest.cc b/mojo/common/binding_set_unittest.cc
index 421a405..c37053e 100644
--- a/mojo/common/binding_set_unittest.cc
+++ b/mojo/common/binding_set_unittest.cc
@@ -5,8 +5,8 @@
 #include "mojo/common/binding_set.h"
 
 #include "base/message_loop/message_loop.h"
-#include "mojo/common/message_pump_mojo.h"
 #include "mojo/common/test_interfaces.mojom.h"
+#include "mojo/message_pump/message_pump_mojo.h"
 #include "mojo/public/cpp/bindings/binding.h"
 #include "mojo/public/cpp/bindings/interface_request.h"
 #include "testing/gtest/include/gtest/gtest.h"
diff --git a/mojo/common/callback_binding_unittest.cc b/mojo/common/callback_binding_unittest.cc
new file mode 100644
index 0000000..aa59856
--- /dev/null
+++ b/mojo/common/callback_binding_unittest.cc
@@ -0,0 +1,104 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/bind.h"
+#include "mojo/public/cpp/bindings/callback.h"
+#include "mojo/public/cpp/bindings/map.h"
+#include "mojo/public/cpp/bindings/string.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+struct RunnableNoArgs {
+  RunnableNoArgs(int* calls) : calls(calls) {}
+  void Run() const { (*calls)++; }
+
+  int* calls;
+};
+
+TEST(CallbackBindingTest, BaseBindToMojoCallbackNoParams) {
+  mojo::Callback<void()> cb;
+  int calls = 0;
+  RunnableNoArgs r(&calls);
+  cb = r;
+  cb.Run();
+  EXPECT_EQ(1, calls);
+
+  cb = base::Bind(&RunnableNoArgs::Run, base::Unretained(&r));
+  cb.Run();
+  EXPECT_EQ(2, calls);
+}
+
+struct RunnableOnePrimitiveArg {
+  explicit RunnableOnePrimitiveArg(int* calls) : calls(calls) {}
+  void Run(int a) const { (*calls)++; }
+
+  int* calls;
+};
+
+TEST(CallbackBindingTest, BaseBindToMojoCallbackPrimitiveParam) {
+  mojo::Callback<void(int)> mojo_callback;
+  int calls = 0;
+  RunnableOnePrimitiveArg r(&calls);
+  mojo_callback = r;
+  mojo_callback.Run(0);
+  EXPECT_EQ(1, calls);
+
+  base::Callback<void(int)> base_callback =
+      base::Bind(&RunnableOnePrimitiveArg::Run, base::Unretained(&r));
+  mojo_callback = base_callback;
+  mojo_callback.Run(0);
+  EXPECT_EQ(2, calls);
+}
+
+struct RunnableOneMojoStringParam {
+  explicit RunnableOneMojoStringParam(int* calls) : calls(calls) {}
+  void Run(const mojo::String& s) const { (*calls)++; }
+
+  int* calls;
+};
+
+TEST(CallbackBindingTest, BaseBindToMojoCallbackMojoStringParam) {
+  // The mojo type is a callback on mojo::String, but it'll expect to invoke
+  // callbacks with a parameter of type 'const Mojo::String&'.
+  mojo::Callback<void(mojo::String)> mojo_callback;
+  int calls = 0;
+  RunnableOneMojoStringParam r(&calls);
+  mojo_callback = r;
+  mojo_callback.Run(0);
+  EXPECT_EQ(1, calls);
+
+  base::Callback<void(const mojo::String&)> base_callback =
+      base::Bind(&RunnableOneMojoStringParam::Run, base::Unretained(&r));
+  mojo_callback = base_callback;
+  mojo_callback.Run(0);
+  EXPECT_EQ(2, calls);
+}
+
+using ExampleMoveOnlyType = mojo::Map<int, int>;
+
+struct RunnableOneMoveOnlyParam {
+  explicit RunnableOneMoveOnlyParam(int* calls) : calls(calls) {}
+
+  void Run(ExampleMoveOnlyType m) const { (*calls)++; }
+  int* calls;
+};
+
+TEST(CallbackBindingTest, BaseBindToMoveOnlyParam) {
+  mojo::Callback<void(ExampleMoveOnlyType)> mojo_callback;
+  int calls = 0;
+  RunnableOneMoveOnlyParam r(&calls);
+  mojo_callback = r;
+  ExampleMoveOnlyType m;
+  mojo_callback.Run(m.Clone());
+  EXPECT_EQ(1, calls);
+
+  base::Callback<void(ExampleMoveOnlyType)> base_callback =
+      base::Bind(&RunnableOneMoveOnlyParam::Run, base::Unretained(&r));
+  mojo_callback = base_callback;
+  mojo_callback.Run(m.Clone());
+  EXPECT_EQ(2, calls);
+}
+
+}  // namespace
diff --git a/mojo/common/common_type_converters.cc b/mojo/common/common_type_converters.cc
deleted file mode 100644
index 114b409..0000000
--- a/mojo/common/common_type_converters.cc
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "mojo/common/common_type_converters.h"
-
-#include <string>
-
-#include "base/strings/utf_string_conversions.h"
-#include "url/gurl.h"
-
-namespace mojo {
-
-// static
-String TypeConverter<String, base::StringPiece>::Convert(
-    const base::StringPiece& input) {
-  if (input.empty()) {
-    char c = 0;
-    return String(&c, 0);
-  }
-  return String(input.data(), input.size());
-}
-// static
-base::StringPiece TypeConverter<base::StringPiece, String>::Convert(
-    const String& input) {
-  return input.get();
-}
-
-// static
-String TypeConverter<String, base::string16>::Convert(
-    const base::string16& input) {
-  return TypeConverter<String, base::StringPiece>::Convert(
-      base::UTF16ToUTF8(input));
-}
-// static
-base::string16 TypeConverter<base::string16, String>::Convert(
-    const String& input) {
-  return base::UTF8ToUTF16(input.To<base::StringPiece>());
-}
-
-String TypeConverter<String, GURL>::Convert(const GURL& input) {
-  return String(input.spec());
-}
-
-GURL TypeConverter<GURL, String>::Convert(const String& input) {
-  return GURL(input.get());
-}
-
-std::string TypeConverter<std::string, Array<uint8_t> >::Convert(
-    const Array<uint8_t>& input) {
-  if (input.is_null())
-    return std::string();
-
-  return std::string(reinterpret_cast<const char*>(&input.front()),
-                     input.size());
-}
-
-Array<uint8_t> TypeConverter<Array<uint8_t>, std::string>::Convert(
-    const std::string& input) {
-  Array<uint8_t> result(input.size());
-  memcpy(&result.front(), input.c_str(), input.size());
-  return result.Pass();
-}
-
-}  // namespace mojo
diff --git a/mojo/common/common_type_converters.h b/mojo/common/common_type_converters.h
deleted file mode 100644
index 9bd21e8..0000000
--- a/mojo/common/common_type_converters.h
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef MOJO_COMMON_COMMON_TYPE_CONVERTERS_H_
-#define MOJO_COMMON_COMMON_TYPE_CONVERTERS_H_
-
-#include "base/strings/string16.h"
-#include "base/strings/string_piece.h"
-#include "mojo/public/cpp/bindings/array.h"
-#include "mojo/public/cpp/bindings/string.h"
-#include "mojo/public/cpp/bindings/type_converter.h"
-
-class GURL;
-
-namespace mojo {
-
-template <>
-struct TypeConverter<String, base::StringPiece> {
-  static String Convert(const base::StringPiece& input);
-};
-
-template <>
-struct TypeConverter<base::StringPiece, String> {
-  static base::StringPiece Convert(const String& input);
-};
-
-template <>
-struct TypeConverter<String, base::string16> {
-  static String Convert(const base::string16& input);
-};
-
-template <>
-struct TypeConverter<base::string16, String> {
-  static base::string16 Convert(const String& input);
-};
-
-template <>
-struct TypeConverter<String, GURL> {
-  static String Convert(const GURL& input);
-};
-
-template <>
-struct TypeConverter<GURL, String> {
-  static GURL Convert(const String& input);
-};
-
-// TODO(erg): In the very long term, we will want to remove conversion between
-// std::strings and arrays of unsigned bytes. However, there is too much code
-// across chrome which uses std::string as a bag of bytes that we probably
-// don't want to roll this function at each callsite.
-template <>
-struct TypeConverter<std::string, Array<uint8_t>> {
-  static std::string Convert(const Array<uint8_t>& input);
-};
-
-template <>
-struct TypeConverter<Array<uint8_t>, std::string> {
-  static Array<uint8_t> Convert(const std::string& input);
-};
-
-}  // namespace mojo
-
-#endif  // MOJO_COMMON_COMMON_TYPE_CONVERTERS_H_
diff --git a/mojo/common/common_type_converters_unittest.cc b/mojo/common/common_type_converters_unittest.cc
deleted file mode 100644
index 4a360bd..0000000
--- a/mojo/common/common_type_converters_unittest.cc
+++ /dev/null
@@ -1,203 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "mojo/common/common_type_converters.h"
-
-#include "base/bind.h"
-#include "base/strings/utf_string_conversions.h"
-#include "mojo/public/cpp/bindings/callback.h"
-#include "mojo/public/cpp/bindings/map.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "url/gurl.h"
-
-namespace mojo {
-namespace common {
-namespace test {
-namespace {
-
-void ExpectEqualsStringPiece(const std::string& expected,
-                             const base::StringPiece& str) {
-  EXPECT_EQ(expected, str.as_string());
-}
-
-void ExpectEqualsMojoString(const std::string& expected,
-                            const String& str) {
-  EXPECT_EQ(expected, str.get());
-}
-
-void ExpectEqualsString16(const base::string16& expected,
-                          const base::string16& actual) {
-  EXPECT_EQ(expected, actual);
-}
-
-void ExpectEqualsMojoString(const base::string16& expected,
-                            const String& str) {
-  EXPECT_EQ(expected, str.To<base::string16>());
-}
-
-TEST(CommonTypeConvertersTest, StringPiece) {
-  std::string kText("hello world");
-
-  base::StringPiece string_piece(kText);
-  String mojo_string(String::From(string_piece));
-
-  ExpectEqualsMojoString(kText, mojo_string);
-  ExpectEqualsStringPiece(kText, mojo_string.To<base::StringPiece>());
-
-  // Test implicit construction and conversion:
-  ExpectEqualsMojoString(kText, String::From(string_piece));
-  ExpectEqualsStringPiece(kText, mojo_string.To<base::StringPiece>());
-
-  // Test null String:
-  base::StringPiece empty_string_piece = String().To<base::StringPiece>();
-  EXPECT_TRUE(empty_string_piece.empty());
-}
-
-TEST(CommonTypeConvertersTest, String16) {
-  const base::string16 string16(base::ASCIIToUTF16("hello world"));
-  const String mojo_string(String::From(string16));
-
-  ExpectEqualsMojoString(string16, mojo_string);
-  EXPECT_EQ(string16, mojo_string.To<base::string16>());
-
-  // Test implicit construction and conversion:
-  ExpectEqualsMojoString(string16, String::From(string16));
-  ExpectEqualsString16(string16, mojo_string.To<base::string16>());
-
-  // Test empty string conversion.
-  ExpectEqualsMojoString(base::string16(), String::From(base::string16()));
-}
-
-TEST(CommonTypeConvertersTest, URL) {
-  GURL url("mojo:foo");
-  String mojo_string(String::From(url));
-
-  ASSERT_EQ(url.spec(), mojo_string);
-  EXPECT_EQ(url.spec(), mojo_string.To<GURL>().spec());
-  EXPECT_EQ(url.spec(), String::From(url));
-
-  GURL invalid = String().To<GURL>();
-  ASSERT_TRUE(invalid.spec().empty());
-
-  String string_from_invalid = String::From(invalid);
-  EXPECT_FALSE(string_from_invalid.is_null());
-  ASSERT_EQ(0U, string_from_invalid.size());
-}
-
-TEST(CommonTypeConvertersTest, ArrayUint8ToStdString) {
-  Array<uint8_t> data(4);
-  data[0] = 'd';
-  data[1] = 'a';
-  data[2] = 't';
-  data[3] = 'a';
-
-  EXPECT_EQ("data", data.To<std::string>());
-}
-
-TEST(CommonTypeConvertersTest, StdStringToArrayUint8) {
-  std::string input("data");
-  Array<uint8_t> data = Array<uint8_t>::From(input);
-
-  ASSERT_EQ(4ul, data.size());
-  EXPECT_EQ('d', data[0]);
-  EXPECT_EQ('a', data[1]);
-  EXPECT_EQ('t', data[2]);
-  EXPECT_EQ('a', data[3]);
-}
-
-struct RunnableNoArgs {
-  RunnableNoArgs(int* calls) : calls(calls) {}
-  void Run() const { (*calls)++; }
-
-  int* calls;
-};
-
-TEST(CommonTypeConvertersTest, BaseBindToMojoCallbackNoParams) {
-  mojo::Callback<void()> cb;
-  int calls = 0;
-  RunnableNoArgs r(&calls);
-  cb = r;
-  cb.Run();
-  EXPECT_EQ(1, calls);
-
-  cb = base::Bind(&RunnableNoArgs::Run, base::Unretained(&r));
-  cb.Run();
-  EXPECT_EQ(2, calls);
-}
-
-struct RunnableOnePrimitiveArg {
-  explicit RunnableOnePrimitiveArg(int* calls) : calls(calls) {}
-  void Run(int a) const { (*calls)++; }
-
-  int* calls;
-};
-
-TEST(CommonTypeConvertersTest, BaseBindToMojoCallbackPrimitiveParam) {
-  mojo::Callback<void(int)> mojo_callback;
-  int calls = 0;
-  RunnableOnePrimitiveArg r(&calls);
-  mojo_callback = r;
-  mojo_callback.Run(0);
-  EXPECT_EQ(1, calls);
-
-  base::Callback<void(int)> base_callback =
-      base::Bind(&RunnableOnePrimitiveArg::Run, base::Unretained(&r));
-  mojo_callback = base_callback;
-  mojo_callback.Run(0);
-  EXPECT_EQ(2, calls);
-}
-
-struct RunnableOneMojoStringParam {
-  explicit RunnableOneMojoStringParam(int* calls) : calls(calls) {}
-  void Run(const String& s) const { (*calls)++; }
-
-  int* calls;
-};
-
-TEST(CommonTypeConvertersTest, BaseBindToMojoCallbackMojoStringParam) {
-  // The mojo type is a callback on mojo::String, but it'll expect to invoke
-  // callbacks with a parameter of type 'const Mojo::String&'.
-  mojo::Callback<void(mojo::String)> mojo_callback;
-  int calls = 0;
-  RunnableOneMojoStringParam r(&calls);
-  mojo_callback = r;
-  mojo_callback.Run(0);
-  EXPECT_EQ(1, calls);
-
-  base::Callback<void(const mojo::String&)> base_callback =
-      base::Bind(&RunnableOneMojoStringParam::Run, base::Unretained(&r));
-  mojo_callback = base_callback;
-  mojo_callback.Run(0);
-  EXPECT_EQ(2, calls);
-}
-
-using ExampleMoveOnlyType = Map<int, int>;
-
-struct RunnableOneMoveOnlyParam {
-  explicit RunnableOneMoveOnlyParam(int* calls) : calls(calls) {}
-
-  void Run(ExampleMoveOnlyType m) const { (*calls)++; }
-  int* calls;
-};
-
-TEST(CommonTypeConvertersTest, BaseBindToMoveOnlyParam) {
-  mojo::Callback<void(ExampleMoveOnlyType)> mojo_callback;
-  int calls = 0;
-  RunnableOneMoveOnlyParam r(&calls);
-  mojo_callback = r;
-  ExampleMoveOnlyType m;
-  mojo_callback.Run(m.Clone());
-  EXPECT_EQ(1, calls);
-
-  base::Callback<void(ExampleMoveOnlyType)> base_callback =
-      base::Bind(&RunnableOneMoveOnlyParam::Run, base::Unretained(&r));
-  mojo_callback = base_callback;
-  mojo_callback.Run(m.Clone());
-  EXPECT_EQ(2, calls);
-}
-
-}  // namespace
-}  // namespace test
-}  // namespace common
-}  // namespace mojo
diff --git a/mojo/common/interface_ptr_set_unittest.cc b/mojo/common/interface_ptr_set_unittest.cc
index 8edd4ca..848b268 100644
--- a/mojo/common/interface_ptr_set_unittest.cc
+++ b/mojo/common/interface_ptr_set_unittest.cc
@@ -5,8 +5,8 @@
 #include "mojo/common/interface_ptr_set.h"
 
 #include "base/message_loop/message_loop.h"
-#include "mojo/common/message_pump_mojo.h"
 #include "mojo/common/test_interfaces.mojom.h"
+#include "mojo/message_pump/message_pump_mojo.h"
 #include "mojo/public/cpp/bindings/binding.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
diff --git a/mojo/converters/array_string/BUILD.gn b/mojo/converters/array_string/BUILD.gn
new file mode 100644
index 0000000..8a36103
--- /dev/null
+++ b/mojo/converters/array_string/BUILD.gn
@@ -0,0 +1,28 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+source_set("array_string") {
+  sources = [
+    "array_string_type_converters.cc",
+    "array_string_type_converters.h",
+  ]
+
+  deps = [
+    "//base",
+    "//mojo/public/cpp/bindings",
+  ]
+}
+
+source_set("tests") {
+  testonly = true
+  sources = [
+    "array_string_type_converters_unittest.cc",
+  ]
+
+  deps = [
+    ":array_string",
+    "//base",
+    "//testing/gtest",
+  ]
+}
diff --git a/mojo/converters/array_string/array_string_type_converters.cc b/mojo/converters/array_string/array_string_type_converters.cc
new file mode 100644
index 0000000..02019f0
--- /dev/null
+++ b/mojo/converters/array_string/array_string_type_converters.cc
@@ -0,0 +1,29 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/converters/array_string/array_string_type_converters.h"
+
+#include <string>
+
+#include "base/strings/utf_string_conversions.h"
+
+namespace mojo {
+
+std::string TypeConverter<std::string, Array<uint8_t>>::Convert(
+    const Array<uint8_t>& input) {
+  if (input.is_null())
+    return std::string();
+
+  return std::string(reinterpret_cast<const char*>(&input.front()),
+                     input.size());
+}
+
+Array<uint8_t> TypeConverter<Array<uint8_t>, std::string>::Convert(
+    const std::string& input) {
+  Array<uint8_t> result(input.size());
+  memcpy(&result.front(), input.c_str(), input.size());
+  return result.Pass();
+}
+
+}  // namespace mojo
diff --git a/mojo/converters/array_string/array_string_type_converters.h b/mojo/converters/array_string/array_string_type_converters.h
new file mode 100644
index 0000000..f5e1996
--- /dev/null
+++ b/mojo/converters/array_string/array_string_type_converters.h
@@ -0,0 +1,32 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_CONVERTERS_ARRAY_STRING_ARRAY_STRING_TYPE_CONVERTERS_H_
+#define MOJO_CONVERTERS_ARRAY_STRING_ARRAY_STRING_TYPE_CONVERTERS_H_
+
+#include "base/strings/string16.h"
+#include "base/strings/string_piece.h"
+#include "mojo/public/cpp/bindings/array.h"
+#include "mojo/public/cpp/bindings/string.h"
+#include "mojo/public/cpp/bindings/type_converter.h"
+
+namespace mojo {
+
+// TODO(erg): In the very long term, we will want to remove conversion between
+// std::strings and arrays of unsigned bytes. However, there is too much code
+// across chrome which uses std::string as a bag of bytes that we probably
+// don't want to roll this function at each callsite.
+template <>
+struct TypeConverter<std::string, Array<uint8_t>> {
+  static std::string Convert(const Array<uint8_t>& input);
+};
+
+template <>
+struct TypeConverter<Array<uint8_t>, std::string> {
+  static Array<uint8_t> Convert(const std::string& input);
+};
+
+}  // namespace mojo
+
+#endif  // MOJO_CONVERTERS_ARRAY_STRING_ARRAY_STRING_TYPE_CONVERTERS_H_
diff --git a/mojo/converters/array_string/array_string_type_converters_unittest.cc b/mojo/converters/array_string/array_string_type_converters_unittest.cc
new file mode 100644
index 0000000..a28f571
--- /dev/null
+++ b/mojo/converters/array_string/array_string_type_converters_unittest.cc
@@ -0,0 +1,38 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/converters/array_string/array_string_type_converters.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace mojo {
+namespace common {
+namespace test {
+namespace {
+
+TEST(CommonTypeConvertersTest, ArrayUint8ToStdString) {
+  Array<uint8_t> data(4);
+  data[0] = 'd';
+  data[1] = 'a';
+  data[2] = 't';
+  data[3] = 'a';
+
+  EXPECT_EQ("data", data.To<std::string>());
+}
+
+TEST(CommonTypeConvertersTest, StdStringToArrayUint8) {
+  std::string input("data");
+  Array<uint8_t> data = Array<uint8_t>::From(input);
+
+  ASSERT_EQ(4ul, data.size());
+  EXPECT_EQ('d', data[0]);
+  EXPECT_EQ('a', data[1]);
+  EXPECT_EQ('t', data[2]);
+  EXPECT_EQ('a', data[3]);
+}
+
+}  // namespace
+}  // namespace test
+}  // namespace common
+}  // namespace mojo
diff --git a/mojo/converters/base/BUILD.gn b/mojo/converters/base/BUILD.gn
new file mode 100644
index 0000000..3779edf
--- /dev/null
+++ b/mojo/converters/base/BUILD.gn
@@ -0,0 +1,30 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+source_set("base") {
+  sources = [
+    "base_type_converters.cc",
+    "base_type_converters.h",
+  ]
+
+  deps = [
+    "//base",
+    "//mojo/public/cpp/bindings",
+  ]
+}
+
+source_set("tests") {
+  testonly = true
+
+  sources = [
+    "base_type_converters_unittest.cc",
+  ]
+
+  deps = [
+    ":base",
+    "//base",
+    "//mojo/public/cpp/bindings",
+    "//testing/gtest",
+  ]
+}
diff --git a/mojo/converters/base/base_type_converters.cc b/mojo/converters/base/base_type_converters.cc
new file mode 100644
index 0000000..d4649ce
--- /dev/null
+++ b/mojo/converters/base/base_type_converters.cc
@@ -0,0 +1,40 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/converters/base/base_type_converters.h"
+
+#include <string>
+
+#include "base/strings/utf_string_conversions.h"
+
+namespace mojo {
+
+// static
+String TypeConverter<String, base::StringPiece>::Convert(
+    const base::StringPiece& input) {
+  if (input.empty()) {
+    char c = 0;
+    return String(&c, 0);
+  }
+  return String(input.data(), input.size());
+}
+// static
+base::StringPiece TypeConverter<base::StringPiece, String>::Convert(
+    const String& input) {
+  return input.get();
+}
+
+// static
+String TypeConverter<String, base::string16>::Convert(
+    const base::string16& input) {
+  return TypeConverter<String, base::StringPiece>::Convert(
+      base::UTF16ToUTF8(input));
+}
+// static
+base::string16 TypeConverter<base::string16, String>::Convert(
+    const String& input) {
+  return base::UTF8ToUTF16(input.To<base::StringPiece>());
+}
+
+}  // namespace mojo
diff --git a/mojo/converters/base/base_type_converters.h b/mojo/converters/base/base_type_converters.h
new file mode 100644
index 0000000..c83bc90
--- /dev/null
+++ b/mojo/converters/base/base_type_converters.h
@@ -0,0 +1,38 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_CONVERTERS_BASE_BASE_TYPE_CONVERTERS_H_
+#define MOJO_CONVERTERS_BASE_BASE_TYPE_CONVERTERS_H_
+
+#include "base/strings/string16.h"
+#include "base/strings/string_piece.h"
+#include "mojo/public/cpp/bindings/array.h"
+#include "mojo/public/cpp/bindings/string.h"
+#include "mojo/public/cpp/bindings/type_converter.h"
+
+namespace mojo {
+
+template <>
+struct TypeConverter<String, base::StringPiece> {
+  static String Convert(const base::StringPiece& input);
+};
+
+template <>
+struct TypeConverter<base::StringPiece, String> {
+  static base::StringPiece Convert(const String& input);
+};
+
+template <>
+struct TypeConverter<String, base::string16> {
+  static String Convert(const base::string16& input);
+};
+
+template <>
+struct TypeConverter<base::string16, String> {
+  static base::string16 Convert(const String& input);
+};
+
+}  // namespace mojo
+
+#endif  // MOJO_CONVERTERS_BASE_BASE_TYPE_CONVERTERS_H_
diff --git a/mojo/converters/base/base_type_converters_unittest.cc b/mojo/converters/base/base_type_converters_unittest.cc
new file mode 100644
index 0000000..351eebc
--- /dev/null
+++ b/mojo/converters/base/base_type_converters_unittest.cc
@@ -0,0 +1,66 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/converters/base/base_type_converters.h"
+
+#include "base/bind.h"
+#include "base/strings/utf_string_conversions.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace mojo {
+namespace {
+
+void ExpectEqualsStringPiece(const std::string& expected,
+                             const base::StringPiece& str) {
+  EXPECT_EQ(expected, str.as_string());
+}
+
+void ExpectEqualsMojoString(const std::string& expected, const String& str) {
+  EXPECT_EQ(expected, str.get());
+}
+
+void ExpectEqualsString16(const base::string16& expected,
+                          const base::string16& actual) {
+  EXPECT_EQ(expected, actual);
+}
+
+void ExpectEqualsMojoString(const base::string16& expected, const String& str) {
+  EXPECT_EQ(expected, str.To<base::string16>());
+}
+
+TEST(BaseTypeConvertersTest, StringPiece) {
+  std::string kText("hello world");
+
+  base::StringPiece string_piece(kText);
+  String mojo_string(String::From(string_piece));
+
+  ExpectEqualsMojoString(kText, mojo_string);
+  ExpectEqualsStringPiece(kText, mojo_string.To<base::StringPiece>());
+
+  // Test implicit construction and conversion:
+  ExpectEqualsMojoString(kText, String::From(string_piece));
+  ExpectEqualsStringPiece(kText, mojo_string.To<base::StringPiece>());
+
+  // Test null String:
+  base::StringPiece empty_string_piece = String().To<base::StringPiece>();
+  EXPECT_TRUE(empty_string_piece.empty());
+}
+
+TEST(BaseTypeConvertersTest, String16) {
+  const base::string16 string16(base::ASCIIToUTF16("hello world"));
+  const String mojo_string(String::From(string16));
+
+  ExpectEqualsMojoString(string16, mojo_string);
+  EXPECT_EQ(string16, mojo_string.To<base::string16>());
+
+  // Test implicit construction and conversion:
+  ExpectEqualsMojoString(string16, String::From(string16));
+  ExpectEqualsString16(string16, mojo_string.To<base::string16>());
+
+  // Test empty string conversion.
+  ExpectEqualsMojoString(base::string16(), String::From(base::string16()));
+}
+
+}  // namespace
+}  // namespace mojo
diff --git a/mojo/converters/url/BUILD.gn b/mojo/converters/url/BUILD.gn
new file mode 100644
index 0000000..4082c67
--- /dev/null
+++ b/mojo/converters/url/BUILD.gn
@@ -0,0 +1,30 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+source_set("url") {
+  sources = [
+    "url_type_converters.cc",
+    "url_type_converters.h",
+  ]
+
+  deps = [
+    "//mojo/public/cpp/bindings",
+    "//url",
+  ]
+}
+
+source_set("tests") {
+  testonly = true
+
+  sources = [
+    "url_type_converters_unittest.cc",
+  ]
+
+  deps = [
+    ":url",
+    "//mojo/public/cpp/bindings",
+    "//testing/gtest",
+    "//url",
+  ]
+}
diff --git a/mojo/converters/url/url_type_converters.cc b/mojo/converters/url/url_type_converters.cc
new file mode 100644
index 0000000..8b504ff
--- /dev/null
+++ b/mojo/converters/url/url_type_converters.cc
@@ -0,0 +1,19 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/converters/url/url_type_converters.h"
+
+#include "url/gurl.h"
+
+namespace mojo {
+
+String TypeConverter<String, GURL>::Convert(const GURL& input) {
+  return String(input.spec());
+}
+
+GURL TypeConverter<GURL, String>::Convert(const String& input) {
+  return GURL(input.get());
+}
+
+}  // namespace mojo
diff --git a/mojo/converters/url/url_type_converters.h b/mojo/converters/url/url_type_converters.h
new file mode 100644
index 0000000..7842d54
--- /dev/null
+++ b/mojo/converters/url/url_type_converters.h
@@ -0,0 +1,26 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_CONVERTERS_URL_URL_TYPE_CONVERTERS_H_
+#define MOJO_CONVERTERS_URL_URL_TYPE_CONVERTERS_H_
+
+#include "mojo/public/cpp/bindings/type_converter.h"
+#include "mojo/public/cpp/bindings/string.h"
+
+class GURL;
+
+namespace mojo {
+template <>
+struct TypeConverter<String, GURL> {
+  static String Convert(const GURL& input);
+};
+
+template <>
+struct TypeConverter<GURL, String> {
+  static GURL Convert(const String& input);
+};
+
+}  // namespace mojo
+
+#endif  // MOJO_CONVERTERS_URL_URL_TYPE_CONVERTERS_H_
diff --git a/mojo/converters/url/url_type_converters_unittest.cc b/mojo/converters/url/url_type_converters_unittest.cc
new file mode 100644
index 0000000..bc94074
--- /dev/null
+++ b/mojo/converters/url/url_type_converters_unittest.cc
@@ -0,0 +1,31 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/converters/url/url_type_converters.h"
+
+#include "mojo/public/cpp/bindings/string.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "url/gurl.h"
+
+namespace mojo {
+namespace {
+
+TEST(UrlTypeConvertersTest, URL) {
+  GURL url("mojo:foo");
+  String mojo_string(String::From(url));
+
+  ASSERT_EQ(url.spec(), mojo_string);
+  EXPECT_EQ(url.spec(), mojo_string.To<GURL>().spec());
+  EXPECT_EQ(url.spec(), String::From(url));
+
+  GURL invalid = String().To<GURL>();
+  ASSERT_TRUE(invalid.spec().empty());
+
+  String string_from_invalid = String::From(invalid);
+  EXPECT_FALSE(string_from_invalid.is_null());
+  ASSERT_EQ(0U, string_from_invalid.size());
+}
+
+}  // namespace
+}  // namespace mojo
diff --git a/mojo/dart/embedder/BUILD.gn b/mojo/dart/embedder/BUILD.gn
index 97f441f..bb1c512 100644
--- a/mojo/dart/embedder/BUILD.gn
+++ b/mojo/dart/embedder/BUILD.gn
@@ -43,7 +43,7 @@
     "//dart/runtime:libdart",
     "//dart/runtime/bin:libdart_embedder_noio",
     "//third_party/dart-pkg",
-    "//mojo/common",
+    "//mojo/message_pump",
     "//mojo/public/c/system",
     "//mojo/public/cpp/system",
     "//mojo/services/network/public/interfaces",
diff --git a/mojo/dart/embedder/dart_controller.cc b/mojo/dart/embedder/dart_controller.cc
index eb9c05e..ad86db9 100644
--- a/mojo/dart/embedder/dart_controller.cc
+++ b/mojo/dart/embedder/dart_controller.cc
@@ -13,11 +13,11 @@
 #include "base/sys_info.h"
 #include "dart/runtime/include/dart_api.h"
 #include "dart/runtime/include/dart_native_api.h"
-#include "mojo/common/message_pump_mojo.h"
 #include "mojo/dart/embedder/builtin.h"
 #include "mojo/dart/embedder/dart_controller.h"
 #include "mojo/dart/embedder/mojo_dart_state.h"
 #include "mojo/dart/embedder/vmservice.h"
+#include "mojo/message_pump/message_pump_mojo.h"
 #include "mojo/public/c/system/core.h"
 #include "tonic/dart_converter.h"
 #include "tonic/dart_debugger.h"
diff --git a/mojo/data_pipe_utils/BUILD.gn b/mojo/data_pipe_utils/BUILD.gn
new file mode 100644
index 0000000..d9b5dea
--- /dev/null
+++ b/mojo/data_pipe_utils/BUILD.gn
@@ -0,0 +1,39 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+source_set("data_pipe_utils") {
+  sources = [
+    "data_pipe_drainer.cc",
+    "data_pipe_drainer.h",
+    "data_pipe_file_utils.cc",
+    "data_pipe_utils.cc",
+    "data_pipe_utils.h",
+    "data_pipe_utils_internal.h",
+  ]
+
+  if (is_nacl) {
+    sources -= [ "data_pipe_file_utils.cc" ]
+  }
+
+  deps = [
+    "//base",
+    "//mojo/message_pump",
+    "//mojo/public/cpp/environment:environment",
+    "//mojo/public/cpp/system",
+  ]
+}
+
+source_set("tests") {
+  testonly = true
+
+  sources = [
+    "data_pipe_utils_unittest.cc",
+  ]
+
+  deps = [
+    ":data_pipe_utils",
+    "//base",
+    "//testing/gtest",
+  ]
+}
diff --git a/mojo/common/data_pipe_drainer.cc b/mojo/data_pipe_utils/data_pipe_drainer.cc
similarity index 73%
rename from mojo/common/data_pipe_drainer.cc
rename to mojo/data_pipe_utils/data_pipe_drainer.cc
index 5477109..8ed8b2d 100644
--- a/mojo/common/data_pipe_drainer.cc
+++ b/mojo/data_pipe_utils/data_pipe_drainer.cc
@@ -2,7 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "mojo/common/data_pipe_drainer.h"
+#include "mojo/data_pipe_utils/data_pipe_drainer.h"
+
 #include "base/bind.h"
 
 namespace mojo {
@@ -10,21 +11,18 @@
 
 DataPipeDrainer::DataPipeDrainer(Client* client,
                                  mojo::ScopedDataPipeConsumerHandle source)
-    : client_(client),
-      source_(source.Pass()),
-      weak_factory_(this) {
+    : client_(client), source_(source.Pass()), weak_factory_(this) {
   DCHECK(client_);
   ReadData();
 }
 
-DataPipeDrainer::~DataPipeDrainer() {
-}
+DataPipeDrainer::~DataPipeDrainer() {}
 
 void DataPipeDrainer::ReadData() {
   const void* buffer = nullptr;
   uint32_t num_bytes = 0;
-  MojoResult rv = BeginReadDataRaw(source_.get(),
-      &buffer, &num_bytes, MOJO_READ_DATA_FLAG_NONE);
+  MojoResult rv = BeginReadDataRaw(source_.get(), &buffer, &num_bytes,
+                                   MOJO_READ_DATA_FLAG_NONE);
   if (rv == MOJO_RESULT_OK) {
     client_->OnDataAvailable(buffer, num_bytes);
     EndReadDataRaw(source_.get(), num_bytes);
@@ -39,8 +37,8 @@
 }
 
 void DataPipeDrainer::WaitForData() {
-  handle_watcher_.Start(source_.get(),
-      MOJO_HANDLE_SIGNAL_READABLE, MOJO_DEADLINE_INDEFINITE,
+  handle_watcher_.Start(
+      source_.get(), MOJO_HANDLE_SIGNAL_READABLE, MOJO_DEADLINE_INDEFINITE,
       base::Bind(&DataPipeDrainer::WaitComplete, weak_factory_.GetWeakPtr()));
 }
 
diff --git a/mojo/common/data_pipe_drainer.h b/mojo/data_pipe_utils/data_pipe_drainer.h
similarity index 80%
rename from mojo/common/data_pipe_drainer.h
rename to mojo/data_pipe_utils/data_pipe_drainer.h
index c9669be..80cb933 100644
--- a/mojo/common/data_pipe_drainer.h
+++ b/mojo/data_pipe_utils/data_pipe_drainer.h
@@ -2,11 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef MOJO_COMMON_DATA_PIPE_DRAINER_H_
-#define MOJO_COMMON_DATA_PIPE_DRAINER_H_
+#ifndef MOJO_DATA_PIPE_UTILS_DATA_PIPE_DRAINER_H_
+#define MOJO_DATA_PIPE_UTILS_DATA_PIPE_DRAINER_H_
 
 #include "base/memory/weak_ptr.h"
-#include "mojo/common/handle_watcher.h"
+#include "mojo/message_pump/handle_watcher.h"
 #include "mojo/public/cpp/system/core.h"
 
 namespace mojo {
@@ -20,7 +20,7 @@
     virtual void OnDataComplete() = 0;
 
    protected:
-    virtual ~Client() { }
+    virtual ~Client() {}
   };
 
   DataPipeDrainer(Client*, mojo::ScopedDataPipeConsumerHandle source);
@@ -43,4 +43,4 @@
 }  // namespace common
 }  // namespace mojo
 
-#endif  // MOJO_COMMON_DATA_PIPE_DRAINER_H_
+#endif  // MOJO_DATA_PIPE_UTILS_DATA_PIPE_DRAINER_H_
diff --git a/mojo/common/data_pipe_file_utils.cc b/mojo/data_pipe_utils/data_pipe_file_utils.cc
similarity index 98%
rename from mojo/common/data_pipe_file_utils.cc
rename to mojo/data_pipe_utils/data_pipe_file_utils.cc
index aa14225..e37c8df 100644
--- a/mojo/common/data_pipe_file_utils.cc
+++ b/mojo/data_pipe_utils/data_pipe_file_utils.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "mojo/common/data_pipe_utils.h"
+#include "mojo/data_pipe_utils/data_pipe_utils.h"
 
 #include <stdio.h>
 
@@ -14,7 +14,7 @@
 #include "base/files/scoped_file.h"
 #include "base/location.h"
 #include "base/trace_event/trace_event.h"
-#include "mojo/common/data_pipe_utils_internal.h"
+#include "mojo/data_pipe_utils/data_pipe_utils_internal.h"
 #include "mojo/public/cpp/environment/async_waiter.h"
 
 namespace mojo {
diff --git a/mojo/common/data_pipe_utils.cc b/mojo/data_pipe_utils/data_pipe_utils.cc
similarity index 82%
rename from mojo/common/data_pipe_utils.cc
rename to mojo/data_pipe_utils/data_pipe_utils.cc
index daaef2c..af9f206 100644
--- a/mojo/common/data_pipe_utils.cc
+++ b/mojo/data_pipe_utils/data_pipe_utils.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "mojo/common/data_pipe_utils.h"
+#include "mojo/data_pipe_utils/data_pipe_utils.h"
 
 #include <stdio.h>
 
@@ -10,18 +10,19 @@
 #include "base/task_runner_util.h"
 #include "base/threading/platform_thread.h"
 #include "base/trace_event/trace_event.h"
-#include "mojo/common/data_pipe_utils_internal.h"
+#include "mojo/data_pipe_utils/data_pipe_utils_internal.h"
 
 namespace mojo {
 namespace common {
 
-bool BlockingCopyHelper(ScopedDataPipeConsumerHandle source,
+bool BlockingCopyHelper(
+    ScopedDataPipeConsumerHandle source,
     const base::Callback<size_t(const void*, uint32_t)>& write_bytes) {
   for (;;) {
     const void* buffer = nullptr;
     uint32_t num_bytes = 0;
-    MojoResult result = BeginReadDataRaw(
-        source.get(), &buffer, &num_bytes, MOJO_READ_DATA_FLAG_NONE);
+    MojoResult result = BeginReadDataRaw(source.get(), &buffer, &num_bytes,
+                                         MOJO_READ_DATA_FLAG_NONE);
     if (result == MOJO_RESULT_OK) {
       size_t bytes_written = write_bytes.Run(buffer, num_bytes);
       if (bytes_written < num_bytes) {
@@ -39,10 +40,8 @@
         return false;
       }
     } else if (result == MOJO_RESULT_SHOULD_WAIT) {
-      result = Wait(source.get(),
-                    MOJO_HANDLE_SIGNAL_READABLE,
-                    MOJO_DEADLINE_INDEFINITE,
-                    nullptr);
+      result = Wait(source.get(), MOJO_HANDLE_SIGNAL_READABLE,
+                    MOJO_DEADLINE_INDEFINITE, nullptr);
       if (result != MOJO_RESULT_OK) {
         // If the producer handle was closed, then treat as EOF.
         return result == MOJO_RESULT_FAILED_PRECONDITION;
@@ -60,13 +59,14 @@
 
 namespace {
 
-size_t CopyToStringHelper(
-    std::string* result, const void* buffer, uint32_t num_bytes) {
+size_t CopyToStringHelper(std::string* result,
+                          const void* buffer,
+                          uint32_t num_bytes) {
   result->append(static_cast<const char*>(buffer), num_bytes);
   return num_bytes;
 }
 
-} // namespace
+}  // namespace
 
 // TODO(hansmuller): Add a max_size parameter.
 bool BlockingCopyToString(ScopedDataPipeConsumerHandle source,
@@ -74,8 +74,8 @@
   TRACE_EVENT0("data_pipe_utils", "BlockingCopyToString");
   CHECK(result);
   result->clear();
-  return BlockingCopyHelper(
-      source.Pass(), base::Bind(&CopyToStringHelper, result));
+  return BlockingCopyHelper(source.Pass(),
+                            base::Bind(&CopyToStringHelper, result));
 }
 
 bool BlockingCopyFromString(const std::string& source,
diff --git a/mojo/common/data_pipe_utils.h b/mojo/data_pipe_utils/data_pipe_utils.h
similarity index 92%
rename from mojo/common/data_pipe_utils.h
rename to mojo/data_pipe_utils/data_pipe_utils.h
index 08e6fa0..289fe12 100644
--- a/mojo/common/data_pipe_utils.h
+++ b/mojo/data_pipe_utils/data_pipe_utils.h
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef MOJO_SHELL_DATA_PIPE_UTILS_H_
-#define MOJO_SHELL_DATA_PIPE_UTILS_H_
+#ifndef MOJO_DATA_PIPE_UTILS_DATA_PIPE_UTILS_H_
+#define MOJO_DATA_PIPE_UTILS_DATA_PIPE_UTILS_H_
 
 #include <string>
 
@@ -51,4 +51,4 @@
 }  // namespace common
 }  // namespace mojo
 
-#endif  // MOJO_SHELL_DATA_PIPE_UTILS_H_
+#endif  // MOJO_DATA_PIPE_UTILS_DATA_PIPE_UTILS_H_
diff --git a/mojo/common/data_pipe_utils_internal.h b/mojo/data_pipe_utils/data_pipe_utils_internal.h
similarity index 75%
rename from mojo/common/data_pipe_utils_internal.h
rename to mojo/data_pipe_utils/data_pipe_utils_internal.h
index 26164ec..40086fb 100644
--- a/mojo/common/data_pipe_utils_internal.h
+++ b/mojo/data_pipe_utils/data_pipe_utils_internal.h
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef MOJO_COMMON_DATA_PIPE_UTILS_INTERNAL_H_
-#define MOJO_COMMON_DATA_PIPE_UTILS_INTERNAL_H_
+#ifndef MOJO_DATA_PIPE_UTILS_DATA_PIPE_UTILS_INTERNAL_H_
+#define MOJO_DATA_PIPE_UTILS_DATA_PIPE_UTILS_INTERNAL_H_
 
 #include "base/callback_forward.h"
 #include "mojo/public/cpp/system/core.h"
@@ -19,4 +19,4 @@
 }  // namespace common
 }  // namespace mojo
 
-#endif  // MOJO_COMMON_DATA_PIPE_UTILS_INTERNAL_H_
+#endif  // MOJO_DATA_PIPE_UTILS_DATA_PIPE_UTILS_INTERNAL_H_
diff --git a/mojo/common/data_pipe_utils_unittest.cc b/mojo/data_pipe_utils/data_pipe_utils_unittest.cc
similarity index 97%
rename from mojo/common/data_pipe_utils_unittest.cc
rename to mojo/data_pipe_utils/data_pipe_utils_unittest.cc
index edfc2c4..6c0f600 100644
--- a/mojo/common/data_pipe_utils_unittest.cc
+++ b/mojo/data_pipe_utils/data_pipe_utils_unittest.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "mojo/common/data_pipe_utils.h"
+#include "mojo/data_pipe_utils/data_pipe_utils.h"
 
 #include "base/bind.h"
 #include "base/files/file_util.h"
diff --git a/mojo/environment/BUILD.gn b/mojo/environment/BUILD.gn
index 5371935..5c7a9f0 100644
--- a/mojo/environment/BUILD.gn
+++ b/mojo/environment/BUILD.gn
@@ -3,8 +3,6 @@
 # found in the LICENSE file.
 
 source_set("chromium") {
-  output_name = "mojo_environment_chromium"
-
   sources = [
     "default_async_waiter.cc",
     "default_async_waiter.h",
@@ -27,6 +25,7 @@
     "//base",
     "//base/third_party/dynamic_annotations",
     "//mojo/common",
+    "//mojo/message_pump",
     "//mojo/public/c/environment",
     "//mojo/public/cpp/bindings:callback",
     "//mojo/public/cpp/environment",
diff --git a/mojo/environment/default_async_waiter.cc b/mojo/environment/default_async_waiter.cc
index 863cfe3..014e5c1 100644
--- a/mojo/environment/default_async_waiter.cc
+++ b/mojo/environment/default_async_waiter.cc
@@ -5,7 +5,7 @@
 #include "mojo/environment/default_async_waiter.h"
 
 #include "base/bind.h"
-#include "mojo/common/handle_watcher.h"
+#include "mojo/message_pump/handle_watcher.h"
 #include "mojo/public/c/environment/async_waiter.h"
 
 namespace mojo {
diff --git a/mojo/message_pump/BUILD.gn b/mojo/message_pump/BUILD.gn
new file mode 100644
index 0000000..14daad6
--- /dev/null
+++ b/mojo/message_pump/BUILD.gn
@@ -0,0 +1,39 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+source_set("message_pump") {
+  sources = [
+    "handle_watcher.cc",
+    "handle_watcher.h",
+    "message_pump_mojo.cc",
+    "message_pump_mojo.h",
+    "message_pump_mojo_handler.h",
+    "time_helper.cc",
+    "time_helper.h",
+  ]
+
+  deps = [
+    "//base",
+    "//mojo/public/cpp/system",
+  ]
+}
+
+source_set("tests") {
+  testonly = true
+
+  sources = [
+    "handle_watcher_unittest.cc",
+    "message_pump_mojo_unittest.cc",
+  ]
+
+  deps = [
+    ":message_pump",
+    "//base",
+    "//base/test:test_support",
+    "//base:message_loop_tests",
+    "//mojo/public/cpp/system",
+    "//mojo/public/cpp/test_support:test_utils",
+    "//testing/gtest",
+  ]
+}
diff --git a/mojo/common/handle_watcher.cc b/mojo/message_pump/handle_watcher.cc
similarity index 98%
rename from mojo/common/handle_watcher.cc
rename to mojo/message_pump/handle_watcher.cc
index c7fa81f..2465579 100644
--- a/mojo/common/handle_watcher.cc
+++ b/mojo/message_pump/handle_watcher.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "mojo/common/handle_watcher.h"
+#include "mojo/message_pump/handle_watcher.h"
 
 #include <map>
 
@@ -20,9 +20,9 @@
 #include "base/threading/thread.h"
 #include "base/threading/thread_restrictions.h"
 #include "base/time/time.h"
-#include "mojo/common/message_pump_mojo.h"
-#include "mojo/common/message_pump_mojo_handler.h"
-#include "mojo/common/time_helper.h"
+#include "mojo/message_pump/message_pump_mojo.h"
+#include "mojo/message_pump/message_pump_mojo_handler.h"
+#include "mojo/message_pump/time_helper.h"
 
 namespace mojo {
 namespace common {
diff --git a/mojo/common/handle_watcher.h b/mojo/message_pump/handle_watcher.h
similarity index 92%
rename from mojo/common/handle_watcher.h
rename to mojo/message_pump/handle_watcher.h
index fb89716..f024d94 100644
--- a/mojo/common/handle_watcher.h
+++ b/mojo/message_pump/handle_watcher.h
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef MOJO_COMMON_HANDLE_WATCHER_H_
-#define MOJO_COMMON_HANDLE_WATCHER_H_
+#ifndef MOJO_MESSAGE_PUMP_HANDLE_WATCHER_H_
+#define MOJO_MESSAGE_PUMP_HANDLE_WATCHER_H_
 
 #include "base/basictypes.h"
 #include "base/callback_forward.h"
@@ -60,4 +60,4 @@
 }  // namespace common
 }  // namespace mojo
 
-#endif  // MOJO_COMMON_HANDLE_WATCHER_H_
+#endif  // MOJO_MESSAGE_PUMP_HANDLE_WATCHER_H_
diff --git a/mojo/common/handle_watcher_unittest.cc b/mojo/message_pump/handle_watcher_unittest.cc
similarity index 98%
rename from mojo/common/handle_watcher_unittest.cc
rename to mojo/message_pump/handle_watcher_unittest.cc
index 46d2a27..36f15ac 100644
--- a/mojo/common/handle_watcher_unittest.cc
+++ b/mojo/message_pump/handle_watcher_unittest.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "mojo/common/handle_watcher.h"
+#include "mojo/message_pump/handle_watcher.h"
 
 #include <string>
 
@@ -13,8 +13,8 @@
 #include "base/run_loop.h"
 #include "base/test/simple_test_tick_clock.h"
 #include "base/threading/thread.h"
-#include "mojo/common/message_pump_mojo.h"
-#include "mojo/common/time_helper.h"
+#include "mojo/message_pump/message_pump_mojo.h"
+#include "mojo/message_pump/time_helper.h"
 #include "mojo/public/cpp/system/core.h"
 #include "mojo/public/cpp/test_support/test_utils.h"
 #include "testing/gtest/include/gtest/gtest.h"
diff --git a/mojo/common/message_pump_mojo.cc b/mojo/message_pump/message_pump_mojo.cc
similarity index 98%
rename from mojo/common/message_pump_mojo.cc
rename to mojo/message_pump/message_pump_mojo.cc
index 544960b..e7f7d10 100644
--- a/mojo/common/message_pump_mojo.cc
+++ b/mojo/message_pump/message_pump_mojo.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "mojo/common/message_pump_mojo.h"
+#include "mojo/message_pump/message_pump_mojo.h"
 
 #include <algorithm>
 #include <vector>
@@ -12,8 +12,8 @@
 #include "base/logging.h"
 #include "base/threading/thread_local.h"
 #include "base/time/time.h"
-#include "mojo/common/message_pump_mojo_handler.h"
-#include "mojo/common/time_helper.h"
+#include "mojo/message_pump/message_pump_mojo_handler.h"
+#include "mojo/message_pump/time_helper.h"
 
 namespace mojo {
 namespace common {
diff --git a/mojo/common/message_pump_mojo.h b/mojo/message_pump/message_pump_mojo.h
similarity index 96%
rename from mojo/common/message_pump_mojo.h
rename to mojo/message_pump/message_pump_mojo.h
index fc1e40b..522b0e5 100644
--- a/mojo/common/message_pump_mojo.h
+++ b/mojo/message_pump/message_pump_mojo.h
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef MOJO_COMMON_MESSAGE_PUMP_MOJO_H_
-#define MOJO_COMMON_MESSAGE_PUMP_MOJO_H_
+#ifndef MOJO_MESSAGE_PUMP_MESSAGE_PUMP_MOJO_H_
+#define MOJO_MESSAGE_PUMP_MESSAGE_PUMP_MOJO_H_
 
 #include <map>
 #include <utility>
@@ -135,4 +135,4 @@
 }  // namespace common
 }  // namespace mojo
 
-#endif  // MOJO_COMMON_MESSAGE_PUMP_MOJO_H_
+#endif  // MOJO_MESSAGE_PUMP_MESSAGE_PUMP_MOJO_H_
diff --git a/mojo/common/message_pump_mojo_handler.h b/mojo/message_pump/message_pump_mojo_handler.h
similarity index 79%
rename from mojo/common/message_pump_mojo_handler.h
rename to mojo/message_pump/message_pump_mojo_handler.h
index b55132d..3a4eccc 100644
--- a/mojo/common/message_pump_mojo_handler.h
+++ b/mojo/message_pump/message_pump_mojo_handler.h
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef MOJO_COMMON_MESSAGE_PUMP_MOJO_HANDLER_H_
-#define MOJO_COMMON_MESSAGE_PUMP_MOJO_HANDLER_H_
+#ifndef MOJO_MESSAGE_PUMP_MESSAGE_PUMP_MOJO_HANDLER_H_
+#define MOJO_MESSAGE_PUMP_MESSAGE_PUMP_MOJO_HANDLER_H_
 
 #include "mojo/public/cpp/system/core.h"
 
@@ -25,4 +25,4 @@
 }  // namespace common
 }  // namespace mojo
 
-#endif  // MOJO_COMMON_MESSAGE_PUMP_MOJO_HANDLER_H_
+#endif  // MOJO_MESSAGE_PUMP_MESSAGE_PUMP_MOJO_HANDLER_H_
diff --git a/mojo/common/message_pump_mojo_unittest.cc b/mojo/message_pump/message_pump_mojo_unittest.cc
similarity index 96%
rename from mojo/common/message_pump_mojo_unittest.cc
rename to mojo/message_pump/message_pump_mojo_unittest.cc
index 09cbe54..687d5f3 100644
--- a/mojo/common/message_pump_mojo_unittest.cc
+++ b/mojo/message_pump/message_pump_mojo_unittest.cc
@@ -2,11 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "mojo/common/message_pump_mojo.h"
+#include "mojo/message_pump/message_pump_mojo.h"
 
 #include "base/message_loop/message_loop_test.h"
 #include "base/run_loop.h"
-#include "mojo/common/message_pump_mojo_handler.h"
+#include "mojo/message_pump/message_pump_mojo_handler.h"
 #include "mojo/public/cpp/system/core.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
diff --git a/mojo/common/time_helper.cc b/mojo/message_pump/time_helper.cc
similarity index 93%
rename from mojo/common/time_helper.cc
rename to mojo/message_pump/time_helper.cc
index 36fd087..ffd667e 100644
--- a/mojo/common/time_helper.cc
+++ b/mojo/message_pump/time_helper.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "mojo/common/time_helper.h"
+#include "mojo/message_pump/time_helper.h"
 
 #include "base/time/tick_clock.h"
 
diff --git a/mojo/common/time_helper.h b/mojo/message_pump/time_helper.h
similarity index 83%
rename from mojo/common/time_helper.h
rename to mojo/message_pump/time_helper.h
index 84029ec..dfdc7bb 100644
--- a/mojo/common/time_helper.h
+++ b/mojo/message_pump/time_helper.h
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef MOJO_COMMON_TIME_HELPER_H_
-#define MOJO_COMMON_TIME_HELPER_H_
+#ifndef MOJO_MESSAGE_PUMP_TIME_HELPER_H_
+#define MOJO_MESSAGE_PUMP_TIME_HELPER_H_
 
 #include "base/time/time.h"
 
@@ -30,4 +30,4 @@
 }  // namespace common
 }  // namespace mojo
 
-#endif  // MOJO_COMMON_TIME_HELPER_H_
+#endif  // MOJO_MESSAGE_PUMP_TIME_HELPER_H_
diff --git a/mojo/tests/BUILD.gn b/mojo/tests/BUILD.gn
index 03411fe..a752534 100644
--- a/mojo/tests/BUILD.gn
+++ b/mojo/tests/BUILD.gn
@@ -8,11 +8,11 @@
 test("mojo_task_tracker_perftests") {
   deps = [
     "//base/test:test_support",
-    "//mojo/common",
     "//mojo/edk/system",
     "//mojo/edk/test:test_support",
     "//mojo/edk/test:test_support_impl",
     "//mojo/environment:chromium",
+    "//mojo/message_pump",
     "//mojo/public/c/test_support",
     "//mojo/public/cpp/bindings",
     "//mojo/public/cpp/bindings:callback",
diff --git a/mojo/tests/task_tracker_perftest.cc b/mojo/tests/task_tracker_perftest.cc
index a2ffdb3..ff3e07e 100644
--- a/mojo/tests/task_tracker_perftest.cc
+++ b/mojo/tests/task_tracker_perftest.cc
@@ -8,7 +8,7 @@
 #include "base/message_loop/message_loop.h"
 #include "base/timer/elapsed_timer.h"
 #include "base/tracked_objects.h"
-#include "mojo/common/message_pump_mojo.h"
+#include "mojo/message_pump/message_pump_mojo.h"
 #include "mojo/public/cpp/bindings/binding.h"
 #include "mojo/public/cpp/environment/environment.h"
 #include "mojo/public/cpp/environment/task_tracker.h"