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 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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()) { |
1281 // Empty path means in-memory store. | 1281 // Empty path means in-memory store. |
1282 cookie_monster = new net::CookieMonster(NULL, config.cookie_delegate); | 1282 cookie_monster = new net::CookieMonster(NULL, config.cookie_delegate.get()); |
1283 } else { | 1283 } else { |
1284 scoped_refptr<base::SequencedTaskRunner> client_task_runner = | 1284 scoped_refptr<base::SequencedTaskRunner> client_task_runner = |
1285 config.client_task_runner; | 1285 config.client_task_runner; |
1286 scoped_refptr<base::SequencedTaskRunner> background_task_runner = | 1286 scoped_refptr<base::SequencedTaskRunner> background_task_runner = |
1287 config.background_task_runner; | 1287 config.background_task_runner; |
1288 | 1288 |
1289 if (!client_task_runner) { | 1289 if (!client_task_runner.get()) { |
1290 client_task_runner = | 1290 client_task_runner = |
1291 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 1291 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
1292 } | 1292 } |
1293 | 1293 |
1294 if (!background_task_runner) { | 1294 if (!background_task_runner.get()) { |
1295 background_task_runner = | 1295 background_task_runner = |
1296 BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( | 1296 BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( |
1297 BrowserThread::GetBlockingPool()->GetSequenceToken()); | 1297 BrowserThread::GetBlockingPool()->GetSequenceToken()); |
1298 } | 1298 } |
1299 | 1299 |
1300 SQLitePersistentCookieStore* persistent_store = | 1300 SQLitePersistentCookieStore* persistent_store = |
1301 new SQLitePersistentCookieStore( | 1301 new SQLitePersistentCookieStore( |
1302 config.path, | 1302 config.path, |
1303 client_task_runner, | 1303 client_task_runner, |
1304 background_task_runner, | 1304 background_task_runner, |
1305 (config.session_cookie_mode == | 1305 (config.session_cookie_mode == |
1306 CookieStoreConfig::RESTORED_SESSION_COOKIES), | 1306 CookieStoreConfig::RESTORED_SESSION_COOKIES), |
1307 config.storage_policy, | 1307 config.storage_policy.get(), |
1308 config.crypto_delegate); | 1308 config.crypto_delegate); |
1309 | 1309 |
1310 cookie_monster = | 1310 cookie_monster = |
1311 new net::CookieMonster(persistent_store, config.cookie_delegate); | 1311 new net::CookieMonster(persistent_store, config.cookie_delegate.get()); |
1312 if ((config.session_cookie_mode == | 1312 if ((config.session_cookie_mode == |
1313 CookieStoreConfig::PERSISTANT_SESSION_COOKIES) || | 1313 CookieStoreConfig::PERSISTANT_SESSION_COOKIES) || |
1314 (config.session_cookie_mode == | 1314 (config.session_cookie_mode == |
1315 CookieStoreConfig::RESTORED_SESSION_COOKIES)) { | 1315 CookieStoreConfig::RESTORED_SESSION_COOKIES)) { |
1316 cookie_monster->SetPersistSessionCookies(true); | 1316 cookie_monster->SetPersistSessionCookies(true); |
1317 } | 1317 } |
1318 } | 1318 } |
1319 | 1319 |
1320 // In the case of Android WebView, the cookie store may be created | 1320 // In the case of Android WebView, the cookie store may be created |
1321 // before the browser process fully initializes -- certainly before | 1321 // before the browser process fully initializes -- certainly before |
1322 // the main loop ever runs. In this situation, the CommandLine singleton | 1322 // the main loop ever runs. In this situation, the CommandLine singleton |
1323 // will not have been set up. Android tests do not need file cookies | 1323 // will not have been set up. Android tests do not need file cookies |
1324 // so always ignore them here. | 1324 // so always ignore them here. |
1325 // | 1325 // |
1326 // TODO(ajwong): Remove the InitializedForCurrentProcess() check | 1326 // TODO(ajwong): Remove the InitializedForCurrentProcess() check |
1327 // once http://crbug.com/331424 is resolved. | 1327 // once http://crbug.com/331424 is resolved. |
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 |