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

Side by Side Diff: base/trace_event/trace_log.cc

Issue 1308823002: Move Singleton and related structs to namespace base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add \n Created 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/trace_event/trace_log.h" 5 #include "base/trace_event/trace_log.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/base_switches.h" 10 #include "base/base_switches.h"
(...skipping 21 matching lines...) Expand all
32 #include "base/trace_event/trace_event.h" 32 #include "base/trace_event/trace_event.h"
33 #include "base/trace_event/trace_event_synthetic_delay.h" 33 #include "base/trace_event/trace_event_synthetic_delay.h"
34 #include "base/trace_event/trace_log.h" 34 #include "base/trace_event/trace_log.h"
35 #include "base/trace_event/trace_sampling_thread.h" 35 #include "base/trace_event/trace_sampling_thread.h"
36 36
37 #if defined(OS_WIN) 37 #if defined(OS_WIN)
38 #include "base/trace_event/trace_event_etw_export_win.h" 38 #include "base/trace_event/trace_event_etw_export_win.h"
39 #include "base/trace_event/trace_event_win.h" 39 #include "base/trace_event/trace_event_win.h"
40 #endif 40 #endif
41 41
42 class DeleteTraceLogForTesting {
43 public:
44 static void Delete() {
45 Singleton<base::trace_event::TraceLog,
46 LeakySingletonTraits<base::trace_event::TraceLog>>::OnExit(0);
47 }
48 };
49
50 // The thread buckets for the sampling profiler. 42 // The thread buckets for the sampling profiler.
51 BASE_EXPORT TRACE_EVENT_API_ATOMIC_WORD g_trace_state[3]; 43 BASE_EXPORT TRACE_EVENT_API_ATOMIC_WORD g_trace_state[3];
52 44
53 namespace base { 45 namespace base {
46
47 class DeleteTraceLogForTesting {
48 public:
49 static void Delete() {
50 base::Singleton<
51 trace_event::TraceLog,
52 LeakySingletonTraits<base::trace_event::TraceLog>>::OnExit(0);
53 }
54 };
55
54 namespace trace_event { 56 namespace trace_event {
55 57
56 namespace { 58 namespace {
57 59
58 // Controls the number of trace events we will buffer in-memory 60 // Controls the number of trace events we will buffer in-memory
59 // before throwing them away. 61 // before throwing them away.
60 const size_t kTraceBufferChunkSize = TraceBufferChunk::kTraceBufferChunkSize; 62 const size_t kTraceBufferChunkSize = TraceBufferChunk::kTraceBufferChunkSize;
61 63
62 const size_t kTraceEventVectorBigBufferChunks = 64 const size_t kTraceEventVectorBigBufferChunks =
63 512000000 / kTraceBufferChunkSize; 65 512000000 / kTraceBufferChunkSize;
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 // Otherwise this method may be called from the destructor, or TraceLog will 390 // Otherwise this method may be called from the destructor, or TraceLog will
389 // find the generation mismatch and delete this buffer soon. 391 // find the generation mismatch and delete this buffer soon.
390 } 392 }
391 393
392 TraceLogStatus::TraceLogStatus() : event_capacity(0), event_count(0) {} 394 TraceLogStatus::TraceLogStatus() : event_capacity(0), event_count(0) {}
393 395
394 TraceLogStatus::~TraceLogStatus() {} 396 TraceLogStatus::~TraceLogStatus() {}
395 397
396 // static 398 // static
397 TraceLog* TraceLog::GetInstance() { 399 TraceLog* TraceLog::GetInstance() {
398 return Singleton<TraceLog, LeakySingletonTraits<TraceLog>>::get(); 400 return base::Singleton<TraceLog, base::LeakySingletonTraits<TraceLog>>::get();
399 } 401 }
400 402
401 TraceLog::TraceLog() 403 TraceLog::TraceLog()
402 : mode_(DISABLED), 404 : mode_(DISABLED),
403 num_traces_recorded_(0), 405 num_traces_recorded_(0),
404 event_callback_(0), 406 event_callback_(0),
405 dispatching_to_observer_list_(false), 407 dispatching_to_observer_list_(false),
406 process_sort_index_(0), 408 process_sort_index_(0),
407 process_id_hash_(0), 409 process_id_hash_(0),
408 process_id_(0), 410 process_id_(0),
(...skipping 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1765 } 1767 }
1766 1768
1767 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { 1769 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() {
1768 if (*category_group_enabled_) { 1770 if (*category_group_enabled_) {
1769 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, 1771 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_,
1770 event_handle_); 1772 event_handle_);
1771 } 1773 }
1772 } 1774 }
1773 1775
1774 } // namespace trace_event_internal 1776 } // namespace trace_event_internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698