Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_REQUEST_JOB_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_REQUEST_JOB_H_ |
| 6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_REQUEST_JOB_H_ | 6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_REQUEST_JOB_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/time/time.h" | |
| 9 #include "content/public/browser/resource_request_info.h" | 10 #include "content/public/browser/resource_request_info.h" |
| 10 #include "content/public/common/resource_type.h" | 11 #include "content/public/common/resource_type.h" |
| 11 #include "net/url_request/url_request_file_job.h" | 12 #include "net/url_request/url_request_file_job.h" |
| 12 | 13 |
| 13 namespace base { | 14 namespace base { |
| 14 class FilePath; | 15 class FilePath; |
| 15 } | 16 } |
| 16 | 17 |
| 17 namespace previews { | 18 namespace previews { |
| 18 class PreviewsDecider; | 19 class PreviewsDecider; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 static OfflinePageRequestJob* Create( | 73 static OfflinePageRequestJob* Create( |
| 73 net::URLRequest* request, | 74 net::URLRequest* request, |
| 74 net::NetworkDelegate* network_delegate, | 75 net::NetworkDelegate* network_delegate, |
| 75 previews::PreviewsDecider* previews_decider); | 76 previews::PreviewsDecider* previews_decider); |
| 76 | 77 |
| 77 ~OfflinePageRequestJob() override; | 78 ~OfflinePageRequestJob() override; |
| 78 | 79 |
| 79 // net::URLRequestJob overrides: | 80 // net::URLRequestJob overrides: |
| 80 void Start() override; | 81 void Start() override; |
| 81 void Kill() override; | 82 void Kill() override; |
| 83 bool IsRedirectResponse(GURL* location, int* http_status_code) override; | |
| 84 void GetResponseInfo(net::HttpResponseInfo* info) override; | |
| 85 void GetLoadTimingInfo(net::LoadTimingInfo* load_timing_info) const override; | |
| 86 bool CopyFragmentOnRedirect(const GURL& location) const; | |
| 87 int GetResponseCode() const override; | |
| 82 | 88 |
| 83 void OnOfflineFilePathAvailable(const base::FilePath& offline_file_path); | 89 void OnOfflineFilePathAvailable(const base::FilePath& offline_file_path); |
| 84 void OnOfflineRedirectAvailabe(const GURL& redirected_url); | 90 void OnOfflineRedirectAvailabe(const GURL& redirected_url); |
| 85 | 91 |
| 86 void SetDelegateForTesting(std::unique_ptr<Delegate> delegate); | 92 void SetDelegateForTesting(std::unique_ptr<Delegate> delegate); |
| 87 | 93 |
| 88 private: | 94 private: |
| 89 OfflinePageRequestJob(net::URLRequest* request, | 95 OfflinePageRequestJob(net::URLRequest* request, |
| 90 net::NetworkDelegate* network_delegate, | 96 net::NetworkDelegate* network_delegate, |
| 91 previews::PreviewsDecider* previews_decider); | 97 previews::PreviewsDecider* previews_decider); |
| 92 | 98 |
| 93 void StartAsync(); | 99 void StartAsync(); |
| 94 | 100 |
| 95 // Restarts the request job in order to fall back to the default handling. | 101 // Restarts the request job in order to fall back to the default handling. |
| 96 void FallbackToDefault(); | 102 void FallbackToDefault(); |
| 97 | 103 |
| 98 std::unique_ptr<Delegate> delegate_; | 104 std::unique_ptr<Delegate> delegate_; |
|
mmenke
2016/11/17 18:42:26
include <memory>
jianli
2016/11/17 23:42:06
Done.
| |
| 99 | 105 |
| 106 // For redirect simulation. | |
| 107 scoped_refptr<net::HttpResponseHeaders> fake_headers_for_redirect_; | |
|
mmenke
2016/11/17 18:42:26
include ref_counted
jianli
2016/11/17 23:42:06
Done.
| |
| 108 base::TimeTicks receive_redirect_headers_end_; | |
| 109 base::Time redirect_response_time_; | |
| 110 | |
| 100 // Used to determine if an URLRequest is eligible for offline previews. | 111 // Used to determine if an URLRequest is eligible for offline previews. |
| 101 previews::PreviewsDecider* previews_decider_; | 112 previews::PreviewsDecider* previews_decider_; |
| 102 | 113 |
| 103 base::WeakPtrFactory<OfflinePageRequestJob> weak_ptr_factory_; | 114 base::WeakPtrFactory<OfflinePageRequestJob> weak_ptr_factory_; |
| 104 | 115 |
| 105 DISALLOW_COPY_AND_ASSIGN(OfflinePageRequestJob); | 116 DISALLOW_COPY_AND_ASSIGN(OfflinePageRequestJob); |
| 106 }; | 117 }; |
| 107 | 118 |
| 108 } // namespace offline_pages | 119 } // namespace offline_pages |
| 109 | 120 |
| 110 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_REQUEST_JOB_H_ | 121 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_REQUEST_JOB_H_ |
| OLD | NEW |