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

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

Issue 27047003: Precache tracking database (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@precache
Patch Set: Moved MostVisitedURLsProvider into chrome/browser/precache Created 7 years, 1 month 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
OLDNEW
(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
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(sql::Connection* db);
mmenke 2013/10/29 18:23:34 May want to pass in the db as a scoped_ptr<sql::Co
sclittle 2013/10/29 23:40:45 Done.
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.
43 void ReportAndDeleteOldStats(base::Time end_date);
44
45 // Update metrics in response to a URL being fetched. Parameters are passed by
46 // value and not by const reference so that this method can be posted on a
47 // thread.
48 void RecordURLFetched(GURL url, base::Time fetch_time, int64 size,
49 bool was_cached, bool is_precaching, bool is_cellular);
50
51 private:
52 friend class base::RefCountedThreadSafe<PrecacheDatabase>;
53 friend class PrecacheDatabaseTest;
54 ~PrecacheDatabase();
mmenke 2013/10/29 18:23:34 nit: Think there should be a blank line between f
sclittle 2013/10/29 23:40:45 Done.
55
56 bool CantAccessDatabase();
57
58 scoped_ptr<sql::Connection> db_;
59 scoped_ptr<PrecacheURLTable> precache_url_table_;
60 scoped_ptr<PrecacheStatisticsTable> precache_statistics_table_;
61
62 DISALLOW_COPY_AND_ASSIGN(PrecacheDatabase);
63 };
64
65 } // namespace precache
66
67 #endif // COMPONENTS_PRECACHE_CORE_PRECACHE_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698