Chromium Code Reviews| 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" |
| 11 #include "components/enhanced_bookmarks/image_record.h" | 11 #include "components/enhanced_bookmarks/image_record.h" |
| 12 #include "components/enhanced_bookmarks/image_store.h" | 12 #include "components/enhanced_bookmarks/image_store.h" |
| 13 #include "components/keyed_service/core/keyed_service.h" | 13 #include "components/keyed_service/core/keyed_service.h" |
| 14 #include "net/url_request/url_request.h" | 14 #include "net/url_request/url_request.h" |
| 15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 16 | 16 |
| 17 namespace base { | 17 namespace base { |
| 18 class SingleThreadTaskRunner; | 18 class SingleThreadTaskRunner; |
| 19 } | 19 } |
| 20 | |
| 21 namespace bookmarks { | |
| 20 class BookmarkNode; | 22 class BookmarkNode; |
| 23 } | |
| 21 | 24 |
| 22 namespace enhanced_bookmarks { | 25 namespace enhanced_bookmarks { |
| 23 | 26 |
| 24 class EnhancedBookmarkModel; | 27 class EnhancedBookmarkModel; |
| 25 | 28 |
| 26 // The BookmarkImageService stores salient images for bookmarks. | 29 // The BookmarkImageService stores salient images for bookmarks. |
| 27 class BookmarkImageService : public KeyedService, | 30 class BookmarkImageService : public KeyedService, |
| 28 public bookmarks::BookmarkModelObserver, | 31 public bookmarks::BookmarkModelObserver, |
| 29 public base::NonThreadSafe { | 32 public base::NonThreadSafe { |
| 30 public: | 33 public: |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 44 | 47 |
| 45 // Returns a salient image for a URL. This may trigger a network request for | 48 // Returns a salient image for a URL. This may trigger a network request for |
| 46 // the image if the image was not retrieved before and if a bookmark node has | 49 // the image if the image was not retrieved before and if a bookmark node has |
| 47 // a URL for this salient image available. The image (which may be empty) is | 50 // a URL for this salient image available. The image (which may be empty) is |
| 48 // sent via the callback. The callback may be called synchronously if it is | 51 // sent via the callback. The callback may be called synchronously if it is |
| 49 // possible. The callback is always triggered on the main thread. | 52 // possible. The callback is always triggered on the main thread. |
| 50 void SalientImageForUrl(const GURL& page_url, ImageCallback callback); | 53 void SalientImageForUrl(const GURL& page_url, ImageCallback callback); |
| 51 | 54 |
| 52 // bookmarks::BookmarkModelObserver: | 55 // bookmarks::BookmarkModelObserver: |
| 53 void BookmarkNodeRemoved(bookmarks::BookmarkModel* model, | 56 void BookmarkNodeRemoved(bookmarks::BookmarkModel* model, |
| 54 const BookmarkNode* parent, | 57 const bookmarks::BookmarkNode* parent, |
| 55 int old_index, | 58 int old_index, |
| 56 const BookmarkNode* node, | 59 const bookmarks::BookmarkNode* node, |
| 57 const std::set<GURL>& removed_urls) override; | 60 const std::set<GURL>& removed_urls) override; |
| 58 void BookmarkModelLoaded(bookmarks::BookmarkModel* model, | 61 void BookmarkModelLoaded(bookmarks::BookmarkModel* model, |
| 59 bool ids_reassigned) override; | 62 bool ids_reassigned) override; |
| 60 void BookmarkNodeMoved(bookmarks::BookmarkModel* model, | 63 void BookmarkNodeMoved(bookmarks::BookmarkModel* model, |
| 61 const BookmarkNode* old_parent, | 64 const bookmarks::BookmarkNode* old_parent, |
| 62 int old_index, | 65 int old_index, |
| 63 const BookmarkNode* new_parent, | 66 const bookmarks::BookmarkNode* new_parent, |
| 64 int new_index) override; | 67 int new_index) override; |
| 65 void BookmarkNodeAdded(bookmarks::BookmarkModel* model, | 68 void BookmarkNodeAdded(bookmarks::BookmarkModel* model, |
| 66 const BookmarkNode* parent, | 69 const bookmarks::BookmarkNode* parent, |
| 67 int index) override; | 70 int index) override; |
| 68 void OnWillChangeBookmarkNode(bookmarks::BookmarkModel* model, | 71 void OnWillChangeBookmarkNode(bookmarks::BookmarkModel* model, |
| 69 const BookmarkNode* node) override; | 72 const bookmarks::BookmarkNode* node) override; |
| 70 void BookmarkNodeChanged(bookmarks::BookmarkModel* model, | 73 void BookmarkNodeChanged(bookmarks::BookmarkModel* model, |
| 71 const BookmarkNode* node) override; | 74 const bookmarks::BookmarkNode* node) override; |
| 72 void BookmarkNodeFaviconChanged(bookmarks::BookmarkModel* model, | 75 void BookmarkNodeFaviconChanged(bookmarks::BookmarkModel* model, |
| 73 const BookmarkNode* node) override; | 76 const bookmarks::BookmarkNode* node) override; |
| 74 void BookmarkNodeChildrenReordered(bookmarks::BookmarkModel* model, | 77 void BookmarkNodeChildrenReordered( |
| 75 const BookmarkNode* node) override; | 78 bookmarks::BookmarkModel* model, |
| 79 const bookmarks::BookmarkNode* node) override; | |
| 76 void BookmarkAllUserNodesRemoved(bookmarks::BookmarkModel* model, | 80 void BookmarkAllUserNodesRemoved(bookmarks::BookmarkModel* model, |
| 77 const std::set<GURL>& removed_urls) override; | 81 const std::set<GURL>& removed_urls) override; |
| 78 | 82 |
| 79 protected: | 83 protected: |
| 80 // 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. |
| 81 bool IsPageUrlInProgress(const GURL& page_url); | 85 bool IsPageUrlInProgress(const GURL& page_url); |
| 82 | 86 |
| 83 // Once an image has been retrieved, store the image and notify all the | 87 // Once an image has been retrieved, store the image and notify all the |
| 84 // consumers that were waiting on it. | 88 // consumers that were waiting on it. |
| 85 void ProcessNewImage(const GURL& page_url, | 89 void ProcessNewImage(const GURL& page_url, |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 // before the change is saved in this instance variable. | 174 // before the change is saved in this instance variable. |
| 171 GURL previous_url_; | 175 GURL previous_url_; |
| 172 | 176 |
| 173 // The worker pool to enqueue the requests onto. | 177 // The worker pool to enqueue the requests onto. |
| 174 scoped_refptr<base::SequencedWorkerPool> pool_; | 178 scoped_refptr<base::SequencedWorkerPool> pool_; |
| 175 DISALLOW_COPY_AND_ASSIGN(BookmarkImageService); | 179 DISALLOW_COPY_AND_ASSIGN(BookmarkImageService); |
| 176 }; | 180 }; |
| 177 | 181 |
| 178 } // namespace enhanced_bookmarks | 182 } // namespace enhanced_bookmarks |
| 179 | 183 |
| 180 #endif // COMPONENTS_ENHANCED_BOOKMARKS_BOOKMARK_IMAGE_SERVICE_H_ | 184 #endif // COMPONENTS_ENHANCED_BOOKMARKS_BOOKMARK_IMAGE_SERVICE_H_/home/tfarina/ chromium/src/buildtools/linux64/clang-format |
|
sky
2015/02/03 17:08:37
Yay, I found one thing that needs fixing.
tfarina
2015/02/04 20:51:14
Done.
| |
| 185 | |
| OLD | NEW |