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

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

Issue 476573004: Set version field when changes are made to enhanced bookmarks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Added flags TODO Created 6 years, 3 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
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"
11 #include "components/enhanced_bookmarks/image_store.h" 11 #include "components/enhanced_bookmarks/image_store.h"
12 #include "components/keyed_service/core/keyed_service.h" 12 #include "components/keyed_service/core/keyed_service.h"
13 #include "net/url_request/url_request.h" 13 #include "net/url_request/url_request.h"
14 #include "url/gurl.h" 14 #include "url/gurl.h"
15 15
16 namespace base { 16 namespace base {
17 class SingleThreadTaskRunner; 17 class SingleThreadTaskRunner;
18 } 18 }
19 class BookmarkNode; 19 class BookmarkNode;
20 20
21 namespace enhanced_bookmarks { 21 namespace enhanced_bookmarks {
22 22
23 class EnhancedBookmarkModel;
24
23 // The BookmarkImageService stores salient images for bookmarks. 25 // The BookmarkImageService stores salient images for bookmarks.
24 class BookmarkImageService : public KeyedService, 26 class BookmarkImageService : public KeyedService,
25 public BookmarkModelObserver, 27 public BookmarkModelObserver,
26 public base::NonThreadSafe { 28 public base::NonThreadSafe {
27 public: 29 public:
28 explicit BookmarkImageService(const base::FilePath& path, 30 BookmarkImageService(const base::FilePath& path,
29 BookmarkModel* bookmark_model, 31 BookmarkModel* bookmark_model,
30 scoped_refptr<base::SequencedWorkerPool> pool); 32 EnhancedBookmarkModel* enhanced_bookmark_model,
noyau (Ping after 24h) 2014/09/05 12:04:43 Can't we access the bookmark_model inside the enha
Rune Fevang 2014/09/06 00:01:56 Done.
33 scoped_refptr<base::SequencedWorkerPool> pool);
31 BookmarkImageService(scoped_ptr<ImageStore> store, 34 BookmarkImageService(scoped_ptr<ImageStore> store,
32 BookmarkModel* bookmark_model, 35 BookmarkModel* bookmark_model,
36 EnhancedBookmarkModel* enhanced_bookmark_model,
33 scoped_refptr<base::SequencedWorkerPool> pool); 37 scoped_refptr<base::SequencedWorkerPool> pool);
34 38
35 virtual ~BookmarkImageService(); 39 virtual ~BookmarkImageService();
36 40
37 typedef base::Callback<void(const gfx::Image&, const GURL& url)> Callback; 41 typedef base::Callback<void(const gfx::Image&, const GURL& url)> Callback;
38 42
39 // Returns a salient image for a URL. This may trigger a network request for 43 // Returns a salient image for a URL. This may trigger a network request for
40 // the image if the image was not retrieved before and if a bookmark node has 44 // the image if the image was not retrieved before and if a bookmark node has
41 // a URL for this salient image available. The image (which may be empty) is 45 // a URL for this salient image available. The image (which may be empty) is
42 // sent via the callback. The callback may be called synchronously if it is 46 // sent via the callback. The callback may be called synchronously if it is
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 net::URLRequest::ReferrerPolicy referrer_policy, 97 net::URLRequest::ReferrerPolicy referrer_policy,
94 bool update_bookmark) = 0; 98 bool update_bookmark) = 0;
95 99
96 // Retrieves a salient image for a given page_url by downloading the image in 100 // Retrieves a salient image for a given page_url by downloading the image in
97 // one of the bookmark. 101 // one of the bookmark.
98 virtual void RetrieveSalientImageForPageUrl(const GURL& page_url); 102 virtual void RetrieveSalientImageForPageUrl(const GURL& page_url);
99 103
100 // PageUrls currently in the progress of being retrieved. 104 // PageUrls currently in the progress of being retrieved.
101 std::set<GURL> in_progress_page_urls_; 105 std::set<GURL> in_progress_page_urls_;
102 106
103 // Cached pointer to the bookmarks model. 107 // Cached pointers to the bookmark models.
104 BookmarkModel* bookmark_model_; // weak 108 BookmarkModel* bookmark_model_; // weak
109 EnhancedBookmarkModel* enhanced_bookmark_model_;
105 110
106 private: 111 private:
107 // Same as SalientImageForUrl(const GURL&, Callback) but can prevent the 112 // Same as SalientImageForUrl(const GURL&, Callback) but can prevent the
108 // network request if fetch_from_bookmark is false. 113 // network request if fetch_from_bookmark is false.
109 void SalientImageForUrl(const GURL& page_url, 114 void SalientImageForUrl(const GURL& page_url,
110 bool fetch_from_bookmark, 115 bool fetch_from_bookmark,
111 Callback stack_callback); 116 Callback stack_callback);
112 117
113 // Processes the requests that have been waiting on an image. 118 // Processes the requests that have been waiting on an image.
114 void ProcessRequests(const GURL& page_url, 119 void ProcessRequests(const GURL& page_url,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 GURL previous_url_; 163 GURL previous_url_;
159 164
160 // The worker pool to enqueue the store requests onto. 165 // The worker pool to enqueue the store requests onto.
161 scoped_refptr<base::SequencedWorkerPool> pool_; 166 scoped_refptr<base::SequencedWorkerPool> pool_;
162 DISALLOW_COPY_AND_ASSIGN(BookmarkImageService); 167 DISALLOW_COPY_AND_ASSIGN(BookmarkImageService);
163 }; 168 };
164 169
165 } // namespace enhanced_bookmarks 170 } // namespace enhanced_bookmarks
166 171
167 #endif // COMPONENTS_ENHANCED_BOOKMARKS_BOOKMARK_IMAGE_SERVICE_H_ 172 #endif // COMPONENTS_ENHANCED_BOOKMARKS_BOOKMARK_IMAGE_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698