Chromium Code Reviews| Index: components/password_manager/core/browser/site_affiliation/asset_link_retriever.h |
| diff --git a/components/password_manager/core/browser/site_affiliation/asset_link_retriever.h b/components/password_manager/core/browser/site_affiliation/asset_link_retriever.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..59becc18e6a7d19585ba269b7fe5c6ed0e6780ce |
| --- /dev/null |
| +++ b/components/password_manager/core/browser/site_affiliation/asset_link_retriever.h |
| @@ -0,0 +1,67 @@ |
| +// 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_PASSWORD_MANAGER_CORE_BROWSER_SITE_AFFILIATION_ASSET_LINK_RETRIEVER_H_ |
| +#define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_SITE_AFFILIATION_ASSET_LINK_RETRIEVER_H_ |
| + |
| +#include <memory> |
| + |
| +#include "base/macros.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "net/url_request/url_fetcher_delegate.h" |
| +#include "url/gurl.h" |
| + |
| +namespace net { |
| +class URLRequestContextGetter; |
| +} |
| + |
| +namespace password_manager { |
| + |
| +// The class is responsible for fetching and parsing the digit asset links file. |
| +// The file is a JSON containing different directives for the domain. The class |
| +// is only interested in those related to credentials delegations. |
| +// The spec is |
| +// https://github.com/google/digitalassetlinks/blob/master/well-known/details.md |
| +class AssetLinkRetriever : public base::RefCounted<AssetLinkRetriever>, |
|
vabr (Chromium)
2017/06/18 16:37:51
Why does this need to be refcounted? Does net::URL
vasilii
2017/06/19 12:20:20
This is a part of a bigger plan. If two requests r
vabr (Chromium)
2017/06/19 13:07:54
Acknowledged.
|
| + public net::URLFetcherDelegate { |
| + public: |
| + enum class State { |
| + INACTIVE, |
| + NETWORK_REQUEST, |
| + FINISHED, |
| + }; |
| + |
| + AssetLinkRetriever(GURL file_url); |
|
vabr (Chromium)
2017/06/18 16:37:51
Should this be explicit?
vasilii
2017/06/19 12:20:20
Done.
|
| + |
| + // Starts a network request if the current state is INACTIVE. All the calls |
| + // afterwards are ignored. |
| + void Start(net::URLRequestContextGetter* context_getter); |
| + |
| + State state() const { return state_; } |
| + |
| + bool error() const { return error_; } |
| + |
| + private: |
| + friend class base::RefCounted<AssetLinkRetriever>; |
| + ~AssetLinkRetriever() override; |
| + |
| + // net::URLFetcherDelegate: |
| + void OnURLFetchComplete(const net::URLFetcher* source) override; |
| + |
| + // URL of the file retrieved. |
| + const GURL url_; |
| + |
| + // Current state of the retrieval. |
| + State state_; |
| + |
| + // Whether the reading finished with error. |
| + bool error_; |
| + |
| + std::unique_ptr<net::URLFetcher> fetcher_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AssetLinkRetriever); |
| +}; |
| + |
| +} // namespace password_manager |
| +#endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_SITE_AFFILIATION_ASSET_LINK_RETRIEVER_H_ |