OLD | NEW |
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 21 matching lines...) Expand all Loading... |
32 scoped_refptr<base::SequencedWorkerPool> pool); | 32 scoped_refptr<base::SequencedWorkerPool> pool); |
33 BookmarkImageService(scoped_ptr<ImageStore> store, | 33 BookmarkImageService(scoped_ptr<ImageStore> store, |
34 EnhancedBookmarkModel* enhanced_bookmark_model, | 34 EnhancedBookmarkModel* enhanced_bookmark_model, |
35 scoped_refptr<base::SequencedWorkerPool> pool); | 35 scoped_refptr<base::SequencedWorkerPool> pool); |
36 | 36 |
37 virtual ~BookmarkImageService(); | 37 virtual ~BookmarkImageService(); |
38 | 38 |
39 typedef base::Callback<void(const gfx::Image&, const GURL& url)> Callback; | 39 typedef base::Callback<void(const gfx::Image&, const GURL& url)> Callback; |
40 | 40 |
41 // KeyedService: | 41 // KeyedService: |
42 virtual void Shutdown() OVERRIDE; | 42 virtual void Shutdown() override; |
43 | 43 |
44 // Returns a salient image for a URL. This may trigger a network request for | 44 // Returns a salient image for a URL. This may trigger a network request for |
45 // the image if the image was not retrieved before and if a bookmark node has | 45 // the image if the image was not retrieved before and if a bookmark node has |
46 // a URL for this salient image available. The image (which may be empty) is | 46 // a URL for this salient image available. The image (which may be empty) is |
47 // sent via the callback. The callback may be called synchronously if it is | 47 // sent via the callback. The callback may be called synchronously if it is |
48 // possible. The callback is always triggered on the main thread. | 48 // possible. The callback is always triggered on the main thread. |
49 void SalientImageForUrl(const GURL& page_url, Callback callback); | 49 void SalientImageForUrl(const GURL& page_url, Callback callback); |
50 | 50 |
51 // BookmarkModelObserver methods. | 51 // BookmarkModelObserver methods. |
52 virtual void BookmarkNodeRemoved(BookmarkModel* model, | 52 virtual void BookmarkNodeRemoved(BookmarkModel* model, |
53 const BookmarkNode* parent, | 53 const BookmarkNode* parent, |
54 int old_index, | 54 int old_index, |
55 const BookmarkNode* node, | 55 const BookmarkNode* node, |
56 const std::set<GURL>& removed_urls) OVERRIDE; | 56 const std::set<GURL>& removed_urls) override; |
57 virtual void BookmarkModelLoaded(BookmarkModel* model, | 57 virtual void BookmarkModelLoaded(BookmarkModel* model, |
58 bool ids_reassigned) OVERRIDE; | 58 bool ids_reassigned) override; |
59 virtual void BookmarkNodeMoved(BookmarkModel* model, | 59 virtual void BookmarkNodeMoved(BookmarkModel* model, |
60 const BookmarkNode* old_parent, | 60 const BookmarkNode* old_parent, |
61 int old_index, | 61 int old_index, |
62 const BookmarkNode* new_parent, | 62 const BookmarkNode* new_parent, |
63 int new_index) OVERRIDE; | 63 int new_index) override; |
64 virtual void BookmarkNodeAdded(BookmarkModel* model, | 64 virtual void BookmarkNodeAdded(BookmarkModel* model, |
65 const BookmarkNode* parent, | 65 const BookmarkNode* parent, |
66 int index) OVERRIDE; | 66 int index) override; |
67 virtual void OnWillChangeBookmarkNode(BookmarkModel* model, | 67 virtual void OnWillChangeBookmarkNode(BookmarkModel* model, |
68 const BookmarkNode* node) OVERRIDE; | 68 const BookmarkNode* node) override; |
69 virtual void BookmarkNodeChanged(BookmarkModel* model, | 69 virtual void BookmarkNodeChanged(BookmarkModel* model, |
70 const BookmarkNode* node) OVERRIDE; | 70 const BookmarkNode* node) override; |
71 virtual void BookmarkNodeFaviconChanged(BookmarkModel* model, | 71 virtual void BookmarkNodeFaviconChanged(BookmarkModel* model, |
72 const BookmarkNode* node) OVERRIDE; | 72 const BookmarkNode* node) override; |
73 virtual void BookmarkNodeChildrenReordered(BookmarkModel* model, | 73 virtual void BookmarkNodeChildrenReordered(BookmarkModel* model, |
74 const BookmarkNode* node) OVERRIDE; | 74 const BookmarkNode* node) override; |
75 virtual void BookmarkAllUserNodesRemoved( | 75 virtual void BookmarkAllUserNodesRemoved( |
76 BookmarkModel* model, | 76 BookmarkModel* model, |
77 const std::set<GURL>& removed_urls) OVERRIDE; | 77 const std::set<GURL>& removed_urls) override; |
78 | 78 |
79 protected: | 79 protected: |
80 // Returns true if the image for the page_url is currently being fetched. | 80 // Returns true if the image for the page_url is currently being fetched. |
81 bool IsPageUrlInProgress(const GURL& page_url); | 81 bool IsPageUrlInProgress(const GURL& page_url); |
82 | 82 |
83 // Once an image has been retrieved, store the image and notify all the | 83 // Once an image has been retrieved, store the image and notify all the |
84 // consumers that were waiting on it. | 84 // consumers that were waiting on it. |
85 void ProcessNewImage(const GURL& page_url, | 85 void ProcessNewImage(const GURL& page_url, |
86 bool update_bookmarks, | 86 bool update_bookmarks, |
87 const gfx::Image& image, | 87 const gfx::Image& image, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 GURL previous_url_; | 163 GURL previous_url_; |
164 | 164 |
165 // The worker pool to enqueue the store requests onto. | 165 // The worker pool to enqueue the store requests onto. |
166 scoped_refptr<base::SequencedWorkerPool> pool_; | 166 scoped_refptr<base::SequencedWorkerPool> pool_; |
167 DISALLOW_COPY_AND_ASSIGN(BookmarkImageService); | 167 DISALLOW_COPY_AND_ASSIGN(BookmarkImageService); |
168 }; | 168 }; |
169 | 169 |
170 } // namespace enhanced_bookmarks | 170 } // namespace enhanced_bookmarks |
171 | 171 |
172 #endif // COMPONENTS_ENHANCED_BOOKMARKS_BOOKMARK_IMAGE_SERVICE_H_ | 172 #endif // COMPONENTS_ENHANCED_BOOKMARKS_BOOKMARK_IMAGE_SERVICE_H_ |
OLD | NEW |