Adds the ability for MessageLoop to take a MessagePump

Using default args is against style guide, but there are a ton of
places (mostly tests) that define a MessageLoop as a member. I'll see
about a cleanup pass that removes the default args.

BUG=none
TEST=NONE
R=darin@chromium.org

Review URL: https://codereview.chromium.org/61643006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233800 0039d316-1c4b-4281-b951-d872f2087c98


CrOS-Libchrome-Original-Commit: 9f0e4f712366b55628efeffca4e55438aef80691
diff --git a/base/message_loop/message_loop.h b/base/message_loop/message_loop.h
index 0eb1803..84e1449 100644
--- a/base/message_loop/message_loop.h
+++ b/base/message_loop/message_loop.h
@@ -128,9 +128,13 @@
   //   TYPE_JAVA behaves in essence like TYPE_UI, except during construction
   //   where it does not use the main thread specific pump factory.
   //
+  // TYPE_CUSTOM
+  //   MessagePump was supplied to constructor.
+  //
   enum Type {
     TYPE_DEFAULT,
     TYPE_UI,
+    TYPE_CUSTOM,
 #if defined(TOOLKIT_GTK)
     TYPE_GPU,
 #endif
@@ -143,6 +147,9 @@
   // Normally, it is not necessary to instantiate a MessageLoop.  Instead, it
   // is typical to make use of the current thread's MessageLoop instance.
   explicit MessageLoop(Type type = TYPE_DEFAULT);
+  // Creates a TYPE_CUSTOM MessageLoop with the supplied MessagePump, which must
+  // be non-NULL.
+  explicit MessageLoop(scoped_ptr<base::MessagePump> pump);
   virtual ~MessageLoop();
 
   // Returns the MessageLoop object for the current thread, or null if none.
@@ -442,6 +449,9 @@
   friend class internal::IncomingTaskQueue;
   friend class RunLoop;
 
+  // Configures various members for the two constructors.
+  void Init();
+
   // A function to encapsulate all the exception handling capability in the
   // stacks around the running of a main message loop.  It will run the message
   // loop in a SEH try block or not depending on the set_SEH_restoration()
@@ -504,7 +514,7 @@
   virtual void GetQueueingInformation(size_t* queue_size,
                                       TimeDelta* queueing_delay) OVERRIDE;
 
-  Type type_;
+  const Type type_;
 
   // A list of tasks that need to be processed by this instance.  Note that
   // this queue is only accessed (push/pop) by our current thread.