blob: 2da403b0fd2ff5ee4be8dee9b743f5848a5a520f [file] [log] [blame]
[email protected]7b3941052013-02-13 01:21:591// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_DATA_FETCHER_H_
6#define CHROME_BROWSER_EXTENSIONS_WEBSTORE_DATA_FETCHER_H_
7
dchengc963c7142016-04-08 03:55:228#include <memory>
[email protected]7b3941052013-02-13 01:21:599#include <string>
10
avia2f4804a2015-12-24 23:11:1311#include "base/macros.h"
[email protected]7b3941052013-02-13 01:21:5912#include "base/memory/weak_ptr.h"
Ken Rockotdc32df892019-11-01 06:32:1013#include "services/data_decoder/public/cpp/data_decoder.h"
[email protected]a6483d22013-07-03 22:11:0014#include "url/gurl.h"
[email protected]7b3941052013-02-13 01:21:5915
Mark Pilgrim1a72e0512018-04-25 13:48:4816namespace network {
17class SimpleURLLoader;
18namespace mojom {
19class URLLoaderFactory;
20} // namespace mojom
21} // namespace network
[email protected]7b3941052013-02-13 01:21:5922
23namespace extensions {
24
25class WebstoreDataFetcherDelegate;
26
27// WebstoreDataFetcher fetches web store data and parses it into a
28// DictionaryValue.
Mark Pilgrim1a72e0512018-04-25 13:48:4829class WebstoreDataFetcher : public base::SupportsWeakPtr<WebstoreDataFetcher> {
[email protected]7b3941052013-02-13 01:21:5930 public:
31 WebstoreDataFetcher(WebstoreDataFetcherDelegate* delegate,
[email protected]7b3941052013-02-13 01:21:5932 const GURL& referrer_url,
33 const std::string webstore_item_id);
Mark Pilgrim1a72e0512018-04-25 13:48:4834 ~WebstoreDataFetcher();
[email protected]7b3941052013-02-13 01:21:5935
Mark Pilgrim1a72e0512018-04-25 13:48:4836 void Start(network::mojom::URLLoaderFactory* url_loader_factory);
[email protected]7b3941052013-02-13 01:21:5937
[email protected]270dccc2014-07-11 07:20:3738 void set_max_auto_retries(int max_retries) {
39 max_auto_retries_ = max_retries;
40 }
41
[email protected]7b3941052013-02-13 01:21:5942 private:
Ken Rockotdc32df892019-11-01 06:32:1043 void OnJsonParsed(data_decoder::DataDecoder::ValueOrError result);
Mark Pilgrim1a72e0512018-04-25 13:48:4844 void OnSimpleLoaderComplete(std::unique_ptr<std::string> response_body);
[email protected]7b3941052013-02-13 01:21:5945
46 WebstoreDataFetcherDelegate* delegate_;
[email protected]7b3941052013-02-13 01:21:5947 GURL referrer_url_;
48 std::string id_;
Jialiu Linfc668ec12018-01-31 01:28:4449 std::string post_data_;
[email protected]7b3941052013-02-13 01:21:5950
51 // For fetching webstore JSON data.
Mark Pilgrim1a72e0512018-04-25 13:48:4852 std::unique_ptr<network::SimpleURLLoader> simple_url_loader_;
[email protected]7b3941052013-02-13 01:21:5953
[email protected]270dccc2014-07-11 07:20:3754 // Maximum auto retry times on server 5xx error or ERR_NETWORK_CHANGED.
55 // Default is 0 which means to use the URLFetcher default behavior.
56 int max_auto_retries_;
57
[email protected]7b3941052013-02-13 01:21:5958 DISALLOW_COPY_AND_ASSIGN(WebstoreDataFetcher);
59};
60
61} // namespace extensions
62
63#endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_DATA_FETCHER_H_