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

Side by Side Diff: chrome/browser/password_manager/password_manager_util_win.cc

Issue 2527123004: Use TaskScheduler instead of WorkerPool in password_manager_util_win.cc. (Closed)
Patch Set: add withwait() Created 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // windows.h must be first otherwise Win8 SDK breaks. 5 // windows.h must be first otherwise Win8 SDK breaks.
6 #include <windows.h> 6 #include <windows.h>
7 #include <LM.h> 7 #include <LM.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <wincred.h> 10 #include <wincred.h>
11 11
12 #include <memory> 12 #include <memory>
13 13
14 // SECURITY_WIN32 must be defined in order to get 14 // SECURITY_WIN32 must be defined in order to get
15 // EXTENDED_NAME_FORMAT enumeration. 15 // EXTENDED_NAME_FORMAT enumeration.
16 #define SECURITY_WIN32 1 16 #define SECURITY_WIN32 1
17 #include <security.h> 17 #include <security.h>
18 #undef SECURITY_WIN32 18 #undef SECURITY_WIN32
19 19
20 #include "chrome/browser/password_manager/password_manager_util_win.h" 20 #include "chrome/browser/password_manager/password_manager_util_win.h"
21 21
22 #include "base/bind.h" 22 #include "base/bind.h"
23 #include "base/bind_helpers.h" 23 #include "base/bind_helpers.h"
24 #include "base/metrics/histogram_macros.h" 24 #include "base/metrics/histogram_macros.h"
25 #include "base/strings/utf_string_conversions.h" 25 #include "base/strings/utf_string_conversions.h"
26 #include "base/threading/worker_pool.h" 26 #include "base/task_scheduler/post_task.h"
27 #include "base/time/time.h" 27 #include "base/time/time.h"
28 #include "base/win/windows_version.h" 28 #include "base/win/windows_version.h"
29 #include "chrome/browser/browser_process.h" 29 #include "chrome/browser/browser_process.h"
30 #include "chrome/grit/chromium_strings.h" 30 #include "chrome/grit/chromium_strings.h"
31 #include "components/password_manager/core/browser/password_manager.h" 31 #include "components/password_manager/core/browser/password_manager.h"
32 #include "components/password_manager/core/common/password_manager_pref_names.h" 32 #include "components/password_manager/core/common/password_manager_pref_names.h"
33 #include "components/prefs/pref_service.h" 33 #include "components/prefs/pref_service.h"
34 #include "content/public/browser/browser_thread.h" 34 #include "content/public/browser/browser_thread.h"
35 #include "content/public/browser/render_view_host.h" 35 #include "content/public/browser/render_view_host.h"
36 #include "content/public/browser/render_widget_host_view.h" 36 #include "content/public/browser/render_widget_host_view.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 void GetOsPasswordStatus() { 200 void GetOsPasswordStatus() {
201 // Preferences can be accessed on the UI thread only. 201 // Preferences can be accessed on the UI thread only.
202 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 202 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
203 PrefService* local_state = g_browser_process->local_state(); 203 PrefService* local_state = g_browser_process->local_state();
204 std::unique_ptr<PasswordCheckPrefs> prefs(new PasswordCheckPrefs); 204 std::unique_ptr<PasswordCheckPrefs> prefs(new PasswordCheckPrefs);
205 prefs->Read(local_state); 205 prefs->Read(local_state);
206 std::unique_ptr<OsPasswordStatus> status( 206 std::unique_ptr<OsPasswordStatus> status(
207 new OsPasswordStatus(PASSWORD_STATUS_UNKNOWN)); 207 new OsPasswordStatus(PASSWORD_STATUS_UNKNOWN));
208 PasswordCheckPrefs* prefs_weak = prefs.get(); 208 PasswordCheckPrefs* prefs_weak = prefs.get();
209 OsPasswordStatus* status_weak = status.get(); 209 OsPasswordStatus* status_weak = status.get();
210 bool posted = base::WorkerPool::PostTaskAndReply( 210 base::PostTaskWithTraitsAndReply(
211 FROM_HERE, 211 FROM_HERE, base::TaskTraits()
212 .WithPriority(base::TaskPriority::BACKGROUND)
213 .WithWait(),
212 base::Bind(&GetOsPasswordStatusInternal, prefs_weak, status_weak), 214 base::Bind(&GetOsPasswordStatusInternal, prefs_weak, status_weak),
213 base::Bind(&ReplyOsPasswordStatus, base::Passed(&prefs), 215 base::Bind(&ReplyOsPasswordStatus, base::Passed(&prefs),
214 base::Passed(&status)), 216 base::Passed(&status)));
215 true);
216 if (!posted) {
217 UMA_HISTOGRAM_ENUMERATION("PasswordManager.OsPasswordStatus",
218 PASSWORD_STATUS_UNKNOWN, MAX_PASSWORD_STATUS);
219 }
220 } 217 }
221 218
222 } // namespace 219 } // namespace
223 220
224 void DelayReportOsPassword() { 221 void DelayReportOsPassword() {
225 content::BrowserThread::PostDelayedTask(content::BrowserThread::UI, FROM_HERE, 222 content::BrowserThread::PostDelayedTask(content::BrowserThread::UI, FROM_HERE,
226 base::Bind(&GetOsPasswordStatus), 223 base::Bind(&GetOsPasswordStatus),
227 base::TimeDelta::FromSeconds(40)); 224 base::TimeDelta::FromSeconds(40));
228 } 225 }
229 226
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 } 317 }
321 } 318 }
322 SecureZeroMemory(password, sizeof(password)); 319 SecureZeroMemory(password, sizeof(password));
323 } 320 }
324 } while (credErr == NO_ERROR && 321 } while (credErr == NO_ERROR &&
325 (retval == false && tries < kMaxPasswordRetries)); 322 (retval == false && tries < kMaxPasswordRetries));
326 return retval; 323 return retval;
327 } 324 }
328 325
329 } // namespace password_manager_util_win 326 } // namespace password_manager_util_win
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698