Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_PRECACHE_CORE_PRECACHE_DATABASE_H_ | |
| 6 #define COMPONENTS_PRECACHE_CORE_PRECACHE_DATABASE_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/threading/non_thread_safe.h" | |
| 12 #include "base/time/time.h" | |
| 13 #include "url/gurl.h" | |
| 14 | |
| 15 namespace sql { | |
| 16 class Connection; | |
| 17 } | |
| 18 | |
| 19 namespace precache { | |
| 20 | |
| 21 class PrecacheURLTable; | |
| 22 class PrecacheStatisticsTable; | |
| 23 | |
| 24 // Class that tracks information related to precaching. This class can be | |
| 25 // constructed or destroyed on any threads, but all other methods must be called | |
|
bengr
2013/10/23 19:03:36
threads -> thread
on a single thread -> on the sa
sclittle
2013/10/24 22:11:38
Done.
| |
| 26 // on a single thread (e.g. the DB thread). | |
| 27 class PrecacheDatabase : public base::RefCountedThreadSafe<PrecacheDatabase>, | |
| 28 base::NonThreadSafe { | |
| 29 public: | |
| 30 // A PrecacheDatabase can be constructed on any thread. | |
| 31 PrecacheDatabase(); | |
| 32 | |
| 33 // Initializes the precache database with the specified connection. The | |
| 34 // PrecacheDatabase takes ownership of |db|. | |
| 35 void Init(sql::Connection* db); | |
| 36 | |
| 37 // Reports UMA of precache statistics for days up to and including the day of | |
| 38 // |flush_end_date|. The precache statistics for these days are deleted from | |
| 39 // the database after they have been reported, and expired precache history is | |
| 40 // deleted from the precache URL table. | |
| 41 void FlushOldStats(base::Time flush_end_date); | |
|
bengr
2013/10/23 19:03:36
ReportPreviousDaysStats() ?
sclittle
2013/10/24 22:11:38
Changed to ReportAndDeleteOldStats.
Passing in a
| |
| 42 | |
| 43 // Update metrics in response to a URL being fetched. | |
| 44 void RecordURLFetched(GURL url, base::Time fetch_time, int64 size, | |
| 45 bool was_cached, bool is_precaching, bool is_cellular); | |
| 46 | |
| 47 private: | |
| 48 friend class base::RefCountedThreadSafe<PrecacheDatabase>; | |
| 49 friend class PrecacheDatabaseTest; | |
| 50 ~PrecacheDatabase(); | |
| 51 | |
| 52 void CreateTableIfNonExistent(); | |
| 53 | |
| 54 scoped_ptr<sql::Connection> db_; | |
| 55 scoped_ptr<PrecacheURLTable> precache_url_table_; | |
| 56 scoped_ptr<PrecacheStatisticsTable> precache_statistics_table_; | |
| 57 | |
| 58 DISALLOW_COPY_AND_ASSIGN(PrecacheDatabase); | |
| 59 }; | |
| 60 | |
| 61 } // namespace precache | |
| 62 | |
| 63 #endif // COMPONENTS_PRECACHE_CORE_PRECACHE_DATABASE_H_ | |
| OLD | NEW |