| OLD | NEW |
| 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 "content/browser/tracing/background_tracing_manager_impl.h" | 5 #include "content/browser/tracing/background_tracing_manager_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 14 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
| 15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "content/browser/tracing/background_tracing_rule.h" | 18 #include "content/browser/tracing/background_tracing_rule.h" |
| 19 #include "content/browser/tracing/tracing_controller_impl.h" |
| 19 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/browser/content_browser_client.h" | 21 #include "content/public/browser/content_browser_client.h" |
| 21 #include "content/public/browser/tracing_delegate.h" | 22 #include "content/public/browser/tracing_delegate.h" |
| 22 #include "content/public/common/content_client.h" | 23 #include "content/public/common/content_client.h" |
| 23 #include "content/public/common/content_switches.h" | 24 #include "content/public/common/content_switches.h" |
| 24 | 25 |
| 25 namespace content { | 26 namespace content { |
| 26 | 27 |
| 27 namespace { | 28 namespace { |
| 28 | 29 |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 triggered_named_event_handle_ = -1; | 500 triggered_named_event_handle_ = -1; |
| 500 tracing_timer_.reset(); | 501 tracing_timer_.reset(); |
| 501 | 502 |
| 502 bool is_allowed_finalization = | 503 bool is_allowed_finalization = |
| 503 !delegate_ || (config_ && | 504 !delegate_ || (config_ && |
| 504 delegate_->IsAllowedToEndBackgroundScenario( | 505 delegate_->IsAllowedToEndBackgroundScenario( |
| 505 *config_.get(), requires_anonymized_data_)); | 506 *config_.get(), requires_anonymized_data_)); |
| 506 | 507 |
| 507 scoped_refptr<TracingControllerImpl::TraceDataSink> trace_data_sink; | 508 scoped_refptr<TracingControllerImpl::TraceDataSink> trace_data_sink; |
| 508 if (is_allowed_finalization) { | 509 if (is_allowed_finalization) { |
| 509 trace_data_sink = content::TracingController::CreateCompressedStringSink( | 510 trace_data_sink = TracingControllerImpl::CreateCompressedStringSink( |
| 510 content::TracingController::CreateCallbackEndpoint( | 511 TracingControllerImpl::CreateCallbackEndpoint( |
| 511 base::Bind(&BackgroundTracingManagerImpl::OnFinalizeStarted, | 512 base::Bind(&BackgroundTracingManagerImpl::OnFinalizeStarted, |
| 512 base::Unretained(this)))); | 513 base::Unretained(this)))); |
| 513 RecordBackgroundTracingMetric(FINALIZATION_ALLOWED); | 514 RecordBackgroundTracingMetric(FINALIZATION_ALLOWED); |
| 514 AddCustomMetadata(trace_data_sink.get()); | 515 AddCustomMetadata(trace_data_sink.get()); |
| 515 } else { | 516 } else { |
| 516 RecordBackgroundTracingMetric(FINALIZATION_DISALLOWED); | 517 RecordBackgroundTracingMetric(FINALIZATION_DISALLOWED); |
| 517 } | 518 } |
| 518 | 519 |
| 519 content::TracingController::GetInstance()->StopTracing(trace_data_sink); | 520 content::TracingController::GetInstance()->StopTracing(trace_data_sink); |
| 520 | 521 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 case BackgroundTracingConfigImpl::CategoryPreset::BLINK_STYLE: | 560 case BackgroundTracingConfigImpl::CategoryPreset::BLINK_STYLE: |
| 560 return "blink_style"; | 561 return "blink_style"; |
| 561 case BackgroundTracingConfigImpl::CategoryPreset::CATEGORY_PRESET_UNSET: | 562 case BackgroundTracingConfigImpl::CategoryPreset::CATEGORY_PRESET_UNSET: |
| 562 NOTREACHED(); | 563 NOTREACHED(); |
| 563 } | 564 } |
| 564 NOTREACHED(); | 565 NOTREACHED(); |
| 565 return ""; | 566 return ""; |
| 566 } | 567 } |
| 567 | 568 |
| 568 } // namspace content | 569 } // namspace content |
| OLD | NEW |