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

Side by Side Diff: ios/chrome/browser/dom_distiller/web_state_pool_impl.h

Issue 2529283002: Save favicon during reading list distillation (Closed)
Patch Set: Use WebState pool Created 4 years 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_DOM_DISTILLER_WEB_STATE_POOL_IMPL_H_
6 #define IOS_CHROME_BROWSER_DOM_DISTILLER_WEB_STATE_POOL_IMPL_H_
7
8 #include <list>
9 #include <map>
10 #include <memory>
11
12 #include "base/memory/weak_ptr.h"
13 #include "components/dom_distiller/ios/web_state_pool.h"
14 #include "components/favicon/core/favicon_driver_observer.h"
15 #import "ios/web/public/web_state/web_state.h"
16
17 namespace favicon {
18 class FaviconDriver;
19 }
20
21 class GURL;
22
23 namespace gfx {
24 class Image;
25 }
26
27 namespace dom_distiller {
28
29 // Implementation of the WebStatePool.
30 class WebStatePoolImpl : public WebStatePool, favicon::FaviconDriverObserver {
31 public:
32 WebStatePoolImpl(web::BrowserState* browser_state);
33 ~WebStatePoolImpl() override;
34
35 // WebStatePool implementation.
36 void RequestWebState(WebStatePoolDelegate* delegate) override;
37 void ReturnWebState(web::WebState* web_state) override;
38
39 // FaviconDriverObserver implementation.
40 void OnFaviconUpdated(favicon::FaviconDriver* favicon_driver,
41 NotificationIconType notification_icon_type,
42 const GURL& icon_url,
43 bool icon_url_changed,
44 const gfx::Image& image) override;
45
46 private:
47 // Creates a WebState at the index position with a favicon driver. This object
48 // is an observer for the favicon driver.
49 void CreateWebState(int web_state_index);
50 // Removes the corresponding WebState from the list of WebStates used by
51 // favicon drivers.
52 void OnFaviconDownloaded(favicon::FaviconDriver*);
53 // Returns the index of the first WebState available, -1 if no WebState is
54 // available.
55 int GetFirstWebStateAvailable();
56
57 web::BrowserState* browser_state_;
58 // List of delegates waiting for a WebState.
59 std::list<WebStatePoolDelegate*> pending_delegates_;
60 // List of unique pointers to the WebStates. Used only to ensure the lifespan
61 // of the WebStates.
62 std::vector<std::unique_ptr<web::WebState>> unique_web_states_;
63 // Corresponding list of raw pointers to the WebStates.
64 std::vector<web::WebState*> web_states_;
65 // Map of the WebStates used by Favicon Drivers.
66 std::map<favicon::FaviconDriver*, int> favicon_web_state_;
67 // Map of the WebStates used by the delegates.
68 std::map<web::WebState*, int> registered_web_state_;
69 base::WeakPtrFactory<WebStatePoolImpl> weak_ptr_factory_;
70 };
71
72 } // namespace dom_distiller
73
74 #endif // IOS_CHROME_BROWSER_DOM_DISTILLER_WEB_STATE_POOL_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698