Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / net / cookies / cookie_store_test_helpers.cc
blob49f9d9ac83dba07a500bf60eba0b67d45cc94370
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/location.h"
9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h"
12 namespace net {
14 const int kDelayedTime = 0;
16 DelayedCookieMonster::DelayedCookieMonster()
17 : cookie_monster_(new CookieMonster(NULL, NULL)),
18 did_run_(false),
19 result_(false) {
22 DelayedCookieMonster::~DelayedCookieMonster() {
25 void DelayedCookieMonster::SetCookiesInternalCallback(bool result) {
26 result_ = result;
27 did_run_ = true;
30 void DelayedCookieMonster::GetCookiesWithOptionsInternalCallback(
31 const std::string& cookie) {
32 cookie_ = cookie;
33 did_run_ = true;
36 void DelayedCookieMonster::SetCookieWithOptionsAsync(
37 const GURL& url,
38 const std::string& cookie_line,
39 const CookieOptions& options,
40 const CookieMonster::SetCookiesCallback& callback) {
41 did_run_ = false;
42 cookie_monster_->SetCookieWithOptionsAsync(
43 url, cookie_line, options,
44 base::Bind(&DelayedCookieMonster::SetCookiesInternalCallback,
45 base::Unretained(this)));
46 DCHECK_EQ(did_run_, true);
47 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
48 FROM_HERE, base::Bind(&DelayedCookieMonster::InvokeSetCookiesCallback,
49 base::Unretained(this), 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::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
64 FROM_HERE,
65 base::Bind(&DelayedCookieMonster::InvokeGetCookieStringCallback,
66 base::Unretained(this), callback),
67 base::TimeDelta::FromMilliseconds(kDelayedTime));
70 void DelayedCookieMonster::GetAllCookiesForURLAsync(
71 const GURL& url,
72 const GetCookieListCallback& callback) {
73 cookie_monster_->GetAllCookiesForURLAsync(url, callback);
76 void DelayedCookieMonster::InvokeSetCookiesCallback(
77 const CookieMonster::SetCookiesCallback& callback) {
78 if (!callback.is_null())
79 callback.Run(result_);
82 void DelayedCookieMonster::InvokeGetCookieStringCallback(
83 const CookieMonster::GetCookiesCallback& callback) {
84 if (!callback.is_null())
85 callback.Run(cookie_);
88 bool DelayedCookieMonster::SetCookieWithOptions(
89 const GURL& url,
90 const std::string& cookie_line,
91 const CookieOptions& options) {
92 ADD_FAILURE();
93 return false;
96 std::string DelayedCookieMonster::GetCookiesWithOptions(
97 const GURL& url,
98 const CookieOptions& options) {
99 ADD_FAILURE();
100 return std::string();
103 void DelayedCookieMonster::DeleteCookie(const GURL& url,
104 const std::string& cookie_name) {
105 ADD_FAILURE();
108 void DelayedCookieMonster::DeleteCookieAsync(const GURL& url,
109 const std::string& cookie_name,
110 const base::Closure& callback) {
111 ADD_FAILURE();
114 void DelayedCookieMonster::DeleteAllCreatedBetweenAsync(
115 const base::Time& delete_begin,
116 const base::Time& delete_end,
117 const DeleteCallback& callback) {
118 ADD_FAILURE();
121 void DelayedCookieMonster::DeleteAllCreatedBetweenForHostAsync(
122 const base::Time delete_begin,
123 const base::Time delete_end,
124 const GURL& url,
125 const DeleteCallback& callback) {
126 ADD_FAILURE();
129 void DelayedCookieMonster::DeleteSessionCookiesAsync(const DeleteCallback&) {
130 ADD_FAILURE();
133 CookieMonster* DelayedCookieMonster::GetCookieMonster() {
134 return cookie_monster_.get();
137 scoped_ptr<CookieStore::CookieChangedSubscription>
138 DelayedCookieMonster::AddCallbackForCookie(
139 const GURL& url,
140 const std::string& name,
141 const CookieChangedCallback& callback) {
142 ADD_FAILURE();
143 return scoped_ptr<CookieStore::CookieChangedSubscription>();
146 } // namespace net