Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 | 4 |
| 5 #ifndef COMPONENTS_FAVICON_CORE_LARGE_ICON_SERVICE_H_ | 5 #ifndef COMPONENTS_FAVICON_CORE_LARGE_ICON_SERVICE_H_ |
| 6 #define COMPONENTS_FAVICON_CORE_LARGE_ICON_SERVICE_H_ | 6 #define COMPONENTS_FAVICON_CORE_LARGE_ICON_SERVICE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | |
|
pkotwicz
2015/05/11 18:57:39
Nit: The include can now be in the .cc file?
huangs
2015/05/11 20:24:37
Done.
| |
| 10 #include "base/task/cancelable_task_tracker.h" | 11 #include "base/task/cancelable_task_tracker.h" |
| 11 #include "components/favicon_base/favicon_callback.h" | 12 #include "components/favicon_base/favicon_callback.h" |
| 12 #include "components/keyed_service/core/keyed_service.h" | 13 #include "components/keyed_service/core/keyed_service.h" |
| 13 | 14 |
| 14 class GURL; | 15 class GURL; |
| 15 | 16 |
| 16 namespace favicon_base { | 17 namespace base { |
| 17 struct FaviconRawBitmapResult; | 18 class TaskRunner; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace favicon { | 21 namespace favicon { |
| 21 | 22 |
| 22 class FaviconService; | 23 class FaviconService; |
| 23 | 24 |
| 24 // The large icon service provides methods to access large icons. It relies on | 25 // The large icon service provides methods to access large icons. It relies on |
| 25 // the favicon service. | 26 // the favicon service. |
| 26 class LargeIconService : public KeyedService { | 27 class LargeIconService : public KeyedService { |
| 27 public: | 28 public: |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 40 // - Returns the default fallback icon style. | 41 // - Returns the default fallback icon style. |
| 41 // For cases 2 and 3, this function returns the style of the fallback icon | 42 // For cases 2 and 3, this function returns the style of the fallback icon |
| 42 // instead of rendering an icon so clients can render the icon themselves. | 43 // instead of rendering an icon so clients can render the icon themselves. |
| 43 base::CancelableTaskTracker::TaskId GetLargeIconOrFallbackStyle( | 44 base::CancelableTaskTracker::TaskId GetLargeIconOrFallbackStyle( |
| 44 const GURL& page_url, | 45 const GURL& page_url, |
| 45 int min_source_size_in_pixel, | 46 int min_source_size_in_pixel, |
| 46 int desired_size_in_pixel, | 47 int desired_size_in_pixel, |
| 47 const favicon_base::LargeIconCallback& callback, | 48 const favicon_base::LargeIconCallback& callback, |
| 48 base::CancelableTaskTracker* tracker); | 49 base::CancelableTaskTracker* tracker); |
| 49 | 50 |
| 51 // Returns TaskRunner used to execute background task. | |
| 52 virtual scoped_refptr<base::TaskRunner> GetBackgroundTaskRunner(); | |
| 53 | |
| 50 private: | 54 private: |
| 51 // For testing. | 55 // For testing. |
| 52 friend class TestLargeIconService; | 56 friend class TestLargeIconService; |
| 53 | 57 |
| 54 // Resizes |bitmap_result| to |desired_size_in_pixel|x|desired_size_in_pixel|. | |
| 55 // Stores the resized bitmap data in |resized_bitmap_result| and returns true | |
| 56 // if successful. | |
| 57 bool ResizeLargeIconIfValid( | |
| 58 int min_source_size_in_pixel, | |
| 59 int desired_size_in_pixel, | |
| 60 const favicon_base::FaviconRawBitmapResult& bitmap_result, | |
| 61 favicon_base::FaviconRawBitmapResult* resized_bitmap_result); | |
| 62 | |
| 63 // Intermediate callback for GetLargeIconOrFallbackStyle(). Tries to resize | |
| 64 // |bitmap_result| and pass the output to |callback|. If that does not work, | |
| 65 // computes the icon fallback style and uses it to invoke |callback|. | |
| 66 void RunLargeIconCallback( | |
| 67 const favicon_base::LargeIconCallback& callback, | |
| 68 int min_source_size_in_pixel, | |
| 69 int desired_size_in_pixel, | |
| 70 const favicon_base::FaviconRawBitmapResult& bitmap_result); | |
| 71 | |
| 72 FaviconService* favicon_service_; | 58 FaviconService* favicon_service_; |
| 73 | 59 |
| 74 // A pre-populated list of the types of icon files to consider when looking | 60 // A pre-populated list of icon types to consider when looking for large |
| 75 // for large icons. This is an optimization over populating an icon type | 61 // icons. This is an optimization over populating an icon type vector on each |
| 76 // vector on each request. | 62 // request. |
| 77 std::vector<int> large_icon_types_; | 63 std::vector<int> large_icon_types_; |
| 78 | 64 |
| 79 DISALLOW_COPY_AND_ASSIGN(LargeIconService); | 65 DISALLOW_COPY_AND_ASSIGN(LargeIconService); |
| 80 }; | 66 }; |
| 81 | 67 |
| 82 } // namespace favicon | 68 } // namespace favicon |
| 83 | 69 |
| 84 #endif // COMPONENTS_FAVICON_CORE_LARGE_ICON_SERVICE_H_ | 70 #endif // COMPONENTS_FAVICON_CORE_LARGE_ICON_SERVICE_H_ |
| OLD | NEW |