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

Side by Side Diff: chrome/browser/net/cookie_policy_browsertest.cc

Issue 7833042: Finalize a CL originally by departed intern ycxiao@ that detaches the loading of cookies from the... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/bind.h"
5 #include "base/task.h" 6 #include "base/task.h"
6 #include "base/synchronization/waitable_event.h" 7 #include "base/synchronization/waitable_event.h"
7 #include "chrome/browser/content_settings/host_content_settings_map.h" 8 #include "chrome/browser/content_settings/host_content_settings_map.h"
8 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
10 #include "chrome/test/base/in_process_browser_test.h" 11 #include "chrome/test/base/in_process_browser_test.h"
11 #include "chrome/test/base/ui_test_utils.h" 12 #include "chrome/test/base/ui_test_utils.h"
12 #include "net/base/cookie_store.h" 13 #include "net/base/cookie_store.h"
13 #include "net/base/mock_host_resolver.h" 14 #include "net/base/mock_host_resolver.h"
14 #include "net/test/test_server.h" 15 #include "net/test/test_server.h"
15 #include "net/url_request/url_request_context.h" 16 #include "net/url_request/url_request_context.h"
16 #include "net/url_request/url_request_context_getter.h" 17 #include "net/url_request/url_request_context_getter.h"
17 18
18 namespace { 19 namespace {
19 20
20 class GetCookiesTask : public Task { 21 class GetCookiesTask : public Task {
21 public: 22 public:
22 GetCookiesTask(const GURL& url, 23 GetCookiesTask(const GURL& url,
23 net::URLRequestContextGetter* context_getter, 24 net::URLRequestContextGetter* context_getter,
24 base::WaitableEvent* event, 25 base::WaitableEvent* event,
25 std::string* cookies) 26 std::string* cookies)
26 : url_(url), 27 : url_(url),
27 context_getter_(context_getter), 28 context_getter_(context_getter),
28 event_(event), 29 event_(event),
29 cookies_(cookies) {} 30 cookies_(cookies) {}
30 31
31 virtual void Run() { 32 virtual void Run() {
32 *cookies_ = 33 net::CookieOptions options;
33 context_getter_->GetURLRequestContext()->cookie_store()-> 34 context_getter_->GetURLRequestContext()->cookie_store()
34 GetCookies(url_); 35 ->GetCookiesWithOptionsAsync(
35 event_->Signal(); 36 url_, options, base::Bind(&GetCookiesTask::GetCookiesCallback,
37 base::Unretained(cookies_),
38 base::Unretained(event_)));
39 }
40
41 static void GetCookiesCallback(std::string* cookies_out,
42 base::WaitableEvent* event,
43 const std::string& cookies) {
44 *cookies_out = cookies;
45 event->Signal();
36 } 46 }
37 47
38 private: 48 private:
39 const GURL& url_; 49 const GURL& url_;
40 net::URLRequestContextGetter* const context_getter_; 50 net::URLRequestContextGetter* const context_getter_;
41 base::WaitableEvent* const event_; 51 base::WaitableEvent* const event_;
42 std::string* const cookies_; 52 std::string* const cookies_;
43 53
44 DISALLOW_COPY_AND_ASSIGN(GetCookiesTask); 54 DISALLOW_COPY_AND_ASSIGN(GetCookiesTask);
45 }; 55 };
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 host_resolver()->AddRule("www.example.com", "127.0.0.1"); 121 host_resolver()->AddRule("www.example.com", "127.0.0.1");
112 122
113 ui_test_utils::NavigateToURL(browser(), 123 ui_test_utils::NavigateToURL(browser(),
114 GURL(url.spec() + redirected_url.spec())); 124 GURL(url.spec() + redirected_url.spec()));
115 125
116 cookie = GetCookies(redirected_url); 126 cookie = GetCookies(redirected_url);
117 EXPECT_EQ("cookie2", cookie); 127 EXPECT_EQ("cookie2", cookie);
118 } 128 }
119 129
120 } // namespace 130 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/fast_shutdown_uitest.cc ('k') | chrome/browser/net/sqlite_persistent_cookie_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698