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

Side by Side Diff: components/precache/core/precache_database.cc

Issue 1551433002: Switch to standard integer types in components/, part 3 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more Created 4 years, 12 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/precache/core/precache_database.h" 5 #include "components/precache/core/precache_database.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 } 84 }
85 85
86 buffered_writes_.push_back(base::Bind( 86 buffered_writes_.push_back(base::Bind(
87 &PrecacheURLTable::DeleteAll, base::Unretained(&precache_url_table_))); 87 &PrecacheURLTable::DeleteAll, base::Unretained(&precache_url_table_)));
88 Flush(); 88 Flush();
89 } 89 }
90 90
91 void PrecacheDatabase::RecordURLPrefetch(const GURL& url, 91 void PrecacheDatabase::RecordURLPrefetch(const GURL& url,
92 const base::TimeDelta& latency, 92 const base::TimeDelta& latency,
93 const base::Time& fetch_time, 93 const base::Time& fetch_time,
94 int64 size, 94 int64_t size,
95 bool was_cached) { 95 bool was_cached) {
96 UMA_HISTOGRAM_TIMES("Precache.Latency.Prefetch", latency); 96 UMA_HISTOGRAM_TIMES("Precache.Latency.Prefetch", latency);
97 97
98 if (!IsDatabaseAccessible()) { 98 if (!IsDatabaseAccessible()) {
99 // Don't track anything if unable to access the database. 99 // Don't track anything if unable to access the database.
100 return; 100 return;
101 } 101 }
102 102
103 if (buffered_urls_.find(url.spec()) != buffered_urls_.end()) { 103 if (buffered_urls_.find(url.spec()) != buffered_urls_.end()) {
104 // If the URL for this fetch is in the write buffer, then flush the write 104 // If the URL for this fetch is in the write buffer, then flush the write
(...skipping 22 matching lines...) Expand all
127 buffered_writes_.push_back( 127 buffered_writes_.push_back(
128 base::Bind(&PrecacheURLTable::AddURL, 128 base::Bind(&PrecacheURLTable::AddURL,
129 base::Unretained(&precache_url_table_), url, fetch_time)); 129 base::Unretained(&precache_url_table_), url, fetch_time));
130 buffered_urls_.insert(url.spec()); 130 buffered_urls_.insert(url.spec());
131 MaybePostFlush(); 131 MaybePostFlush();
132 } 132 }
133 133
134 void PrecacheDatabase::RecordURLNonPrefetch(const GURL& url, 134 void PrecacheDatabase::RecordURLNonPrefetch(const GURL& url,
135 const base::TimeDelta& latency, 135 const base::TimeDelta& latency,
136 const base::Time& fetch_time, 136 const base::Time& fetch_time,
137 int64 size, 137 int64_t size,
138 bool was_cached, 138 bool was_cached,
139 int host_rank, 139 int host_rank,
140 bool is_connection_cellular) { 140 bool is_connection_cellular) {
141 UMA_HISTOGRAM_TIMES("Precache.Latency.NonPrefetch", latency); 141 UMA_HISTOGRAM_TIMES("Precache.Latency.NonPrefetch", latency);
142 142
143 if (host_rank != history::kMaxTopHosts) { 143 if (host_rank != history::kMaxTopHosts) {
144 // The resource was loaded on a page that could have been affected by 144 // The resource was loaded on a page that could have been affected by
145 // precaching. 145 // precaching.
146 UMA_HISTOGRAM_TIMES("Precache.Latency.NonPrefetch.TopHosts", latency); 146 UMA_HISTOGRAM_TIMES("Precache.Latency.NonPrefetch.TopHosts", latency);
147 } else { 147 } else {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 // database writes can be buffered up and flushed together in the same 253 // database writes can be buffered up and flushed together in the same
254 // transaction. 254 // transaction.
255 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 255 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
256 FROM_HERE, base::Bind(&PrecacheDatabase::PostedFlush, 256 FROM_HERE, base::Bind(&PrecacheDatabase::PostedFlush,
257 scoped_refptr<PrecacheDatabase>(this)), 257 scoped_refptr<PrecacheDatabase>(this)),
258 base::TimeDelta::FromSeconds(1)); 258 base::TimeDelta::FromSeconds(1));
259 is_flush_posted_ = true; 259 is_flush_posted_ = true;
260 } 260 }
261 261
262 } // namespace precache 262 } // namespace precache
OLDNEW
« no previous file with comments | « components/precache/core/precache_database.h ('k') | components/precache/core/precache_database_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698