Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Side by Side Diff: components/metrics/profiler/tracking_synchronizer.cc

Issue 636363004: Make remaining parts of components/metrics use metrics namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix cros compile Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/metrics/profiler/tracking_synchronizer.h" 5 #include "components/metrics/profiler/tracking_synchronizer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/threading/thread.h" 9 #include "base/threading/thread.h"
10 #include "base/tracked_objects.h" 10 #include "base/tracked_objects.h"
11 #include "components/metrics/profiler/tracking_synchronizer_observer.h" 11 #include "components/metrics/profiler/tracking_synchronizer_observer.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/profiler_controller.h" 13 #include "content/public/browser/profiler_controller.h"
14 #include "content/public/common/process_type.h" 14 #include "content/public/common/process_type.h"
15 15
16 using base::TimeTicks; 16 using base::TimeTicks;
17 using content::BrowserThread; 17 using content::BrowserThread;
18 18
19 namespace metrics {
20
19 namespace { 21 namespace {
20 22
21 // Negative numbers are never used as sequence numbers. We explicitly pick a 23 // Negative numbers are never used as sequence numbers. We explicitly pick a
22 // negative number that is "so negative" that even when we add one (as is done 24 // negative number that is "so negative" that even when we add one (as is done
23 // when we generated the next sequence number) that it will still be negative. 25 // when we generated the next sequence number) that it will still be negative.
24 // We have code that handles wrapping around on an overflow into negative 26 // We have code that handles wrapping around on an overflow into negative
25 // territory. 27 // territory.
26 const int kNeverUsableSequenceNumber = -2; 28 const int kNeverUsableSequenceNumber = -2;
27 29
28 // This singleton instance should be started during the single threaded 30 // This singleton instance should be started during the single threaded
29 // portion of main(). It initializes globals to provide support for all future 31 // portion of main(). It initializes globals to provide support for all future
30 // calls. This object is created on the UI thread, and it is destroyed after 32 // calls. This object is created on the UI thread, and it is destroyed after
31 // all the other threads have gone away. As a result, it is ok to call it 33 // all the other threads have gone away. As a result, it is ok to call it
32 // from the UI thread, or for about:profiler. 34 // from the UI thread, or for about:profiler.
33 static metrics::TrackingSynchronizer* g_tracking_synchronizer = 35 static TrackingSynchronizer* g_tracking_synchronizer = NULL;
34 NULL;
35 36
36 } // anonymous namespace 37 } // namespace
37
38 namespace metrics {
39 38
40 // The "RequestContext" structure describes an individual request received 39 // The "RequestContext" structure describes an individual request received
41 // from the UI. All methods are accessible on UI thread. 40 // from the UI. All methods are accessible on UI thread.
42 class TrackingSynchronizer::RequestContext { 41 class TrackingSynchronizer::RequestContext {
43 public: 42 public:
44 // A map from sequence_number_ to the actual RequestContexts. 43 // A map from sequence_number_ to the actual RequestContexts.
45 typedef std::map<int, RequestContext*> RequestContextMap; 44 typedef std::map<int, RequestContext*> RequestContextMap;
46 45
47 RequestContext( 46 RequestContext(
48 const base::WeakPtr<TrackingSynchronizerObserver>& callback_object, 47 const base::WeakPtr<TrackingSynchronizerObserver>& callback_object,
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 287
289 ++last_used_sequence_number_; 288 ++last_used_sequence_number_;
290 289
291 // Watch out for wrapping to a negative number. 290 // Watch out for wrapping to a negative number.
292 if (last_used_sequence_number_ < 0) 291 if (last_used_sequence_number_ < 0)
293 last_used_sequence_number_ = 1; 292 last_used_sequence_number_ = 1;
294 return last_used_sequence_number_; 293 return last_used_sequence_number_;
295 } 294 }
296 295
297 } // namespace metrics 296 } // namespace metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698