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. 4 5 #ifndef CHROME_BROWSER_PREDICTORS_LOGGED_IN_PREDICTOR_TABLE_H_ 6 #define CHROME_BROWSER_PREDICTORS_LOGGED_IN_PREDICTOR_TABLE_H_ 7 8 #include <string> 9 10 #include "base/containers/hash_tables.h" 11 #include "base/time/time.h" 12 #include "chrome/browser/predictors/predictor_table_base.h" 13 #include "url/gurl.h" 14 15 namespace sql { 16 class Statement; 17 } 18 19 namespace predictors { 20 21 // Interface for database table to keep track of what sites a user is logged 22 // in to. 23 // All methods except the constructor and destructor need to be called on the DB 24 // thread. 25 // Manages one table { domain (primary key), added_timestamp }. 26 class LoggedInPredictorTable : public PredictorTableBase { 27 public: 28 typedef base::hash_map<std::string, int64> LoggedInStateMap; 29 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); 44 45 static std::string GetKey(const GURL& url); 46 static std::string GetKeyFromDomain(const std::string& domain); 47 48 private: 49 friend class PredictorDatabaseInternal; 50 51 LoggedInPredictorTable(); 52 virtual ~LoggedInPredictorTable(); 53 54 // PredictorTableBase methods. 55 virtual void CreateTableIfNonExistent() OVERRIDE; 56 virtual void LogDatabaseStats() OVERRIDE; 57 58 DISALLOW_COPY_AND_ASSIGN(LoggedInPredictorTable); 59 }; 60 61 } // namespace predictors 62 63 #endif // CHROME_BROWSER_PREDICTORS_LOGGED_IN_PREDICTOR_TABLE_H_ 64