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

Side by Side Diff: ios/chrome/browser/reading_list/reading_list_web_state_observer.h

Issue 2378123002: Load offline page if reading list entry takes more than 1s to load. (Closed)
Patch Set: Experimental change (reviewers: do not review this PS). 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef IOS_CHROME_BROWSER_READING_LIST_READING_LIST_WEB_STATE_OBSERVER_H_
6 #define IOS_CHROME_BROWSER_READING_LIST_READING_LIST_WEB_STATE_OBSERVER_H_
7
8 #include "base/macros.h"
9 #include "base/timer/timer.h"
10 #include "ios/web/public/web_state/web_state_observer.h"
11 #include "ios/web/public/web_state/web_state_user_data.h"
12
13 class BrowserState;
14 class ReadingListModel;
15
16 // Observes the loading of pages coming from the reading list and determines
17 // whether and loading an offline version of the page is needed.
18 class ReadingListWebStateObserver
19 : public web::WebStateUserData<ReadingListWebStateObserver>,
20 public web::WebStateObserver {
21 public:
22 static void CreateForWebState(web::WebState* web_state,
23 web::BrowserState* browser_state);
sdefresne 2016/10/04 13:26:46 You should pass a ios::ChromeBrowserState, only co
24
25 ~ReadingListWebStateObserver() override;
26
27 private:
28 explicit ReadingListWebStateObserver(web::WebState* web_state,
sdefresne 2016/10/04 13:26:46 "explicit" is for constructor with one parameter o
29 web::BrowserState* browser_state);
30 friend class WebStateUserData<ReadingListWebStateObserver>;
31
32 // WebContentsObserver implementation.
33 void NavigationItemChanged() override;
34 void NavigationItemCommitted(
35 const web::LoadCommittedDetails& load_details) override;
36 void DidStartLoading() override;
37 void DidStopLoading() override;
38 void PageLoaded(
39 web::PageLoadCompletionStatus load_completion_status) override;
40 void WebStateDestroyed() override;
41
42 private:
43 // Heuristically determine if the reading list entry is loading quickly.
44 // If it doesn't load quickly, tries to load an offline version of the page.
45 void VerifyIfReadingListEntryStartedLoading();
46
47 web::WebState* web_state_;
48 ReadingListModel* reading_list_model_;
49 std::unique_ptr<base::Timer> timer_;
50
51 DISALLOW_COPY_AND_ASSIGN(ReadingListWebStateObserver);
52 };
53
54 #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_WEB_STATE_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698