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

Side by Side Diff: chrome/browser/media/tab_desktop_media_list.cc

Issue 2240823003: Avoid a crash in ProfileManager::GetLastUsedProfileAllowedByPolicy() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Early return Created 4 years, 4 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/profiles/profile_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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "chrome/browser/media/tab_desktop_media_list.h" 5 #include "chrome/browser/media/tab_desktop_media_list.h"
6 6
7 #include "base/hash.h" 7 #include "base/hash.h"
8 #include "base/threading/sequenced_worker_pool.h" 8 #include "base/threading/sequenced_worker_pool.h"
9 #include "chrome/browser/profiles/profile_manager.h" 9 #include "chrome/browser/profiles/profile_manager.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 thumbnail_task_runner_ = 66 thumbnail_task_runner_ =
67 worker_pool->GetSequencedTaskRunner(worker_pool->GetSequenceToken()); 67 worker_pool->GetSequencedTaskRunner(worker_pool->GetSequenceToken());
68 } 68 }
69 69
70 TabDesktopMediaList::~TabDesktopMediaList() {} 70 TabDesktopMediaList::~TabDesktopMediaList() {}
71 71
72 void TabDesktopMediaList::Refresh() { 72 void TabDesktopMediaList::Refresh() {
73 DCHECK_CURRENTLY_ON(BrowserThread::UI); 73 DCHECK_CURRENTLY_ON(BrowserThread::UI);
74 74
75 Profile* profile = ProfileManager::GetLastUsedProfileAllowedByPolicy(); 75 Profile* profile = ProfileManager::GetLastUsedProfileAllowedByPolicy();
76 if (!profile)
77 return;
Sergey Ulanov 2016/08/20 01:08:48 I think ScheduleNextRefresh still need to be poste
afakhry 2016/08/20 01:33:52 Done.
78
76 std::vector<Browser*> browsers; 79 std::vector<Browser*> browsers;
77 for (auto* browser : *BrowserList::GetInstance()) { 80 for (auto* browser : *BrowserList::GetInstance()) {
78 if (browser->profile()->GetOriginalProfile() == 81 if (browser->profile()->GetOriginalProfile() ==
79 profile->GetOriginalProfile()) { 82 profile->GetOriginalProfile()) {
80 browsers.push_back(browser); 83 browsers.push_back(browser);
81 } 84 }
82 } 85 }
83 86
84 ImageHashesMap new_favicon_hashes; 87 ImageHashesMap new_favicon_hashes;
85 std::vector<SourceDescription> sources; 88 std::vector<SourceDescription> sources;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 (favicon_hashes_[media_id] != new_favicon_hashes[media_id])) { 126 (favicon_hashes_[media_id] != new_favicon_hashes[media_id])) {
124 gfx::ImageSkia image = favicon.AsImageSkia(); 127 gfx::ImageSkia image = favicon.AsImageSkia();
125 image.MakeThreadSafe(); 128 image.MakeThreadSafe();
126 favicon_pairs.push_back(std::make_pair(media_id, image)); 129 favicon_pairs.push_back(std::make_pair(media_id, image));
127 } 130 }
128 } 131 }
129 } 132 }
130 favicon_hashes_ = new_favicon_hashes; 133 favicon_hashes_ = new_favicon_hashes;
131 134
132 // Sort tab sources by time. Most recent one first. Then update sources list. 135 // Sort tab sources by time. Most recent one first. Then update sources list.
133 for (auto it = tab_map.rbegin(); it != tab_map.rend(); ++it) { 136 for (auto it = tab_map.rbegin(); it != tab_map.rend(); ++it)
134 sources.push_back(it->second); 137 sources.push_back(it->second);
135 } 138
136 UpdateSourcesList(sources); 139 UpdateSourcesList(sources);
137 140
138 for (const auto& it : favicon_pairs) { 141 for (const auto& it : favicon_pairs) {
139 // Create a thumbail in a different thread and update the thumbnail in 142 // Create a thumbail in a different thread and update the thumbnail in
140 // current thread. 143 // current thread.
141 base::PostTaskAndReplyWithResult( 144 base::PostTaskAndReplyWithResult(
142 thumbnail_task_runner_.get(), FROM_HERE, 145 thumbnail_task_runner_.get(), FROM_HERE,
143 base::Bind(&CreateEnclosedFaviconImage, thumbnail_size_, it.second), 146 base::Bind(&CreateEnclosedFaviconImage, thumbnail_size_, it.second),
144 base::Bind(&TabDesktopMediaList::UpdateSourceThumbnail, 147 base::Bind(&TabDesktopMediaList::UpdateSourceThumbnail,
145 weak_factory_.GetWeakPtr(), it.first)); 148 weak_factory_.GetWeakPtr(), it.first));
146 } 149 }
147 150
148 // ScheduleNextRefresh() needs to be called after all calls for 151 // ScheduleNextRefresh() needs to be called after all calls for
149 // UpdateSourceThumbnail() have done. Therefore, a DoNothing task is posted 152 // UpdateSourceThumbnail() have done. Therefore, a DoNothing task is posted
150 // to the same sequenced task runner that CreateEnlargedFaviconImag() 153 // to the same sequenced task runner that CreateEnlargedFaviconImag()
151 // is posted. 154 // is posted.
152 thumbnail_task_runner_.get()->PostTaskAndReply( 155 thumbnail_task_runner_.get()->PostTaskAndReply(
153 FROM_HERE, base::Bind(&base::DoNothing), 156 FROM_HERE, base::Bind(&base::DoNothing),
154 base::Bind(&TabDesktopMediaList::ScheduleNextRefresh, 157 base::Bind(&TabDesktopMediaList::ScheduleNextRefresh,
155 weak_factory_.GetWeakPtr())); 158 weak_factory_.GetWeakPtr()));
156 } 159 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/profiles/profile_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698