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

Side by Side Diff: net/base/cookie_monster_store_test.cc

Issue 7831056: Fix a memory leak in a unit test. (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
« no previous file with comments | « net/base/cookie_monster_store_test.h ('k') | net/base/cookie_monster_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "net/base/cookie_monster_store_test.h" 5 #include "net/base/cookie_monster_store_test.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "googleurl/src/gurl.h" 10 #include "googleurl/src/gurl.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 changes_.push_back(notification); 73 changes_.push_back(notification);
74 } 74 }
75 75
76 MockCookieMonsterDelegate::~MockCookieMonsterDelegate() {} 76 MockCookieMonsterDelegate::~MockCookieMonsterDelegate() {}
77 77
78 void AddCookieToList( 78 void AddCookieToList(
79 const std::string& key, 79 const std::string& key,
80 const std::string& cookie_line, 80 const std::string& cookie_line,
81 const base::Time& creation_time, 81 const base::Time& creation_time,
82 std::vector<CookieMonster::CanonicalCookie*>* out_list) { 82 std::vector<CookieMonster::CanonicalCookie*>* out_list) {
83 scoped_ptr<CookieMonster::CanonicalCookie> cookie(
84 new CookieMonster::CanonicalCookie(
85 BuildCanonicalCookie(key, cookie_line, creation_time)));
86
87 out_list->push_back(cookie.release());
88 }
89
90 CookieMonster::CanonicalCookie BuildCanonicalCookie(
91 const std::string& key,
92 const std::string& cookie_line,
93 const base::Time& creation_time) {
83 94
84 // Parse the cookie line. 95 // Parse the cookie line.
85 CookieMonster::ParsedCookie pc(cookie_line); 96 CookieMonster::ParsedCookie pc(cookie_line);
86 EXPECT_TRUE(pc.IsValid()); 97 EXPECT_TRUE(pc.IsValid());
87 98
88 // This helper is simplistic in interpreting a parsed cookie, in order to 99 // This helper is simplistic in interpreting a parsed cookie, in order to
89 // avoid duplicated CookieMonster's CanonPath() and CanonExpiration() 100 // avoid duplicated CookieMonster's CanonPath() and CanonExpiration()
90 // functions. Would be nice to export them, and re-use here. 101 // functions. Would be nice to export them, and re-use here.
91 EXPECT_FALSE(pc.HasMaxAge()); 102 EXPECT_FALSE(pc.HasMaxAge());
92 EXPECT_TRUE(pc.HasPath()); 103 EXPECT_TRUE(pc.HasPath());
93 base::Time cookie_expires = pc.HasExpires() ? 104 base::Time cookie_expires = pc.HasExpires() ?
94 CookieMonster::ParseCookieTime(pc.Expires()) : base::Time(); 105 CookieMonster::ParseCookieTime(pc.Expires()) : base::Time();
95 std::string cookie_path = pc.Path(); 106 std::string cookie_path = pc.Path();
96 107
97 scoped_ptr<CookieMonster::CanonicalCookie> cookie( 108 return CookieMonster::CanonicalCookie(
98 new CookieMonster::CanonicalCookie( 109 GURL(), pc.Name(), pc.Value(), key, cookie_path,
99 GURL(), pc.Name(), pc.Value(), key, cookie_path, 110 pc.MACKey(), pc.MACAlgorithm(),
100 pc.MACKey(), pc.MACAlgorithm(), 111 creation_time, creation_time, cookie_expires,
101 creation_time, creation_time, cookie_expires, 112 pc.IsSecure(), pc.IsHttpOnly(),
102 pc.IsSecure(), pc.IsHttpOnly(), 113 !cookie_expires.is_null());
103 !cookie_expires.is_null()));
104
105 out_list->push_back(cookie.release());
106 } 114 }
107 115
108 MockSimplePersistentCookieStore::MockSimplePersistentCookieStore() {} 116 MockSimplePersistentCookieStore::MockSimplePersistentCookieStore() {}
109 117
110 MockSimplePersistentCookieStore::~MockSimplePersistentCookieStore() {} 118 MockSimplePersistentCookieStore::~MockSimplePersistentCookieStore() {}
111 119
112 bool MockSimplePersistentCookieStore::Load( 120 bool MockSimplePersistentCookieStore::Load(
113 const LoadedCallback& loaded_callback) { 121 const LoadedCallback& loaded_callback) {
114 std::vector<CookieMonster::CanonicalCookie*> out_cookies; 122 std::vector<CookieMonster::CanonicalCookie*> out_cookies;
115 for (CanonicalCookieMap::const_iterator it = cookies_.begin(); 123 for (CanonicalCookieMap::const_iterator it = cookies_.begin();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 GURL(), "a", "1", base::StringPrintf("h%05d.izzle", i), "/path", 183 GURL(), "a", "1", base::StringPrintf("h%05d.izzle", i), "/path",
176 mac_key, mac_algorithm, creation_time, expiration_time, 184 mac_key, mac_algorithm, creation_time, expiration_time,
177 last_access_time, false, false, true); 185 last_access_time, false, false, true);
178 store->AddCookie(cc); 186 store->AddCookie(cc);
179 } 187 }
180 188
181 return new CookieMonster(store, NULL); 189 return new CookieMonster(store, NULL);
182 } 190 }
183 191
184 } // namespace net 192 } // namespace net
OLDNEW
« no previous file with comments | « net/base/cookie_monster_store_test.h ('k') | net/base/cookie_monster_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698