Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1153)

Unified Diff: chrome/browser/net/chrome_cookie_policy.cc

Issue 6749044: Remove async functionality from net::CookiePolicy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/net/chrome_cookie_policy.h ('k') | chrome/browser/net/chrome_url_request_context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/chrome_cookie_policy.cc
diff --git a/chrome/browser/net/chrome_cookie_policy.cc b/chrome/browser/net/chrome_cookie_policy.cc
index cfaf1676ca2b36b59813abb491e4f80a878bd8f2..142aedd9f0da61041bb0fe6bc9505fb01df01db5 100644
--- a/chrome/browser/net/chrome_cookie_policy.cc
+++ b/chrome/browser/net/chrome_cookie_policy.cc
@@ -13,33 +13,26 @@
#include "net/base/net_errors.h"
#include "net/base/static_cookie_policy.h"
-// If we queue up more than this number of completions, then switch from ASK to
-// BLOCK. More than this number of requests at once seems like it could be a
-// sign of trouble anyways.
-static const size_t kMaxCompletionsPerHost = 10000;
-
// ----------------------------------------------------------------------------
ChromeCookiePolicy::ChromeCookiePolicy(HostContentSettingsMap* map)
- : host_content_settings_map_(map) {
- strict_third_party_blocking_ = CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kBlockReadingThirdPartyCookies);
-}
+ : host_content_settings_map_(map),
+ strict_third_party_blocking_(
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kBlockReadingThirdPartyCookies)) {}
-ChromeCookiePolicy::~ChromeCookiePolicy() {
- DCHECK(host_completions_map_.empty());
-}
+ChromeCookiePolicy::~ChromeCookiePolicy() {}
int ChromeCookiePolicy::CanGetCookies(const GURL& url,
- const GURL& first_party,
- net::CompletionCallback* callback) {
+ const GURL& first_party) const {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (host_content_settings_map_->BlockThirdPartyCookies()) {
net::StaticCookiePolicy policy(strict_third_party_blocking_ ?
net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES :
net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES);
- int rv = policy.CanGetCookies(url, first_party, NULL);
+ int rv = policy.CanGetCookies(url, first_party);
+ DCHECK_NE(net::ERR_IO_PENDING, rv);
if (rv != net::OK)
return rv;
}
@@ -47,56 +40,26 @@ int ChromeCookiePolicy::CanGetCookies(const GURL& url,
int policy = CheckPolicy(url);
if (policy == net::OK_FOR_SESSION_ONLY)
policy = net::OK;
- if (policy != net::ERR_IO_PENDING)
- return policy;
-
- DCHECK(callback);
-
- // If we are currently prompting the user for a 'set-cookie' matching this
- // host, then we need to defer reading cookies.
- HostCompletionsMap::iterator it = host_completions_map_.find(url.host());
- if (it == host_completions_map_.end()) {
- policy = net::OK;
- } else if (it->second.size() >= kMaxCompletionsPerHost) {
- LOG(ERROR) << "Would exceed kMaxCompletionsPerHost";
- policy = net::ERR_ACCESS_DENIED;
- } else {
- it->second.push_back(Completion::ForGetCookies(callback));
- policy = net::ERR_IO_PENDING;
- }
+ DCHECK_NE(net::ERR_IO_PENDING, policy);
return policy;
}
int ChromeCookiePolicy::CanSetCookie(const GURL& url,
const GURL& first_party,
- const std::string& cookie_line,
- net::CompletionCallback* callback) {
+ const std::string& cookie_line) const {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (host_content_settings_map_->BlockThirdPartyCookies()) {
net::StaticCookiePolicy policy(strict_third_party_blocking_ ?
net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES :
net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES);
- int rv = policy.CanSetCookie(url, first_party, cookie_line, NULL);
+ int rv = policy.CanSetCookie(url, first_party, cookie_line);
if (rv != net::OK)
return rv;
}
int policy = CheckPolicy(url);
- if (policy != net::ERR_IO_PENDING)
- return policy;
-
- DCHECK(callback);
-
- Completions& completions = host_completions_map_[url.host()];
- if (completions.size() >= kMaxCompletionsPerHost) {
- LOG(ERROR) << "Would exceed kMaxCompletionsPerHost";
- policy = net::ERR_ACCESS_DENIED;
- } else {
- completions.push_back(Completion::ForSetCookie(callback));
- policy = net::ERR_IO_PENDING;
- }
-
+ DCHECK_NE(net::ERR_IO_PENDING, policy);
return policy;
}
@@ -109,6 +72,6 @@ int ChromeCookiePolicy::CheckPolicy(const GURL& url) const {
return net::OK;
if (setting == CONTENT_SETTING_SESSION_ONLY)
return net::OK_FOR_SESSION_ONLY;
- return net::ERR_IO_PENDING; // Need to prompt.
+ NOTREACHED();
+ return net::ERR_ACCESS_DENIED;
}
-
« no previous file with comments | « chrome/browser/net/chrome_cookie_policy.h ('k') | chrome/browser/net/chrome_url_request_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698