summaryrefslogtreecommitdiffstats
path: root/net/url_request
diff options
context:
space:
mode:
authorerikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-08 18:03:31 +0000
committererikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-08 18:03:31 +0000
commit5e9791ee25e21ea59ffbde31d9330b4d3ccb4b85 (patch)
tree08280972fffb91b4729a4f2d3d61db84d9f0630b /net/url_request
parent73455b1bf7535666dd7d0655b398934f5ea9e953 (diff)
downloadchromium_src-5e9791ee25e21ea59ffbde31d9330b4d3ccb4b85.zip
chromium_src-5e9791ee25e21ea59ffbde31d9330b4d3ccb4b85.tar.gz
chromium_src-5e9791ee25e21ea59ffbde31d9330b4d3ccb4b85.tar.bz2
Finalize a CL originally by departed intern ycxiao@ that detaches the loading of cookies from the IO thread.
They are now loaded on the DB thread. Cookie operations received in the meantime are queued and executed, on the IO thread, in the order they were received, when loading completes. A few straggler clients are updated to use the asynchronous CookieStore/CookieMonster API as part of this CL, as the synchronous API is removed. BUG=68657 TEST=net_unittests / DeferredCookieTaskTest.* and CookieMonsterTest.* Review URL: http://codereview.chromium.org/7833042 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100188 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/url_request')
-rw-r--r--net/url_request/url_request_http_job.cc10
-rw-r--r--net/url_request/url_request_http_job.h4
-rw-r--r--net/url_request/url_request_unittest.cc17
3 files changed, 20 insertions, 11 deletions
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc
index 89a0ef9..8b13d5b1 100644
--- a/net/url_request/url_request_http_job.cc
+++ b/net/url_request/url_request_http_job.cc
@@ -543,14 +543,14 @@ void URLRequestHttpJob::CheckCookiePolicyAndLoad(
}
void URLRequestHttpJob::OnCookiesLoaded(
- std::string* cookie_line,
- std::vector<net::CookieStore::CookieInfo>* cookie_infos) {
- if (!cookie_line->empty()) {
+ const std::string& cookie_line,
+ const std::vector<net::CookieStore::CookieInfo>& cookie_infos) {
+ if (!cookie_line.empty()) {
request_info_.extra_headers.SetHeader(
- HttpRequestHeaders::kCookie, *cookie_line);
+ HttpRequestHeaders::kCookie, cookie_line);
}
if (URLRequest::AreMacCookiesEnabled())
- AddAuthorizationHeader(*cookie_infos, &request_info_);
+ AddAuthorizationHeader(cookie_infos, &request_info_);
DoStartTransaction();
}
diff --git a/net/url_request/url_request_http_job.h b/net/url_request/url_request_http_job.h
index 1957dfd..8293c13 100644
--- a/net/url_request/url_request_http_job.h
+++ b/net/url_request/url_request_http_job.h
@@ -169,8 +169,8 @@ class URLRequestHttpJob : public URLRequestJob {
// Callback functions for Cookie Monster
void CheckCookiePolicyAndLoad(const CookieList& cookie_list);
void OnCookiesLoaded(
- std::string* cookie_line,
- std::vector<CookieStore::CookieInfo>* cookie_infos);
+ const std::string& cookie_line,
+ const std::vector<CookieStore::CookieInfo>& cookie_infos);
void DoStartTransaction();
void OnCookieSaved(bool cookie_status);
void CookieHandled();
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
index a8f4a47..44f6560 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -13,6 +13,7 @@
#include <string>
#include "base/basictypes.h"
+#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/file_util.h"
#include "base/format_macros.h"
@@ -2017,6 +2018,13 @@ TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy_Async) {
}
}
+void CheckCookiePolicyCallback(bool* was_run, const CookieList& cookies) {
+ EXPECT_EQ(1U, cookies.size());
+ EXPECT_FALSE(cookies[0].IsPersistent());
+ *was_run = true;
+ MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
+}
+
TEST_F(URLRequestTest, CookiePolicy_ForceSession) {
TestServer test_server(TestServer::TYPE_HTTP, FilePath());
ASSERT_TRUE(test_server.Start());
@@ -2037,10 +2045,11 @@ TEST_F(URLRequestTest, CookiePolicy_ForceSession) {
}
// Now, check the cookie store.
- CookieList cookies =
- default_context_->cookie_store()->GetCookieMonster()->GetAllCookies();
- EXPECT_EQ(1U, cookies.size());
- EXPECT_FALSE(cookies[0].IsPersistent());
+ bool was_run = false;
+ default_context_->cookie_store()->GetCookieMonster()->GetAllCookiesAsync(
+ base::Bind(&CheckCookiePolicyCallback, &was_run));
+ MessageLoop::current()->RunAllPending();
+ DCHECK(was_run);
}
// In this test, we do a POST which the server will 302 redirect.