Updating trunk VERSION from 1014.0 to 1015.0
[chromium-blink-merge.git] / net / base / cookie_store_test_helpers.h
blob34746558307bb5782743c76ccbec00f0fcfb8648
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
3 // found in the LICENSE file.
5 #ifndef NET_BASE_COOKIE_STORE_TEST_HELPERS_H_
6 #define NET_BASE_COOKIE_STORE_TEST_HELPERS_H_
7 #pragma once
9 #include "net/base/cookie_monster.h"
11 #include <string>
12 #include <vector>
14 #include "base/callback_forward.h"
15 #include "testing/gtest/include/gtest/gtest.h"
17 namespace net {
19 class DelayedCookieMonster : public CookieStore {
20 public:
21 DelayedCookieMonster();
23 // Call the asynchronous CookieMonster function, expect it to immediately
24 // invoke the internal callback.
25 // Post a delayed task to invoke the original callback with the results.
27 virtual void SetCookieWithOptionsAsync(
28 const GURL& url,
29 const std::string& cookie_line,
30 const CookieOptions& options,
31 const CookieMonster::SetCookiesCallback& callback) OVERRIDE;
33 virtual void GetCookiesWithOptionsAsync(
34 const GURL& url, const CookieOptions& options,
35 const CookieMonster::GetCookiesCallback& callback) OVERRIDE;
37 virtual void GetCookiesWithInfoAsync(
38 const GURL& url,
39 const CookieOptions& options,
40 const CookieMonster::GetCookieInfoCallback& callback) OVERRIDE;
42 virtual bool SetCookieWithOptions(const GURL& url,
43 const std::string& cookie_line,
44 const CookieOptions& options);
46 virtual std::string GetCookiesWithOptions(const GURL& url,
47 const CookieOptions& options);
49 virtual void GetCookiesWithInfo(const GURL& url,
50 const CookieOptions& options,
51 std::string* cookie_line,
52 std::vector<CookieInfo>* cookie_infos);
54 virtual void DeleteCookie(const GURL& url,
55 const std::string& cookie_name);
57 virtual void DeleteCookieAsync(const GURL& url,
58 const std::string& cookie_name,
59 const base::Closure& callback) OVERRIDE;
61 virtual void DeleteAllCreatedBetweenAsync(
62 const base::Time& delete_begin,
63 const base::Time& delete_end,
64 const DeleteCallback& callback) OVERRIDE;
66 virtual CookieMonster* GetCookieMonster() OVERRIDE;
68 private:
70 // Be called immediately from CookieMonster.
72 void GetCookiesInternalCallback(
73 const std::string& cookie_line,
74 const std::vector<CookieStore::CookieInfo>& cookie_info);
76 void SetCookiesInternalCallback(bool result);
78 void GetCookiesWithOptionsInternalCallback(const std::string& cookie);
80 // Invoke the original callbacks.
82 void InvokeGetCookiesCallback(
83 const CookieMonster::GetCookieInfoCallback& callback);
85 void InvokeSetCookiesCallback(
86 const CookieMonster::SetCookiesCallback& callback);
88 void InvokeGetCookieStringCallback(
89 const CookieMonster::GetCookiesCallback& callback);
91 friend class base::RefCountedThreadSafe<DelayedCookieMonster>;
92 virtual ~DelayedCookieMonster();
94 scoped_refptr<CookieMonster> cookie_monster_;
96 bool did_run_;
97 bool result_;
98 std::string cookie_;
99 std::string cookie_line_;
100 std::vector<CookieStore::CookieInfo> cookie_info_;
103 } // namespace net
105 #endif // NET_BASE_COOKIE_STORE_TEST_HELPERS_H_