OLD | NEW |
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_store_test_helpers.h" | 5 #include "net/base/cookie_store_test_helpers.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 | 8 |
9 namespace net { | 9 namespace net { |
10 | 10 |
11 const int kDelayedTime = 0; | 11 const int kDelayedTime = 0; |
12 | 12 |
13 DelayedCookieMonster::DelayedCookieMonster() | 13 DelayedCookieMonster::DelayedCookieMonster() |
14 : cookie_monster_(new CookieMonster(NULL, NULL)), | 14 : cookie_monster_(new CookieMonster(NULL, NULL)), |
15 did_run_(false), | 15 did_run_(false), |
16 result_(false) { | 16 result_(false) { |
17 } | 17 } |
18 | 18 |
19 DelayedCookieMonster::~DelayedCookieMonster() { | 19 DelayedCookieMonster::~DelayedCookieMonster() { |
20 } | 20 } |
21 | 21 |
22 void DelayedCookieMonster::GetCookiesInternalCallback( | 22 void DelayedCookieMonster::GetCookiesInternalCallback( |
23 std::string* cookie_line, | 23 const std::string& cookie_line, |
24 std::vector<CookieStore::CookieInfo>* cookie_info) { | 24 const std::vector<CookieStore::CookieInfo>& cookie_info) { |
25 cookie_line_ = *cookie_line; | 25 cookie_line_ = cookie_line; |
26 cookie_info_ = *cookie_info; | 26 cookie_info_ = cookie_info; |
27 did_run_ = true; | 27 did_run_ = true; |
28 } | 28 } |
29 | 29 |
30 void DelayedCookieMonster::SetCookiesInternalCallback(bool result) { | 30 void DelayedCookieMonster::SetCookiesInternalCallback(bool result) { |
31 result_ = result; | 31 result_ = result; |
32 did_run_ = true; | 32 did_run_ = true; |
33 } | 33 } |
34 | 34 |
35 void DelayedCookieMonster::GetCookiesWithOptionsInternalCallback( | 35 void DelayedCookieMonster::GetCookiesWithOptionsInternalCallback( |
36 std::string cookie) { | 36 std::string cookie) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 MessageLoop::current()->PostDelayedTask( | 84 MessageLoop::current()->PostDelayedTask( |
85 FROM_HERE, | 85 FROM_HERE, |
86 base::Bind(&DelayedCookieMonster::InvokeGetCookieStringCallback, | 86 base::Bind(&DelayedCookieMonster::InvokeGetCookieStringCallback, |
87 base::Unretained(this), callback), | 87 base::Unretained(this), callback), |
88 kDelayedTime); | 88 kDelayedTime); |
89 } | 89 } |
90 | 90 |
91 void DelayedCookieMonster::InvokeGetCookiesCallback( | 91 void DelayedCookieMonster::InvokeGetCookiesCallback( |
92 const CookieMonster::GetCookieInfoCallback& callback) { | 92 const CookieMonster::GetCookieInfoCallback& callback) { |
93 if (!callback.is_null()) | 93 if (!callback.is_null()) |
94 callback.Run(&cookie_line_, &cookie_info_); | 94 callback.Run(cookie_line_, cookie_info_); |
95 } | 95 } |
96 | 96 |
97 void DelayedCookieMonster::InvokeSetCookiesCallback( | 97 void DelayedCookieMonster::InvokeSetCookiesCallback( |
98 const CookieMonster::SetCookiesCallback& callback) { | 98 const CookieMonster::SetCookiesCallback& callback) { |
99 if (!callback.is_null()) | 99 if (!callback.is_null()) |
100 callback.Run(result_); | 100 callback.Run(result_); |
101 } | 101 } |
102 | 102 |
103 void DelayedCookieMonster::InvokeGetCookieStringCallback( | 103 void DelayedCookieMonster::InvokeGetCookieStringCallback( |
104 const CookieMonster::GetCookiesCallback& callback) { | 104 const CookieMonster::GetCookiesCallback& callback) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 const std::string& cookie_name, | 138 const std::string& cookie_name, |
139 const base::Closure& callback) { | 139 const base::Closure& callback) { |
140 ADD_FAILURE(); | 140 ADD_FAILURE(); |
141 } | 141 } |
142 | 142 |
143 CookieMonster* DelayedCookieMonster::GetCookieMonster() { | 143 CookieMonster* DelayedCookieMonster::GetCookieMonster() { |
144 return cookie_monster_; | 144 return cookie_monster_; |
145 } | 145 } |
146 | 146 |
147 } // namespace net | 147 } // namespace net |
OLD | NEW |