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

Side by Side Diff: chrome/browser/win/jumplist_updater.cc

Issue 2831433003: Time out jumplist update for very slow or busy OS (Closed)
Patch Set: Remove myself from being an owner and remove Windows version check Created 3 years, 8 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/win/jumplist.cc ('k') | tools/metrics/histograms/histograms.xml » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/win/jumplist_updater.h" 5 #include "chrome/browser/win/jumplist_updater.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <propkey.h> 8 #include <propkey.h>
9 #include <shobjidl.h> 9 #include <shobjidl.h>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/metrics/histogram_macros.h" 13 #include "base/metrics/histogram_macros.h"
14 #include "base/path_service.h" 14 #include "base/path_service.h"
15 #include "base/win/win_util.h" 15 #include "base/win/win_util.h"
16 #include "base/win/windows_version.h"
17 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
18 #include "content/public/common/content_switches.h" 17 #include "content/public/common/content_switches.h"
19 18
20 namespace { 19 namespace {
21 20
22 // Creates an IShellLink object. 21 // Creates an IShellLink object.
23 // An IShellLink object is almost the same as an application shortcut, and it 22 // An IShellLink object is almost the same as an application shortcut, and it
24 // requires three items: the absolute path to an application, an argument 23 // requires three items: the absolute path to an application, an argument
25 // string, and a title string. 24 // string, and a title string.
26 bool AddShellLink(base::win::ScopedComPtr<IObjectCollection> collection, 25 bool AddShellLink(base::win::ScopedComPtr<IObjectCollection> collection,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 JumpListUpdater::JumpListUpdater(const std::wstring& app_user_model_id) 102 JumpListUpdater::JumpListUpdater(const std::wstring& app_user_model_id)
104 : app_user_model_id_(app_user_model_id), 103 : app_user_model_id_(app_user_model_id),
105 user_max_items_(0) { 104 user_max_items_(0) {
106 } 105 }
107 106
108 JumpListUpdater::~JumpListUpdater() { 107 JumpListUpdater::~JumpListUpdater() {
109 } 108 }
110 109
111 // static 110 // static
112 bool JumpListUpdater::IsEnabled() { 111 bool JumpListUpdater::IsEnabled() {
113 // JumpList is implemented only on Windows 7 or later.
114 // Do not create custom JumpLists in tests. See http://crbug.com/389375. 112 // Do not create custom JumpLists in tests. See http://crbug.com/389375.
115 return base::win::GetVersion() >= base::win::VERSION_WIN7 && 113 return !base::CommandLine::ForCurrentProcess()->HasSwitch(
116 !base::CommandLine::ForCurrentProcess()->HasSwitch( 114 switches::kTestType);
117 switches::kTestType);
118 } 115 }
119 116
120 bool JumpListUpdater::BeginUpdate() { 117 bool JumpListUpdater::BeginUpdate() {
121 // TODO(chengx): Remove the UMA histogram after fixing http://crbug.com/40407. 118 // TODO(chengx): Remove the UMA histogram after fixing http://crbug.com/40407.
122 SCOPED_UMA_HISTOGRAM_TIMER("WinJumplistUpdater.BeginUpdateDuration"); 119 SCOPED_UMA_HISTOGRAM_TIMER("WinJumplistUpdater.BeginUpdateDuration");
123 120
124 // This instance is expected to be one-time-use only. 121 // This instance is expected to be one-time-use only.
125 DCHECK(!destination_list_.Get()); 122 DCHECK(!destination_list_.Get());
126 123
127 // Check preconditions. 124 // Check preconditions.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 // It seems the ICustomDestinationList::AppendCategory() function just 246 // It seems the ICustomDestinationList::AppendCategory() function just
250 // replaces all items in the given category with the ones in the new list. 247 // replaces all items in the given category with the ones in the new list.
251 base::win::ScopedComPtr<IObjectArray> object_array; 248 base::win::ScopedComPtr<IObjectArray> object_array;
252 result = collection.QueryInterface(object_array.Receive()); 249 result = collection.QueryInterface(object_array.Receive());
253 if (FAILED(result)) 250 if (FAILED(result))
254 return false; 251 return false;
255 252
256 return SUCCEEDED(destination_list_->AppendCategory(category_name.c_str(), 253 return SUCCEEDED(destination_list_->AppendCategory(category_name.c_str(),
257 object_array.Get())); 254 object_array.Get()));
258 } 255 }
OLDNEW
« no previous file with comments | « chrome/browser/win/jumplist.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698