| Index: components/subresource_filter/content/browser/subresource_filter_safe_browsing_client_request.h
|
| diff --git a/components/subresource_filter/content/browser/subresource_filter_safe_browsing_client_request.h b/components/subresource_filter/content/browser/subresource_filter_safe_browsing_client_request.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ef8bf14b5c1a05cd8e3f1f3d865bc3350fa47714
|
| --- /dev/null
|
| +++ b/components/subresource_filter/content/browser/subresource_filter_safe_browsing_client_request.h
|
| @@ -0,0 +1,95 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_SUBRESOURCE_FILTER_SAFE_BROWSING_CLIENT_REQUEST_H_
|
| +#define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_SUBRESOURCE_FILTER_SAFE_BROWSING_CLIENT_REQUEST_H_
|
| +
|
| +#include <stddef.h>
|
| +
|
| +#include "base/macros.h"
|
| +#include "base/memory/ref_counted.h"
|
| +#include "base/time/time.h"
|
| +#include "base/timer/timer.h"
|
| +#include "components/safe_browsing_db/database_manager.h"
|
| +#include "components/safe_browsing_db/util.h"
|
| +#include "components/safe_browsing_db/v4_local_database_manager.h"
|
| +#include "url/gurl.h"
|
| +
|
| +namespace base {
|
| +class SingleThreadTaskRunner;
|
| +} // namespace base
|
| +
|
| +namespace safe_browsing {
|
| +struct ThreatMetadata;
|
| +} // namespace safe_browsing
|
| +
|
| +namespace subresource_filter {
|
| +
|
| +class SubresourceFilterSafeBrowsingClient;
|
| +
|
| +// This class is scoped to a single database check, and it lives on the IO
|
| +// thread exclusively.
|
| +class SubresourceFilterSafeBrowsingClientRequest
|
| + : public safe_browsing::SafeBrowsingDatabaseManager::Client {
|
| + public:
|
| + SubresourceFilterSafeBrowsingClientRequest(
|
| + const GURL& url,
|
| + size_t request_id,
|
| + scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager>
|
| + database_manager,
|
| + scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
|
| + SubresourceFilterSafeBrowsingClient* client);
|
| + ~SubresourceFilterSafeBrowsingClientRequest() override;
|
| +
|
| + void Start();
|
| +
|
| + // safe_browsing::SafeBrowsingDatabaseManager::Client:
|
| + void OnCheckBrowseUrlResult(
|
| + const GURL& url,
|
| + safe_browsing::SBThreatType threat_type,
|
| + const safe_browsing::ThreatMetadata& metadata) override;
|
| +
|
| + const GURL& url() const { return url_; }
|
| + size_t request_id() const { return request_id_; }
|
| +
|
| + // Maximum time in milliseconds to wait for the Safe Browsing service to
|
| + // verify a URL. After this amount of time the outstanding check will be
|
| + // aborted, and the URL will be treated as if it didn't belong to the
|
| + // Subresource Filter only list.
|
| + static constexpr base::TimeDelta kCheckURLTimeout =
|
| + base::TimeDelta::FromSeconds(5);
|
| +
|
| + private:
|
| + // Callback for when the safe browsing check has taken longer than
|
| + // kCheckURLTimeout.
|
| + void OnCheckUrlTimeout();
|
| +
|
| + void SendCheckResultToClient(bool served_from_network,
|
| + safe_browsing::SBThreatType threat_type,
|
| + const safe_browsing::ThreatMetadata& metadata);
|
| +
|
| + const GURL url_;
|
| +
|
| + // The |request_id_| identifies a particular request, as issued from the
|
| + // SubresourceFilterSafeBrowsingClient. It will be unique in the scope of a
|
| + // single navigation (i.e. the scope of the
|
| + // SubresourceFilterSafeBrowsingClient).
|
| + const size_t request_id_;
|
| +
|
| + scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> database_manager_;
|
| + SubresourceFilterSafeBrowsingClient* client_ = nullptr;
|
| +
|
| + // Timer to abort the safe browsing check if it takes too long.
|
| + base::OneShotTimer timer_;
|
| +
|
| + base::TimeTicks start_time_;
|
| +
|
| + bool request_completed_ = false;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(SubresourceFilterSafeBrowsingClientRequest);
|
| +};
|
| +
|
| +} // namespace subresource_filter
|
| +
|
| +#endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_SUBRESOURCE_FILTER_SAFE_BROWSING_CLIENT_REQUEST_H_
|
|
|