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 | 4 |
5 #ifndef COMPONENTS_SUGGESTIONS_IMAGE_MANAGER_H_ | 5 #ifndef COMPONENTS_SUGGESTIONS_IMAGE_MANAGER_H_ |
6 #define COMPONENTS_SUGGESTIONS_IMAGE_MANAGER_H_ | 6 #define COMPONENTS_SUGGESTIONS_IMAGE_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 // A class used to fetch server images asynchronously and manage the caching | 34 // A class used to fetch server images asynchronously and manage the caching |
35 // layer (both in memory and on disk). | 35 // layer (both in memory and on disk). |
36 class ImageManager : public ImageFetcherDelegate { | 36 class ImageManager : public ImageFetcherDelegate { |
37 public: | 37 public: |
38 typedef std::vector<ImageData> ImageDataVector; | 38 typedef std::vector<ImageData> ImageDataVector; |
39 | 39 |
40 ImageManager(scoped_ptr<ImageFetcher> image_fetcher, | 40 ImageManager(scoped_ptr<ImageFetcher> image_fetcher, |
41 scoped_ptr<leveldb_proto::ProtoDatabase<ImageData> > database, | 41 scoped_ptr<leveldb_proto::ProtoDatabase<ImageData> > database, |
42 const base::FilePath& database_dir); | 42 const base::FilePath& database_dir); |
43 virtual ~ImageManager(); | 43 ~ImageManager() override; |
44 | 44 |
45 virtual void Initialize(const SuggestionsProfile& suggestions); | 45 virtual void Initialize(const SuggestionsProfile& suggestions); |
46 | 46 |
47 // Should be called from the UI thread. | 47 // Should be called from the UI thread. |
48 virtual void GetImageForURL( | 48 virtual void GetImageForURL( |
49 const GURL& url, | 49 const GURL& url, |
50 base::Callback<void(const GURL&, const SkBitmap*)> callback); | 50 base::Callback<void(const GURL&, const SkBitmap*)> callback); |
51 | 51 |
52 protected: | 52 protected: |
53 // Perform additional tasks when an image has been fetched. | 53 // Perform additional tasks when an image has been fetched. |
54 virtual void OnImageFetched(const GURL& url, const SkBitmap* bitmap) override; | 54 void OnImageFetched(const GURL& url, const SkBitmap* bitmap) override; |
55 | 55 |
56 private: | 56 private: |
57 friend class MockImageManager; | 57 friend class MockImageManager; |
58 friend class ImageManagerTest; | 58 friend class ImageManagerTest; |
59 FRIEND_TEST_ALL_PREFIXES(ImageManagerTest, InitializeTest); | 59 FRIEND_TEST_ALL_PREFIXES(ImageManagerTest, InitializeTest); |
60 FRIEND_TEST_ALL_PREFIXES(ImageManagerTest, GetImageForURLNetworkCacheHit); | 60 FRIEND_TEST_ALL_PREFIXES(ImageManagerTest, GetImageForURLNetworkCacheHit); |
61 FRIEND_TEST_ALL_PREFIXES(ImageManagerTest, | 61 FRIEND_TEST_ALL_PREFIXES(ImageManagerTest, |
62 GetImageForURLNetworkCacheNotInitialized); | 62 GetImageForURLNetworkCacheNotInitialized); |
63 | 63 |
64 // Used for testing. | 64 // Used for testing. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 base::WeakPtrFactory<ImageManager> weak_ptr_factory_; | 139 base::WeakPtrFactory<ImageManager> weak_ptr_factory_; |
140 | 140 |
141 base::ThreadChecker thread_checker_; | 141 base::ThreadChecker thread_checker_; |
142 | 142 |
143 DISALLOW_COPY_AND_ASSIGN(ImageManager); | 143 DISALLOW_COPY_AND_ASSIGN(ImageManager); |
144 }; | 144 }; |
145 | 145 |
146 } // namespace suggestions | 146 } // namespace suggestions |
147 | 147 |
148 #endif // COMPONENTS_SUGGESTIONS_IMAGE_MANAGER_H_ | 148 #endif // COMPONENTS_SUGGESTIONS_IMAGE_MANAGER_H_ |
OLD | NEW |