Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / base / profiler / scoped_profile.cc
index e1edc97..4f8bc2d 100644 (file)
 namespace tracked_objects {
 
 
-ScopedProfile::ScopedProfile(const Location& location)
-    : birth_(ThreadData::TallyABirthIfActive(location)) {
+ScopedProfile::ScopedProfile(const Location& location, Mode mode)
+    : birth_(NULL) {
+  if (mode == DISABLED)
+    return;
+
+  birth_ = ThreadData::TallyABirthIfActive(location);
+  if (!birth_)
+    return;
+
   ThreadData::PrepareForStartOfRun(birth_);
+  stopwatch_.Start();
 }
 
 ScopedProfile::~ScopedProfile() {
-  StopClockAndTally();
-}
-
-void ScopedProfile::StopClockAndTally() {
-  stopwatch_.Stop();
-
   if (!birth_)
     return;
+
+  stopwatch_.Stop();
   ThreadData::TallyRunInAScopedRegionIfTracking(birth_, stopwatch_);
-  birth_ = NULL;
 }
 
 }  // namespace tracked_objects