1 // Copyright (c) 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.
5 #ifndef CHROME_BROWSER_PREDICTORS_LOGGED_IN_PREDICTOR_TABLE_H_
6 #define CHROME_BROWSER_PREDICTORS_LOGGED_IN_PREDICTOR_TABLE_H_
10 #include "base/containers/hash_tables.h"
11 #include "base/time/time.h"
12 #include "chrome/browser/predictors/predictor_table_base.h"
19 namespace predictors
{
21 // Interface for database table to keep track of what sites a user is logged
23 // All methods except the constructor and destructor need to be called on the DB
25 // Manages one table { domain (primary key), added_timestamp }.
26 class LoggedInPredictorTable
: public PredictorTableBase
{
28 typedef base::hash_map
<std::string
, int64
> LoggedInStateMap
;
30 // Adds the relevant part of the domain of the URL provided to the database
31 // as the user having performed a login action.
32 void AddDomainFromURL(const GURL
& url
);
33 // Deletes a record for the domain corresponding to the URL provided.
34 void DeleteDomainFromURL(const GURL
& url
);
35 // Deletes a record for the domain provided.
36 void DeleteDomain(const std::string
& domain
);
37 // Checks whether for the relevant part of the domain of the URL provided,
38 // the user has performed a login action in the past.
39 void HasUserLoggedIn(const GURL
& url
, bool* is_present
,
40 bool* lookup_succeeded
);
41 void DeleteAllCreatedBetween(const base::Time
& delete_begin
,
42 const base::Time
& delete_end
);
43 void GetAllData(LoggedInStateMap
* state_map
);
45 static std::string
GetKey(const GURL
& url
);
46 static std::string
GetKeyFromDomain(const std::string
& domain
);
49 friend class PredictorDatabaseInternal
;
51 LoggedInPredictorTable();
52 ~LoggedInPredictorTable() override
;
54 // PredictorTableBase methods.
55 void CreateTableIfNonExistent() override
;
56 void LogDatabaseStats() override
;
58 DISALLOW_COPY_AND_ASSIGN(LoggedInPredictorTable
);
61 } // namespace predictors
63 #endif // CHROME_BROWSER_PREDICTORS_LOGGED_IN_PREDICTOR_TABLE_H_