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

Side by Side Diff: base/debug/trace_event_impl.h

Issue 816543004: Update from https://crrev.com/308996 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « base/command_line.cc ('k') | base/debug/trace_event_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5
6 #ifndef BASE_DEBUG_TRACE_EVENT_IMPL_H_ 6 #ifndef BASE_DEBUG_TRACE_EVENT_IMPL_H_
7 #define BASE_DEBUG_TRACE_EVENT_IMPL_H_ 7 #define BASE_DEBUG_TRACE_EVENT_IMPL_H_
8 8
9 #include <stack> 9 #include <stack>
10 #include <string> 10 #include <string>
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 void SetEventCallbackDisabled(); 531 void SetEventCallbackDisabled();
532 532
533 // Flush all collected events to the given output callback. The callback will 533 // Flush all collected events to the given output callback. The callback will
534 // be called one or more times either synchronously or asynchronously from 534 // be called one or more times either synchronously or asynchronously from
535 // the current thread with IPC-bite-size chunks. The string format is 535 // the current thread with IPC-bite-size chunks. The string format is
536 // undefined. Use TraceResultBuffer to convert one or more trace strings to 536 // undefined. Use TraceResultBuffer to convert one or more trace strings to
537 // JSON. The callback can be null if the caller doesn't want any data. 537 // JSON. The callback can be null if the caller doesn't want any data.
538 // Due to the implementation of thread-local buffers, flush can't be 538 // Due to the implementation of thread-local buffers, flush can't be
539 // done when tracing is enabled. If called when tracing is enabled, the 539 // done when tracing is enabled. If called when tracing is enabled, the
540 // callback will be called directly with (empty_string, false) to indicate 540 // callback will be called directly with (empty_string, false) to indicate
541 // the end of this unsuccessful flush. 541 // the end of this unsuccessful flush. Flush does the serialization
542 // on the same thread if the caller doesn't set use_worker_thread explicitly.
542 typedef base::Callback<void(const scoped_refptr<base::RefCountedString>&, 543 typedef base::Callback<void(const scoped_refptr<base::RefCountedString>&,
543 bool has_more_events)> OutputCallback; 544 bool has_more_events)> OutputCallback;
544 void Flush(const OutputCallback& cb); 545 void Flush(const OutputCallback& cb, bool use_worker_thread = false);
545 void FlushButLeaveBufferIntact(const OutputCallback& flush_output_callback); 546 void FlushButLeaveBufferIntact(const OutputCallback& flush_output_callback);
546 547
547 // Called by TRACE_EVENT* macros, don't call this directly. 548 // Called by TRACE_EVENT* macros, don't call this directly.
548 // The name parameter is a category group for example: 549 // The name parameter is a category group for example:
549 // TRACE_EVENT0("renderer,webkit", "WebViewImpl::HandleInputEvent") 550 // TRACE_EVENT0("renderer,webkit", "WebViewImpl::HandleInputEvent")
550 static const unsigned char* GetCategoryGroupEnabled(const char* name); 551 static const unsigned char* GetCategoryGroupEnabled(const char* name);
551 static const char* GetCategoryGroupName( 552 static const char* GetCategoryGroupName(
552 const unsigned char* category_group_enabled); 553 const unsigned char* category_group_enabled);
553 554
554 // Called by TRACE_EVENT* macros, don't call this directly. 555 // Called by TRACE_EVENT* macros, don't call this directly.
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 bool check_buffer_is_full); 704 bool check_buffer_is_full);
704 void CheckIfBufferIsFullWhileLocked(); 705 void CheckIfBufferIsFullWhileLocked();
705 void SetDisabledWhileLocked(); 706 void SetDisabledWhileLocked();
706 707
707 TraceEvent* GetEventByHandleInternal(TraceEventHandle handle, 708 TraceEvent* GetEventByHandleInternal(TraceEventHandle handle,
708 OptionalAutoLock* lock); 709 OptionalAutoLock* lock);
709 710
710 // |generation| is used in the following callbacks to check if the callback 711 // |generation| is used in the following callbacks to check if the callback
711 // is called for the flush of the current |logged_events_|. 712 // is called for the flush of the current |logged_events_|.
712 void FlushCurrentThread(int generation); 713 void FlushCurrentThread(int generation);
713 void ConvertTraceEventsToTraceFormat(scoped_ptr<TraceBuffer> logged_events, 714 // Usually it runs on a different thread.
715 static void ConvertTraceEventsToTraceFormat(
716 scoped_ptr<TraceBuffer> logged_events,
714 const TraceLog::OutputCallback& flush_output_callback); 717 const TraceLog::OutputCallback& flush_output_callback);
715 void FinishFlush(int generation); 718 void FinishFlush(int generation);
716 void OnFlushTimeout(int generation); 719 void OnFlushTimeout(int generation);
717 720
718 int generation() const { 721 int generation() const {
719 return static_cast<int>(subtle::NoBarrier_Load(&generation_)); 722 return static_cast<int>(subtle::NoBarrier_Load(&generation_));
720 } 723 }
721 bool CheckGeneration(int generation) const { 724 bool CheckGeneration(int generation) const {
722 return generation == this->generation(); 725 return generation == this->generation();
723 } 726 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 800
798 // For events which can't be added into the thread local buffer, e.g. events 801 // For events which can't be added into the thread local buffer, e.g. events
799 // from threads without a message loop. 802 // from threads without a message loop.
800 scoped_ptr<TraceBufferChunk> thread_shared_chunk_; 803 scoped_ptr<TraceBufferChunk> thread_shared_chunk_;
801 size_t thread_shared_chunk_index_; 804 size_t thread_shared_chunk_index_;
802 805
803 // Set when asynchronous Flush is in progress. 806 // Set when asynchronous Flush is in progress.
804 OutputCallback flush_output_callback_; 807 OutputCallback flush_output_callback_;
805 scoped_refptr<MessageLoopProxy> flush_message_loop_proxy_; 808 scoped_refptr<MessageLoopProxy> flush_message_loop_proxy_;
806 subtle::AtomicWord generation_; 809 subtle::AtomicWord generation_;
810 bool use_worker_thread_;
807 811
808 DISALLOW_COPY_AND_ASSIGN(TraceLog); 812 DISALLOW_COPY_AND_ASSIGN(TraceLog);
809 }; 813 };
810 814
811 } // namespace debug 815 } // namespace debug
812 } // namespace base 816 } // namespace base
813 817
814 #endif // BASE_DEBUG_TRACE_EVENT_IMPL_H_ 818 #endif // BASE_DEBUG_TRACE_EVENT_IMPL_H_
OLDNEW
« no previous file with comments | « base/command_line.cc ('k') | base/debug/trace_event_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698