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

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

Issue 577823002: Moves ProfilerMetricsProvider to //components/metrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebaase Created 6 years, 3 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 "chrome/browser/metrics/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 "chrome/browser/metrics/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 { 19 namespace {
20 20
21 // Negative numbers are never used as sequence numbers. We explicitly pick a 21 // 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 22 // 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. 23 // 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 24 // We have code that handles wrapping around on an overflow into negative
25 // territory. 25 // territory.
26 const int kNeverUsableSequenceNumber = -2; 26 const int kNeverUsableSequenceNumber = -2;
27 27
28 // This singleton instance should be started during the single threaded 28 // This singleton instance should be started during the single threaded
29 // portion of main(). It initializes globals to provide support for all future 29 // 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 30 // 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 31 // 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. 32 // from the UI thread, or for about:profiler.
33 static chrome_browser_metrics::TrackingSynchronizer* g_tracking_synchronizer = 33 static metrics::TrackingSynchronizer* g_tracking_synchronizer =
34 NULL; 34 NULL;
35 35
36 } // anonymous namespace 36 } // anonymous namespace
37 37
38 namespace chrome_browser_metrics { 38 namespace metrics {
39 39
40 // The "RequestContext" structure describes an individual request received 40 // The "RequestContext" structure describes an individual request received
41 // from the UI. All methods are accessible on UI thread. 41 // from the UI. All methods are accessible on UI thread.
42 class TrackingSynchronizer::RequestContext { 42 class TrackingSynchronizer::RequestContext {
43 public: 43 public:
44 // A map from sequence_number_ to the actual RequestContexts. 44 // A map from sequence_number_ to the actual RequestContexts.
45 typedef std::map<int, RequestContext*> RequestContextMap; 45 typedef std::map<int, RequestContext*> RequestContextMap;
46 46
47 RequestContext( 47 RequestContext(
48 const base::WeakPtr<TrackingSynchronizerObserver>& callback_object, 48 const base::WeakPtr<TrackingSynchronizerObserver>& callback_object,
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 287 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
288 288
289 ++last_used_sequence_number_; 289 ++last_used_sequence_number_;
290 290
291 // Watch out for wrapping to a negative number. 291 // Watch out for wrapping to a negative number.
292 if (last_used_sequence_number_ < 0) 292 if (last_used_sequence_number_ < 0)
293 last_used_sequence_number_ = 1; 293 last_used_sequence_number_ = 1;
294 return last_used_sequence_number_; 294 return last_used_sequence_number_;
295 } 295 }
296 296
297 } // namespace chrome_browser_metrics 297 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/profiler/tracking_synchronizer.h ('k') | components/metrics/profiler/tracking_synchronizer_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698