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

Side by Side Diff: components/history/core/browser/top_sites_backend.cc

Issue 1018713002: Record the time to update top sites through db thread to understand if this is low and how slow it … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/history/core/browser/top_sites_backend.h" 5 #include "components/history/core/browser/top_sites_backend.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/metrics/histogram_macros.h"
12 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
13 #include "base/task/cancelable_task_tracker.h" 14 #include "base/task/cancelable_task_tracker.h"
15 #include "base/trace_event/trace_event.h"
14 #include "components/history/core/browser/top_sites_database.h" 16 #include "components/history/core/browser/top_sites_database.h"
15 #include "sql/connection.h" 17 #include "sql/connection.h"
16 18
17 namespace history { 19 namespace history {
18 20
19 TopSitesBackend::TopSitesBackend( 21 TopSitesBackend::TopSitesBackend(
20 const scoped_refptr<base::SingleThreadTaskRunner>& db_task_runner) 22 const scoped_refptr<base::SingleThreadTaskRunner>& db_task_runner)
21 : db_(new TopSitesDatabase()), db_task_runner_(db_task_runner) { 23 : db_(new TopSitesDatabase()), db_task_runner_(db_task_runner) {
22 DCHECK(db_task_runner_); 24 DCHECK(db_task_runner_);
23 } 25 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 if (db_) { 97 if (db_) {
96 db_->GetPageThumbnails(&(thumbnails->most_visited), 98 db_->GetPageThumbnails(&(thumbnails->most_visited),
97 &(thumbnails->url_to_images_map)); 99 &(thumbnails->url_to_images_map));
98 } 100 }
99 } 101 }
100 102
101 void TopSitesBackend::UpdateTopSitesOnDBThread(const TopSitesDelta& delta) { 103 void TopSitesBackend::UpdateTopSitesOnDBThread(const TopSitesDelta& delta) {
102 if (!db_) 104 if (!db_)
103 return; 105 return;
104 106
107 TRACE_EVENT0("startup", "history::TopSitesBackend::UpdateTopSitesOnDBThread");
rkaplow 2015/03/17 22:41:12 trace event should even be before the !db check.
yao 2015/03/18 19:38:05 I was trying to differenciate the cases where io d
rkaplow 2015/03/19 20:30:03 I think TRACE is supposed to be always at the star
108 // TODO(yiyaoliu): Remove the histogram and related code when crbug/223430 is
109 // fixed.
110 base::Time begin_time = base::Time::Now();
111
105 for (size_t i = 0; i < delta.deleted.size(); ++i) 112 for (size_t i = 0; i < delta.deleted.size(); ++i)
106 db_->RemoveURL(delta.deleted[i]); 113 db_->RemoveURL(delta.deleted[i]);
107 114
108 for (size_t i = 0; i < delta.added.size(); ++i) 115 for (size_t i = 0; i < delta.added.size(); ++i)
109 db_->SetPageThumbnail(delta.added[i].url, delta.added[i].rank, Images()); 116 db_->SetPageThumbnail(delta.added[i].url, delta.added[i].rank, Images());
110 117
111 for (size_t i = 0; i < delta.moved.size(); ++i) 118 for (size_t i = 0; i < delta.moved.size(); ++i)
112 db_->UpdatePageRank(delta.moved[i].url, delta.moved[i].rank); 119 db_->UpdatePageRank(delta.moved[i].url, delta.moved[i].rank);
120
121 UMA_HISTOGRAM_TIMES("History.UpdateTopSitesOnDBThreadTimeConsumption",
rkaplow 2015/03/17 22:41:12 I would get rid of 'Consumption' FunctionTime is
yao 2015/03/18 19:38:06 Done.
122 base::Time::Now() - begin_time);
113 } 123 }
114 124
115 void TopSitesBackend::SetPageThumbnailOnDBThread(const MostVisitedURL& url, 125 void TopSitesBackend::SetPageThumbnailOnDBThread(const MostVisitedURL& url,
116 int url_rank, 126 int url_rank,
117 const Images& thumbnail) { 127 const Images& thumbnail) {
118 if (!db_) 128 if (!db_)
119 return; 129 return;
120 130
121 db_->SetPageThumbnail(url, url_rank, thumbnail); 131 db_->SetPageThumbnail(url, url_rank, thumbnail);
122 } 132 }
123 133
124 void TopSitesBackend::ResetDatabaseOnDBThread(const base::FilePath& file_path) { 134 void TopSitesBackend::ResetDatabaseOnDBThread(const base::FilePath& file_path) {
125 DCHECK(db_task_runner_->BelongsToCurrentThread()); 135 DCHECK(db_task_runner_->BelongsToCurrentThread());
126 db_.reset(NULL); 136 db_.reset(NULL);
127 sql::Connection::Delete(db_path_); 137 sql::Connection::Delete(db_path_);
128 db_.reset(new TopSitesDatabase()); 138 db_.reset(new TopSitesDatabase());
129 InitDBOnDBThread(db_path_); 139 InitDBOnDBThread(db_path_);
130 } 140 }
131 141
132 } // namespace history 142 } // namespace history
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