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

Side by Side Diff: chrome/browser/icon_loader.h

Issue 2953633002: Move the IconLoader to use the task scheduler. (Closed)
Patch Set: simpler Created 3 years, 6 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 | « no previous file | chrome/browser/icon_loader.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 (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_ICON_LOADER_H_ 5 #ifndef CHROME_BROWSER_ICON_LOADER_H_
6 #define CHROME_BROWSER_ICON_LOADER_H_ 6 #define CHROME_BROWSER_ICON_LOADER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
15 #include "base/task_scheduler/task_traits.h"
15 #include "build/build_config.h" 16 #include "build/build_config.h"
16 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
17 #include "ui/gfx/image/image.h" 18 #include "ui/gfx/image/image.h"
18 19
19 //////////////////////////////////////////////////////////////////////////////// 20 ////////////////////////////////////////////////////////////////////////////////
20 // 21 //
21 // A facility to read a file containing an icon asynchronously in the IO 22 // A facility to read a file containing an icon asynchronously in the IO
22 // thread. Returns the icon in the form of an ImageSkia. 23 // thread. Returns the icon in the form of an ImageSkia.
23 // 24 //
24 //////////////////////////////////////////////////////////////////////////////// 25 ////////////////////////////////////////////////////////////////////////////////
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 private: 60 private:
60 IconLoader(const base::FilePath& file_path, 61 IconLoader(const base::FilePath& file_path,
61 IconSize size, 62 IconSize size,
62 IconLoadedCallback callback); 63 IconLoadedCallback callback);
63 64
64 ~IconLoader(); 65 ~IconLoader();
65 66
66 // Given a file path, get the group for the given file. 67 // Given a file path, get the group for the given file.
67 static IconGroup GroupForFilepath(const base::FilePath& file_path); 68 static IconGroup GroupForFilepath(const base::FilePath& file_path);
68 69
69 // The thread ReadIcon() should be called on. 70 // The TaskRunner that ReadIcon() must be called on.
70 static content::BrowserThread::ID ReadIconThreadID(); 71 static scoped_refptr<base::TaskRunner> ReadIconTaskRunner();
sky 2017/06/22 21:20:49 Mild preference for GetReadIconTaskRunner() as rea
Avi (use Gerrit) 2017/06/22 21:46:34 Done.
71 72
72 void ReadGroup(); 73 void ReadGroup();
73 void OnReadGroup();
74 void ReadIcon(); 74 void ReadIcon();
75 75
76 // The traits of the tasks posted by this class. These operations may block,
77 // because they are fetching icons from the disk, yet the result will be seen
78 // by the user so they should be prioritized accordingly.
79 static constexpr base::TaskTraits traits() {
80 return {base::MayBlock(), base::TaskPriority::USER_VISIBLE};
81 }
82
76 // The task runner object of the thread in which we notify the delegate. 83 // The task runner object of the thread in which we notify the delegate.
77 scoped_refptr<base::SingleThreadTaskRunner> target_task_runner_; 84 scoped_refptr<base::SingleThreadTaskRunner> target_task_runner_;
78 85
79 base::FilePath file_path_; 86 base::FilePath file_path_;
80 87
81 IconGroup group_; 88 IconGroup group_;
82 89
83 IconSize icon_size_; 90 IconSize icon_size_;
84 91
85 IconLoadedCallback callback_; 92 IconLoadedCallback callback_;
86 93
87 DISALLOW_COPY_AND_ASSIGN(IconLoader); 94 DISALLOW_COPY_AND_ASSIGN(IconLoader);
88 }; 95 };
89 96
90 #endif // CHROME_BROWSER_ICON_LOADER_H_ 97 #endif // CHROME_BROWSER_ICON_LOADER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/icon_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698