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

Side by Side Diff: components/offline_pages/offline_page_model.cc

Issue 2015793002: [Offline Pages] Linking storage manager and model with UMAs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wisp
Patch Set: Created 4 years, 6 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/offline_pages/offline_page_model.h" 5 #include "components/offline_pages/offline_page_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 offline_page, base::Bind(&OfflinePageModel::OnExpirePageDone, 524 offline_page, base::Bind(&OfflinePageModel::OnExpirePageDone,
525 weak_ptr_factory_.GetWeakPtr(), offline_id, 525 weak_ptr_factory_.GetWeakPtr(), offline_id,
526 expiration_time)); 526 expiration_time));
527 } 527 }
528 archive_manager_->DeleteMultipleArchives(paths_to_delete, callback); 528 archive_manager_->DeleteMultipleArchives(paths_to_delete, callback);
529 } 529 }
530 530
531 void OfflinePageModel::OnExpirePageDone(int64_t offline_id, 531 void OfflinePageModel::OnExpirePageDone(int64_t offline_id,
532 const base::Time& expiration_time, 532 const base::Time& expiration_time,
533 bool success) { 533 bool success) {
534 // TODO(romax): Report UMA about successful expiration. 534 // TODO(romax): Report UMA about successful expiration.
jianli 2016/05/26 20:37:52 Do you also want to address this comment by adding
romax 2016/05/27 02:01:37 yes, but it would come with the model-storage mana
535 if (success) { 535 if (success) {
536 auto iter = offline_pages_.find(offline_id); 536 auto iter = offline_pages_.find(offline_id);
537 if (iter != offline_pages_.end()) 537 if (iter != offline_pages_.end()) {
jianli 2016/05/26 20:37:52 nit: simpler to do early return for non-match case
romax 2016/05/27 02:01:37 Done.
538 iter->second.expiration_time = expiration_time; 538 iter->second.expiration_time = expiration_time;
539 ClientId client_id = iter->second.client_id;
540 UMA_HISTOGRAM_CUSTOM_COUNTS(
541 AddHistogramSuffix(client_id, "OfflinePages.ExpirePage.PageLifetime")
542 .c_str(),
543 (expiration_time - iter->second.creation_time).InMinutes(), 1,
544 base::TimeDelta::FromDays(60).InMinutes(), 10);
jianli 2016/05/26 20:37:52 Are 10 buckets enough?
romax 2016/05/27 02:01:37 I misunderstood this argument, changing to 120.
545 UMA_HISTOGRAM_CUSTOM_COUNTS(
546 AddHistogramSuffix(client_id,
547 "OfflinePages.ExpirePage.TimeSinceLastAccess")
548 .c_str(),
549 (expiration_time - iter->second.last_access_time).InMinutes(), 1,
550 base::TimeDelta::FromDays(60).InMinutes(), 10);
551 }
539 } 552 }
540 } 553 }
541 554
542 ClientPolicyController* OfflinePageModel::GetPolicyController() { 555 ClientPolicyController* OfflinePageModel::GetPolicyController() {
543 return policy_controller_.get(); 556 return policy_controller_.get();
544 } 557 }
545 558
546 OfflinePageMetadataStore* OfflinePageModel::GetStoreForTesting() { 559 OfflinePageMetadataStore* OfflinePageModel::GetStoreForTesting() {
547 return store_.get(); 560 return store_.get();
548 } 561 }
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 void OfflinePageModel::RunWhenLoaded(const base::Closure& task) { 871 void OfflinePageModel::RunWhenLoaded(const base::Closure& task) {
859 if (!is_loaded_) { 872 if (!is_loaded_) {
860 delayed_tasks_.push_back(task); 873 delayed_tasks_.push_back(task);
861 return; 874 return;
862 } 875 }
863 876
864 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task); 877 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task);
865 } 878 }
866 879
867 } // namespace offline_pages 880 } // namespace offline_pages
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698