| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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_ |
| OLD | NEW |