summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authornednguyen@google.com <nednguyen@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-07 15:41:12 +0000
committernednguyen@google.com <nednguyen@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-07 15:41:12 +0000
commit96faef9ce8848f5959482c177e8b8a852a7d90ff (patch)
treee8b2314561e4890e0d81377bf54be50d28aaa990 /base
parent17214644256fa22a8c72ce9bc7f9dcc86fc8f3e6 (diff)
downloadchromium_src-96faef9ce8848f5959482c177e8b8a852a7d90ff.zip
chromium_src-96faef9ce8848f5959482c177e8b8a852a7d90ff.tar.gz
chromium_src-96faef9ce8848f5959482c177e8b8a852a7d90ff.tar.bz2
Add RECORD_AS_MUCH_AS_POSSIBLE mode to TraceOptions.
With current implementation of devtool_tracing_handler, it doesn't do anything with invalid options and just use RECORD_UNTIL_FULL by default. So the change to telemetry's tracing backend will not break backward compatibility for browsers that don't support "record-as-much-as-possible" option. However, this is a hacky way to maintain backward compatibility, and we should fix devtool_tracing_handler so it can respond with error message on Tracing.start if there is options parsing error. BUG=396081 Review URL: https://codereview.chromium.org/440903003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288047 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/debug/trace_event_impl.cc14
-rw-r--r--base/debug/trace_event_impl.h7
-rw-r--r--base/debug/trace_event_impl_constants.cc21
-rw-r--r--base/debug/trace_event_unittest.cc22
4 files changed, 51 insertions, 13 deletions
diff --git a/base/debug/trace_event_impl.cc b/base/debug/trace_event_impl.cc
index 85fa692..a9f0583 100644
--- a/base/debug/trace_event_impl.cc
+++ b/base/debug/trace_event_impl.cc
@@ -61,6 +61,7 @@ const int kOverheadReportThresholdInMicroseconds = 50;
// String options that can be used to initialize TraceOptions.
const char kRecordUntilFull[] = "record-until-full";
const char kRecordContinuously[] = "record-continuously";
+const char kRecordAsMuchAsPossible[] = "record-as-much-as-possible";
const char kTraceToConsole[] = "trace-to-console";
const char kEnableSampling[] = "enable-sampling";
const char kEnableSystrace[] = "enable-systrace";
@@ -68,6 +69,8 @@ const char kEnableSystrace[] = "enable-systrace";
// Controls the number of trace events we will buffer in-memory
// before throwing them away.
const size_t kTraceBufferChunkSize = TraceBufferChunk::kTraceBufferChunkSize;
+const size_t kTraceEventVectorBigBufferChunks =
+ 512000000 / kTraceBufferChunkSize;
const size_t kTraceEventVectorBufferChunks = 256000 / kTraceBufferChunkSize;
const size_t kTraceEventRingBufferChunks = kTraceEventVectorBufferChunks / 4;
const size_t kTraceEventBatchChunks = 1000 / kTraceBufferChunkSize;
@@ -996,6 +999,8 @@ TraceOptions::TraceOptions(const std::string& options_string)
record_mode = RECORD_CONTINUOUSLY;
} else if (*iter == kTraceToConsole) {
record_mode = ECHO_TO_CONSOLE;
+ } else if (*iter == kRecordAsMuchAsPossible) {
+ record_mode = RECORD_AS_MUCH_AS_POSSIBLE;
} else if (*iter == kEnableSampling) {
enable_sampling = true;
} else if (*iter == kEnableSystrace) {
@@ -1018,6 +1023,9 @@ std::string TraceOptions::ToString() const {
case ECHO_TO_CONSOLE:
ret = kTraceToConsole;
break;
+ case RECORD_AS_MUCH_AS_POSSIBLE:
+ ret = kRecordAsMuchAsPossible;
+ break;
default:
NOTREACHED();
}
@@ -1478,6 +1486,8 @@ TraceLog::InternalTraceOptions TraceLog::GetInternalOptionsFromTraceOptions(
return ret | kInternalRecordContinuously;
case ECHO_TO_CONSOLE:
return ret | kInternalEchoToConsole;
+ case RECORD_AS_MUCH_AS_POSSIBLE:
+ return ret | kInternalRecordAsMuchAsPossible;
}
NOTREACHED();
return kInternalNone;
@@ -1498,6 +1508,8 @@ TraceOptions TraceLog::GetCurrentTraceOptions() const {
ret.record_mode = RECORD_CONTINUOUSLY;
else if (option & kInternalEchoToConsole)
ret.record_mode = ECHO_TO_CONSOLE;
+ else if (option & kInternalRecordAsMuchAsPossible)
+ ret.record_mode = RECORD_AS_MUCH_AS_POSSIBLE;
else
NOTREACHED();
return ret;
@@ -1599,6 +1611,8 @@ TraceBuffer* TraceLog::CreateTraceBuffer() {
return new TraceBufferRingBuffer(kMonitorTraceEventBufferChunks);
else if (options & kInternalEchoToConsole)
return new TraceBufferRingBuffer(kEchoToConsoleTraceEventBufferChunks);
+ else if (options & kInternalRecordAsMuchAsPossible)
+ return CreateTraceBufferVectorOfSize(kTraceEventVectorBigBufferChunks);
return CreateTraceBufferVectorOfSize(kTraceEventVectorBufferChunks);
}
diff --git a/base/debug/trace_event_impl.h b/base/debug/trace_event_impl.h
index 32cd648..ab5d09e 100644
--- a/base/debug/trace_event_impl.h
+++ b/base/debug/trace_event_impl.h
@@ -384,6 +384,9 @@ enum TraceRecordMode {
// Echo to console. Events are discarded.
ECHO_TO_CONSOLE,
+
+ // Record until the trace buffer is full, but with a huge buffer size.
+ RECORD_AS_MUCH_AS_POSSIBLE
};
struct BASE_EXPORT TraceOptions {
@@ -649,7 +652,8 @@ class BASE_EXPORT TraceLog {
TraceBufferVectorReportFull);
FRIEND_TEST_ALL_PREFIXES(TraceEventTestFixture,
ConvertTraceOptionsToInternalOptions);
-
+ FRIEND_TEST_ALL_PREFIXES(TraceEventTestFixture,
+ TraceRecordAsMuchAsPossibleMode);
// This allows constructor and destructor to be private and usable only
// by the Singleton class.
@@ -729,6 +733,7 @@ class BASE_EXPORT TraceLog {
static const InternalTraceOptions kInternalRecordContinuously;
static const InternalTraceOptions kInternalEchoToConsole;
static const InternalTraceOptions kInternalEnableSampling;
+ static const InternalTraceOptions kInternalRecordAsMuchAsPossible;
// This lock protects TraceLog member accesses (except for members protected
// by thread_info_lock_) from arbitrary threads.
diff --git a/base/debug/trace_event_impl_constants.cc b/base/debug/trace_event_impl_constants.cc
index 17a270a..24d7af7 100644
--- a/base/debug/trace_event_impl_constants.cc
+++ b/base/debug/trace_event_impl_constants.cc
@@ -11,15 +11,18 @@ namespace debug {
const char* CategoryFilter::kDefaultCategoryFilterString = "-*Debug,-*Test";
// Constant used by TraceLog's internal implementation of trace_option.
-const TraceLog::InternalTraceOptions TraceLog::kInternalNone = 0;
-const TraceLog::InternalTraceOptions TraceLog::kInternalRecordUntilFull =
- 1 << 0;
-const TraceLog::InternalTraceOptions TraceLog::kInternalRecordContinuously =
- 1 << 1;
-const TraceLog::InternalTraceOptions TraceLog::kInternalEnableSampling = 1
- << 2;
-const TraceLog::InternalTraceOptions TraceLog::kInternalEchoToConsole = 1
- << 3;
+const TraceLog::InternalTraceOptions
+ TraceLog::kInternalNone = 0;
+const TraceLog::InternalTraceOptions
+ TraceLog::kInternalRecordUntilFull = 1 << 0;
+const TraceLog::InternalTraceOptions
+ TraceLog::kInternalRecordContinuously = 1 << 1;
+const TraceLog::InternalTraceOptions
+ TraceLog::kInternalEnableSampling = 1 << 2;
+const TraceLog::InternalTraceOptions
+ TraceLog::kInternalEchoToConsole = 1 << 3;
+const TraceLog::InternalTraceOptions
+ TraceLog::kInternalRecordAsMuchAsPossible = 1 << 4;
} // namespace debug
} // namespace base
diff --git a/base/debug/trace_event_unittest.cc b/base/debug/trace_event_unittest.cc
index cc67a51..2615e66 100644
--- a/base/debug/trace_event_unittest.cc
+++ b/base/debug/trace_event_unittest.cc
@@ -2602,6 +2602,15 @@ TEST_F(TraceEventTestFixture, TraceBufferRingBufferFullIteration) {
TraceLog::GetInstance()->SetDisabled();
}
+TEST_F(TraceEventTestFixture, TraceRecordAsMuchAsPossibleMode) {
+ TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"),
+ TraceLog::RECORDING_MODE,
+ TraceOptions(RECORD_AS_MUCH_AS_POSSIBLE));
+ TraceBuffer* buffer = TraceLog::GetInstance()->trace_buffer();
+ EXPECT_EQ(512000000UL, buffer->Capacity());
+ TraceLog::GetInstance()->SetDisabled();
+}
+
// Test the category filter.
TEST_F(TraceEventTestFixture, CategoryFilter) {
// Using the default filter.
@@ -3005,6 +3014,11 @@ TEST(TraceOptionsTest, DISABLED_TraceOptionsFromString) {
EXPECT_FALSE(options.enable_sampling);
EXPECT_FALSE(options.enable_systrace);
+ options = TraceOptions("record-as-much-as-possible");
+ EXPECT_EQ(RECORD_AS_MUCH_AS_POSSIBLE, options.record_mode);
+ EXPECT_FALSE(options.enable_sampling);
+ EXPECT_FALSE(options.enable_systrace);
+
options = TraceOptions("record-until-full, enable-sampling");
EXPECT_EQ(RECORD_UNTIL_FULL, options.record_mode);
EXPECT_TRUE(options.enable_sampling);
@@ -3039,12 +3053,14 @@ TEST(TraceOptionsTest, DISABLED_TraceOptionsFromString) {
TEST(TraceOptionsTest, TraceOptionsToString) {
// Test that we can intialize TraceOptions from a string got from
// TraceOptions.ToString() method to get a same TraceOptions.
- TraceRecordMode modes[] = {
- RECORD_UNTIL_FULL, RECORD_CONTINUOUSLY, ECHO_TO_CONSOLE};
+ TraceRecordMode modes[] = {RECORD_UNTIL_FULL,
+ RECORD_CONTINUOUSLY,
+ ECHO_TO_CONSOLE,
+ RECORD_AS_MUCH_AS_POSSIBLE};
bool enable_sampling_options[] = {true, false};
bool enable_systrace_options[] = {true, false};
- for (int i = 0; i < 3; ++i) {
+ for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 2; ++j) {
for (int k = 0; k < 2; ++k) {
TraceOptions original_option = TraceOptions(modes[i]);