Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(612)

Side by Side Diff: components/offline_pages/core/prefetch/prefetch_request_fetcher.h

Issue 2856793002: [Offline Prefetch] Prefetch request fetcher (Closed)
Patch Set: Address feedback Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 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 COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_REQUEST_FETCHER_H_
6 #define COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_REQUEST_FETCHER_H_
7
8 #include "base/callback.h"
9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h"
11 #include "net/url_request/url_fetcher_delegate.h"
12
13 class GURL;
14 namespace net {
15 class URLRequestContextGetter;
16 }
17
18 namespace offline_prefetch {
19
20 class PrefetchRequestFetcher : public net::URLFetcherDelegate {
21 public:
22 enum class Status {
23 // Request completed successfully.
24 SUCCESS,
25 // Request failed due to to local network problem, unrelated to server load
26 // levels. The caller will simply reschedule the retry in the next available
27 // WiFi window after 15 minutes have passed.
28 SHOULD_RETRY_WITHOUT_BACKOFF,
29 // Request failed probably related to transient server problems. The caller
30 // will reschedule the retry with backoff included.
31 SHOULD_RETRY_WITH_BACKOFF,
32 // Request failed with error indicating that the server no longer knows how
33 // to service a request. The caller will prevent network requests for the
34 // period of 1 day.
35 SHOULD_SUSPEND
36 };
37
38 using FinishedCallback =
39 base::Callback<void(Status status, const std::string& data)>;
40
41 PrefetchRequestFetcher(
42 const GURL& url,
43 const std::string& message,
44 scoped_refptr<net::URLRequestContextGetter> request_context_getter,
45 const FinishedCallback& callback);
46 ~PrefetchRequestFetcher() override;
47
48 // URLFetcherDelegate implementation.
49 void OnURLFetchComplete(const net::URLFetcher* source) override;
50
51 private:
52 Status ParseResponse(const net::URLFetcher* source, std::string* data);
53
54 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
55 std::unique_ptr<net::URLFetcher> url_fetcher_;
56 FinishedCallback callback_;
57
58 DISALLOW_COPY_AND_ASSIGN(PrefetchRequestFetcher);
59 };
60
61 } // namespace offline_prefetch
62
63 #endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_REQUEST_FETCHER_H_
OLDNEW
« no previous file with comments | « components/offline_pages/core/prefetch/BUILD.gn ('k') | components/offline_pages/core/prefetch/prefetch_request_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698