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

Unified Diff: net/base/cookie_monster_store_test.h

Issue 7864008: Split initial load of cookies by domains (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/cookie_monster_perftest.cc ('k') | net/base/cookie_monster_store_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/cookie_monster_store_test.h
===================================================================
--- net/base/cookie_monster_store_test.h (revision 105637)
+++ net/base/cookie_monster_store_test.h (working copy)
@@ -23,6 +23,29 @@
namespace net {
+// Wrapper class for posting a loaded callback. Since the Callback class is not
+// reference counted, we cannot post a callback to the message loop directly,
+// instead we post a LoadedCallbackTask.
+class LoadedCallbackTask
+ : public base::RefCountedThreadSafe<LoadedCallbackTask> {
+ public:
+ typedef CookieMonster::PersistentCookieStore::LoadedCallback LoadedCallback;
+
+ LoadedCallbackTask(LoadedCallback loaded_callback,
+ std::vector<CookieMonster::CanonicalCookie*> cookies);
+ ~LoadedCallbackTask();
+
+ void Run() {
+ loaded_callback_.Run(cookies_);
+ }
+
+ private:
+ LoadedCallback loaded_callback_;
+ std::vector<CookieMonster::CanonicalCookie*> cookies_;
+
+ DISALLOW_COPY_AND_ASSIGN(LoadedCallbackTask);
+}; // Wrapper class LoadedCallbackTask
+
// Describes a call to one of the 3 functions of PersistentCookieStore.
struct CookieStoreCommand {
enum Type {
@@ -59,8 +82,11 @@
return commands_;
}
- virtual bool Load(const LoadedCallback& loaded_callback) OVERRIDE;
+ virtual void Load(const LoadedCallback& loaded_callback) OVERRIDE;
+ virtual void LoadCookiesForKey(const std::string& key,
+ const LoadedCallback& loaded_callback) OVERRIDE;
+
virtual void AddCookie(const CookieMonster::CanonicalCookie& cookie) OVERRIDE;
virtual void UpdateCookieAccessTime(
@@ -80,6 +106,9 @@
// Deferred result to use when Load() is called.
bool load_return_value_;
std::vector<CookieMonster::CanonicalCookie*> load_result_;
+ // Indicates if the store has been fully loaded to avoid returning duplicate
+ // cookies.
+ bool loaded_;
DISALLOW_COPY_AND_ASSIGN(MockPersistentCookieStore);
};
@@ -130,26 +159,33 @@
MockSimplePersistentCookieStore();
virtual ~MockSimplePersistentCookieStore();
- virtual bool Load(const LoadedCallback& loaded_callback);
+ virtual void Load(const LoadedCallback& loaded_callback) OVERRIDE;
+ virtual void LoadCookiesForKey(const std::string& key,
+ const LoadedCallback& loaded_callback) OVERRIDE;
+
virtual void AddCookie(
- const CookieMonster::CanonicalCookie& cookie);
+ const CookieMonster::CanonicalCookie& cookie) OVERRIDE;
virtual void UpdateCookieAccessTime(
- const CookieMonster::CanonicalCookie& cookie);
+ const CookieMonster::CanonicalCookie& cookie) OVERRIDE;
virtual void DeleteCookie(
- const CookieMonster::CanonicalCookie& cookie);
+ const CookieMonster::CanonicalCookie& cookie) OVERRIDE;
- virtual void Flush(Task* completion_task);
+ virtual void Flush(Task* completion_task) OVERRIDE;
- virtual void SetClearLocalStateOnExit(bool clear_local_state);
+ virtual void SetClearLocalStateOnExit(bool clear_local_state) OVERRIDE;
private:
typedef std::map<int64, CookieMonster::CanonicalCookie>
CanonicalCookieMap;
CanonicalCookieMap cookies_;
+
+ // Indicates if the store has been fully loaded to avoid return duplicate
+ // cookies in subsequent load requests
+ bool loaded_;
};
// Helper function for creating a CookieMonster backed by a
« no previous file with comments | « net/base/cookie_monster_perftest.cc ('k') | net/base/cookie_monster_store_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698