Blink roll 25b6bd3a7a131ffe68d809546ad1a20707915cdc:3a503f41ae42e5b79cfcd2ff10e65afde...
[chromium-blink-merge.git] / base / profiler / scoped_profile.cc
blob4f8bc2d1e0e3e35b5e9d260a145e240807460f95
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/profiler/scoped_profile.h"
7 #include "base/location.h"
8 #include "base/tracked_objects.h"
11 namespace tracked_objects {
14 ScopedProfile::ScopedProfile(const Location& location, Mode mode)
15 : birth_(NULL) {
16 if (mode == DISABLED)
17 return;
19 birth_ = ThreadData::TallyABirthIfActive(location);
20 if (!birth_)
21 return;
23 ThreadData::PrepareForStartOfRun(birth_);
24 stopwatch_.Start();
27 ScopedProfile::~ScopedProfile() {
28 if (!birth_)
29 return;
31 stopwatch_.Stop();
32 ThreadData::TallyRunInAScopedRegionIfTracking(birth_, stopwatch_);
35 } // namespace tracked_objects