[android_webview] Call super.onMeasure in AwTestContainerView.
[chromium-blink-merge.git] / net / cookies / cookie_store_test_helpers.cc
blobfdf2c1f1ee803432f21ce74977ee6cb7869209ea
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.
5 #include "net/cookies/cookie_store_test_helpers.h"
7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h"
10 namespace net {
12 const int kDelayedTime = 0;
14 DelayedCookieMonster::DelayedCookieMonster()
15 : cookie_monster_(new CookieMonster(NULL, NULL)),
16 did_run_(false),
17 result_(false) {
20 DelayedCookieMonster::~DelayedCookieMonster() {
23 void DelayedCookieMonster::SetCookiesInternalCallback(bool result) {
24 result_ = result;
25 did_run_ = true;
28 void DelayedCookieMonster::GetCookiesWithOptionsInternalCallback(
29 const std::string& cookie) {
30 cookie_ = cookie;
31 did_run_ = true;
34 void DelayedCookieMonster::SetCookieWithOptionsAsync(
35 const GURL& url,
36 const std::string& cookie_line,
37 const CookieOptions& options,
38 const CookieMonster::SetCookiesCallback& callback) {
39 did_run_ = false;
40 cookie_monster_->SetCookieWithOptionsAsync(
41 url, cookie_line, options,
42 base::Bind(&DelayedCookieMonster::SetCookiesInternalCallback,
43 base::Unretained(this)));
44 DCHECK_EQ(did_run_, true);
45 base::MessageLoop::current()->PostDelayedTask(
46 FROM_HERE,
47 base::Bind(&DelayedCookieMonster::InvokeSetCookiesCallback,
48 base::Unretained(this),
49 callback),
50 base::TimeDelta::FromMilliseconds(kDelayedTime));
53 void DelayedCookieMonster::GetCookiesWithOptionsAsync(
54 const GURL& url,
55 const CookieOptions& options,
56 const CookieMonster::GetCookiesCallback& callback) {
57 did_run_ = false;
58 cookie_monster_->GetCookiesWithOptionsAsync(
59 url, options,
60 base::Bind(&DelayedCookieMonster::GetCookiesWithOptionsInternalCallback,
61 base::Unretained(this)));
62 DCHECK_EQ(did_run_, true);
63 base::MessageLoop::current()->PostDelayedTask(
64 FROM_HERE,
65 base::Bind(&DelayedCookieMonster::InvokeGetCookieStringCallback,
66 base::Unretained(this),
67 callback),
68 base::TimeDelta::FromMilliseconds(kDelayedTime));
71 void DelayedCookieMonster::GetAllCookiesForURLAsync(
72 const GURL& url,
73 const GetCookieListCallback& callback) {
74 cookie_monster_->GetAllCookiesForURLAsync(url, callback);
77 void DelayedCookieMonster::InvokeSetCookiesCallback(
78 const CookieMonster::SetCookiesCallback& callback) {
79 if (!callback.is_null())
80 callback.Run(result_);
83 void DelayedCookieMonster::InvokeGetCookieStringCallback(
84 const CookieMonster::GetCookiesCallback& callback) {
85 if (!callback.is_null())
86 callback.Run(cookie_);
89 bool DelayedCookieMonster::SetCookieWithOptions(
90 const GURL& url,
91 const std::string& cookie_line,
92 const CookieOptions& options) {
93 ADD_FAILURE();
94 return false;
97 std::string DelayedCookieMonster::GetCookiesWithOptions(
98 const GURL& url,
99 const CookieOptions& options) {
100 ADD_FAILURE();
101 return std::string();
104 void DelayedCookieMonster::DeleteCookie(const GURL& url,
105 const std::string& cookie_name) {
106 ADD_FAILURE();
109 void DelayedCookieMonster::DeleteCookieAsync(const GURL& url,
110 const std::string& cookie_name,
111 const base::Closure& callback) {
112 ADD_FAILURE();
115 void DelayedCookieMonster::DeleteAllCreatedBetweenAsync(
116 const base::Time& delete_begin,
117 const base::Time& delete_end,
118 const DeleteCallback& callback) {
119 ADD_FAILURE();
122 void DelayedCookieMonster::DeleteAllCreatedBetweenForHostAsync(
123 const base::Time delete_begin,
124 const base::Time delete_end,
125 const GURL& url,
126 const DeleteCallback& callback) {
127 ADD_FAILURE();
130 void DelayedCookieMonster::DeleteSessionCookiesAsync(const DeleteCallback&) {
131 ADD_FAILURE();
134 CookieMonster* DelayedCookieMonster::GetCookieMonster() {
135 return cookie_monster_.get();
138 } // namespace net