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

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

Issue 9703011: Move the cookie store implementation into its own directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: net/base/cookies/ -> net/cookies/ Created 8 years, 9 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_store_test_helpers.h ('k') | net/base/cookie_store_unittest.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 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.
4
5 #include "net/base/cookie_store_test_helpers.h"
6
7 #include "base/bind.h"
8 #include "base/message_loop.h"
9
10 namespace net {
11
12 const int kDelayedTime = 0;
13
14 DelayedCookieMonster::DelayedCookieMonster()
15 : cookie_monster_(new CookieMonster(NULL, NULL)),
16 did_run_(false),
17 result_(false) {
18 }
19
20 DelayedCookieMonster::~DelayedCookieMonster() {
21 }
22
23 void DelayedCookieMonster::GetCookiesInternalCallback(
24 const std::string& cookie_line,
25 const std::vector<CookieStore::CookieInfo>& cookie_info) {
26 cookie_line_ = cookie_line;
27 cookie_info_ = cookie_info;
28 did_run_ = true;
29 }
30
31 void DelayedCookieMonster::SetCookiesInternalCallback(bool result) {
32 result_ = result;
33 did_run_ = true;
34 }
35
36 void DelayedCookieMonster::GetCookiesWithOptionsInternalCallback(
37 const std::string& cookie) {
38 cookie_ = cookie;
39 did_run_ = true;
40 }
41
42 void DelayedCookieMonster::GetCookiesWithInfoAsync(
43 const GURL& url,
44 const CookieOptions& options,
45 const CookieMonster::GetCookieInfoCallback& callback) {
46 did_run_ = false;
47 cookie_monster_->GetCookiesWithInfoAsync(
48 url, options,
49 base::Bind(&DelayedCookieMonster::GetCookiesInternalCallback,
50 base::Unretained(this)));
51 DCHECK_EQ(did_run_, true);
52 MessageLoop::current()->PostDelayedTask(
53 FROM_HERE,
54 base::Bind(&DelayedCookieMonster::InvokeGetCookiesCallback,
55 base::Unretained(this), callback),
56 base::TimeDelta::FromMilliseconds(kDelayedTime));
57 }
58
59 void DelayedCookieMonster::SetCookieWithOptionsAsync(
60 const GURL& url, const std::string& cookie_line,
61 const CookieOptions& options,
62 const CookieMonster::SetCookiesCallback& callback) {
63 did_run_ = false;
64 cookie_monster_->SetCookieWithOptionsAsync(
65 url, cookie_line, options,
66 base::Bind(&DelayedCookieMonster::SetCookiesInternalCallback,
67 base::Unretained(this)));
68 DCHECK_EQ(did_run_, true);
69 MessageLoop::current()->PostDelayedTask(
70 FROM_HERE,
71 base::Bind(&DelayedCookieMonster::InvokeSetCookiesCallback,
72 base::Unretained(this), callback),
73 base::TimeDelta::FromMilliseconds(kDelayedTime));
74 }
75
76 void DelayedCookieMonster::GetCookiesWithOptionsAsync(
77 const GURL& url, const CookieOptions& options,
78 const CookieMonster::GetCookiesCallback& callback) {
79 did_run_ = false;
80 cookie_monster_->GetCookiesWithOptionsAsync(
81 url, options,
82 base::Bind(&DelayedCookieMonster::GetCookiesWithOptionsInternalCallback,
83 base::Unretained(this)));
84 DCHECK_EQ(did_run_, true);
85 MessageLoop::current()->PostDelayedTask(
86 FROM_HERE,
87 base::Bind(&DelayedCookieMonster::InvokeGetCookieStringCallback,
88 base::Unretained(this), callback),
89 base::TimeDelta::FromMilliseconds(kDelayedTime));
90 }
91
92 void DelayedCookieMonster::InvokeGetCookiesCallback(
93 const CookieMonster::GetCookieInfoCallback& callback) {
94 if (!callback.is_null())
95 callback.Run(cookie_line_, cookie_info_);
96 }
97
98 void DelayedCookieMonster::InvokeSetCookiesCallback(
99 const CookieMonster::SetCookiesCallback& callback) {
100 if (!callback.is_null())
101 callback.Run(result_);
102 }
103
104 void DelayedCookieMonster::InvokeGetCookieStringCallback(
105 const CookieMonster::GetCookiesCallback& callback) {
106 if (!callback.is_null())
107 callback.Run(cookie_);
108 }
109
110 bool DelayedCookieMonster::SetCookieWithOptions(
111 const GURL& url,
112 const std::string& cookie_line,
113 const CookieOptions& options) {
114 ADD_FAILURE();
115 return false;
116 }
117
118 std::string DelayedCookieMonster::GetCookiesWithOptions(
119 const GURL& url,
120 const CookieOptions& options) {
121 ADD_FAILURE();
122 return "";
123 }
124
125 void DelayedCookieMonster::GetCookiesWithInfo(
126 const GURL& url,
127 const CookieOptions& options,
128 std::string* cookie_line,
129 std::vector<CookieInfo>* cookie_infos) {
130 ADD_FAILURE();
131 }
132
133 void DelayedCookieMonster::DeleteCookie(const GURL& url,
134 const std::string& cookie_name) {
135 ADD_FAILURE();
136 }
137
138 void DelayedCookieMonster::DeleteCookieAsync(const GURL& url,
139 const std::string& cookie_name,
140 const base::Closure& callback) {
141 ADD_FAILURE();
142 }
143
144 void DelayedCookieMonster::DeleteAllCreatedBetweenAsync(
145 const base::Time& delete_begin,
146 const base::Time& delete_end,
147 const DeleteCallback& callback) {
148 ADD_FAILURE();
149 }
150
151 CookieMonster* DelayedCookieMonster::GetCookieMonster() {
152 return cookie_monster_;
153 }
154
155 } // namespace net
OLDNEW
« no previous file with comments | « net/base/cookie_store_test_helpers.h ('k') | net/base/cookie_store_unittest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698