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

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

Issue 2656763002: [Offline pages] Add navigation error handling to background loader. (Closed)
Patch Set: cl comments and format Created 3 years, 10 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 25 matching lines...) Expand all
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() override;
41 41
42 // WebContentsObserver implementation. 42 // WebContentsObserver implementation.
43 void DidStopLoading() override; 43 void DidStopLoading() override;
44 void RenderProcessGone(base::TerminationStatus status) override; 44 void RenderProcessGone(base::TerminationStatus status) override;
45 void WebContentsDestroyed() override; 45 void WebContentsDestroyed() override;
46 void DidFinishNavigation(
47 content::NavigationHandle* navigation_handle) override;
46 48
47 protected: 49 protected:
48 // Called to reset internal loader and observer state. 50 // Called to reset internal loader and observer state.
49 virtual void ResetState(); 51 virtual void ResetState();
50 52
51 private: 53 private:
52 friend class TestBackgroundLoaderOffliner; 54 friend class TestBackgroundLoaderOffliner;
53 55
54 enum SaveState { NONE, SAVING, DELETE_AFTER_SAVE }; 56 enum SaveState { NONE, SAVING, DELETE_AFTER_SAVE };
57 enum PageLoadState { SUCCESS, RETRIABLE, NONRETRIABLE };
55 58
56 // Called when the page has been saved. 59 // Called when the page has been saved.
57 void OnPageSaved(SavePageResult save_result, int64_t offline_id); 60 void OnPageSaved(SavePageResult save_result, int64_t offline_id);
58 61
59 // Called when application state has changed. 62 // Called when application state has changed.
60 void OnApplicationStateChange( 63 void OnApplicationStateChange(
61 base::android::ApplicationState application_state); 64 base::android::ApplicationState application_state);
62 65
63 std::unique_ptr<background_loader::BackgroundLoaderContents> loader_; 66 std::unique_ptr<background_loader::BackgroundLoaderContents> loader_;
64 // Not owned. 67 // Not owned.
65 content::BrowserContext* browser_context_; 68 content::BrowserContext* browser_context_;
66 // Not owned. 69 // Not owned.
67 OfflinePageModel* offline_page_model_; 70 OfflinePageModel* offline_page_model_;
68 // Tracks pending request, if any. 71 // Tracks pending request, if any.
69 std::unique_ptr<SavePageRequest> pending_request_; 72 std::unique_ptr<SavePageRequest> pending_request_;
70 // Callback when pending request completes. 73 // Callback when pending request completes.
71 CompletionCallback completion_callback_; 74 CompletionCallback completion_callback_;
72 // ApplicationStatusListener to monitor if Chrome moves to the foreground. 75 // ApplicationStatusListener to monitor if Chrome moves to the foreground.
73 std::unique_ptr<base::android::ApplicationStatusListener> app_listener_; 76 std::unique_ptr<base::android::ApplicationStatusListener> app_listener_;
74 // Whether we are on a low-end device. 77 // Whether we are on a low-end device.
75 bool is_low_end_device_; 78 bool is_low_end_device_;
76 // Save state. 79 // Save state.
77 SaveState save_state_; 80 SaveState save_state_;
81 // Page load state.
82 PageLoadState page_load_state_;
78 83
79 base::WeakPtrFactory<BackgroundLoaderOffliner> weak_ptr_factory_; 84 base::WeakPtrFactory<BackgroundLoaderOffliner> weak_ptr_factory_;
80 DISALLOW_COPY_AND_ASSIGN(BackgroundLoaderOffliner); 85 DISALLOW_COPY_AND_ASSIGN(BackgroundLoaderOffliner);
81 }; 86 };
82 87
83 } // namespace offline_pages 88 } // namespace offline_pages
84 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_BACKGROUND_LOADER_OFFLINER_H_ 89 #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