Commit 47d5537b authored by John Delaney's avatar John Delaney Committed by Commit Bot

Add trace events to RulesetService

Add trace of prefs format and content version at RulesetService
creation. Add trace of invalid Indexed Ruleset file read.

Bug: 721512
Change-Id: I6809a2cccb8903889b74e64a8c08788ff3c8422a
Reviewed-on: https://chromium-review.googlesource.com/1108242Reviewed-by: default avatarCharlie Harrison <csharrison@chromium.org>
Commit-Queue: John Delaney <johnidel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570227}
parent 8a418700
...@@ -30,6 +30,9 @@ base::File VerifiedRulesetDealer::OpenAndSetRulesetFile( ...@@ -30,6 +30,9 @@ base::File VerifiedRulesetDealer::OpenAndSetRulesetFile(
// there are handles to it still open. // there are handles to it still open.
base::File file(file_path, base::File::FLAG_OPEN | base::File::FLAG_READ | base::File file(file_path, base::File::FLAG_OPEN | base::File::FLAG_READ |
base::File::FLAG_SHARE_DELETE); base::File::FLAG_SHARE_DELETE);
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("loading"),
"VerifiedRulesetDealer::OpenAndSetRulesetFile", "file_valid",
file.IsValid());
if (file.IsValid()) if (file.IsValid())
SetRulesetFile(file.Duplicate()); SetRulesetFile(file.Duplicate());
return file; return file;
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/task_runner_util.h" #include "base/task_runner_util.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "base/trace_event/trace_event.h"
#include "base/trace_event/trace_event_argument.h"
#include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/subresource_filter/core/browser/copying_file_stream.h" #include "components/subresource_filter/core/browser/copying_file_stream.h"
...@@ -136,6 +138,14 @@ void IndexedRulesetVersion::SaveToPrefs(PrefService* local_state) const { ...@@ -136,6 +138,14 @@ void IndexedRulesetVersion::SaveToPrefs(PrefService* local_state) const {
content_version); content_version);
} }
std::unique_ptr<base::trace_event::TracedValue>
IndexedRulesetVersion::ToTracedValue() const {
auto value = std::make_unique<base::trace_event::TracedValue>();
value->SetString("content_version", content_version);
value->SetInteger("format_version", format_version);
return value;
}
// IndexedRulesetLocator ------------------------------------------------------ // IndexedRulesetLocator ------------------------------------------------------
// static // static
...@@ -227,6 +237,9 @@ RulesetService::RulesetService( ...@@ -227,6 +237,9 @@ RulesetService::RulesetService(
IndexedRulesetVersion most_recently_indexed_version; IndexedRulesetVersion most_recently_indexed_version;
most_recently_indexed_version.ReadFromPrefs(local_state_); most_recently_indexed_version.ReadFromPrefs(local_state_);
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("loading"),
"RulesetService::RulesetService", "prefs_version",
most_recently_indexed_version.ToTracedValue());
if (most_recently_indexed_version.IsValid() && if (most_recently_indexed_version.IsValid() &&
most_recently_indexed_version.IsCurrentFormatVersion()) { most_recently_indexed_version.IsCurrentFormatVersion()) {
OpenAndPublishRuleset(most_recently_indexed_version); OpenAndPublishRuleset(most_recently_indexed_version);
......
...@@ -26,6 +26,10 @@ class PrefRegistrySimple; ...@@ -26,6 +26,10 @@ class PrefRegistrySimple;
namespace base { namespace base {
class SequencedTaskRunner; class SequencedTaskRunner;
namespace trace_event {
class TracedValue;
} // namespace trace_event
} // namespace base } // namespace base
namespace subresource_filter { namespace subresource_filter {
...@@ -79,6 +83,8 @@ struct IndexedRulesetVersion { ...@@ -79,6 +83,8 @@ struct IndexedRulesetVersion {
void SaveToPrefs(PrefService* local_state) const; void SaveToPrefs(PrefService* local_state) const;
void ReadFromPrefs(PrefService* local_state); void ReadFromPrefs(PrefService* local_state);
std::unique_ptr<base::trace_event::TracedValue> ToTracedValue() const;
std::string content_version; std::string content_version;
int format_version = 0; int format_version = 0;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment