| 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 CHROME_BROWSER_BITMAP_FETCHER_BITMAP_FETCHER_SERVICE_H_ | 4 #ifndef CHROME_BROWSER_BITMAP_FETCHER_BITMAP_FETCHER_SERVICE_H_ |
| 5 #define CHROME_BROWSER_BITMAP_FETCHER_BITMAP_FETCHER_SERVICE_H_ | 5 #define CHROME_BROWSER_BITMAP_FETCHER_BITMAP_FETCHER_SERVICE_H_ |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <vector> |
| 8 | 9 |
| 9 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 10 #include "base/containers/mru_cache.h" | 11 #include "base/containers/mru_cache.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/memory/scoped_vector.h" | |
| 13 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_delegate.h" | 13 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_delegate.h" |
| 14 #include "components/keyed_service/core/keyed_service.h" | 14 #include "components/keyed_service/core/keyed_service.h" |
| 15 #include "net/traffic_annotation/network_traffic_annotation.h" | 15 #include "net/traffic_annotation/network_traffic_annotation.h" |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 class BrowserContext; | 18 class BrowserContext; |
| 19 } // namespace content | 19 } // namespace content |
| 20 | 20 |
| 21 namespace chrome { | 21 namespace chrome { |
| 22 class BitmapFetcher; | 22 class BitmapFetcher; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 // the list. | 89 // the list. |
| 90 void RemoveFetcher(const chrome::BitmapFetcher* fetcher); | 90 void RemoveFetcher(const chrome::BitmapFetcher* fetcher); |
| 91 | 91 |
| 92 // BitmapFetcherDelegate implementation. | 92 // BitmapFetcherDelegate implementation. |
| 93 void OnFetchComplete(const GURL& url, const SkBitmap* bitmap) override; | 93 void OnFetchComplete(const GURL& url, const SkBitmap* bitmap) override; |
| 94 | 94 |
| 95 // Currently active image fetchers. | 95 // Currently active image fetchers. |
| 96 std::vector<std::unique_ptr<chrome::BitmapFetcher>> active_fetchers_; | 96 std::vector<std::unique_ptr<chrome::BitmapFetcher>> active_fetchers_; |
| 97 | 97 |
| 98 // Currently active requests. | 98 // Currently active requests. |
| 99 ScopedVector<BitmapFetcherRequest> requests_; | 99 std::vector<std::unique_ptr<BitmapFetcherRequest>> requests_; |
| 100 | 100 |
| 101 // Cache of retrieved images. | 101 // Cache of retrieved images. |
| 102 struct CacheEntry { | 102 struct CacheEntry { |
| 103 CacheEntry(); | 103 CacheEntry(); |
| 104 ~CacheEntry(); | 104 ~CacheEntry(); |
| 105 | 105 |
| 106 std::unique_ptr<const SkBitmap> bitmap; | 106 std::unique_ptr<const SkBitmap> bitmap; |
| 107 }; | 107 }; |
| 108 base::MRUCache<GURL, std::unique_ptr<CacheEntry>> cache_; | 108 base::MRUCache<GURL, std::unique_ptr<CacheEntry>> cache_; |
| 109 | 109 |
| 110 // Current request ID to be used. | 110 // Current request ID to be used. |
| 111 int current_request_id_; | 111 int current_request_id_; |
| 112 | 112 |
| 113 // Browser context this service is active for. | 113 // Browser context this service is active for. |
| 114 content::BrowserContext* context_; | 114 content::BrowserContext* context_; |
| 115 | 115 |
| 116 DISALLOW_COPY_AND_ASSIGN(BitmapFetcherService); | 116 DISALLOW_COPY_AND_ASSIGN(BitmapFetcherService); |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 #endif // CHROME_BROWSER_BITMAP_FETCHER_BITMAP_FETCHER_SERVICE_H_ | 119 #endif // CHROME_BROWSER_BITMAP_FETCHER_BITMAP_FETCHER_SERVICE_H_ |
| OLD | NEW |