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

Side by Side Diff: chrome/browser/shell_integration.cc

Issue 2888693003: Remove the usage of BrowserThread::FILE in the shell_integration* files (Closed)
Patch Set: Again Created 3 years, 7 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
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 #include "chrome/browser/shell_integration.h" 5 #include "chrome/browser/shell_integration.h"
6 6
7 #include "base//task_scheduler/post_task.h"
Lei Zhang 2017/05/19 23:23:13 Extra /
Patrick Monette 2017/05/26 01:50:12 Done.
7 #include "base/bind.h" 8 #include "base/bind.h"
8 #include "base/command_line.h" 9 #include "base/command_line.h"
9 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
10 #include "base/metrics/histogram_macros.h" 11 #include "base/metrics/histogram_macros.h"
11 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
12 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
13 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
14 #include "base/threading/thread_restrictions.h" 15 #include "base/threading/thread_restrictions.h"
15 #include "build/build_config.h" 16 #include "build/build_config.h"
16 #include "chrome/browser/policy/policy_path_parser.h" 17 #include "chrome/browser/policy/policy_path_parser.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 return l10n_util::GetStringUTF16(IDS_APP_SHORTCUTS_SUBDIR_NAME_CANARY); 130 return l10n_util::GetStringUTF16(IDS_APP_SHORTCUTS_SUBDIR_NAME_CANARY);
130 return l10n_util::GetStringUTF16(IDS_APP_SHORTCUTS_SUBDIR_NAME); 131 return l10n_util::GetStringUTF16(IDS_APP_SHORTCUTS_SUBDIR_NAME);
131 } 132 }
132 #endif // !defined(OS_WIN) 133 #endif // !defined(OS_WIN)
133 134
134 /////////////////////////////////////////////////////////////////////////////// 135 ///////////////////////////////////////////////////////////////////////////////
135 // DefaultWebClientWorker 136 // DefaultWebClientWorker
136 // 137 //
137 138
138 void DefaultWebClientWorker::StartCheckIsDefault() { 139 void DefaultWebClientWorker::StartCheckIsDefault() {
139 BrowserThread::PostTask( 140 base::CreateSequencedTaskRunnerWithTraits({base::MayBlock()})
140 BrowserThread::FILE, FROM_HERE, 141 ->PostTask(FROM_HERE, base::Bind(&DefaultWebClientWorker::CheckIsDefault,
141 base::Bind(&DefaultWebClientWorker::CheckIsDefault, this, false)); 142 this, false));
142 } 143 }
143 144
144 void DefaultWebClientWorker::StartSetAsDefault() { 145 void DefaultWebClientWorker::StartSetAsDefault() {
145 BrowserThread::PostTask( 146 // TODO(pmonette): Windows' implementation uses a base::Timer which currently
146 BrowserThread::FILE, FROM_HERE, 147 // still requires a SingleThreadTaskRunner. Change this to a
147 base::Bind(&DefaultWebClientWorker::SetAsDefault, this)); 148 // SequencedTaskRunner when crbug.com/552633 is fixed.
149 base::CreateSingleThreadTaskRunnerWithTraits({base::MayBlock()})
150 ->PostTask(FROM_HERE,
151 base::Bind(&DefaultWebClientWorker::SetAsDefault, this));
148 } 152 }
149 153
150 /////////////////////////////////////////////////////////////////////////////// 154 ///////////////////////////////////////////////////////////////////////////////
151 // DefaultWebClientWorker, protected: 155 // DefaultWebClientWorker, protected:
152 156
153 DefaultWebClientWorker::DefaultWebClientWorker( 157 DefaultWebClientWorker::DefaultWebClientWorker(
154 const DefaultWebClientWorkerCallback& callback, 158 const DefaultWebClientWorkerCallback& callback,
155 const char* worker_name) 159 const char* worker_name)
156 : callback_(callback), worker_name_(worker_name) {} 160 : callback_(callback), worker_name_(worker_name) {}
157 161
158 DefaultWebClientWorker::~DefaultWebClientWorker() = default; 162 DefaultWebClientWorker::~DefaultWebClientWorker() = default;
159 163
160 void DefaultWebClientWorker::OnCheckIsDefaultComplete( 164 void DefaultWebClientWorker::OnCheckIsDefaultComplete(
161 DefaultWebClientState state, 165 DefaultWebClientState state,
162 bool is_following_set_as_default) { 166 bool is_following_set_as_default) {
163 DCHECK_CURRENTLY_ON(BrowserThread::UI); 167 DCHECK_CURRENTLY_ON(BrowserThread::UI);
164 UpdateUI(state); 168 UpdateUI(state);
165 169
166 if (is_following_set_as_default) 170 if (is_following_set_as_default)
167 ReportSetDefaultResult(state); 171 ReportSetDefaultResult(state);
168 } 172 }
169 173
170 /////////////////////////////////////////////////////////////////////////////// 174 ///////////////////////////////////////////////////////////////////////////////
171 // DefaultWebClientWorker, private: 175 // DefaultWebClientWorker, private:
172 176
173 void DefaultWebClientWorker::CheckIsDefault(bool is_following_set_as_default) { 177 void DefaultWebClientWorker::CheckIsDefault(bool is_following_set_as_default) {
174 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 178 base::ThreadRestrictions::AssertIOAllowed();
179
175 DefaultWebClientState state = CheckIsDefaultImpl(); 180 DefaultWebClientState state = CheckIsDefaultImpl();
176 BrowserThread::PostTask( 181 BrowserThread::PostTask(
177 BrowserThread::UI, FROM_HERE, 182 BrowserThread::UI, FROM_HERE,
178 base::Bind(&DefaultBrowserWorker::OnCheckIsDefaultComplete, this, state, 183 base::Bind(&DefaultBrowserWorker::OnCheckIsDefaultComplete, this, state,
179 is_following_set_as_default)); 184 is_following_set_as_default));
180 } 185 }
181 186
182 void DefaultWebClientWorker::SetAsDefault() { 187 void DefaultWebClientWorker::SetAsDefault() {
183 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 188 base::ThreadRestrictions::AssertIOAllowed();
184 189
185 // SetAsDefaultImpl will make sure the callback is executed exactly once. 190 // SetAsDefaultImpl will make sure the callback is executed exactly once.
186 SetAsDefaultImpl( 191 SetAsDefaultImpl(
187 base::Bind(&DefaultWebClientWorker::CheckIsDefault, this, true)); 192 base::Bind(&DefaultWebClientWorker::CheckIsDefault, this, true));
188 } 193 }
189 194
190 void DefaultWebClientWorker::ReportSetDefaultResult( 195 void DefaultWebClientWorker::ReportSetDefaultResult(
191 DefaultWebClientState state) { 196 DefaultWebClientState state) {
192 base::LinearHistogram::FactoryGet( 197 base::LinearHistogram::FactoryGet(
193 base::StringPrintf("%s.SetDefaultResult2", worker_name_), 1, 198 base::StringPrintf("%s.SetDefaultResult2", worker_name_), 1,
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 return; 313 return;
309 } 314 }
310 } 315 }
311 #endif // defined(OS_WIN) 316 #endif // defined(OS_WIN)
312 break; 317 break;
313 } 318 }
314 on_finished_callback.Run(); 319 on_finished_callback.Run();
315 } 320 }
316 321
317 } // namespace shell_integration 322 } // namespace shell_integration
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698