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_CONTENT_PRECACHE_MANAGER_H_ | 5 #ifndef COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_ |
6 #define COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_ | 6 #define COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_ |
7 | 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
8 #include <list> | 11 #include <list> |
9 #include <string> | 12 #include <string> |
10 #include <utility> | 13 #include <utility> |
11 #include <vector> | 14 #include <vector> |
12 | 15 |
13 #include "base/callback.h" | 16 #include "base/callback.h" |
14 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
| 18 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_ptr.h" | 20 #include "base/memory/scoped_ptr.h" |
17 #include "base/memory/weak_ptr.h" | 21 #include "base/memory/weak_ptr.h" |
18 #include "components/history/core/browser/history_types.h" | 22 #include "components/history/core/browser/history_types.h" |
19 #include "components/keyed_service/core/keyed_service.h" | 23 #include "components/keyed_service/core/keyed_service.h" |
20 #include "components/precache/core/precache_fetcher.h" | 24 #include "components/precache/core/precache_fetcher.h" |
21 #include "url/gurl.h" | 25 #include "url/gurl.h" |
22 | 26 |
23 namespace base { | 27 namespace base { |
24 class Time; | 28 class Time; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 void CancelPrecaching(); | 91 void CancelPrecaching(); |
88 | 92 |
89 // Returns true if precaching is currently in progress, or false otherwise. | 93 // Returns true if precaching is currently in progress, or false otherwise. |
90 bool IsPrecaching() const; | 94 bool IsPrecaching() const; |
91 | 95 |
92 // Update precache-related metrics in response to a URL being fetched. | 96 // Update precache-related metrics in response to a URL being fetched. |
93 void RecordStatsForFetch(const GURL& url, | 97 void RecordStatsForFetch(const GURL& url, |
94 const GURL& referrer, | 98 const GURL& referrer, |
95 const base::TimeDelta& latency, | 99 const base::TimeDelta& latency, |
96 const base::Time& fetch_time, | 100 const base::Time& fetch_time, |
97 int64 size, | 101 int64_t size, |
98 bool was_cached); | 102 bool was_cached); |
99 | 103 |
100 // Posts a task to the DB thread to delete all history entries from the | 104 // Posts a task to the DB thread to delete all history entries from the |
101 // database. Does not wait for completion of this task. | 105 // database. Does not wait for completion of this task. |
102 void ClearHistory(); | 106 void ClearHistory(); |
103 | 107 |
104 private: | 108 private: |
105 enum class AllowedType { | 109 enum class AllowedType { |
106 ALLOWED, | 110 ALLOWED, |
107 DISALLOWED, | 111 DISALLOWED, |
(...skipping 14 matching lines...) Expand all Loading... |
122 void OnHostsReceivedThenDone(const history::TopHostsList& host_counts); | 126 void OnHostsReceivedThenDone(const history::TopHostsList& host_counts); |
123 | 127 |
124 // Returns true if precaching is allowed for the browser context. | 128 // Returns true if precaching is allowed for the browser context. |
125 AllowedType PrecachingAllowed() const; | 129 AllowedType PrecachingAllowed() const; |
126 | 130 |
127 // Update precache-related metrics in response to a URL being fetched. Called | 131 // Update precache-related metrics in response to a URL being fetched. Called |
128 // by RecordStatsForFetch() by way of an asynchronous HistoryService callback. | 132 // by RecordStatsForFetch() by way of an asynchronous HistoryService callback. |
129 void RecordStatsForFetchInternal(const GURL& url, | 133 void RecordStatsForFetchInternal(const GURL& url, |
130 const base::TimeDelta& latency, | 134 const base::TimeDelta& latency, |
131 const base::Time& fetch_time, | 135 const base::Time& fetch_time, |
132 int64 size, | 136 int64_t size, |
133 bool was_cached, | 137 bool was_cached, |
134 int host_rank); | 138 int host_rank); |
135 | 139 |
136 // The browser context that owns this PrecacheManager. | 140 // The browser context that owns this PrecacheManager. |
137 content::BrowserContext* const browser_context_; | 141 content::BrowserContext* const browser_context_; |
138 | 142 |
139 // The sync service corresponding to the browser context. Used to determine | 143 // The sync service corresponding to the browser context. Used to determine |
140 // whether precache can run. May be null. | 144 // whether precache can run. May be null. |
141 const sync_driver::SyncService* const sync_service_; | 145 const sync_driver::SyncService* const sync_service_; |
142 | 146 |
(...skipping 15 matching lines...) Expand all Loading... |
158 | 162 |
159 // Flag indicating whether or not precaching is currently in progress. | 163 // Flag indicating whether or not precaching is currently in progress. |
160 bool is_precaching_; | 164 bool is_precaching_; |
161 | 165 |
162 DISALLOW_COPY_AND_ASSIGN(PrecacheManager); | 166 DISALLOW_COPY_AND_ASSIGN(PrecacheManager); |
163 }; | 167 }; |
164 | 168 |
165 } // namespace precache | 169 } // namespace precache |
166 | 170 |
167 #endif // COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_ | 171 #endif // COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_ |
OLD | NEW |