[gperftools] Cleaned up profiler initialization

Change-Id: I7e074d91d27793175b1f443a9717292f0681b640
diff --git a/src/profiler.cc b/src/profiler.cc
index c9b159e..540b321 100644
--- a/src/profiler.cc
+++ b/src/profiler.cc
@@ -186,13 +186,19 @@
 // out to disk.
 CpuProfiler CpuProfiler::instance_;
 
-// Initialize profiling: activated if getenv("CPUPROFILE") exists.
+#ifdef __Fuchsia__
+
 CpuProfiler::CpuProfiler()
-#ifndef __Fuchsia__
-    : prof_handler_token_(NULL)
-#endif
 {
-#ifndef __Fuchsia__
+  ThreadInterrupter::InitOnce(&instance_);
+  ThreadInterrupter::SetInterruptPeriod(1 /* msec */);
+  ThreadInterrupter::Startup();
+}
+
+#else
+
+// Initialize profiling: activated if getenv("CPUPROFILE") exists.
+CpuProfiler::CpuProfiler() : prof_handler_token_(NULL) {
   // TODO(cgd) Move this code *out* of the CpuProfile constructor into a
   // separate object responsible for initialization. With ProfileHandler there
   // is no need to limit the number of profilers.
@@ -202,7 +208,6 @@
     }
     return;
   }
-#endif
 
   // We don't enable profiling if setuid -- it's a security risk
 #ifdef HAVE_GETEUID
@@ -229,32 +234,21 @@
     }
   } else {
     char fname[PATH_MAX];
-#ifdef __Fuchsia__
-    // TODO: We need to parametrize this
-    sprintf(fname, "/tmp/profiledata_unittest.tmp");
-#else
     if (!GetUniquePathFromEnv("CPUPROFILE", fname)) {
       if (!FLAGS_cpu_profiler_unittest) {
         RAW_LOG(WARNING, "CPU profiler linked but no valid CPUPROFILE environment variable found\n");
       }
       return;
     }
-#endif
-
     if (!Start(fname, NULL)) {
       RAW_LOG(FATAL, "Can't turn on cpu profiling for '%s': %s\n",
               fname, strerror(errno));
     }
   }
-
-#ifdef __Fuchsia__
-  ThreadInterrupter::InitOnce(&instance_);
-  // TODO: Parametrize this
-  ThreadInterrupter::SetInterruptPeriod(100 /* msec */);
-  ThreadInterrupter::Startup();
-#endif
 }
 
+#endif // __Fuchsia__
+
 bool CpuProfiler::Start(const char* fname, const ProfilerOptions* options) {
   SpinLockHolder cl(&lock_);