Expose the sandbox related code through the content API. I did a bit of cleanup while I was doing this.

-got rid of SandboxInitWrapper, since I didn't see a need to expose given that we can just expose sandbox::SandboxInterfaceInfo
-got rid of the duplicated code to initialize the broker
-since I made MainFunctionParams only have the sandbox struct on Windows, I also made the mac specific auto release pool behind an ifdef as well. It seemed odd to make something so mac specific compile on all platforms to save some #ifdefs.

BUG=98716
Review URL: http://codereview.chromium.org/8414020

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107863 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/base/mac/scoped_nsautorelease_pool.h b/base/mac/scoped_nsautorelease_pool.h
index 3f73017..06122b6 100644
--- a/base/mac/scoped_nsautorelease_pool.h
+++ b/base/mac/scoped_nsautorelease_pool.h
@@ -9,31 +9,22 @@
 #include "base/base_export.h"
 #include "base/basictypes.h"
 
-#if defined(OS_MACOSX)
 #if defined(__OBJC__)
 @class NSAutoreleasePool;
 #else  // __OBJC__
 class NSAutoreleasePool;
 #endif  // __OBJC__
-#endif  // OS_MACOSX
 
 namespace base {
 namespace mac {
 
-// On the Mac, ScopedNSAutoreleasePool allocates an NSAutoreleasePool when
-// instantiated and sends it a -drain message when destroyed.  This allows an
-// autorelease pool to be maintained in ordinary C++ code without bringing in
-// any direct Objective-C dependency.
-//
-// On other platforms, ScopedNSAutoreleasePool is an empty object with no
-// effects.  This allows it to be used directly in cross-platform code without
-// ugly #ifdefs.
+// ScopedNSAutoreleasePool allocates an NSAutoreleasePool when instantiated and
+// sends it a -drain message when destroyed.  This allows an autorelease pool to
+// be maintained in ordinary C++ code without bringing in any direct Objective-C
+// dependency.
+
 class BASE_EXPORT ScopedNSAutoreleasePool {
  public:
-#if !defined(OS_MACOSX)
-  ScopedNSAutoreleasePool() {}
-  void Recycle() { }
-#else  // OS_MACOSX
   ScopedNSAutoreleasePool();
   ~ScopedNSAutoreleasePool();
 
@@ -44,7 +35,6 @@
   void Recycle();
  private:
   NSAutoreleasePool* autorelease_pool_;
-#endif  // OS_MACOSX
 
  private:
   DISALLOW_COPY_AND_ASSIGN(ScopedNSAutoreleasePool);
diff --git a/base/message_pump_default.cc b/base/message_pump_default.cc
index d9eddc41..9a98064 100644
--- a/base/message_pump_default.cc
+++ b/base/message_pump_default.cc
@@ -5,7 +5,10 @@
 #include "base/message_pump_default.h"
 
 #include "base/logging.h"
+
+#if defined(OS_MACOSX)
 #include "base/mac/scoped_nsautorelease_pool.h"
+#endif
 
 namespace base {
 
@@ -18,7 +21,9 @@
   DCHECK(keep_running_) << "Quit must have been called outside of Run!";
 
   for (;;) {
+#if defined(OS_MACOSX)
     mac::ScopedNSAutoreleasePool autorelease_pool;
+#endif
 
     bool did_work = delegate->DoWork();
     if (!keep_running_)
diff --git a/base/message_pump_libevent.cc b/base/message_pump_libevent.cc
index 9bef229..23b707e 100644
--- a/base/message_pump_libevent.cc
+++ b/base/message_pump_libevent.cc
@@ -11,7 +11,6 @@
 #include "base/compiler_specific.h"
 #include "base/eintr_wrapper.h"
 #include "base/logging.h"
-#include "base/mac/scoped_nsautorelease_pool.h"
 #include "base/memory/scoped_ptr.h"
 #include "base/observer_list.h"
 #include "base/time.h"
@@ -21,6 +20,10 @@
 #include "third_party/libevent/event.h"
 #endif
 
+#if defined(OS_MACOSX)
+#include "base/mac/scoped_nsautorelease_pool.h"
+#endif
+
 // Lifecycle of struct event
 // Libevent uses two main data structures:
 // struct event_base (of which there is one per message pump), and
@@ -228,7 +231,9 @@
   scoped_ptr<event> timer_event(new event);
 
   for (;;) {
+#if defined(OS_MACOSX)
     mac::ScopedNSAutoreleasePool autorelease_pool;
+#endif
 
     bool did_work = delegate->DoWork();
     if (!keep_running_)
diff --git a/base/shared_memory_unittest.cc b/base/shared_memory_unittest.cc
index 330add485..9f69a5d 100644
--- a/base/shared_memory_unittest.cc
+++ b/base/shared_memory_unittest.cc
@@ -3,7 +3,6 @@
 // found in the LICENSE file.
 
 #include "base/basictypes.h"
-#include "base/mac/scoped_nsautorelease_pool.h"
 #include "base/memory/scoped_ptr.h"
 #include "base/shared_memory.h"
 #include "base/test/multiprocess_test.h"
@@ -12,6 +11,10 @@
 #include "testing/gtest/include/gtest/gtest.h"
 #include "testing/multiprocess_func_list.h"
 
+#if defined(OS_MACOSX)
+#include "base/mac/scoped_nsautorelease_pool.h"
+#endif
+
 static const int kNumThreads = 5;
 static const int kNumTasks = 5;
 
@@ -34,7 +37,9 @@
 
   // PlatformThread::Delegate interface.
   void ThreadMain() {
-    mac::ScopedNSAutoreleasePool pool;  // noop if not OSX
+#if defined(OS_MACOSX)
+    mac::ScopedNSAutoreleasePool pool;
+#endif
     const uint32 kDataSize = 1024;
     SharedMemory memory;
     bool rv = memory.CreateNamed(s_test_name_, true, kDataSize);
@@ -339,7 +344,9 @@
 
   static int TaskTestMain() {
     int errors = 0;
-    mac::ScopedNSAutoreleasePool pool;  // noop if not OSX
+#if defined(OS_MACOSX)
+    mac::ScopedNSAutoreleasePool pool;
+#endif
     const uint32 kDataSize = 1024;
     SharedMemory memory;
     bool rv = memory.CreateNamed(s_test_name_, true, kDataSize);
diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc
index 912a6f9a..05dfa31 100644
--- a/base/test/test_suite.cc
+++ b/base/test/test_suite.cc
@@ -13,7 +13,6 @@
 #include "base/file_path.h"
 #include "base/i18n/icu_util.h"
 #include "base/logging.h"
-#include "base/mac/scoped_nsautorelease_pool.h"
 #include "base/memory/scoped_ptr.h"
 #include "base/path_service.h"
 #include "base/process_util.h"
@@ -24,6 +23,7 @@
 #include "testing/multiprocess_func_list.h"
 
 #if defined(OS_MACOSX)
+#include "base/mac/scoped_nsautorelease_pool.h"
 #include "base/test/mock_chrome_application_mac.h"
 #endif
 
@@ -123,7 +123,9 @@
 // Don't add additional code to this method.  Instead add it to
 // Initialize().  See bug 6436.
 int TestSuite::Run() {
+#if defined(OS_MACOSX)
   base::mac::ScopedNSAutoreleasePool scoped_pool;
+#endif
 
   Initialize();
   std::string client_func =
@@ -152,10 +154,12 @@
            failing_count, failing_count == 1 ? "test" : "tests");
   }
 
+#if defined(OS_MACOSX)
   // This MUST happen before Shutdown() since Shutdown() tears down
   // objects (such as NotificationService::current()) that Cocoa
   // objects use to remove themselves as observers.
   scoped_pool.Recycle();
+#endif
 
   Shutdown();