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

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

Issue 2596093002: Create a synthetic field trial for precache. (Closed)
Patch Set: Rebase. Created 3 years, 11 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/precache/content/precache_manager_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef COMPONENTS_PRECACHE_CORE_PRECACHE_DATABASE_H_ 5 #ifndef COMPONENTS_PRECACHE_CORE_PRECACHE_DATABASE_H_
6 #define COMPONENTS_PRECACHE_CORE_PRECACHE_DATABASE_H_ 6 #define COMPONENTS_PRECACHE_CORE_PRECACHE_DATABASE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 void DeleteExpiredPrecacheHistory(const base::Time& current_time); 60 void DeleteExpiredPrecacheHistory(const base::Time& current_time);
61 61
62 // Delete all history entries from the database. 62 // Delete all history entries from the database.
63 void ClearHistory(); 63 void ClearHistory();
64 64
65 // Setter and getter for the last precache timestamp. 65 // Setter and getter for the last precache timestamp.
66 void SetLastPrecacheTimestamp(const base::Time& time); 66 void SetLastPrecacheTimestamp(const base::Time& time);
67 base::Time GetLastPrecacheTimestamp(); 67 base::Time GetLastPrecacheTimestamp();
68 68
69 // Report precache-related metrics in response to a URL being fetched, where 69 // Report precache-related metrics in response to a URL being fetched, where
70 // the fetch was motivated by precaching. 70 // the fetch was motivated by precaching. This is called from the network
71 // delegate, via precache_util.
71 void RecordURLPrefetchMetrics(const net::HttpResponseInfo& info, 72 void RecordURLPrefetchMetrics(const net::HttpResponseInfo& info,
72 const base::TimeDelta& latency); 73 const base::TimeDelta& latency);
73 74
74 // Records the precache of an url |url| for top host |referrer_host|. 75 // Records the precache of an url |url| for top host |referrer_host|. This is
76 // called from PrecacheFetcher.
75 void RecordURLPrefetch(const GURL& url, 77 void RecordURLPrefetch(const GURL& url,
76 const std::string& referrer_host, 78 const std::string& referrer_host,
77 const base::Time& fetch_time, 79 const base::Time& fetch_time,
78 bool was_cached, 80 bool was_cached,
79 int64_t size); 81 int64_t size);
80 82
81 // Report precache-related metrics in response to a URL being fetched, where 83 // Report precache-related metrics in response to a URL being fetched, where
82 // the fetch was not motivated by precaching. |is_connection_cellular| 84 // the fetch was not motivated by precaching. |is_connection_cellular|
83 // indicates whether the current network connection is a cellular network. 85 // indicates whether the current network connection is a cellular network.
86 // This is called from the network delegate, via precache_util.
84 void RecordURLNonPrefetch(const GURL& url, 87 void RecordURLNonPrefetch(const GURL& url,
85 const base::TimeDelta& latency, 88 const base::TimeDelta& latency,
86 const base::Time& fetch_time, 89 const base::Time& fetch_time,
87 const net::HttpResponseInfo& info, 90 const net::HttpResponseInfo& info,
88 int64_t size, 91 int64_t size,
89 int host_rank, 92 int host_rank,
90 bool is_connection_cellular); 93 bool is_connection_cellular);
91 94
92 // Returns the referrer host entry for the |referrer_host|. 95 // Returns the referrer host entry for the |referrer_host|.
93 PrecacheReferrerHostEntry GetReferrerHost(const std::string& referrer_host); 96 PrecacheReferrerHostEntry GetReferrerHost(const std::string& referrer_host);
(...skipping 23 matching lines...) Expand all
117 120
118 // Precache quota. 121 // Precache quota.
119 void SaveQuota(const PrecacheQuota& quota); 122 void SaveQuota(const PrecacheQuota& quota);
120 PrecacheQuota GetQuota(); 123 PrecacheQuota GetQuota();
121 124
122 base::WeakPtr<PrecacheDatabase> GetWeakPtr(); 125 base::WeakPtr<PrecacheDatabase> GetWeakPtr();
123 126
124 private: 127 private:
125 friend class PrecacheDatabaseTest; 128 friend class PrecacheDatabaseTest;
126 friend class PrecacheFetcherTest; 129 friend class PrecacheFetcherTest;
130 friend class PrecacheManagerTest;
127 131
128 bool IsDatabaseAccessible() const; 132 bool IsDatabaseAccessible() const;
129 133
130 // Flushes any buffered write operations. |buffered_writes_| will be empty 134 // Flushes any buffered write operations. |buffered_writes_| will be empty
131 // after calling this function. To maximize performance, all the buffered 135 // after calling this function. To maximize performance, all the buffered
132 // writes are run in a single database transaction. 136 // writes are run in a single database transaction.
133 void Flush(); 137 void Flush();
134 138
135 // Same as Flush(), but also updates the flag |is_flush_posted_| to indicate 139 // Same as Flush(), but also updates the flag |is_flush_posted_| to indicate
136 // that a flush is no longer posted. 140 // that a flush is no longer posted.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 194
191 // This must be the last member of this class. 195 // This must be the last member of this class.
192 base::WeakPtrFactory<PrecacheDatabase> weak_factory_; 196 base::WeakPtrFactory<PrecacheDatabase> weak_factory_;
193 197
194 DISALLOW_COPY_AND_ASSIGN(PrecacheDatabase); 198 DISALLOW_COPY_AND_ASSIGN(PrecacheDatabase);
195 }; 199 };
196 200
197 } // namespace precache 201 } // namespace precache
198 202
199 #endif // COMPONENTS_PRECACHE_CORE_PRECACHE_DATABASE_H_ 203 #endif // COMPONENTS_PRECACHE_CORE_PRECACHE_DATABASE_H_
OLDNEW
« no previous file with comments | « components/precache/content/precache_manager_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698