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

Side by Side Diff: content/browser/appcache/appcache_update_url_fetcher.h

Issue 2978373002: Move the URLFetcher class used by the AppCacheUpdateJob class into its own file. (Closed)
Patch Set: Move forward declaration for URLFetcher outside the AppCacheUpdateJob class to fix compile failures. Created 3 years, 5 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 (c) 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 CONTENT_BROWSER_APPCACHE_APPCACHE_UPDATE_URL_FETCHER_H_
6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_UPDATE_URL_FETCHER_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include "content/browser/appcache/appcache_response.h"
12 #include "content/browser/appcache/appcache_update_job.h"
13 #include "net/base/io_buffer.h"
14 #include "net/url_request/url_request.h"
15 #include "url/gurl.h"
16
17 namespace content {
18
19 // Helper class to fetch resources. Depending on the fetch type,
20 // can either fetch to an in-memory string or write the response
21 // data out to the disk cache.
22 class URLFetcher : public net::URLRequest::Delegate {
23 public:
24 enum FetchType {
25 MANIFEST_FETCH,
26 URL_FETCH,
27 MASTER_ENTRY_FETCH,
28 MANIFEST_REFETCH,
29 };
30 URLFetcher(const GURL& url,
31 FetchType fetch_type,
32 AppCacheUpdateJob* job,
33 int buffer_size);
34 ~URLFetcher() override;
35 void Start();
36 FetchType fetch_type() const { return fetch_type_; }
37 net::URLRequest* request() const { return request_.get(); }
38 const AppCacheEntry& existing_entry() const { return existing_entry_; }
39 const std::string& manifest_data() const { return manifest_data_; }
40 AppCacheResponseWriter* response_writer() const {
41 return response_writer_.get();
42 }
43 void set_existing_response_headers(net::HttpResponseHeaders* headers) {
44 existing_response_headers_ = headers;
45 }
46 void set_existing_entry(const AppCacheEntry& entry) {
47 existing_entry_ = entry;
48 }
49 AppCacheUpdateJob::ResultType result() const { return result_; }
50 int redirect_response_code() const { return redirect_response_code_; }
51
52 private:
53 // URLRequest::Delegate overrides
54 void OnReceivedRedirect(net::URLRequest* request,
55 const net::RedirectInfo& redirect_info,
56 bool* defer_redirect) override;
57 void OnResponseStarted(net::URLRequest* request, int net_error) override;
58 void OnReadCompleted(net::URLRequest* request, int bytes_read) override;
59
60 void AddConditionalHeaders(const net::HttpResponseHeaders* headers);
61 void OnWriteComplete(int result);
62 void ReadResponseData();
63 bool ConsumeResponseData(int bytes_read);
64 void OnResponseCompleted(int net_error);
65 bool MaybeRetryRequest();
66
67 GURL url_;
68 AppCacheUpdateJob* job_;
69 FetchType fetch_type_;
70 int retry_503_attempts_;
71 scoped_refptr<net::IOBuffer> buffer_;
72 std::unique_ptr<net::URLRequest> request_;
73 AppCacheEntry existing_entry_;
74 scoped_refptr<net::HttpResponseHeaders> existing_response_headers_;
75 std::string manifest_data_;
76 AppCacheUpdateJob::ResultType result_;
77 int redirect_response_code_;
78 std::unique_ptr<AppCacheResponseWriter> response_writer_;
79 int buffer_size_;
80 }; // class URLFetcher
81
82 } // namespace content.
83
84 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_UPDATE_URL_FETCHER_H_
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_update_job.cc ('k') | content/browser/appcache/appcache_update_url_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698