OLD | NEW |
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/bind.h" |
6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "base/test/thread_test_helper.h" | 8 #include "base/test/thread_test_helper.h" |
9 #include "chrome/browser/net/sqlite_persistent_cookie_store.h" | 9 #include "chrome/browser/net/sqlite_persistent_cookie_store.h" |
10 #include "chrome/common/chrome_constants.h" | 10 #include "chrome/common/chrome_constants.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 } | 35 } |
36 | 36 |
37 // Looks for the given |cookie| in the cookie store. If it exists, puts the | 37 // Looks for the given |cookie| in the cookie store. If it exists, puts the |
38 // cookie's value in |cookie_value| and sets |has_cookie| to true. Sets | 38 // cookie's value in |cookie_value| and sets |has_cookie| to true. Sets |
39 // |has_cookie| to false if the |cookie| wasn't found. | 39 // |has_cookie| to false if the |cookie| wasn't found. |
40 void GetCookie(const net::CookieMonster::CanonicalCookie& cookie, | 40 void GetCookie(const net::CookieMonster::CanonicalCookie& cookie, |
41 bool* has_cookie, std::string* cookie_value) { | 41 bool* has_cookie, std::string* cookie_value) { |
42 scoped_refptr<SQLitePersistentCookieStore> cookie_store( | 42 scoped_refptr<SQLitePersistentCookieStore> cookie_store( |
43 new SQLitePersistentCookieStore( | 43 new SQLitePersistentCookieStore( |
44 user_data_dir_.AppendASCII(chrome::kInitialProfile) | 44 user_data_dir_.AppendASCII(chrome::kInitialProfile) |
45 .Append(chrome::kCookieFilename))); | 45 .Append(chrome::kCookieFilename), |
| 46 false)); |
46 std::vector<net::CookieMonster::CanonicalCookie*> cookies; | 47 std::vector<net::CookieMonster::CanonicalCookie*> cookies; |
47 cookie_store->Load( | 48 cookie_store->Load( |
48 base::Bind(&FastShutdown::LoadCookiesCallback, | 49 base::Bind(&FastShutdown::LoadCookiesCallback, |
49 base::Unretained(this), | 50 base::Unretained(this), |
50 MessageLoop::current(), | 51 MessageLoop::current(), |
51 base::Unretained(&cookies))); | 52 base::Unretained(&cookies))); |
52 // Will receive a QuitTask when LoadCookiesCallback is invoked. | 53 // Will receive a QuitTask when LoadCookiesCallback is invoked. |
53 MessageLoop::current()->Run(); | 54 MessageLoop::current()->Run(); |
54 *has_cookie = false; | 55 *has_cookie = false; |
55 for (size_t i = 0; i < cookies.size(); ++i) { | 56 for (size_t i = 0; i < cookies.size(); ++i) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 // cookie that's stored to disk. | 125 // cookie that's stored to disk. |
125 QuitBrowser(); | 126 QuitBrowser(); |
126 | 127 |
127 bool has_cookie = false; | 128 bool has_cookie = false; |
128 std::string cookie_value; | 129 std::string cookie_value; |
129 // Read the cookie and check that it has the expected value. | 130 // Read the cookie and check that it has the expected value. |
130 GetCookie(cookie, &has_cookie, &cookie_value); | 131 GetCookie(cookie, &has_cookie, &cookie_value); |
131 EXPECT_TRUE(has_cookie); | 132 EXPECT_TRUE(has_cookie); |
132 EXPECT_EQ("ohyeah", cookie_value); | 133 EXPECT_EQ("ohyeah", cookie_value); |
133 } | 134 } |
OLD | NEW |