Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: components/suggestions/image_manager.h

Issue 1314493013: Popular sites on the NTP: add thumbnails! (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix android_clang_dbg_recipe build Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/android/popular_sites.cc ('k') | components/suggestions/image_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 30 matching lines...) Expand all
41 41
42 ImageManager(scoped_ptr<ImageFetcher> image_fetcher, 42 ImageManager(scoped_ptr<ImageFetcher> image_fetcher,
43 scoped_ptr<leveldb_proto::ProtoDatabase<ImageData>> database, 43 scoped_ptr<leveldb_proto::ProtoDatabase<ImageData>> database,
44 const base::FilePath& database_dir, 44 const base::FilePath& database_dir,
45 scoped_refptr<base::TaskRunner> background_task_runner); 45 scoped_refptr<base::TaskRunner> background_task_runner);
46 ~ImageManager() override; 46 ~ImageManager() override;
47 47
48 virtual void Initialize(const SuggestionsProfile& suggestions); 48 virtual void Initialize(const SuggestionsProfile& suggestions);
49 49
50 // Should be called from the UI thread. 50 // Should be called from the UI thread.
51 virtual void AddImageURL(const GURL& url, const GURL& image_url);
52
53 // Should be called from the UI thread.
51 virtual void GetImageForURL( 54 virtual void GetImageForURL(
52 const GURL& url, 55 const GURL& url,
53 base::Callback<void(const GURL&, const SkBitmap*)> callback); 56 base::Callback<void(const GURL&, const SkBitmap*)> callback);
54 57
55 protected: 58 protected:
56 // Perform additional tasks when an image has been fetched. 59 // Perform additional tasks when an image has been fetched.
57 void OnImageFetched(const GURL& url, const SkBitmap* bitmap) override; 60 void OnImageFetched(const GURL& url, const SkBitmap* bitmap) override;
58 61
59 private: 62 private:
60 friend class MockImageManager; 63 friend class MockImageManager;
61 friend class ImageManagerTest; 64 friend class ImageManagerTest;
62 FRIEND_TEST_ALL_PREFIXES(ImageManagerTest, InitializeTest); 65 FRIEND_TEST_ALL_PREFIXES(ImageManagerTest, InitializeTest);
66 FRIEND_TEST_ALL_PREFIXES(ImageManagerTest, AddImageURL);
63 FRIEND_TEST_ALL_PREFIXES(ImageManagerTest, GetImageForURLNetworkCacheHit); 67 FRIEND_TEST_ALL_PREFIXES(ImageManagerTest, GetImageForURLNetworkCacheHit);
64 FRIEND_TEST_ALL_PREFIXES(ImageManagerTest, 68 FRIEND_TEST_ALL_PREFIXES(ImageManagerTest,
65 GetImageForURLNetworkCacheNotInitialized); 69 GetImageForURLNetworkCacheNotInitialized);
66 70
67 // Used for testing. 71 // Used for testing.
68 ImageManager(); 72 ImageManager();
69 73
70 typedef std::vector<base::Callback<void(const GURL&, const SkBitmap*)> > 74 typedef std::vector<base::Callback<void(const GURL&, const SkBitmap*)> >
71 CallbackVector; 75 CallbackVector;
72 typedef base::hash_map<std::string, scoped_refptr<base::RefCountedMemory>> 76 typedef base::hash_map<std::string, scoped_refptr<base::RefCountedMemory>>
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 base::ThreadChecker thread_checker_; 150 base::ThreadChecker thread_checker_;
147 151
148 base::WeakPtrFactory<ImageManager> weak_ptr_factory_; 152 base::WeakPtrFactory<ImageManager> weak_ptr_factory_;
149 153
150 DISALLOW_COPY_AND_ASSIGN(ImageManager); 154 DISALLOW_COPY_AND_ASSIGN(ImageManager);
151 }; 155 };
152 156
153 } // namespace suggestions 157 } // namespace suggestions
154 158
155 #endif // COMPONENTS_SUGGESTIONS_IMAGE_MANAGER_H_ 159 #endif // COMPONENTS_SUGGESTIONS_IMAGE_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/popular_sites.cc ('k') | components/suggestions/image_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698