Commit 00d42fc6 authored by rajendrant's avatar rajendrant Committed by Chromium LUCI CQ

Rename RobotsRulesDecider to RobotsRulesParser

Change-Id: I59d9725499dfabe490411391350f5050ebe326c8
Bug: 1152527
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2574258
Commit-Queue: rajendrant <rajendrant@chromium.org>
Reviewed-by: default avatarRobert Ogden <robertogden@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833814}
parent bc20c2e5
...@@ -98,8 +98,8 @@ static_library("renderer") { ...@@ -98,8 +98,8 @@ static_library("renderer") {
"previews/resource_loading_hints_agent.h", "previews/resource_loading_hints_agent.h",
"subresource_redirect/public_image_hints_url_loader_throttle.cc", "subresource_redirect/public_image_hints_url_loader_throttle.cc",
"subresource_redirect/public_image_hints_url_loader_throttle.h", "subresource_redirect/public_image_hints_url_loader_throttle.h",
"subresource_redirect/robots_rules_decider.cc", "subresource_redirect/robots_rules_parser.cc",
"subresource_redirect/robots_rules_decider.h", "subresource_redirect/robots_rules_parser.h",
"subresource_redirect/subresource_redirect_hints_agent.cc", "subresource_redirect/subresource_redirect_hints_agent.cc",
"subresource_redirect/subresource_redirect_hints_agent.h", "subresource_redirect/subresource_redirect_hints_agent.h",
"subresource_redirect/subresource_redirect_params.cc", "subresource_redirect/subresource_redirect_params.cc",
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/renderer/subresource_redirect/robots_rules_decider.h" #include "chrome/renderer/subresource_redirect/robots_rules_parser.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/logging.h" #include "base/logging.h"
...@@ -66,7 +66,7 @@ bool IsMatchingRobotsRule(const std::string& path, const std::string& pattern) { ...@@ -66,7 +66,7 @@ bool IsMatchingRobotsRule(const std::string& path, const std::string& pattern) {
} }
void RecordRobotsRulesReceiveResultHistogram( void RecordRobotsRulesReceiveResultHistogram(
RobotsRulesDecider::SubresourceRedirectRobotsRulesReceiveResult result) { RobotsRulesParser::SubresourceRedirectRobotsRulesReceiveResult result) {
UMA_HISTOGRAM_ENUMERATION( UMA_HISTOGRAM_ENUMERATION(
"SubresourceRedirect.RobotRulesDecider.ReceiveResult", result); "SubresourceRedirect.RobotRulesDecider.ReceiveResult", result);
} }
...@@ -78,27 +78,27 @@ void RecordRobotsRulesApplyDurationHistogram(base::TimeDelta duration) { ...@@ -78,27 +78,27 @@ void RecordRobotsRulesApplyDurationHistogram(base::TimeDelta duration) {
} // namespace } // namespace
bool RobotsRulesDecider::RobotsRule::Match(const std::string& path) const { bool RobotsRulesParser::RobotsRule::Match(const std::string& path) const {
return IsMatchingRobotsRule(path, pattern_); return IsMatchingRobotsRule(path, pattern_);
} }
RobotsRulesDecider::RobotsRulesDecider() { RobotsRulesParser::RobotsRulesParser() {
// Using base::Unretained(this) is safe here, since the timer // Using base::Unretained(this) is safe here, since the timer
// |rules_receive_timeout_timer_| is owned by |this| and destroyed before // |rules_receive_timeout_timer_| is owned by |this| and destroyed before
// |this|. // |this|.
rules_receive_timeout_timer_.Start( rules_receive_timeout_timer_.Start(
FROM_HERE, GetRobotsRulesReceiveTimeout(), FROM_HERE, GetRobotsRulesReceiveTimeout(),
base::BindOnce(&RobotsRulesDecider::OnRulesReceiveTimeout, base::BindOnce(&RobotsRulesParser::OnRulesReceiveTimeout,
base::Unretained(this))); base::Unretained(this)));
} }
RobotsRulesDecider::~RobotsRulesDecider() { RobotsRulesParser::~RobotsRulesParser() {
// Consider this as a timeout // Consider this as a timeout
if (rules_receive_timeout_timer_.IsRunning()) if (rules_receive_timeout_timer_.IsRunning())
rules_receive_timeout_timer_.FireNow(); rules_receive_timeout_timer_.FireNow();
} }
void RobotsRulesDecider::UpdateRobotsRules(const std::string& rules) { void RobotsRulesParser::UpdateRobotsRules(const std::string& rules) {
robots_rules_.reset(); robots_rules_.reset();
rules_receive_timeout_timer_.Stop(); rules_receive_timeout_timer_.Stop();
...@@ -133,7 +133,7 @@ void RobotsRulesDecider::UpdateRobotsRules(const std::string& rules) { ...@@ -133,7 +133,7 @@ void RobotsRulesDecider::UpdateRobotsRules(const std::string& rules) {
pending_check_requests_.clear(); pending_check_requests_.clear();
} }
void RobotsRulesDecider::CheckRobotsRules(const GURL& url, void RobotsRulesParser::CheckRobotsRules(const GURL& url,
CheckResultCallback callback) { CheckResultCallback callback) {
std::string path_with_query = url.path(); std::string path_with_query = url.path();
if (url.has_query()) if (url.has_query())
...@@ -149,7 +149,7 @@ void RobotsRulesDecider::CheckRobotsRules(const GURL& url, ...@@ -149,7 +149,7 @@ void RobotsRulesDecider::CheckRobotsRules(const GURL& url,
: CheckResult::kDisallowed); : CheckResult::kDisallowed);
} }
bool RobotsRulesDecider::IsAllowed(const std::string& url_path) const { bool RobotsRulesParser::IsAllowed(const std::string& url_path) const {
// Rules not received. Could be rule parse error or timeout. // Rules not received. Could be rule parse error or timeout.
if (!robots_rules_) if (!robots_rules_)
return false; return false;
...@@ -167,7 +167,7 @@ bool RobotsRulesDecider::IsAllowed(const std::string& url_path) const { ...@@ -167,7 +167,7 @@ bool RobotsRulesDecider::IsAllowed(const std::string& url_path) const {
return true; return true;
} }
void RobotsRulesDecider::OnRulesReceiveTimeout() { void RobotsRulesParser::OnRulesReceiveTimeout() {
DCHECK(!rules_receive_timeout_timer_.IsRunning()); DCHECK(!rules_receive_timeout_timer_.IsRunning());
for (auto& request : pending_check_requests_) for (auto& request : pending_check_requests_)
std::move(request.first).Run(CheckResult::kTimedout); std::move(request.first).Run(CheckResult::kTimedout);
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_RENDERER_SUBRESOURCE_REDIRECT_ROBOTS_RULES_DECIDER_H_ #ifndef CHROME_RENDERER_SUBRESOURCE_REDIRECT_ROBOTS_RULES_PARSER_H_
#define CHROME_RENDERER_SUBRESOURCE_REDIRECT_ROBOTS_RULES_DECIDER_H_ #define CHROME_RENDERER_SUBRESOURCE_REDIRECT_ROBOTS_RULES_PARSER_H_
#include <map> #include <map>
#include <vector> #include <vector>
...@@ -20,7 +20,7 @@ namespace subresource_redirect { ...@@ -20,7 +20,7 @@ namespace subresource_redirect {
// url path is allowed or disallowed. Also supports a timeout to receive the // url path is allowed or disallowed. Also supports a timeout to receive the
// robots rules after which it will be treated as a full disallow. The check // robots rules after which it will be treated as a full disallow. The check
// result is delivered via callback asynchronously. // result is delivered via callback asynchronously.
class RobotsRulesDecider { class RobotsRulesParser {
public: public:
// The final result of robots rule retrieval. // The final result of robots rule retrieval.
// This should be kept in sync with // This should be kept in sync with
...@@ -41,11 +41,11 @@ class RobotsRulesDecider { ...@@ -41,11 +41,11 @@ class RobotsRulesDecider {
// Callback to notify the check robot rules result. // Callback to notify the check robot rules result.
using CheckResultCallback = base::OnceCallback<void(CheckResult)>; using CheckResultCallback = base::OnceCallback<void(CheckResult)>;
RobotsRulesDecider(); RobotsRulesParser();
~RobotsRulesDecider(); ~RobotsRulesParser();
RobotsRulesDecider(const RobotsRulesDecider&) = delete; RobotsRulesParser(const RobotsRulesParser&) = delete;
RobotsRulesDecider& operator=(const RobotsRulesDecider&) = delete; RobotsRulesParser& operator=(const RobotsRulesParser&) = delete;
// Update the robots rules. This causes any pending check requests to be // Update the robots rules. This causes any pending check requests to be
// processed immediately and called with th result. // processed immediately and called with th result.
...@@ -95,4 +95,4 @@ class RobotsRulesDecider { ...@@ -95,4 +95,4 @@ class RobotsRulesDecider {
} // namespace subresource_redirect } // namespace subresource_redirect
#endif // CHROME_RENDERER_SUBRESOURCE_REDIRECT_ROBOTS_RULES_DECIDER_H_ #endif // CHROME_RENDERER_SUBRESOURCE_REDIRECT_ROBOTS_RULES_PARSER_H_
...@@ -3816,7 +3816,7 @@ test("unit_tests") { ...@@ -3816,7 +3816,7 @@ test("unit_tests") {
"../renderer/media/flash_embed_rewrite_unittest.cc", "../renderer/media/flash_embed_rewrite_unittest.cc",
"../renderer/net/net_error_helper_core_unittest.cc", "../renderer/net/net_error_helper_core_unittest.cc",
"../renderer/plugins/plugin_uma_unittest.cc", "../renderer/plugins/plugin_uma_unittest.cc",
"../renderer/subresource_redirect/robots_rules_decider_unittest.cc", "../renderer/subresource_redirect/robots_rules_parser_unittest.cc",
"../renderer/subresource_redirect/subresource_redirect_util_unittest.cc", "../renderer/subresource_redirect/subresource_redirect_util_unittest.cc",
"../renderer/v8_unwinder_unittest.cc", "../renderer/v8_unwinder_unittest.cc",
"../test/base/chrome_render_view_test.cc", "../test/base/chrome_render_view_test.cc",
......
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