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

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

Issue 2873393004: [Offline pages] Stop observing web contents and reset to null after use. Only create a new web cont… (Closed)
Patch Set: Created 3 years, 7 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 content::NavigationHandle* navigation_handle) override; 55 content::NavigationHandle* navigation_handle) override;
56 56
57 // SnapshotController::Client implementation. 57 // SnapshotController::Client implementation.
58 void StartSnapshot() override; 58 void StartSnapshot() override;
59 59
60 void SetSnapshotControllerForTest( 60 void SetSnapshotControllerForTest(
61 std::unique_ptr<SnapshotController> controller); 61 std::unique_ptr<SnapshotController> controller);
62 void OnNetworkBytesChanged(int64_t bytes); 62 void OnNetworkBytesChanged(int64_t bytes);
63 63
64 protected: 64 protected:
65 // Called to reset internal loader and observer state. 65 // Called to reset the loader.
66 virtual void ResetState(); 66 virtual void ResetLoader();
67 67
68 private: 68 private:
69 friend class TestBackgroundLoaderOffliner; 69 friend class TestBackgroundLoaderOffliner;
70 70
71 enum SaveState { NONE, SAVING, DELETE_AFTER_SAVE }; 71 enum SaveState { NONE, SAVING, DELETE_AFTER_SAVE };
72 enum PageLoadState { SUCCESS, RETRIABLE, NONRETRIABLE, DELAY_RETRY }; 72 enum PageLoadState { SUCCESS, RETRIABLE, NONRETRIABLE, DELAY_RETRY };
73 73
74 // Called when the page has been saved. 74 // Called when the page has been saved.
75 void OnPageSaved(SavePageResult save_result, int64_t offline_id); 75 void OnPageSaved(SavePageResult save_result, int64_t offline_id);
76 76
77 // Called to reset internal loader and observer state.
78 void ResetState();
79
80 // Called to attach 'this' as the observer to the loader.
81 void AttachObservers();
82
77 // Called when application state has changed. 83 // Called when application state has changed.
78 void OnApplicationStateChange( 84 void OnApplicationStateChange(
79 base::android::ApplicationState application_state); 85 base::android::ApplicationState application_state);
80 void HandleApplicationStateChangeCancel(const SavePageRequest& request, 86 void HandleApplicationStateChangeCancel(const SavePageRequest& request,
81 int64_t offline_id); 87 int64_t offline_id);
82 88
83 std::unique_ptr<background_loader::BackgroundLoaderContents> loader_; 89 std::unique_ptr<background_loader::BackgroundLoaderContents> loader_;
84 // Not owned. 90 // Not owned.
85 content::BrowserContext* browser_context_; 91 content::BrowserContext* browser_context_;
86 // Not owned. 92 // Not owned.
(...skipping 20 matching lines...) Expand all
107 113
108 // Callback for cancel. 114 // Callback for cancel.
109 CancelCallback cancel_callback_; 115 CancelCallback cancel_callback_;
110 116
111 base::WeakPtrFactory<BackgroundLoaderOffliner> weak_ptr_factory_; 117 base::WeakPtrFactory<BackgroundLoaderOffliner> weak_ptr_factory_;
112 DISALLOW_COPY_AND_ASSIGN(BackgroundLoaderOffliner); 118 DISALLOW_COPY_AND_ASSIGN(BackgroundLoaderOffliner);
113 }; 119 };
114 120
115 } // namespace offline_pages 121 } // namespace offline_pages
116 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_BACKGROUND_LOADER_OFFLINER_H_ 122 #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