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

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

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 // This file contains test infrastructure for multiple files 5 // This file contains test infrastructure for multiple files
6 // (current cookie_monster_unittest.cc and cookie_monster_perftest.cc) 6 // (current cookie_monster_unittest.cc and cookie_monster_perftest.cc)
7 // that need to test out CookieMonster interactions with the backing store. 7 // that need to test out CookieMonster interactions with the backing store.
8 // It should only be included by test code. 8 // It should only be included by test code.
9 9
10 #ifndef NET_BASE_COOKIE_MONSTER_STORE_TEST_H_
11 #define NET_BASE_COOKIE_MONSTER_STORE_TEST_H_
12 #pragma once
13
14 #include <map>
15 #include <utility>
16 #include <string>
17 #include <vector>
10 #include "net/base/cookie_monster.h" 18 #include "net/base/cookie_monster.h"
11 19
12 namespace base { 20 namespace base {
13 class Time; 21 class Time;
14 } 22 }
15 23
16 namespace net { 24 namespace net {
17 25
18 // Describes a call to one of the 3 functions of PersistentCookieStore. 26 // Describes a call to one of the 3 functions of PersistentCookieStore.
19 struct CookieStoreCommand { 27 struct CookieStoreCommand {
(...skipping 24 matching lines...) Expand all
44 virtual ~MockPersistentCookieStore(); 52 virtual ~MockPersistentCookieStore();
45 53
46 void SetLoadExpectation( 54 void SetLoadExpectation(
47 bool return_value, 55 bool return_value,
48 const std::vector<CookieMonster::CanonicalCookie*>& result); 56 const std::vector<CookieMonster::CanonicalCookie*>& result);
49 57
50 const CommandList& commands() const { 58 const CommandList& commands() const {
51 return commands_; 59 return commands_;
52 } 60 }
53 61
54 virtual bool Load( 62 virtual bool Load(const LoadedCallback& loaded_callback) OVERRIDE;
55 std::vector<CookieMonster::CanonicalCookie*>* out_cookies);
56 63
57 virtual void AddCookie(const CookieMonster::CanonicalCookie& cookie); 64 virtual void AddCookie(const CookieMonster::CanonicalCookie& cookie) OVERRIDE;
58 65
59 virtual void UpdateCookieAccessTime( 66 virtual void UpdateCookieAccessTime(
60 const CookieMonster::CanonicalCookie& cookie); 67 const CookieMonster::CanonicalCookie& cookie) OVERRIDE;
61 68
62 virtual void DeleteCookie( 69 virtual void DeleteCookie(
63 const CookieMonster::CanonicalCookie& cookie); 70 const CookieMonster::CanonicalCookie& cookie) OVERRIDE;
64 71
65 virtual void Flush(Task* completion_task); 72 virtual void Flush(Task* completion_task) OVERRIDE;
66 73
67 // No files are created so nothing to clear either 74 // No files are created so nothing to clear either
68 virtual void SetClearLocalStateOnExit(bool clear_local_state); 75 virtual void SetClearLocalStateOnExit(bool clear_local_state) OVERRIDE;
69 76
70 private: 77 private:
71 CommandList commands_; 78 CommandList commands_;
72 79
73 // Deferred result to use when Load() is called. 80 // Deferred result to use when Load() is called.
74 bool load_return_value_; 81 bool load_return_value_;
75 std::vector<CookieMonster::CanonicalCookie*> load_result_; 82 std::vector<CookieMonster::CanonicalCookie*> load_result_;
76 83
77 DISALLOW_COPY_AND_ASSIGN(MockPersistentCookieStore); 84 DISALLOW_COPY_AND_ASSIGN(MockPersistentCookieStore);
78 }; 85 };
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 std::vector<CookieMonster::CanonicalCookie*>* out_list); 117 std::vector<CookieMonster::CanonicalCookie*>* out_list);
111 118
112 // Just act like a backing database. Keep cookie information from 119 // Just act like a backing database. Keep cookie information from
113 // Add/Update/Delete and regurgitate it when Load is called. 120 // Add/Update/Delete and regurgitate it when Load is called.
114 class MockSimplePersistentCookieStore 121 class MockSimplePersistentCookieStore
115 : public CookieMonster::PersistentCookieStore { 122 : public CookieMonster::PersistentCookieStore {
116 public: 123 public:
117 MockSimplePersistentCookieStore(); 124 MockSimplePersistentCookieStore();
118 virtual ~MockSimplePersistentCookieStore(); 125 virtual ~MockSimplePersistentCookieStore();
119 126
120 virtual bool Load( 127 virtual bool Load(const LoadedCallback& loaded_callback);
121 std::vector<CookieMonster::CanonicalCookie*>* out_cookies);
122 128
123 virtual void AddCookie( 129 virtual void AddCookie(
124 const CookieMonster::CanonicalCookie& cookie); 130 const CookieMonster::CanonicalCookie& cookie);
125 131
126 virtual void UpdateCookieAccessTime( 132 virtual void UpdateCookieAccessTime(
127 const CookieMonster::CanonicalCookie& cookie); 133 const CookieMonster::CanonicalCookie& cookie);
128 134
129 virtual void DeleteCookie( 135 virtual void DeleteCookie(
130 const CookieMonster::CanonicalCookie& cookie); 136 const CookieMonster::CanonicalCookie& cookie);
131 137
(...skipping 15 matching lines...) Expand all
147 // with access time Now()-days_old, the rest with access time Now(). 153 // with access time Now()-days_old, the rest with access time Now().
148 // Do two SetCookies(). Return whether each of the two SetCookies() took 154 // Do two SetCookies(). Return whether each of the two SetCookies() took
149 // longer than |gc_perf_micros| to complete, and how many cookie were 155 // longer than |gc_perf_micros| to complete, and how many cookie were
150 // left in the store afterwards. 156 // left in the store afterwards.
151 CookieMonster* CreateMonsterFromStoreForGC( 157 CookieMonster* CreateMonsterFromStoreForGC(
152 int num_cookies, 158 int num_cookies,
153 int num_old_cookies, 159 int num_old_cookies,
154 int days_old); 160 int days_old);
155 161
156 } // namespace net 162 } // namespace net
163
164 #endif // NET_BASE_COOKIE_MONSTER_STORE_TEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698