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

Side by Side Diff: chrome/browser/ui/webui/fileicon_source.h

Issue 11441006: Convert IconManager to use new CancelableTaskTracker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and fix mac compiling Created 8 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CHROME_BROWSER_UI_WEBUI_FILEICON_SOURCE_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_FILEICON_SOURCE_H_
6 #define CHROME_BROWSER_UI_WEBUI_FILEICON_SOURCE_H_ 6 #define CHROME_BROWSER_UI_WEBUI_FILEICON_SOURCE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "chrome/browser/icon_manager.h" 11 #include "chrome/browser/icon_manager.h"
12 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 12 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
13 #include "chrome/common/cancelable_task_tracker.h"
13 #include "ui/base/layout.h" 14 #include "ui/base/layout.h"
14 15
15 namespace gfx { 16 namespace gfx {
16 class Image; 17 class Image;
17 } 18 }
18 19
19 // FileIconSource is the gateway between network-level chrome: 20 // FileIconSource is the gateway between network-level chrome:
20 // requests for favicons and the history backend that serves these. 21 // requests for favicons and the history backend that serves these.
21 class FileIconSource : public ChromeURLDataManager::DataSource { 22 class FileIconSource : public ChromeURLDataManager::DataSource {
22 public: 23 public:
23 explicit FileIconSource(); 24 explicit FileIconSource();
24 25
25 // Called when the network layer has requested a resource underneath 26 // Called when the network layer has requested a resource underneath
26 // the path we registered. 27 // the path we registered.
27 virtual void StartDataRequest(const std::string& path, 28 virtual void StartDataRequest(const std::string& path,
28 bool is_incognito, 29 bool is_incognito,
29 int request_id) OVERRIDE; 30 int request_id) OVERRIDE;
30 31
31 virtual std::string GetMimeType(const std::string&) const OVERRIDE; 32 virtual std::string GetMimeType(const std::string&) const OVERRIDE;
32 33
33 // Called when favicon data is available from the history backend.
34 void OnFileIconDataAvailable(
35 IconManager::Handle request_handle,
36 gfx::Image* icon);
37
38 protected: 34 protected:
39 virtual ~FileIconSource(); 35 virtual ~FileIconSource();
40 36
41 // Once the |path| and |icon_size| has been determined from the request, this 37 // Once the |path| and |icon_size| has been determined from the request, this
42 // function is called to perform the actual fetch. Declared as virtual for 38 // function is called to perform the actual fetch. Declared as virtual for
43 // testing. 39 // testing.
44 virtual void FetchFileIcon(const FilePath& path, 40 virtual void FetchFileIcon(const FilePath& path,
45 ui::ScaleFactor scale_factor, 41 ui::ScaleFactor scale_factor,
46 IconLoader::IconSize icon_size, 42 IconLoader::IconSize icon_size,
47 int request_id); 43 int request_id);
48 44
49 private: 45 private:
50 // Contains the necessary information for completing an icon fetch request. 46 // Contains the necessary information for completing an icon fetch request.
51 struct IconRequestDetails { 47 struct IconRequestDetails {
52 // The request id corresponding to these details. 48 // The request id corresponding to these details.
53 int request_id; 49 int request_id;
54 50
55 // The requested scale factor to respond with. 51 // The requested scale factor to respond with.
56 ui::ScaleFactor scale_factor; 52 ui::ScaleFactor scale_factor;
57 }; 53 };
58 54
59 // Consumer for requesting file icons. 55 // Called when favicon data is available from the history backend.
60 CancelableRequestConsumerTSimple<IconRequestDetails> cancelable_consumer_; 56 void OnFileIconDataAvailable(const IconRequestDetails& details,
57 gfx::Image* icon);
58
59 // Tracks tasks requesting file icons.
60 CancelableTaskTracker cancelable_task_tracker_;
61 61
62 DISALLOW_COPY_AND_ASSIGN(FileIconSource); 62 DISALLOW_COPY_AND_ASSIGN(FileIconSource);
63 }; 63 };
64 #endif // CHROME_BROWSER_UI_WEBUI_FILEICON_SOURCE_H_ 64 #endif // CHROME_BROWSER_UI_WEBUI_FILEICON_SOURCE_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/download/download_item_view.cc ('k') | chrome/browser/ui/webui/fileicon_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698