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 "chrome/browser/prerender/prerender_manager.h" | 5 #include "chrome/browser/prerender/prerender_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1431 return; | 1431 return; |
1432 } | 1432 } |
1433 DCHECK(type == chrome::NOTIFICATION_COOKIE_CHANGED); | 1433 DCHECK(type == chrome::NOTIFICATION_COOKIE_CHANGED); |
1434 CookieChanged(content::Details<ChromeCookieDetails>(details).ptr()); | 1434 CookieChanged(content::Details<ChromeCookieDetails>(details).ptr()); |
1435 } | 1435 } |
1436 | 1436 |
1437 void PrerenderManager::RecordLikelyLoginOnURL(const GURL& url) { | 1437 void PrerenderManager::RecordLikelyLoginOnURL(const GURL& url) { |
1438 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1438 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1439 if (!IsWebURL(url)) | 1439 if (!IsWebURL(url)) |
1440 return; | 1440 return; |
1441 if (logged_in_predictor_table_) { | 1441 if (logged_in_predictor_table_.get()) { |
1442 BrowserThread::PostTask( | 1442 BrowserThread::PostTask( |
1443 BrowserThread::DB, FROM_HERE, | 1443 BrowserThread::DB, |
| 1444 FROM_HERE, |
1444 base::Bind(&LoggedInPredictorTable::AddDomainFromURL, | 1445 base::Bind(&LoggedInPredictorTable::AddDomainFromURL, |
1445 logged_in_predictor_table_, url)); | 1446 logged_in_predictor_table_, |
| 1447 url)); |
1446 } | 1448 } |
1447 std::string key = LoggedInPredictorTable::GetKey(url); | 1449 std::string key = LoggedInPredictorTable::GetKey(url); |
1448 if (!logged_in_state_.get()) | 1450 if (!logged_in_state_.get()) |
1449 return; | 1451 return; |
1450 if (logged_in_state_->count(key)) | 1452 if (logged_in_state_->count(key)) |
1451 return; | 1453 return; |
1452 (*logged_in_state_)[key] = base::Time::Now().ToInternalValue(); | 1454 (*logged_in_state_)[key] = base::Time::Now().ToInternalValue(); |
1453 } | 1455 } |
1454 | 1456 |
1455 void PrerenderManager::CheckIfLikelyLoggedInOnURL( | 1457 void PrerenderManager::CheckIfLikelyLoggedInOnURL( |
1456 const GURL& url, | 1458 const GURL& url, |
1457 bool* lookup_result, | 1459 bool* lookup_result, |
1458 bool* database_was_present, | 1460 bool* database_was_present, |
1459 const base::Closure& result_cb) { | 1461 const base::Closure& result_cb) { |
1460 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1462 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1461 if (!logged_in_predictor_table_) { | 1463 if (!logged_in_predictor_table_.get()) { |
1462 *database_was_present = false; | 1464 *database_was_present = false; |
1463 *lookup_result = false; | 1465 *lookup_result = false; |
1464 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, result_cb); | 1466 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, result_cb); |
1465 return; | 1467 return; |
1466 } | 1468 } |
1467 BrowserThread::PostTaskAndReply( | 1469 BrowserThread::PostTaskAndReply( |
1468 BrowserThread::DB, FROM_HERE, | 1470 BrowserThread::DB, FROM_HERE, |
1469 base::Bind(&LoggedInPredictorTable::HasUserLoggedIn, | 1471 base::Bind(&LoggedInPredictorTable::HasUserLoggedIn, |
1470 logged_in_predictor_table_, | 1472 logged_in_predictor_table_, |
1471 url, | 1473 url, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1510 } | 1512 } |
1511 | 1513 |
1512 void PrerenderManager::CookieChangedAnyCookiesLeftLookupResult( | 1514 void PrerenderManager::CookieChangedAnyCookiesLeftLookupResult( |
1513 const std::string& domain_key, | 1515 const std::string& domain_key, |
1514 bool cookies_exist) { | 1516 bool cookies_exist) { |
1515 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1517 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1516 | 1518 |
1517 if (cookies_exist) | 1519 if (cookies_exist) |
1518 return; | 1520 return; |
1519 | 1521 |
1520 if (logged_in_predictor_table_) { | 1522 if (logged_in_predictor_table_.get()) { |
1521 BrowserThread::PostTask( | 1523 BrowserThread::PostTask(BrowserThread::DB, |
1522 BrowserThread::DB, FROM_HERE, | 1524 FROM_HERE, |
1523 base::Bind(&LoggedInPredictorTable::DeleteDomain, | 1525 base::Bind(&LoggedInPredictorTable::DeleteDomain, |
1524 logged_in_predictor_table_, domain_key)); | 1526 logged_in_predictor_table_, |
| 1527 domain_key)); |
1525 } | 1528 } |
1526 | 1529 |
1527 if (logged_in_state_.get()) | 1530 if (logged_in_state_.get()) |
1528 logged_in_state_->erase(domain_key); | 1531 logged_in_state_->erase(domain_key); |
1529 } | 1532 } |
1530 | 1533 |
1531 void PrerenderManager::LoggedInPredictorDataReceived( | 1534 void PrerenderManager::LoggedInPredictorDataReceived( |
1532 scoped_ptr<LoggedInStateMap> new_map) { | 1535 scoped_ptr<LoggedInStateMap> new_map) { |
1533 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1536 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1534 logged_in_state_.swap(new_map); | 1537 logged_in_state_.swap(new_map); |
1535 } | 1538 } |
1536 | 1539 |
1537 } // namespace prerender | 1540 } // namespace prerender |
OLD | NEW |