| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "content/browser/net/sqlite_persistent_cookie_store.h" | 5 #include "content/browser/net/sqlite_persistent_cookie_store.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 // disk on the BG runner every 30 seconds, 512 operations, or call to Flush(), | 69 // disk on the BG runner every 30 seconds, 512 operations, or call to Flush(), |
| 70 // whichever occurs first. | 70 // whichever occurs first. |
| 71 class SQLitePersistentCookieStore::Backend | 71 class SQLitePersistentCookieStore::Backend |
| 72 : public base::RefCountedThreadSafe<SQLitePersistentCookieStore::Backend> { | 72 : public base::RefCountedThreadSafe<SQLitePersistentCookieStore::Backend> { |
| 73 public: | 73 public: |
| 74 Backend( | 74 Backend( |
| 75 const base::FilePath& path, | 75 const base::FilePath& path, |
| 76 const scoped_refptr<base::SequencedTaskRunner>& client_task_runner, | 76 const scoped_refptr<base::SequencedTaskRunner>& client_task_runner, |
| 77 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, | 77 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, |
| 78 bool restore_old_session_cookies, | 78 bool restore_old_session_cookies, |
| 79 quota::SpecialStoragePolicy* special_storage_policy, | 79 storage::SpecialStoragePolicy* special_storage_policy, |
| 80 CookieCryptoDelegate* crypto_delegate) | 80 CookieCryptoDelegate* crypto_delegate) |
| 81 : path_(path), | 81 : path_(path), |
| 82 num_pending_(0), | 82 num_pending_(0), |
| 83 force_keep_session_state_(false), | 83 force_keep_session_state_(false), |
| 84 initialized_(false), | 84 initialized_(false), |
| 85 corruption_detected_(false), | 85 corruption_detected_(false), |
| 86 restore_old_session_cookies_(restore_old_session_cookies), | 86 restore_old_session_cookies_(restore_old_session_cookies), |
| 87 special_storage_policy_(special_storage_policy), | 87 special_storage_policy_(special_storage_policy), |
| 88 num_cookies_read_(0), | 88 num_cookies_read_(0), |
| 89 client_task_runner_(client_task_runner), | 89 client_task_runner_(client_task_runner), |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 // Indicates if DB has been initialized. | 242 // Indicates if DB has been initialized. |
| 243 bool initialized_; | 243 bool initialized_; |
| 244 | 244 |
| 245 // Indicates if the kill-database callback has been scheduled. | 245 // Indicates if the kill-database callback has been scheduled. |
| 246 bool corruption_detected_; | 246 bool corruption_detected_; |
| 247 | 247 |
| 248 // If false, we should filter out session cookies when reading the DB. | 248 // If false, we should filter out session cookies when reading the DB. |
| 249 bool restore_old_session_cookies_; | 249 bool restore_old_session_cookies_; |
| 250 | 250 |
| 251 // Policy defining what data is deleted on shutdown. | 251 // Policy defining what data is deleted on shutdown. |
| 252 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; | 252 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy_; |
| 253 | 253 |
| 254 // The cumulative time spent loading the cookies on the background runner. | 254 // The cumulative time spent loading the cookies on the background runner. |
| 255 // Incremented and reported from the background runner. | 255 // Incremented and reported from the background runner. |
| 256 base::TimeDelta cookie_load_duration_; | 256 base::TimeDelta cookie_load_duration_; |
| 257 | 257 |
| 258 // The total number of cookies read. Incremented and reported on the | 258 // The total number of cookies read. Incremented and reported on the |
| 259 // background runner. | 259 // background runner. |
| 260 int num_cookies_read_; | 260 int num_cookies_read_; |
| 261 | 261 |
| 262 scoped_refptr<base::SequencedTaskRunner> client_task_runner_; | 262 scoped_refptr<base::SequencedTaskRunner> client_task_runner_; |
| (...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1198 LOG(WARNING) << "Failed to post task from " << origin.ToString() | 1198 LOG(WARNING) << "Failed to post task from " << origin.ToString() |
| 1199 << " to client_task_runner_."; | 1199 << " to client_task_runner_."; |
| 1200 } | 1200 } |
| 1201 } | 1201 } |
| 1202 | 1202 |
| 1203 SQLitePersistentCookieStore::SQLitePersistentCookieStore( | 1203 SQLitePersistentCookieStore::SQLitePersistentCookieStore( |
| 1204 const base::FilePath& path, | 1204 const base::FilePath& path, |
| 1205 const scoped_refptr<base::SequencedTaskRunner>& client_task_runner, | 1205 const scoped_refptr<base::SequencedTaskRunner>& client_task_runner, |
| 1206 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, | 1206 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, |
| 1207 bool restore_old_session_cookies, | 1207 bool restore_old_session_cookies, |
| 1208 quota::SpecialStoragePolicy* special_storage_policy, | 1208 storage::SpecialStoragePolicy* special_storage_policy, |
| 1209 CookieCryptoDelegate* crypto_delegate) | 1209 CookieCryptoDelegate* crypto_delegate) |
| 1210 : backend_(new Backend(path, | 1210 : backend_(new Backend(path, |
| 1211 client_task_runner, | 1211 client_task_runner, |
| 1212 background_task_runner, | 1212 background_task_runner, |
| 1213 restore_old_session_cookies, | 1213 restore_old_session_cookies, |
| 1214 special_storage_policy, | 1214 special_storage_policy, |
| 1215 crypto_delegate)) { | 1215 crypto_delegate)) { |
| 1216 } | 1216 } |
| 1217 | 1217 |
| 1218 void SQLitePersistentCookieStore::Load(const LoadedCallback& loaded_callback) { | 1218 void SQLitePersistentCookieStore::Load(const LoadedCallback& loaded_callback) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1252 // a reference if the background runner has not run Close() yet. | 1252 // a reference if the background runner has not run Close() yet. |
| 1253 } | 1253 } |
| 1254 | 1254 |
| 1255 CookieStoreConfig::CookieStoreConfig() | 1255 CookieStoreConfig::CookieStoreConfig() |
| 1256 : session_cookie_mode(EPHEMERAL_SESSION_COOKIES), | 1256 : session_cookie_mode(EPHEMERAL_SESSION_COOKIES), |
| 1257 crypto_delegate(NULL) { | 1257 crypto_delegate(NULL) { |
| 1258 // Default to an in-memory cookie store. | 1258 // Default to an in-memory cookie store. |
| 1259 } | 1259 } |
| 1260 | 1260 |
| 1261 CookieStoreConfig::CookieStoreConfig( | 1261 CookieStoreConfig::CookieStoreConfig( |
| 1262 const base::FilePath& path, | 1262 const base::FilePath& path, |
| 1263 SessionCookieMode session_cookie_mode, | 1263 SessionCookieMode session_cookie_mode, |
| 1264 quota::SpecialStoragePolicy* storage_policy, | 1264 storage::SpecialStoragePolicy* storage_policy, |
| 1265 net::CookieMonsterDelegate* cookie_delegate) | 1265 net::CookieMonsterDelegate* cookie_delegate) |
| 1266 : path(path), | 1266 : path(path), |
| 1267 session_cookie_mode(session_cookie_mode), | 1267 session_cookie_mode(session_cookie_mode), |
| 1268 storage_policy(storage_policy), | 1268 storage_policy(storage_policy), |
| 1269 cookie_delegate(cookie_delegate), | 1269 cookie_delegate(cookie_delegate), |
| 1270 crypto_delegate(NULL) { | 1270 crypto_delegate(NULL) { |
| 1271 CHECK(!path.empty() || session_cookie_mode == EPHEMERAL_SESSION_COOKIES); | 1271 CHECK(!path.empty() || session_cookie_mode == EPHEMERAL_SESSION_COOKIES); |
| 1272 } | 1272 } |
| 1273 | 1273 |
| 1274 CookieStoreConfig::~CookieStoreConfig() { | 1274 CookieStoreConfig::~CookieStoreConfig() { |
| 1275 } | 1275 } |
| 1276 | 1276 |
| 1277 net::CookieStore* CreateCookieStore(const CookieStoreConfig& config) { | 1277 net::CookieStore* CreateCookieStore(const CookieStoreConfig& config) { |
| 1278 net::CookieMonster* cookie_monster = NULL; | 1278 net::CookieMonster* cookie_monster = NULL; |
| 1279 | 1279 |
| 1280 if (config.path.empty()) { | 1280 if (config.path.empty()) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1328 if (base::CommandLine::InitializedForCurrentProcess() && | 1328 if (base::CommandLine::InitializedForCurrentProcess() && |
| 1329 base::CommandLine::ForCurrentProcess()->HasSwitch( | 1329 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1330 switches::kEnableFileCookies)) { | 1330 switches::kEnableFileCookies)) { |
| 1331 cookie_monster->SetEnableFileScheme(true); | 1331 cookie_monster->SetEnableFileScheme(true); |
| 1332 } | 1332 } |
| 1333 | 1333 |
| 1334 return cookie_monster; | 1334 return cookie_monster; |
| 1335 } | 1335 } |
| 1336 | 1336 |
| 1337 } // namespace content | 1337 } // namespace content |
| OLD | NEW |