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; | |
|
mmenke
2013/10/30 18:29:08
nit: Alphabetize.
sclittle
2013/10/30 20:29:48
Done.
| |
| 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 | |
| 26 // on the same 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|. Init must be called before any | |
| 35 // other methods. | |
| 36 void Init(scoped_ptr<sql::Connection> db); | |
| 37 | |
| 38 // Reports UMA of precache statistics for days up to and including the day of | |
| 39 // |end_date|. The precache statistics for these days are deleted from the | |
| 40 // database after they have been reported, and expired precache history is | |
| 41 // deleted from the precache URL table. |end_date| is passed by value and not | |
| 42 // by const reference so that this method can be posted on a thread. | |
|
mmenke
2013/10/30 18:29:08
I don't believe this is true - when you pass by re
sclittle
2013/10/30 20:29:48
Done. I've changed it to pass Time by reference as
| |
| 43 void ReportAndDeleteOldStats(base::Time end_date); | |
| 44 | |
| 45 // Update precache-related metrics in response to a URL being fetched. | |
| 46 // Parameters are passed by value and not by const reference so that this | |
| 47 // method can be posted on a thread. | |
|
mmenke
2013/10/30 18:29:08
Again, this is not true. Should pass URL by refer
sclittle
2013/10/30 20:29:48
Done.
| |
| 48 void RecordURLFetched(GURL url, base::Time fetch_time, int64 size, | |
| 49 bool was_cached, bool is_precaching, bool is_cellular); | |
|
mmenke
2013/10/30 18:29:08
You definitely need to define is_precaching here.
mmenke
2013/10/30 18:29:08
nit: |is_cellular| could be clearer - I suggest i
sclittle
2013/10/30 20:29:48
Done.
sclittle
2013/10/30 20:29:48
It actually meant whether or not we are currently
| |
| 50 | |
| 51 private: | |
| 52 friend class base::RefCountedThreadSafe<PrecacheDatabase>; | |
| 53 friend class PrecacheDatabaseTest; | |
| 54 | |
| 55 ~PrecacheDatabase(); | |
| 56 | |
| 57 bool IsDatabaseAccessible() const; | |
| 58 | |
| 59 scoped_ptr<sql::Connection> db_; | |
| 60 scoped_ptr<PrecacheURLTable> precache_url_table_; | |
| 61 scoped_ptr<PrecacheStatisticsTable> precache_statistics_table_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(PrecacheDatabase); | |
| 64 }; | |
| 65 | |
| 66 } // namespace precache | |
| 67 | |
| 68 #endif // COMPONENTS_PRECACHE_CORE_PRECACHE_DATABASE_H_ | |
| OLD | NEW |