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

Side by Side Diff: chrome/browser/installable/installable_manager.cc

Issue 2844383004: Split the NOT_STARTED and STOPPED_BEFORE_COMPLETION installability metrics. (Closed)
Patch Set: Fix comment 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
« no previous file with comments | « no previous file | chrome/browser/installable/installable_manager_browsertest.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/installable/installable_manager.h" 5 #include "chrome/browser/installable/installable_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "chrome/browser/manifest/manifest_icon_downloader.h" 10 #include "chrome/browser/manifest/manifest_icon_downloader.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 const InstallableCallback& callback) { 138 const InstallableCallback& callback) {
139 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 139 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
140 140
141 // Return immediately if we're already working on a task. The new task will be 141 // Return immediately if we're already working on a task. The new task will be
142 // looked at once the current task is finished. 142 // looked at once the current task is finished.
143 tasks_.push_back({params, callback}); 143 tasks_.push_back({params, callback});
144 if (is_active_) 144 if (is_active_)
145 return; 145 return;
146 146
147 is_active_ = true; 147 is_active_ = true;
148 if (page_status_ == InstallabilityCheckStatus::NOT_STARTED)
149 page_status_ = InstallabilityCheckStatus::NOT_COMPLETED;
148 StartNextTask(); 150 StartNextTask();
149 } 151 }
150 152
151 void InstallableManager::RecordMenuOpenHistogram() { 153 void InstallableManager::RecordMenuOpenHistogram() {
152 if (is_pwa_check_complete_) 154 if (is_pwa_check_complete_)
153 InstallableMetrics::RecordMenuOpenHistogram(page_status_); 155 InstallableMetrics::RecordMenuOpenHistogram(page_status_);
154 else 156 else
155 ++menu_open_count_; 157 ++menu_open_count_;
156 } 158 }
157 159
158 void InstallableManager::RecordMenuItemAddToHomescreenHistogram() { 160 void InstallableManager::RecordMenuItemAddToHomescreenHistogram() {
159 if (is_pwa_check_complete_) 161 if (is_pwa_check_complete_)
160 InstallableMetrics::RecordMenuItemAddToHomescreenHistogram(page_status_); 162 InstallableMetrics::RecordMenuItemAddToHomescreenHistogram(page_status_);
161 else 163 else
162 ++menu_item_add_to_homescreen_count_; 164 ++menu_item_add_to_homescreen_count_;
163 } 165 }
164 166
165 void InstallableManager::RecordQueuedMetricsOnTaskCompletion( 167 void InstallableManager::RecordQueuedMetricsOnTaskCompletion(
166 const InstallableParams& params, 168 const InstallableParams& params,
167 bool check_passed) { 169 bool check_passed) {
168 // Don't do anything if we've already finished the PWA check or if this check 170 // Don't do anything if we've:
169 // was not for the full PWA params. Once a full check is completed, metrics 171 // - already finished the PWA check, or
170 // will be directly recorded in Record*Histogram since 172 // - we passed the check AND it was not for the full PWA params.
171 // |is_pwa_check_complete_| will be true. 173 // In the latter case (i.e. the check passed but we weren't checking
172 if (is_pwa_check_complete_ || !IsParamsForPwaCheck(params)) 174 // everything), we don't yet know if the site is installable. However, if the
175 // check didn't pass, we know for sure the site isn't installable, regardless
176 // of how much we checked.
177 //
178 // Once a full check is completed, metrics will be directly recorded in
179 // Record*Histogram since |is_pwa_check_complete_| will be true.
180 if (is_pwa_check_complete_ || (check_passed && !IsParamsForPwaCheck(params)))
173 return; 181 return;
174 182
175 is_pwa_check_complete_ = true; 183 is_pwa_check_complete_ = true;
176 page_status_ = 184 page_status_ =
177 check_passed 185 check_passed
178 ? InstallabilityCheckStatus::COMPLETE_PROGRESSIVE_WEB_APP 186 ? InstallabilityCheckStatus::COMPLETE_PROGRESSIVE_WEB_APP
179 : InstallabilityCheckStatus::COMPLETE_NON_PROGRESSIVE_WEB_APP; 187 : InstallabilityCheckStatus::COMPLETE_NON_PROGRESSIVE_WEB_APP;
180 188
181 // Compute what the status would have been for any queued calls to 189 // Compute what the status would have been for any queued calls to
182 // Record*Histogram, and record appropriately. 190 // Record*Histogram, and record appropriately.
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 IsIconFetched(ParamsForBadgeIcon(params))); 296 IsIconFetched(ParamsForBadgeIcon(params)));
289 } 297 }
290 298
291 void InstallableManager::Reset() { 299 void InstallableManager::Reset() {
292 // Prevent any outstanding callbacks to or from this object from being called. 300 // Prevent any outstanding callbacks to or from this object from being called.
293 weak_factory_.InvalidateWeakPtrs(); 301 weak_factory_.InvalidateWeakPtrs();
294 tasks_.clear(); 302 tasks_.clear();
295 icons_.clear(); 303 icons_.clear();
296 304
297 // We may have reset prior to completion, in which case |menu_open_count_| or 305 // We may have reset prior to completion, in which case |menu_open_count_| or
298 // |menu_item_add_to_homescreen_count_| will be nonzero. If we completed, then 306 // |menu_item_add_to_homescreen_count_| might be nonzero and |page_status_| is
299 // these values cannot be anything except 0. 307 // one of NOT_STARTED or NOT_COMPLETED. If we completed, then these values
300 page_status_ = InstallabilityCheckStatus::NOT_STARTED; 308 // cannot be anything except 0.
301 is_pwa_check_complete_ = false; 309 is_pwa_check_complete_ = false;
302 310
303 for (; menu_open_count_ > 0; --menu_open_count_) { 311 for (; menu_open_count_ > 0; --menu_open_count_)
304 InstallableMetrics::RecordMenuOpenHistogram( 312 InstallableMetrics::RecordMenuOpenHistogram(page_status_);
305 InstallabilityCheckStatus::STOPPED_BEFORE_COMPLETION);
306 }
307 313
308 for (; menu_item_add_to_homescreen_count_ > 0; 314 for (; menu_item_add_to_homescreen_count_ > 0;
309 --menu_item_add_to_homescreen_count_) { 315 --menu_item_add_to_homescreen_count_) {
310 InstallableMetrics::RecordMenuItemAddToHomescreenHistogram( 316 InstallableMetrics::RecordMenuItemAddToHomescreenHistogram(page_status_);
311 InstallabilityCheckStatus::STOPPED_BEFORE_COMPLETION);
312 } 317 }
313 318
319 page_status_ = InstallabilityCheckStatus::NOT_STARTED;
314 manifest_.reset(new ManifestProperty()); 320 manifest_.reset(new ManifestProperty());
315 installable_.reset(new InstallableProperty()); 321 installable_.reset(new InstallableProperty());
316 322
317 is_active_ = false; 323 is_active_ = false;
318 } 324 }
319 325
320 void InstallableManager::SetManifestDependentTasksComplete() { 326 void InstallableManager::SetManifestDependentTasksComplete() {
321 DCHECK(!tasks_.empty()); 327 DCHECK(!tasks_.empty());
322 const InstallableParams& params = tasks_[0].first; 328 const InstallableParams& params = tasks_[0].first;
323 329
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 return manifest_->url; 586 return manifest_->url;
581 } 587 }
582 588
583 const content::Manifest& InstallableManager::manifest() const { 589 const content::Manifest& InstallableManager::manifest() const {
584 return manifest_->manifest; 590 return manifest_->manifest;
585 } 591 }
586 592
587 bool InstallableManager::is_installable() const { 593 bool InstallableManager::is_installable() const {
588 return installable_->installable; 594 return installable_->installable;
589 } 595 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/installable/installable_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698