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

Unified Diff: content/browser/tracing/background_tracing_manager_impl.cc

Issue 1164023002: Slow Reports: Set a minimum time in between reports, and check for OTR sessions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Buildfixes Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/tracing/background_tracing_manager_impl.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/tracing/background_tracing_manager_impl.cc
diff --git a/content/browser/tracing/background_tracing_manager_impl.cc b/content/browser/tracing/background_tracing_manager_impl.cc
index 14f07cf71db06a8789383f221c95b3a0eadda024..7f4f15ef068223a0dd847d32f54ac599d3ee533b 100644
--- a/content/browser/tracing/background_tracing_manager_impl.cc
+++ b/content/browser/tracing/background_tracing_manager_impl.cc
@@ -9,6 +9,9 @@
#include "content/public/browser/background_tracing_preemptive_config.h"
#include "content/public/browser/background_tracing_reactive_config.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/content_browser_client.h"
+#include "content/public/browser/tracing_delegate.h"
+#include "content/public/common/content_client.h"
namespace content {
@@ -74,7 +77,8 @@ BackgroundTracingManagerImpl* BackgroundTracingManagerImpl::GetInstance() {
}
BackgroundTracingManagerImpl::BackgroundTracingManagerImpl()
- : is_gathering_(false),
+ : delegate_(GetContentClient()->browser()->GetTracingDelegate()),
+ is_gathering_(false),
is_tracing_(false),
requires_anonymized_data_(true),
trigger_handle_ids_(0) {
@@ -135,6 +139,15 @@ bool BackgroundTracingManagerImpl::SetActiveScenario(
if (is_tracing_)
return false;
+ bool requires_anonymized_data = (data_filtering == ANONYMIZE_DATA);
+
+ // TODO(oysteine): Retry when time_until_allowed has elapsed.
+ if (config && delegate_ &&
+ !delegate_->IsAllowedToBeginBackgroundScenario(
+ *config.get(), requires_anonymized_data)) {
+ return false;
+ }
+
if (!IsSupportedConfig(config.get()))
return false;
@@ -144,7 +157,7 @@ bool BackgroundTracingManagerImpl::SetActiveScenario(
config_ = config.Pass();
receive_callback_ = receive_callback;
- requires_anonymized_data_ = (data_filtering == ANONYMIZE_DATA);
+ requires_anonymized_data_ = requires_anonymized_data;
EnableRecordingIfConfigNeedsIt();
@@ -155,6 +168,13 @@ void BackgroundTracingManagerImpl::EnableRecordingIfConfigNeedsIt() {
if (!config_)
return;
+ // TODO(oysteine): Retry later.
+ if (delegate_ &&
+ !delegate_->IsAllowedToBeginBackgroundScenario(
+ *config_.get(), requires_anonymized_data_)) {
+ return;
+ }
+
if (config_->mode == BackgroundTracingConfig::PREEMPTIVE_TRACING_MODE) {
EnableRecording(GetCategoryFilterStringForCategoryPreset(
static_cast<BackgroundTracingPreemptiveConfig*>(config_.get())
@@ -352,12 +372,21 @@ void BackgroundTracingManagerImpl::BeginFinalizing(
is_gathering_ = true;
is_tracing_ = false;
- content::TracingController::GetInstance()->DisableRecording(
- content::TracingController::CreateCompressedStringSink(
- data_endpoint_wrapper_));
+ bool is_allowed_finalization =
+ !delegate_ || (config_ &&
+ delegate_->IsAllowedToEndBackgroundScenario(
+ *config_.get(), requires_anonymized_data_));
+
+ scoped_refptr<TracingControllerImpl::TraceDataSink> trace_data_sink;
+ if (is_allowed_finalization) {
+ trace_data_sink = content::TracingController::CreateCompressedStringSink(
+ data_endpoint_wrapper_);
+ }
+
+ content::TracingController::GetInstance()->DisableRecording(trace_data_sink);
if (!callback.is_null())
- callback.Run(true);
+ callback.Run(is_allowed_finalization);
}
std::string
« no previous file with comments | « content/browser/tracing/background_tracing_manager_impl.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698