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

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, 9 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
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 e95e91a6f60bb17bf2f81ee9854a5f73dd6113c3..15b097438c060b33c651144ceda47de8f983505c 100644
--- a/chrome/browser/net/chrome_cookie_policy.cc
+++ b/chrome/browser/net/chrome_cookie_policy.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -21,25 +21,22 @@ 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)) {}
jochen (gone - plz use gerrit) 2011/03/30 08:15:32 I think the closing bracket should go on the next
willchan no longer on Chromium 2011/04/04 12:29:18 There are two varying styles in Chromium and neith
-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);
if (rv != net::OK)
jochen (gone - plz use gerrit) 2011/03/30 08:15:32 maybe also DCHECK for != ERR_IO_PENDING here?
willchan no longer on Chromium 2011/04/04 12:29:18 Done.
return rv;
}
@@ -47,56 +44,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;
}
@@ -111,4 +78,3 @@ int ChromeCookiePolicy::CheckPolicy(const GURL& url) const {
return net::OK_FOR_SESSION_ONLY;
return net::ERR_IO_PENDING; // Need to prompt.
jochen (gone - plz use gerrit) 2011/03/30 08:15:32 NOTREACHED() && return ACCESS DENIED?
willchan no longer on Chromium 2011/04/04 12:29:18 Done.
}
-

Powered by Google App Engine
This is Rietveld 408576698