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

Side by Side Diff: chrome/browser/android/offline_pages/offline_page_request_job.h

Issue 2388253002: Use the previews black list for offline previews (Closed)
Patch Set: Created 4 years, 2 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
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 "content/public/browser/resource_request_info.h" 9 #include "content/public/browser/resource_request_info.h"
10 #include "content/public/common/resource_type.h" 10 #include "content/public/common/resource_type.h"
11 #include "net/url_request/url_request_file_job.h" 11 #include "net/url_request/url_request_file_job.h"
12 12
13 namespace base { 13 namespace base {
14 class FilePath; 14 class FilePath;
15 } 15 }
16 16
17 namespace previews {
18 class PreviewsBlackList;
19 }
20
17 namespace offline_pages { 21 namespace offline_pages {
18 22
19 // A request job that serves content from offline file. 23 // A request job that serves content from offline file.
20 class OfflinePageRequestJob : public net::URLRequestFileJob { 24 class OfflinePageRequestJob : public net::URLRequestFileJob {
21 public: 25 public:
22 // This enum is used for UMA reporting. It contains all possible outcomes of 26 // This enum is used for UMA reporting. It contains all possible outcomes of
23 // handling requests that might service offline page in different network 27 // handling requests that might service offline page in different network
24 // conditions. Generally one of these outcomes will happen. 28 // conditions. Generally one of these outcomes will happen.
25 // The fringe errors (like no OfflinePageModel, etc.) are not reported due 29 // The fringe errors (like no OfflinePageModel, etc.) are not reported due
26 // to their low probability. 30 // to their low probability.
(...skipping 30 matching lines...) Expand all
57 61
58 virtual TabIdGetter GetTabIdGetter() const = 0; 62 virtual TabIdGetter GetTabIdGetter() const = 0;
59 }; 63 };
60 64
61 // Reports the aggregated result combining both request result and network 65 // Reports the aggregated result combining both request result and network
62 // state. 66 // state.
63 static void ReportAggregatedRequestResult(AggregatedRequestResult result); 67 static void ReportAggregatedRequestResult(AggregatedRequestResult result);
64 68
65 // Creates and returns a job to serve the offline page. Nullptr is returned if 69 // Creates and returns a job to serve the offline page. Nullptr is returned if
66 // offline page cannot or should not be served. 70 // offline page cannot or should not be served.
67 static OfflinePageRequestJob* Create(net::URLRequest* request, 71 static OfflinePageRequestJob* Create(
68 net::NetworkDelegate* network_delegate); 72 net::URLRequest* request,
73 net::NetworkDelegate* network_delegate,
74 previews::PreviewsBlackList* previews_black_list);
69 75
70 ~OfflinePageRequestJob() override; 76 ~OfflinePageRequestJob() override;
71 77
72 // net::URLRequestJob overrides: 78 // net::URLRequestJob overrides:
73 void Start() override; 79 void Start() override;
74 void Kill() override; 80 void Kill() override;
75 81
76 void OnOfflineFilePathAvailable(const base::FilePath& offline_file_path); 82 void OnOfflineFilePathAvailable(const base::FilePath& offline_file_path);
77 83
78 void SetDelegateForTesting(std::unique_ptr<Delegate> delegate); 84 void SetDelegateForTesting(std::unique_ptr<Delegate> delegate);
79 85
80 private: 86 private:
81 OfflinePageRequestJob(net::URLRequest* request, 87 OfflinePageRequestJob(net::URLRequest* request,
82 net::NetworkDelegate* network_delegate); 88 net::NetworkDelegate* network_delegate,
89 previews::PreviewsBlackList* previews_black_list);
83 90
84 void StartAsync(); 91 void StartAsync();
85 92
86 // Restarts the request job in order to fall back to the default handling. 93 // Restarts the request job in order to fall back to the default handling.
87 void FallbackToDefault(); 94 void FallbackToDefault();
88 95
89 std::unique_ptr<Delegate> delegate_; 96 std::unique_ptr<Delegate> delegate_;
90 97
98 // Used to determine if an URLRequest is eligible for offline previews.
tbansal1 2016/10/04 12:38:04 Comment on the lifetime: e.g., is it possible that
RyanSturm 2016/10/04 21:36:38 Done.
99 previews::PreviewsBlackList* previews_black_list_;
100
91 base::WeakPtrFactory<OfflinePageRequestJob> weak_ptr_factory_; 101 base::WeakPtrFactory<OfflinePageRequestJob> weak_ptr_factory_;
92 102
93 DISALLOW_COPY_AND_ASSIGN(OfflinePageRequestJob); 103 DISALLOW_COPY_AND_ASSIGN(OfflinePageRequestJob);
94 }; 104 };
95 105
96 } // namespace offline_pages 106 } // namespace offline_pages
97 107
98 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_REQUEST_JOB_H_ 108 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_REQUEST_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698