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

Side by Side Diff: components/enhanced_bookmarks/bookmark_image_service.h

Issue 899653003: [Enhanced Bookmark]Upstream image fetching code in android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 5 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 | « chrome/chrome_browser.gypi ('k') | components/enhanced_bookmarks/bookmark_image_service.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef COMPONENTS_ENHANCED_BOOKMARKS_BOOKMARK_IMAGE_SERVICE_H_ 4 #ifndef COMPONENTS_ENHANCED_BOOKMARKS_BOOKMARK_IMAGE_SERVICE_H_
5 #define COMPONENTS_ENHANCED_BOOKMARKS_BOOKMARK_IMAGE_SERVICE_H_ 5 #define COMPONENTS_ENHANCED_BOOKMARKS_BOOKMARK_IMAGE_SERVICE_H_
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/singleton.h" 9 #include "base/memory/singleton.h"
10 #include "components/bookmarks/browser/bookmark_model_observer.h" 10 #include "components/bookmarks/browser/bookmark_model_observer.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 void BookmarkNodeChildrenReordered( 77 void BookmarkNodeChildrenReordered(
78 bookmarks::BookmarkModel* model, 78 bookmarks::BookmarkModel* model,
79 const bookmarks::BookmarkNode* node) override; 79 const bookmarks::BookmarkNode* node) override;
80 void BookmarkAllUserNodesRemoved(bookmarks::BookmarkModel* model, 80 void BookmarkAllUserNodesRemoved(bookmarks::BookmarkModel* model,
81 const std::set<GURL>& removed_urls) override; 81 const std::set<GURL>& removed_urls) override;
82 82
83 protected: 83 protected:
84 // Returns true if the image for the page_url is currently being fetched. 84 // Returns true if the image for the page_url is currently being fetched.
85 bool IsPageUrlInProgress(const GURL& page_url); 85 bool IsPageUrlInProgress(const GURL& page_url);
86 86
87 // Once an image has been retrieved, store the image and notify all the 87 // Stores the image to local storage. If update_bookmarks is true, relates the
88 // consumers that were waiting on it. 88 // corresponding bookmark to image_url.
89 void ProcessNewImage(const GURL& page_url, 89 void ProcessNewImage(const GURL& page_url,
90 bool update_bookmarks, 90 bool update_bookmarks,
91 const gfx::Image& image, 91 const gfx::Image& image,
92 const GURL& image_url); 92 const GURL& image_url);
93 93
94 // Sets a new image for a bookmark. If the given page_url is bookmarked and 94 // Sets a new image for a bookmark. If the given page_url is bookmarked and
95 // the image is retrieved from the image_url, then the image is locally 95 // the image is retrieved from the image_url, then the image is locally
96 // stored. If update_bookmark is true the URL is also added to the bookmark. 96 // stored. If update_bookmark is true the URL is also added to the bookmark.
97 // This is the only method subclass needs to implement. 97 // This is the only method subclass needs to implement.
98 virtual void RetrieveSalientImage( 98 virtual void RetrieveSalientImage(
99 const GURL& page_url, 99 const GURL& page_url,
100 const GURL& image_url, 100 const GURL& image_url,
101 const std::string& referrer, 101 const std::string& referrer,
102 net::URLRequest::ReferrerPolicy referrer_policy, 102 net::URLRequest::ReferrerPolicy referrer_policy,
103 bool update_bookmark) = 0; 103 bool update_bookmark) = 0;
104 104
105 // Retrieves a salient image for a given page_url by downloading the image in 105 // Retrieves a salient image for a given page_url by downloading the image in
106 // one of the bookmark. 106 // one of the bookmark.
107 virtual void RetrieveSalientImageForPageUrl(const GURL& page_url); 107 virtual void RetrieveSalientImageForPageUrl(const GURL& page_url);
108 108
109 // PageUrls currently in the progress of being retrieved. 109 // PageUrls currently in the progress of being retrieved.
110 std::set<GURL> in_progress_page_urls_; 110 std::set<GURL> in_progress_page_urls_;
111 111
112 // Cached pointer to the bookmark model. 112 // Cached pointer to the bookmark model.
113 EnhancedBookmarkModel* enhanced_bookmark_model_; 113 EnhancedBookmarkModel* enhanced_bookmark_model_;
114 114
115 private: 115 private:
116 // Same as SalientImageForUrl(const GURL&, ImageCallback) but can 116 // If fetch_from_web is true, retrieves the salient image via a network
117 // prevent the network request if fetch_from_bookmark is false. 117 // request; else only gets the image from local storage.
118 void SalientImageForUrl(const GURL& page_url, 118 void SalientImageForUrl(const GURL& page_url,
119 bool fetch_from_bookmark, 119 bool fetch_from_web,
120 ImageCallback stack_callback); 120 ImageCallback stack_callback);
121 121
122 // Processes the requests that have been waiting on an image. 122 // Processes the requests that have been waiting on an image.
123 void ProcessRequests(const GURL& page_url, const ImageRecord& image); 123 void ProcessRequests(const GURL& page_url, const ImageRecord& image);
124 124
125 // Once an image is retrieved this method updates the store with it. Returns 125 // Once an image is retrieved this method updates the store with it. Returns
126 // the newly formed ImageRecord. This is typically called on |pool_|, the 126 // the newly formed ImageRecord. This is typically called on |pool_|, the
127 // background sequenced worker pool for this object. 127 // background sequenced worker pool for this object.
128 ImageRecord StoreImage(const gfx::Image& image, 128 ImageRecord StoreImage(const gfx::Image& image,
129 const GURL& image_url, 129 const GURL& image_url,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 176
177 // The worker pool to enqueue the requests onto. 177 // The worker pool to enqueue the requests onto.
178 scoped_refptr<base::SequencedWorkerPool> pool_; 178 scoped_refptr<base::SequencedWorkerPool> pool_;
179 DISALLOW_COPY_AND_ASSIGN(BookmarkImageService); 179 DISALLOW_COPY_AND_ASSIGN(BookmarkImageService);
180 }; 180 };
181 181
182 } // namespace enhanced_bookmarks 182 } // namespace enhanced_bookmarks
183 183
184 #endif // COMPONENTS_ENHANCED_BOOKMARKS_BOOKMARK_IMAGE_SERVICE_H_ 184 #endif // COMPONENTS_ENHANCED_BOOKMARKS_BOOKMARK_IMAGE_SERVICE_H_
185 185
OLDNEW
« no previous file with comments | « chrome/chrome_browser.gypi ('k') | components/enhanced_bookmarks/bookmark_image_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698