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

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

Issue 2715433006: [Offline Pages] Turn Offliner::Cancel into an async operation to resolve conflicting assumptions (Closed)
Patch Set: forgot to init Created 3 years, 9 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
« no previous file with comments | « no previous file | chrome/browser/android/offline_pages/background_loader_offliner.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_BACKGROUND_LOADER_OFFLINER_H_ 5 #ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_BACKGROUND_LOADER_OFFLINER_H_
6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_BACKGROUND_LOADER_OFFLINER_H_ 6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_BACKGROUND_LOADER_OFFLINER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/android/application_status_listener.h" 10 #include "base/android/application_status_listener.h"
(...skipping 19 matching lines...) Expand all
30 public content::WebContentsObserver { 30 public content::WebContentsObserver {
31 public: 31 public:
32 BackgroundLoaderOffliner(content::BrowserContext* browser_context, 32 BackgroundLoaderOffliner(content::BrowserContext* browser_context,
33 const OfflinerPolicy* policy, 33 const OfflinerPolicy* policy,
34 OfflinePageModel* offline_page_model); 34 OfflinePageModel* offline_page_model);
35 ~BackgroundLoaderOffliner() override; 35 ~BackgroundLoaderOffliner() override;
36 36
37 // Offliner implementation. 37 // Offliner implementation.
38 bool LoadAndSave(const SavePageRequest& request, 38 bool LoadAndSave(const SavePageRequest& request,
39 const CompletionCallback& callback) override; 39 const CompletionCallback& callback) override;
40 void Cancel() override; 40 void Cancel(const CancelCallback& callback) override;
41 bool HandleTimeout(const SavePageRequest& request) override; 41 bool HandleTimeout(const SavePageRequest& request) override;
42 42
43 // WebContentsObserver implementation. 43 // WebContentsObserver implementation.
44 void DidStopLoading() override; 44 void DidStopLoading() override;
45 void RenderProcessGone(base::TerminationStatus status) override; 45 void RenderProcessGone(base::TerminationStatus status) override;
46 void WebContentsDestroyed() override; 46 void WebContentsDestroyed() override;
47 void DidFinishNavigation( 47 void DidFinishNavigation(
48 content::NavigationHandle* navigation_handle) override; 48 content::NavigationHandle* navigation_handle) override;
49 49
50 void SetPageDelayForTest(long delay_ms); 50 void SetPageDelayForTest(long delay_ms);
(...skipping 10 matching lines...) Expand all
61 61
62 // Called when the page is ready to be saved. 62 // Called when the page is ready to be saved.
63 void SavePage(); 63 void SavePage();
64 64
65 // Called when the page has been saved. 65 // Called when the page has been saved.
66 void OnPageSaved(SavePageResult save_result, int64_t offline_id); 66 void OnPageSaved(SavePageResult save_result, int64_t offline_id);
67 67
68 // Called when application state has changed. 68 // Called when application state has changed.
69 void OnApplicationStateChange( 69 void OnApplicationStateChange(
70 base::android::ApplicationState application_state); 70 base::android::ApplicationState application_state);
71 void HandleApplicationStateChangeCancel(const SavePageRequest& request,
72 int64_t offline_id);
71 73
72 std::unique_ptr<background_loader::BackgroundLoaderContents> loader_; 74 std::unique_ptr<background_loader::BackgroundLoaderContents> loader_;
73 // Not owned. 75 // Not owned.
74 content::BrowserContext* browser_context_; 76 content::BrowserContext* browser_context_;
75 // Not owned. 77 // Not owned.
76 OfflinePageModel* offline_page_model_; 78 OfflinePageModel* offline_page_model_;
77 // Tracks pending request, if any. 79 // Tracks pending request, if any.
78 std::unique_ptr<SavePageRequest> pending_request_; 80 std::unique_ptr<SavePageRequest> pending_request_;
79 // Callback when pending request completes. 81 // Callback when pending request completes.
80 CompletionCallback completion_callback_; 82 CompletionCallback completion_callback_;
81 // ApplicationStatusListener to monitor if Chrome moves to the foreground. 83 // ApplicationStatusListener to monitor if Chrome moves to the foreground.
82 std::unique_ptr<base::android::ApplicationStatusListener> app_listener_; 84 std::unique_ptr<base::android::ApplicationStatusListener> app_listener_;
83 // Whether we are on a low-end device. 85 // Whether we are on a low-end device.
84 bool is_low_end_device_; 86 bool is_low_end_device_;
87
85 // Save state. 88 // Save state.
86 SaveState save_state_; 89 SaveState save_state_;
87 // Page load state. 90 // Page load state.
88 PageLoadState page_load_state_; 91 PageLoadState page_load_state_;
89 // Seconds to delay before taking snapshot. 92 // Seconds to delay before taking snapshot.
90 long page_delay_ms_; 93 long page_delay_ms_;
91 94
95 // Callback for cancel.
96 CancelCallback cancel_callback_;
97
92 base::WeakPtrFactory<BackgroundLoaderOffliner> weak_ptr_factory_; 98 base::WeakPtrFactory<BackgroundLoaderOffliner> weak_ptr_factory_;
93 DISALLOW_COPY_AND_ASSIGN(BackgroundLoaderOffliner); 99 DISALLOW_COPY_AND_ASSIGN(BackgroundLoaderOffliner);
94 }; 100 };
95 101
96 } // namespace offline_pages 102 } // namespace offline_pages
97 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_BACKGROUND_LOADER_OFFLINER_H_ 103 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_BACKGROUND_LOADER_OFFLINER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/offline_pages/background_loader_offliner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698