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

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

Issue 1950423006: Offline Pages: Add Model Load Time UMA. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename metrics for more precision. Created 4 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 | « components/offline_pages/offline_page_model.h ('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 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 const base::FilePath& archives_dir, 112 const base::FilePath& archives_dir,
113 const scoped_refptr<base::SequencedTaskRunner>& task_runner) 113 const scoped_refptr<base::SequencedTaskRunner>& task_runner)
114 : store_(std::move(store)), 114 : store_(std::move(store)),
115 archives_dir_(archives_dir), 115 archives_dir_(archives_dir),
116 is_loaded_(false), 116 is_loaded_(false),
117 task_runner_(task_runner), 117 task_runner_(task_runner),
118 weak_ptr_factory_(this) { 118 weak_ptr_factory_(this) {
119 task_runner_->PostTaskAndReply( 119 task_runner_->PostTaskAndReply(
120 FROM_HERE, base::Bind(EnsureArchivesDirCreated, archives_dir_), 120 FROM_HERE, base::Bind(EnsureArchivesDirCreated, archives_dir_),
121 base::Bind(&OfflinePageModel::OnEnsureArchivesDirCreatedDone, 121 base::Bind(&OfflinePageModel::OnEnsureArchivesDirCreatedDone,
122 weak_ptr_factory_.GetWeakPtr())); 122 weak_ptr_factory_.GetWeakPtr(), base::TimeTicks::Now()));
123 } 123 }
124 124
125 OfflinePageModel::~OfflinePageModel() { 125 OfflinePageModel::~OfflinePageModel() {
126 } 126 }
127 127
128 void OfflinePageModel::AddObserver(Observer* observer) { 128 void OfflinePageModel::AddObserver(Observer* observer) {
129 observers_.AddObserver(observer); 129 observers_.AddObserver(observer);
130 } 130 }
131 131
132 void OfflinePageModel::RemoveObserver(Observer* observer) { 132 void OfflinePageModel::RemoveObserver(Observer* observer) {
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 void OfflinePageModel::OnMarkPageAccesseDone( 567 void OfflinePageModel::OnMarkPageAccesseDone(
568 const OfflinePageItem& offline_page_item, bool success) { 568 const OfflinePageItem& offline_page_item, bool success) {
569 // Update the item in the cache only upon success. 569 // Update the item in the cache only upon success.
570 if (success) 570 if (success)
571 offline_pages_[offline_page_item.offline_id] = offline_page_item; 571 offline_pages_[offline_page_item.offline_id] = offline_page_item;
572 572
573 // No need to fire OfflinePageModelChanged event since updating access info 573 // No need to fire OfflinePageModelChanged event since updating access info
574 // should not have any impact to the UI. 574 // should not have any impact to the UI.
575 } 575 }
576 576
577 void OfflinePageModel::OnEnsureArchivesDirCreatedDone() { 577 void OfflinePageModel::OnEnsureArchivesDirCreatedDone(
578 const base::TimeTicks& start_time) {
579 UMA_HISTOGRAM_TIMES("OfflinePages.Model.ArchiveDirCreationTime",
580 base::TimeTicks::Now() - start_time);
581
578 store_->Load(base::Bind(&OfflinePageModel::OnLoadDone, 582 store_->Load(base::Bind(&OfflinePageModel::OnLoadDone,
579 weak_ptr_factory_.GetWeakPtr())); 583 weak_ptr_factory_.GetWeakPtr(), start_time));
580 } 584 }
581 585
582 void OfflinePageModel::OnLoadDone( 586 void OfflinePageModel::OnLoadDone(
587 const base::TimeTicks& start_time,
583 OfflinePageMetadataStore::LoadStatus load_status, 588 OfflinePageMetadataStore::LoadStatus load_status,
584 const std::vector<OfflinePageItem>& offline_pages) { 589 const std::vector<OfflinePageItem>& offline_pages) {
585 DCHECK(!is_loaded_); 590 DCHECK(!is_loaded_);
586 is_loaded_ = true; 591 is_loaded_ = true;
587 592
588 // TODO(jianli): rebuild the store upon failure. 593 // TODO(jianli): rebuild the store upon failure.
589 594
590 if (load_status == OfflinePageMetadataStore::LOAD_SUCCEEDED) 595 if (load_status == OfflinePageMetadataStore::LOAD_SUCCEEDED)
591 CacheLoadedData(offline_pages); 596 CacheLoadedData(offline_pages);
592 597
598 UMA_HISTOGRAM_TIMES("OfflinePages.Model.ConstructionToLoadedEventTime",
599 base::TimeTicks::Now() - start_time);
600
593 // Run all the delayed tasks. 601 // Run all the delayed tasks.
594 for (const auto& delayed_task : delayed_tasks_) 602 for (const auto& delayed_task : delayed_tasks_)
595 delayed_task.Run(); 603 delayed_task.Run();
596 delayed_tasks_.clear(); 604 delayed_tasks_.clear();
597 605
598 FOR_EACH_OBSERVER(Observer, observers_, OfflinePageModelLoaded(this)); 606 FOR_EACH_OBSERVER(Observer, observers_, OfflinePageModelLoaded(this));
599 607
600 CheckForExternalFileDeletion(); 608 CheckForExternalFileDeletion();
601 } 609 }
602 610
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 void OfflinePageModel::RunWhenLoaded(const base::Closure& task) { 792 void OfflinePageModel::RunWhenLoaded(const base::Closure& task) {
785 if (!is_loaded_) { 793 if (!is_loaded_) {
786 delayed_tasks_.push_back(task); 794 delayed_tasks_.push_back(task);
787 return; 795 return;
788 } 796 }
789 797
790 task_runner_->PostTask(FROM_HERE, task); 798 task_runner_->PostTask(FROM_HERE, task);
791 } 799 }
792 800
793 } // namespace offline_pages 801 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/offline_page_model.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698