| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Brought to you by the letter D and the number 2. | 5 // Brought to you by the letter D and the number 2. |
| 6 | 6 |
| 7 #ifndef NET_BASE_COOKIE_MONSTER_H_ | 7 #ifndef NET_BASE_COOKIE_MONSTER_H_ |
| 8 #define NET_BASE_COOKIE_MONSTER_H_ | 8 #define NET_BASE_COOKIE_MONSTER_H_ |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 #ifdef UNIT_TEST | 65 #ifdef UNIT_TEST |
| 66 CookieMonster(PersistentCookieStore* store, | 66 CookieMonster(PersistentCookieStore* store, |
| 67 Delegate* delegate, | 67 Delegate* delegate, |
| 68 int last_access_threshold_milliseconds) | 68 int last_access_threshold_milliseconds) |
| 69 : initialized_(false), | 69 : initialized_(false), |
| 70 store_(store), | 70 store_(store), |
| 71 last_access_threshold_(base::TimeDelta::FromMilliseconds( | 71 last_access_threshold_(base::TimeDelta::FromMilliseconds( |
| 72 last_access_threshold_milliseconds)), | 72 last_access_threshold_milliseconds)), |
| 73 delegate_(delegate), | 73 delegate_(delegate), |
| 74 last_statistic_record_time_(base::Time::Now()) { | 74 last_statistic_record_time_(base::Time::Now()) { |
| 75 InitializeHistograms(); |
| 75 SetDefaultCookieableSchemes(); | 76 SetDefaultCookieableSchemes(); |
| 76 } | 77 } |
| 77 #endif | 78 #endif |
| 78 | 79 |
| 79 // Parse the string with the cookie time (very forgivingly). | 80 // Parse the string with the cookie time (very forgivingly). |
| 80 static base::Time ParseCookieTime(const std::string& time_string); | 81 static base::Time ParseCookieTime(const std::string& time_string); |
| 81 | 82 |
| 82 // Returns true if a domain string represents a host-only cookie, | 83 // Returns true if a domain string represents a host-only cookie, |
| 83 // i.e. it doesn't begin with a leading '.' character. | 84 // i.e. it doesn't begin with a leading '.' character. |
| 84 static bool DomainIsHostOnly(const std::string& domain_string); | 85 static bool DomainIsHostOnly(const std::string& domain_string); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 bool HasCookieableScheme(const GURL& url); | 281 bool HasCookieableScheme(const GURL& url); |
| 281 | 282 |
| 282 // Statistics support | 283 // Statistics support |
| 283 // Record statistics every kRecordStatisticsIntervalSeconds of uptime. | 284 // Record statistics every kRecordStatisticsIntervalSeconds of uptime. |
| 284 static const int kRecordStatisticsIntervalSeconds = 10 * 60; | 285 static const int kRecordStatisticsIntervalSeconds = 10 * 60; |
| 285 | 286 |
| 286 // This function should be called repeatedly, and will record | 287 // This function should be called repeatedly, and will record |
| 287 // statistics if a sufficient time period has passed. | 288 // statistics if a sufficient time period has passed. |
| 288 void RecordPeriodicStats(const base::Time& current_time); | 289 void RecordPeriodicStats(const base::Time& current_time); |
| 289 | 290 |
| 291 // Histogram variables; see CookieMonster::InitializeHistograms() in |
| 292 // cookie_monster.cc for details. |
| 293 scoped_refptr<Histogram> histogram_expiration_duration_minutes_; |
| 294 scoped_refptr<Histogram> histogram_between_access_interval_minutes_; |
| 295 scoped_refptr<Histogram> histogram_evicted_last_access_minutes_; |
| 296 scoped_refptr<Histogram> histogram_count_; |
| 297 scoped_refptr<Histogram> histogram_number_duplicate_db_cookies_; |
| 298 scoped_refptr<Histogram> histogram_cookie_deletion_cause_; |
| 299 |
| 300 // Initialize the above variables; should only be called from |
| 301 // the constructor. |
| 302 void InitializeHistograms(); |
| 303 |
| 290 CookieMap cookies_; | 304 CookieMap cookies_; |
| 291 | 305 |
| 292 // Indicates whether the cookie store has been initialized. This happens | 306 // Indicates whether the cookie store has been initialized. This happens |
| 293 // lazily in InitStoreIfNecessary(). | 307 // lazily in InitStoreIfNecessary(). |
| 294 bool initialized_; | 308 bool initialized_; |
| 295 | 309 |
| 296 scoped_refptr<PersistentCookieStore> store_; | 310 scoped_refptr<PersistentCookieStore> store_; |
| 297 | 311 |
| 298 // The resolution of our time isn't enough, so we do something | 312 // The resolution of our time isn't enough, so we do something |
| 299 // ugly and increment when we've seen the same time twice. | 313 // ugly and increment when we've seen the same time twice. |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 protected: | 552 protected: |
| 539 PersistentCookieStore() { } | 553 PersistentCookieStore() { } |
| 540 | 554 |
| 541 private: | 555 private: |
| 542 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); | 556 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); |
| 543 }; | 557 }; |
| 544 | 558 |
| 545 } // namespace net | 559 } // namespace net |
| 546 | 560 |
| 547 #endif // NET_BASE_COOKIE_MONSTER_H_ | 561 #endif // NET_BASE_COOKIE_MONSTER_H_ |
| OLD | NEW |