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

Side by Side Diff: chrome/browser/ui/webui/help/version_updater_win.cc

Issue 2207523002: Move on-demand update checks from the FILE thread to the blocking pool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@threadfix
Patch Set: pk review 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 | « chrome/browser/ui/webui/help/version_updater_win.h ('k') | 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 (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/ui/webui/help/version_updater_win.h" 5 #include "chrome/browser/ui/webui/help/version_updater_win.h"
6 6
7 #include "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
8 #include "base/task_runner_util.h" 8 #include "base/task_runner_util.h"
9 #include "base/win/win_util.h" 9 #include "base/win/win_util.h"
10 #include "base/win/windows_version.h" 10 #include "base/win/windows_version.h"
(...skipping 21 matching lines...) Expand all
32 32
33 // On-demand updates for Chrome don't work in Vista RTM when UAC is turned 33 // On-demand updates for Chrome don't work in Vista RTM when UAC is turned
34 // off. So, in this case, the version updater must not mention 34 // off. So, in this case, the version updater must not mention
35 // on-demand updates. Silent updates (in the background) should still 35 // on-demand updates. Silent updates (in the background) should still
36 // work as before - enabling UAC or installing the latest service pack 36 // work as before - enabling UAC or installing the latest service pack
37 // for Vista is another option. 37 // for Vista is another option.
38 if (!(base::win::GetVersion() == base::win::VERSION_VISTA && 38 if (!(base::win::GetVersion() == base::win::VERSION_VISTA &&
39 (base::win::OSInfo::GetInstance()->service_pack().major == 0) && 39 (base::win::OSInfo::GetInstance()->service_pack().major == 0) &&
40 !base::win::UserAccountControlIsEnabled())) { 40 !base::win::UserAccountControlIsEnabled())) {
41 callback_.Run(CHECKING, 0, base::string16()); 41 callback_.Run(CHECKING, 0, base::string16());
42 BeginUpdateCheckOnFileThread(false /* !install_update_if_possible */); 42 BeginUpdateCheckInBlockingPool(false /* !install_update_if_possible */);
43 } 43 }
44 } 44 }
45 45
46 void VersionUpdaterWin::OnUpdateCheckComplete( 46 void VersionUpdaterWin::OnUpdateCheckComplete(
47 const base::string16& new_version) { 47 const base::string16& new_version) {
48 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 48 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
49 Status status = CHECKING; 49 Status status = CHECKING;
50 if (new_version.empty()) { 50 if (new_version.empty()) {
51 // Google Update says that no new version is available. Check to see if a 51 // Google Update says that no new version is available. Check to see if a
52 // restart is needed for a previously-applied update to take effect. 52 // restart is needed for a previously-applied update to take effect.
53 if (base::PostTaskAndReplyWithResult( 53 if (base::PostTaskAndReplyWithResult(
54 content::BrowserThread::GetBlockingPool(), 54 content::BrowserThread::GetBlockingPool(),
55 FROM_HERE, 55 FROM_HERE,
56 base::Bind(&upgrade_util::IsUpdatePendingRestart), 56 base::Bind(&upgrade_util::IsUpdatePendingRestart),
57 base::Bind(&VersionUpdaterWin::OnPendingRestartCheck, 57 base::Bind(&VersionUpdaterWin::OnPendingRestartCheck,
58 weak_factory_.GetWeakPtr()))) { 58 weak_factory_.GetWeakPtr()))) {
59 // Early exit since callback_ will be Run in OnPendingRestartCheck. 59 // Early exit since callback_ will be Run in OnPendingRestartCheck.
60 return; 60 return;
61 } 61 }
62 // Failure to post the task means that Chrome is shutting down. A pending 62 // Failure to post the task means that Chrome is shutting down. A pending
63 // update (if there is one) will be applied as Chrome exits, so tell the 63 // update (if there is one) will be applied as Chrome exits, so tell the
64 // caller that it is up to date in either case. 64 // caller that it is up to date in either case.
65 status = UPDATED; 65 status = UPDATED;
66 } else { 66 } else {
67 // Notify the caller that the update is now beginning and initiate it. 67 // Notify the caller that the update is now beginning and initiate it.
68 status = UPDATING; 68 status = UPDATING;
69 BeginUpdateCheckOnFileThread(true /* install_update_if_possible */); 69 BeginUpdateCheckInBlockingPool(true /* install_update_if_possible */);
70 } 70 }
71 callback_.Run(status, 0, base::string16()); 71 callback_.Run(status, 0, base::string16());
72 } 72 }
73 73
74 void VersionUpdaterWin::OnUpgradeProgress(int progress, 74 void VersionUpdaterWin::OnUpgradeProgress(int progress,
75 const base::string16& new_version) { 75 const base::string16& new_version) {
76 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 76 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
77 callback_.Run(UPDATING, progress, base::string16()); 77 callback_.Run(UPDATING, progress, base::string16());
78 } 78 }
79 79
(...skipping 26 matching lines...) Expand all
106 message = l10n_util::GetStringFUTF16Int(IDS_UPGRADE_ERROR, error_code); 106 message = l10n_util::GetStringFUTF16Int(IDS_UPGRADE_ERROR, error_code);
107 } else { 107 } else {
108 message = l10n_util::GetStringFUTF16( 108 message = l10n_util::GetStringFUTF16(
109 IDS_ABOUT_BOX_ERROR_DURING_UPDATE_CHECK, html_error_message); 109 IDS_ABOUT_BOX_ERROR_DURING_UPDATE_CHECK, html_error_message);
110 } 110 }
111 break; 111 break;
112 } 112 }
113 callback_.Run(status, 0, message); 113 callback_.Run(status, 0, message);
114 } 114 }
115 115
116 void VersionUpdaterWin::BeginUpdateCheckOnFileThread( 116 void VersionUpdaterWin::BeginUpdateCheckInBlockingPool(
117 bool install_update_if_possible) { 117 bool install_update_if_possible) {
118 BeginUpdateCheck(content::BrowserThread::GetTaskRunnerForThread( 118 base::SequencedWorkerPool* blocking_pool =
119 content::BrowserThread::FILE), 119 content::BrowserThread::GetBlockingPool();
120 BeginUpdateCheck(blocking_pool->GetSequencedTaskRunnerWithShutdownBehavior(
121 blocking_pool->GetSequenceToken(),
122 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN),
120 g_browser_process->GetApplicationLocale(), 123 g_browser_process->GetApplicationLocale(),
121 install_update_if_possible, owner_widget_, 124 install_update_if_possible, owner_widget_,
122 weak_factory_.GetWeakPtr()); 125 weak_factory_.GetWeakPtr());
123 } 126 }
124 127
125 void VersionUpdaterWin::OnPendingRestartCheck(bool is_update_pending_restart) { 128 void VersionUpdaterWin::OnPendingRestartCheck(bool is_update_pending_restart) {
126 callback_.Run(is_update_pending_restart ? NEARLY_UPDATED : UPDATED, 0, 129 callback_.Run(is_update_pending_restart ? NEARLY_UPDATED : UPDATED, 0,
127 base::string16()); 130 base::string16());
128 } 131 }
129 132
130 VersionUpdater* VersionUpdater::Create(content::WebContents* web_contents) { 133 VersionUpdater* VersionUpdater::Create(content::WebContents* web_contents) {
131 // Retrieve the HWND for the browser window that is hosting the update check. 134 // Retrieve the HWND for the browser window that is hosting the update check.
132 // This will be used as the parent for a UAC prompt, if needed. It's possible 135 // This will be used as the parent for a UAC prompt, if needed. It's possible
133 // this this window will no longer have focus by the time UAC is needed. In 136 // this this window will no longer have focus by the time UAC is needed. In
134 // that case, the UAC prompt will appear in the taskbar and will require a 137 // that case, the UAC prompt will appear in the taskbar and will require a
135 // user click. This is the least surprising thing we can do for the user, and 138 // user click. This is the least surprising thing we can do for the user, and
136 // is the intended behavior for Windows applications. 139 // is the intended behavior for Windows applications.
137 // It's also possible that the browser window hosting the update check will 140 // It's also possible that the browser window hosting the update check will
138 // have been closed by the time the UAC prompt is needed. In this case, the 141 // have been closed by the time the UAC prompt is needed. In this case, the
139 // web contents may no longer be hosted in a window, leading either 142 // web contents may no longer be hosted in a window, leading either
140 // GetTopLevelNativeWindow or GetHost to return null. Passing nullptr to 143 // GetTopLevelNativeWindow or GetHost to return null. Passing nullptr to
141 // VersionUpdaterWin will then also cause the UAC prompt to appear in the task 144 // VersionUpdaterWin will then also cause the UAC prompt to appear in the task
142 // bar. 145 // bar.
143 gfx::NativeWindow window = web_contents->GetTopLevelNativeWindow(); 146 gfx::NativeWindow window = web_contents->GetTopLevelNativeWindow();
144 aura::WindowTreeHost* window_tree_host = window ? window->GetHost() : nullptr; 147 aura::WindowTreeHost* window_tree_host = window ? window->GetHost() : nullptr;
145 return new VersionUpdaterWin( 148 return new VersionUpdaterWin(
146 window_tree_host ? window_tree_host->GetAcceleratedWidget() : nullptr); 149 window_tree_host ? window_tree_host->GetAcceleratedWidget() : nullptr);
147 } 150 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/help/version_updater_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698