Commit ac9f7c42 authored by Kurt Horimoto's avatar Kurt Horimoto Committed by Commit Bot

[iOS] Allow empty aggregate Overlay[Request/Response]Support.

This allows for a more flexible API that doesn't need additional
checks to verify that conditions are met before creating supports with
their aggregate constructors.

Bug: none
Change-Id: I8e7fdf65780c698339554e5e2c7f3b0799a3a5ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1992004
Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
Auto-Submit: Kurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarMike Dougherty <michaeldo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#729791}
parent cd5a0f4e
...@@ -26,18 +26,13 @@ class DisabledOverlayRequestSupport : public OverlayRequestSupport { ...@@ -26,18 +26,13 @@ class DisabledOverlayRequestSupport : public OverlayRequestSupport {
OverlayRequestSupport::OverlayRequestSupport( OverlayRequestSupport::OverlayRequestSupport(
const std::vector<const OverlayRequestSupport*>& supports) const std::vector<const OverlayRequestSupport*>& supports)
: aggregated_support_(supports) { : aggregated_support_(supports) {}
DCHECK(aggregated_support_.size());
}
OverlayRequestSupport::OverlayRequestSupport() = default; OverlayRequestSupport::OverlayRequestSupport() = default;
OverlayRequestSupport::~OverlayRequestSupport() = default; OverlayRequestSupport::~OverlayRequestSupport() = default;
bool OverlayRequestSupport::IsRequestSupported(OverlayRequest* request) const { bool OverlayRequestSupport::IsRequestSupported(OverlayRequest* request) const {
DCHECK(aggregated_support_.size())
<< "Default implementation is only for aggregated support. Subclasses "
"using the default constructor must implement IsRequestSupported().";
for (const OverlayRequestSupport* support : aggregated_support_) { for (const OverlayRequestSupport* support : aggregated_support_) {
if (support->IsRequestSupported(request)) if (support->IsRequestSupported(request))
return true; return true;
......
...@@ -26,9 +26,7 @@ class DisabledOverlayResponseSupport : public OverlayResponseSupport { ...@@ -26,9 +26,7 @@ class DisabledOverlayResponseSupport : public OverlayResponseSupport {
OverlayResponseSupport::OverlayResponseSupport( OverlayResponseSupport::OverlayResponseSupport(
const std::vector<const OverlayResponseSupport*>& supports) const std::vector<const OverlayResponseSupport*>& supports)
: aggregated_support_(supports) { : aggregated_support_(supports) {}
DCHECK(aggregated_support_.size());
}
OverlayResponseSupport::OverlayResponseSupport() = default; OverlayResponseSupport::OverlayResponseSupport() = default;
...@@ -36,9 +34,6 @@ OverlayResponseSupport::~OverlayResponseSupport() = default; ...@@ -36,9 +34,6 @@ OverlayResponseSupport::~OverlayResponseSupport() = default;
bool OverlayResponseSupport::IsResponseSupported( bool OverlayResponseSupport::IsResponseSupported(
OverlayResponse* response) const { OverlayResponse* response) const {
DCHECK(aggregated_support_.size())
<< "Default implementation is only for aggregated support. Subclasses "
"using the default constructor must implement IsResponseSupported().";
for (const OverlayResponseSupport* support : aggregated_support_) { for (const OverlayResponseSupport* support : aggregated_support_) {
if (support->IsResponseSupported(response)) if (support->IsResponseSupported(response))
return true; return true;
......
...@@ -14,17 +14,18 @@ ...@@ -14,17 +14,18 @@
class OverlayRequestSupport { class OverlayRequestSupport {
public: public:
// Creates an OverlayResponseSupport that aggregates the request support from // Creates an OverlayResponseSupport that aggregates the request support from
// the OverlayRequestSupports in |supports|. |supports| must be non-empty. // the OverlayRequestSupports in |supports|. Instances created with this
// Instances created with this constructor will return true from // constructor will return true from IsRequestSupported() if any of the
// IsRequestSupported() if any of the OverlayRequestSupports in |supports| // OverlayRequestSupports in |supports| returns true from IsRequestSupport()
// returns true from IsRequestSupport() for the same request. // for the same request.
OverlayRequestSupport( OverlayRequestSupport(
const std::vector<const OverlayRequestSupport*>& supports); const std::vector<const OverlayRequestSupport*>& supports);
virtual ~OverlayRequestSupport(); virtual ~OverlayRequestSupport();
// Whether |request| is supported by this instance. The default // Whether |request| is supported by this instance. The default
// implementation returns true is any OverlayRequestSupport in // implementation returns true is any OverlayRequestSupport in
// |aggregated_support_| returns true. // |aggregated_support_| returns true, or false if |aggregated_support_| is
// empty.
virtual bool IsRequestSupported(OverlayRequest* request) const; virtual bool IsRequestSupported(OverlayRequest* request) const;
// Returns an OverlayRequestSupport that supports all requests. // Returns an OverlayRequestSupport that supports all requests.
......
...@@ -14,15 +14,18 @@ ...@@ -14,15 +14,18 @@
class OverlayResponseSupport { class OverlayResponseSupport {
public: public:
// Creates an OverlayResponseSupport that aggregates the support from // Creates an OverlayResponseSupport that aggregates the support from
// the OverlayRequestSupports in |supports|. |supports| must be non-empty. // the OverlayRequestSupports in |supports|. Instances created with this
// Instances created with this constructor will return true from // constructor will return true from IsResponseSupported() if any of the
// IsResponseSupported() if any of the OverlayRequestSupports in |supports| // OverlayRequestSupports in |supports| returns true from
// returns true from IsResponseSupported() for the same response. // IsResponseSupported() for the same response.
OverlayResponseSupport( OverlayResponseSupport(
const std::vector<const OverlayResponseSupport*>& supports); const std::vector<const OverlayResponseSupport*>& supports);
virtual ~OverlayResponseSupport(); virtual ~OverlayResponseSupport();
// Whether |response| is supported by this instance. // Whether |response| is supported by this instance. The default
// implementation returns true is any OverlayResponseSupport in
// |aggregated_support_| returns true, or false if |aggregated_support_| is
// empty.
virtual bool IsResponseSupported(OverlayResponse* response) const; virtual bool IsResponseSupported(OverlayResponse* response) const;
// Returns an OverlayResponseSupport that supports all responses. // Returns an OverlayResponseSupport that supports all responses.
......
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